2 * Copyright 2009, Stephan Aßmus <superstippi@gmx.de>. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 #include "RotatePathIndicesCommand.h"
13 #include "VectorPath.h"
16 #undef B_TRANSLATION_CONTEXT
17 #define B_TRANSLATION_CONTEXT "Icon-O-Matic-RotatePathIndiciesCmd"
20 RotatePathIndicesCommand::RotatePathIndicesCommand(VectorPath
* path
,
29 RotatePathIndicesCommand::~RotatePathIndicesCommand()
35 RotatePathIndicesCommand::InitCheck()
37 status_t ret
= PathCommand::InitCheck();
38 if (ret
== B_OK
&& fPath
->CountPoints() < 2)
39 return B_NOT_SUPPORTED
;
45 RotatePathIndicesCommand::Perform()
47 return _Rotate(fClockWise
);
52 RotatePathIndicesCommand::Undo()
54 return _Rotate(!fClockWise
);
59 RotatePathIndicesCommand::GetName(BString
& name
)
61 name
<< B_TRANSLATE("Rotate Path Indices");
66 RotatePathIndicesCommand::_Rotate(bool clockWise
)
76 removeIndex
= fPath
->CountPoints() - 1;
80 addIndex
= fPath
->CountPoints() - 1;
83 if (!fPath
->GetPointsAt(removeIndex
, point
, pointIn
, pointOut
, &connected
))
86 fPath
->RemovePoint(removeIndex
);
87 fPath
->AddPoint(point
, addIndex
);
88 fPath
->SetPoint(addIndex
, point
, pointIn
, pointOut
, connected
);