2 * Copyright 2006, Haiku.
3 * Distributed under the terms of the MIT License.
6 * Stephan Aßmus <superstippi@gmx.de>
9 #include "AddPointCommand.h"
16 #include "VectorPath.h"
19 #undef B_TRANSLATION_CONTEXT
20 #define B_TRANSLATION_CONTEXT "Icon-O-Matic-AddPointCmd"
24 AddPointCommand::AddPointCommand(VectorPath
* path
,
26 const int32
* selected
,
31 fOldSelectionCount(count
)
33 if (fOldSelectionCount
> 0 && selected
) {
34 fOldSelection
= new int32
[fOldSelectionCount
];
35 memcpy(fOldSelection
, selected
, fOldSelectionCount
* sizeof(int32
));
40 AddPointCommand::~AddPointCommand()
42 delete[] fOldSelection
;
47 AddPointCommand::Perform()
49 status_t status
= InitCheck();
53 // path point is already added,
54 // but we don't know the parameters yet
55 if (!fPath
->GetPointsAt(fIndex
, fPoint
, fPointIn
, fPointOut
))
63 AddPointCommand::Undo()
65 status_t status
= InitCheck();
70 if (fPath
->RemovePoint(fIndex
)) {
71 // restore selection before adding point
72 _Select(fOldSelection
, fOldSelectionCount
);
82 AddPointCommand::Redo()
84 status_t status
= InitCheck();
88 AutoNotificationSuspender
_(fPath
);
91 if (fPath
->AddPoint(fPoint
, fIndex
)) {
92 fPath
->SetPoint(fIndex
, fPoint
, fPointIn
, fPointOut
, true);
104 AddPointCommand::GetName(BString
& name
)
106 // name << _GetString(ADD_CONTROL_POINT, "Add Control Point");
107 name
<< B_TRANSLATE("Add Control Point");