2 * Copyright 2007, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Stephan Aßmus <superstippi@gmx.de>
9 #include "FlipPointsCommand.h"
17 #include "VectorPath.h"
20 #undef B_TRANSLATION_CONTEXT
21 #define B_TRANSLATION_CONTEXT "Icon-O-Matic-FlipPointsCmd"
27 FlipPointsCommand::FlipPointsCommand(VectorPath
* path
,
34 if (indices
&& count
> 0) {
35 fIndex
= new (nothrow
) int32
[count
];
39 if (InitCheck() < B_OK
)
42 memcpy(fIndex
, indices
, count
* sizeof(int32
));
46 FlipPointsCommand::~FlipPointsCommand()
53 FlipPointsCommand::InitCheck()
55 status_t status
= PathCommand::InitCheck();
65 FlipPointsCommand::Perform()
67 status_t status
= B_OK
;
69 AutoNotificationSuspender
_(fPath
);
71 // NOTE: fCount guaranteed > 0
72 for (int32 i
= 0; i
< fCount
; i
++) {
78 if (fPath
->GetPointsAt(fIndex
[i
], point
, pointIn
, pointOut
, &connected
)) {
79 BPoint
p1(point
- (pointOut
- point
));
80 printf("flip: (%.1f, %.1f) -> (%.1f, %.1f)\n", pointOut
.x
, pointOut
.y
, p1
.x
, p1
.y
);
81 // flip "in" and "out" control points
82 fPath
->SetPoint(fIndex
[i
],
84 point
- (pointIn
- point
),
85 point
- (pointOut
- point
),
98 FlipPointsCommand::Undo()
100 status_t status
= Perform();
102 if (status
>= B_OK
) {
104 _Select(fIndex
, fCount
);
112 FlipPointsCommand::GetName(BString
& name
)
115 name
<< B_TRANSLATE("Flip Control Points");
117 name
<< B_TRANSLATE("Flip Control Point");