btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / icon-o-matic / shape / commands / NudgePointsCommand.cpp
blobd395d41d488b210da140597ee7a8865e7a33c811
1 /*
2 * Copyright 2006, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Stephan Aßmus <superstippi@gmx.de>
7 */
9 #include "NudgePointsCommand.h"
11 #include <new>
12 #include <stdio.h>
14 #include <Catalog.h>
15 #include <Locale.h>
17 #include "VectorPath.h"
20 #undef B_TRANSLATION_CONTEXT
21 #define B_TRANSLATION_CONTEXT "Icon-O-Matic-NudgePointsCommand"
24 using std::nothrow;
26 // constructor
27 NudgePointsCommand::NudgePointsCommand(VectorPath* path,
28 const int32* indices,
29 const control_point* points,
30 int32 count)
31 : TransformCommand(B_ORIGIN,
32 B_ORIGIN,
33 0.0,
34 1.0,
35 1.0,
36 count > 1 ? B_TRANSLATE("Nudge Control Points") :
37 B_TRANSLATE("Nudge Control Point"),
38 // count > 1 ? NUDGE_CONTROL_POINTS : NUDGE_CONTROL_POINT),
39 -1),
40 fPath(path),
41 fIndices(NULL),
42 fPoints(NULL),
43 fCount(count)
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));
55 // destructor
56 NudgePointsCommand::~NudgePointsCommand()
58 delete[] fIndices;
59 delete[] fPoints;
62 // InitCheck
63 status_t
64 NudgePointsCommand::InitCheck()
66 if (fPath && fIndices && fPoints)
67 return TransformCommand::InitCheck();
68 else
69 return B_NO_INIT;
72 // _SetTransformation
73 status_t
74 NudgePointsCommand::_SetTransformation(BPoint pivot,
75 BPoint translation,
76 double rotation,
77 double xScale,
78 double yScale) const
80 if (!fPath)
81 return B_NO_INIT;
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);
93 return B_OK;