2 * Copyright 2006, Haiku.
3 * Distributed under the terms of the MIT License.
6 * Stephan Aßmus <superstippi@gmx.de>
9 #include "NudgePointsCommand.h"
17 #include "VectorPath.h"
20 #undef B_TRANSLATION_CONTEXT
21 #define B_TRANSLATION_CONTEXT "Icon-O-Matic-NudgePointsCommand"
27 NudgePointsCommand::NudgePointsCommand(VectorPath
* path
,
29 const control_point
* points
,
31 : TransformCommand(B_ORIGIN
,
36 count
> 1 ? B_TRANSLATE("Nudge Control Points") :
37 B_TRANSLATE("Nudge Control Point"),
38 // count > 1 ? NUDGE_CONTROL_POINTS : NUDGE_CONTROL_POINT),
45 if (fCount
> 0 && indices
) {
46 fIndices
= new (nothrow
) int32
[fCount
];
47 memcpy(fIndices
, indices
, fCount
* sizeof(int32
));
49 if (fCount
> 0 && points
) {
50 fPoints
= new (nothrow
) control_point
[fCount
];
51 memcpy(fPoints
, points
, fCount
* sizeof(control_point
));
56 NudgePointsCommand::~NudgePointsCommand()
64 NudgePointsCommand::InitCheck()
66 if (fPath
&& fIndices
&& fPoints
)
67 return TransformCommand::InitCheck();
74 NudgePointsCommand::_SetTransformation(BPoint pivot
,
83 AutoNotificationSuspender
_(fPath
);
85 // restore original path
86 for (int32 i
= 0; i
< fCount
; i
++) {
87 fPath
->SetPoint(fIndices
[i
], fPoints
[i
].point
+ translation
,
88 fPoints
[i
].point_in
+ translation
,
89 fPoints
[i
].point_out
+ translation
,
90 fPoints
[i
].connected
);