btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / icon-o-matic / shape / commands / RotatePathIndicesCommand.cpp
blob65f3126e79bf99442128553107bb5621bcc1877e
1 /*
2 * Copyright 2009, Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
6 #include "RotatePathIndicesCommand.h"
8 #include <stdio.h>
10 #include <Catalog.h>
11 #include <Locale.h>
13 #include "VectorPath.h"
16 #undef B_TRANSLATION_CONTEXT
17 #define B_TRANSLATION_CONTEXT "Icon-O-Matic-RotatePathIndiciesCmd"
20 RotatePathIndicesCommand::RotatePathIndicesCommand(VectorPath* path,
21 bool clockWise)
23 PathCommand(path),
24 fClockWise(clockWise)
29 RotatePathIndicesCommand::~RotatePathIndicesCommand()
34 status_t
35 RotatePathIndicesCommand::InitCheck()
37 status_t ret = PathCommand::InitCheck();
38 if (ret == B_OK && fPath->CountPoints() < 2)
39 return B_NOT_SUPPORTED;
40 return ret;
44 status_t
45 RotatePathIndicesCommand::Perform()
47 return _Rotate(fClockWise);
51 status_t
52 RotatePathIndicesCommand::Undo()
54 return _Rotate(!fClockWise);
58 void
59 RotatePathIndicesCommand::GetName(BString& name)
61 name << B_TRANSLATE("Rotate Path Indices");
65 status_t
66 RotatePathIndicesCommand::_Rotate(bool clockWise)
68 BPoint point;
69 BPoint pointIn;
70 BPoint pointOut;
71 bool connected;
73 int32 removeIndex;
74 int32 addIndex;
75 if (!clockWise) {
76 removeIndex = fPath->CountPoints() - 1;
77 addIndex = 0;
78 } else {
79 removeIndex = 0;
80 addIndex = fPath->CountPoints() - 1;
83 if (!fPath->GetPointsAt(removeIndex, point, pointIn, pointOut, &connected))
84 return B_ERROR;
86 fPath->RemovePoint(removeIndex);
87 fPath->AddPoint(point, addIndex);
88 fPath->SetPoint(addIndex, point, pointIn, pointOut, connected);
90 return B_OK;