00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 #include "camtypes.h"
00104 #include "fillndge.h"
00105
00106
00107
00108
00109
00110 #include "opnudge.h"
00111
00112
00113
00114
00115
00116 class Spread;
00117
00118 DECLARE_SOURCE("$Revision: 1282 $");
00119
00120 CC_IMPLEMENT_DYNCREATE(OpFillNudge,Operation)
00121 CC_IMPLEMENT_DYNCREATE(FillGeometryNudger, AttrValueChange)
00122
00123 BOOL OpFillNudge::NudgeCols;
00124
00125 static CCRuntimeClass* LastNudgeType = NULL;
00126 static DocCoord LastNudgeStart = DocCoord(0,0);
00127 static DocCoord LastNudgeEnd = DocCoord(0,0);
00128 static DocCoord LastNudgeEnd2 = DocCoord(0,0);
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 void OpFillNudge::NudgeColours(BOOL cols)
00141 {
00142 NudgeCols = cols;
00143 }
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 #define IMPLEMENT_OPFILLNUDGE_CLASS(DIR,X_NUDGE_FACTOR,Y_NUDGE_FACTOR,UNDO_IDS) \
00177 CC_IMPLEMENT_DYNCREATE(OpFillNudge ## DIR,OpFillNudge) \
00178 void OpFillNudge ## DIR::Do(OpDescriptor* pOpDesc) \
00179 { \
00180 X_NudgeFactor = X_NUDGE_FACTOR; \
00181 Y_NudgeFactor = Y_NUDGE_FACTOR; \
00182 NudgeUndoIDS = UNDO_IDS; \
00183 OpFillNudge::Do(pOpDesc); \
00184 } \
00185
00186
00187
00188
00189
00190
00191
00192
00193 IMPLEMENT_OPFILLNUDGE_CLASS (Up1, 0, 1, _R(IDS_UNDO_NUDGE_UP))
00194 IMPLEMENT_OPFILLNUDGE_CLASS (Up5, 0, 5, _R(IDS_UNDO_NUDGE_UP))
00195 IMPLEMENT_OPFILLNUDGE_CLASS (Up10, 0, 10, _R(IDS_UNDO_NUDGE_UP))
00196 IMPLEMENT_OPFILLNUDGE_CLASS (UpFifth, 0, 0.2, _R(IDS_UNDO_NUDGE_UP))
00197 IMPLEMENT_OPFILLNUDGE_CLASS (UpPixel1, 0, 1, _R(IDS_UNDO_NUDGE_UP))
00198 IMPLEMENT_OPFILLNUDGE_CLASS (UpPixel10, 0, 10, _R(IDS_UNDO_NUDGE_UP))
00199
00200 IMPLEMENT_OPFILLNUDGE_CLASS (Down1, 0,-1, _R(IDS_UNDO_NUDGE_DOWN))
00201 IMPLEMENT_OPFILLNUDGE_CLASS (Down5 , 0,-5, _R(IDS_UNDO_NUDGE_DOWN))
00202 IMPLEMENT_OPFILLNUDGE_CLASS (Down10, 0,-10, _R(IDS_UNDO_NUDGE_DOWN))
00203 IMPLEMENT_OPFILLNUDGE_CLASS (DownFifth, 0, -0.2, _R(IDS_UNDO_NUDGE_DOWN))
00204 IMPLEMENT_OPFILLNUDGE_CLASS (DownPixel1, 0, -1, _R(IDS_UNDO_NUDGE_DOWN))
00205 IMPLEMENT_OPFILLNUDGE_CLASS (DownPixel10, 0,-10, _R(IDS_UNDO_NUDGE_DOWN))
00206
00207 IMPLEMENT_OPFILLNUDGE_CLASS (Left1, -1, 0, _R(IDS_UNDO_NUDGE_LEFT))
00208 IMPLEMENT_OPFILLNUDGE_CLASS (Left5, -5, 0, _R(IDS_UNDO_NUDGE_LEFT))
00209 IMPLEMENT_OPFILLNUDGE_CLASS (Left10, -10,0, _R(IDS_UNDO_NUDGE_LEFT))
00210 IMPLEMENT_OPFILLNUDGE_CLASS (LeftFifth, -0.2,0, _R(IDS_UNDO_NUDGE_LEFT))
00211 IMPLEMENT_OPFILLNUDGE_CLASS (LeftPixel1, -1, 0, _R(IDS_UNDO_NUDGE_LEFT))
00212 IMPLEMENT_OPFILLNUDGE_CLASS (LeftPixel10,-10, 0, _R(IDS_UNDO_NUDGE_LEFT))
00213
00214
00215 IMPLEMENT_OPFILLNUDGE_CLASS (Right1, 1, 0, _R(IDS_UNDO_NUDGE_RIGHT))
00216 IMPLEMENT_OPFILLNUDGE_CLASS (Right5, 5, 0, _R(IDS_UNDO_NUDGE_RIGHT))
00217 IMPLEMENT_OPFILLNUDGE_CLASS (Right10, 10, 0, _R(IDS_UNDO_NUDGE_RIGHT))
00218 IMPLEMENT_OPFILLNUDGE_CLASS (RightFifth, 0.2,0, _R(IDS_UNDO_NUDGE_RIGHT))
00219 IMPLEMENT_OPFILLNUDGE_CLASS (RightPixel1, 1, 0, _R(IDS_UNDO_NUDGE_RIGHT))
00220 IMPLEMENT_OPFILLNUDGE_CLASS (RightPixel10, 10, 0, _R(IDS_UNDO_NUDGE_RIGHT))
00221
00222
00223 #define new CAM_DEBUG_NEW
00224
00225 MILLIPOINT OpFillNudge::NudgeStep = 2835;
00226
00227 double OpFillNudge::X_NudgeFactor = 1;
00228 double OpFillNudge::Y_NudgeFactor = 0;
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243 void OpFillNudge::Do(OpDescriptor* pOpDesc)
00244 {
00245
00246
00247 FIXED16 ScaledPixelWidth, ScaledPixelHeight;
00248 GetWorkingView()->GetScaledPixelSize(&ScaledPixelWidth, &ScaledPixelHeight) ;
00249 PixelNudge=ScaledPixelWidth.MakeDouble() ;
00250
00251
00252 String OpToken = pOpDesc->Token;
00253
00254 if (OpToken == String(OPTOKEN_NUDGEUPPIXEL1)) { IsPixelNudgeClass = TRUE; }
00255 else if (OpToken == String(OPTOKEN_NUDGEUPPIXEL10)) { IsPixelNudgeClass = TRUE; }
00256
00257 else if (OpToken == String(OPTOKEN_NUDGEDOWNPIXEL1)) { IsPixelNudgeClass = TRUE; }
00258 else if (OpToken == String(OPTOKEN_NUDGEDOWNPIXEL10)) { IsPixelNudgeClass = TRUE; }
00259
00260 else if (OpToken == String(OPTOKEN_NUDGELEFTPIXEL1)) { IsPixelNudgeClass = TRUE; }
00261 else if (OpToken == String(OPTOKEN_NUDGELEFTPIXEL10)) { IsPixelNudgeClass = TRUE; }
00262
00263 else if (OpToken == String(OPTOKEN_NUDGERIGHTPIXEL1)) { IsPixelNudgeClass = TRUE; }
00264 else if (OpToken == String(OPTOKEN_NUDGERIGHTPIXEL10)) { IsPixelNudgeClass = TRUE; }
00265
00266 else if (OpToken == String(OPTOKEN_NUDGEUP1)) { IsPixelNudgeClass = FALSE; }
00267 else if (OpToken == String(OPTOKEN_NUDGEUP5)) { IsPixelNudgeClass = FALSE; }
00268 else if (OpToken == String(OPTOKEN_NUDGEUP10)) { IsPixelNudgeClass = FALSE; }
00269 else if (OpToken == String(OPTOKEN_NUDGEUPFIFTH)) { IsPixelNudgeClass = FALSE; }
00270
00271 else if (OpToken == String(OPTOKEN_NUDGEDOWN1)) { IsPixelNudgeClass = FALSE; }
00272 else if (OpToken == String(OPTOKEN_NUDGEDOWN5)) { IsPixelNudgeClass = FALSE; }
00273 else if (OpToken == String(OPTOKEN_NUDGEDOWN10)) { IsPixelNudgeClass = FALSE; }
00274 else if (OpToken == String(OPTOKEN_NUDGEDOWNFIFTH)) { IsPixelNudgeClass = FALSE; }
00275
00276 else if (OpToken == String(OPTOKEN_NUDGELEFT1)) { IsPixelNudgeClass = FALSE; }
00277 else if (OpToken == String(OPTOKEN_NUDGELEFT5)) { IsPixelNudgeClass = FALSE; }
00278 else if (OpToken == String(OPTOKEN_NUDGELEFT10)) { IsPixelNudgeClass = FALSE; }
00279 else if (OpToken == String(OPTOKEN_NUDGELEFTFIFTH)) { IsPixelNudgeClass = FALSE; }
00280
00281 else if (OpToken == String(OPTOKEN_NUDGERIGHT1)) { IsPixelNudgeClass = FALSE; }
00282 else if (OpToken == String(OPTOKEN_NUDGERIGHT5)) { IsPixelNudgeClass = FALSE; }
00283 else if (OpToken == String(OPTOKEN_NUDGERIGHT10)) { IsPixelNudgeClass = FALSE; }
00284 else if (OpToken == String(OPTOKEN_NUDGERIGHTFIFTH)) { IsPixelNudgeClass = FALSE; }
00285
00286
00287 DocCoord Offset;
00288
00289 if (IsPixelNudgeClass)
00290 {
00291 Offset.x=(INT32)GetXPixelDisplacement();
00292 Offset.y=(INT32)GetYPixelDisplacement();
00293 }
00294 else if (!IsPixelNudgeClass)
00295 {
00296
00297 Offset.x=(INT32) GetXNudgeDisplacement();
00298 Offset.y=(INT32) GetYNudgeDisplacement();
00299 }
00300
00301 if (AttrFillGeometry::SelectionCount == 0)
00302 {
00303
00304 FailAndExecute();
00305 End();
00306 return;
00307 }
00308
00309 FillGeometryNudger* FillNudger = new FillGeometryNudger();
00310
00311 if (FillNudger == NULL)
00312 {
00313 FailAndExecute();
00314 End();
00315 return;
00316 }
00317
00318 FillNudger->MutateColourFills(NudgeCols);
00319 FillNudger->SetNudgeDistance(Offset.x, Offset.y);
00320
00321 AttributeManager::AttributeSelected(NULL, FillNudger);
00322
00323 LastNudgeType = NULL;
00324 LastNudgeStart = DocCoord(0,0);
00325 LastNudgeEnd = DocCoord(0,0);
00326 LastNudgeEnd2 = DocCoord(0,0);
00327
00328 End();
00329 }
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344 void OpFillNudge::GetOpName(String_256* OpName)
00345 {
00346 *OpName = String_256(NudgeUndoIDS);
00347 }
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367 UINT32 FillGeometryNudger::GetAttrNameID(void)
00368 {
00369 return (_R(IDS_VALUE_CHANGE));
00370 }
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383 AttrFillGeometry* FillGeometryNudger::MutateFill(AttrFillGeometry* FillToMutate)
00384 {
00385 if (!FillToMutate->IsVisible() ||
00386 FillToMutate->GetSelectionCount() == 0)
00387 return NULL;
00388
00389
00390 AttrFillGeometry* NewFill = (AttrFillGeometry*)FillToMutate->SimpleCopy();
00391 if (NewFill == NULL)
00392 return NULL;
00393
00394
00395 Trans2DMatrix TransMat(X_NudgeDistance, Y_NudgeDistance);
00396
00397 BOOL isARampBlob = FALSE;
00398
00399
00400
00401 NewFill->TransformSelectedControlPoints(TransMat, &isARampBlob);
00402
00403 if (LastNudgeType == FillToMutate->GetRuntimeClass())
00404 {
00405 BOOL IsSame = TRUE;
00406
00407 if (FillToMutate->GetStartPoint() &&
00408 *FillToMutate->GetStartPoint() != LastNudgeStart)
00409 IsSame = FALSE;
00410
00411 if (FillToMutate->GetEndPoint() &&
00412 *FillToMutate->GetEndPoint() != LastNudgeEnd)
00413 IsSame = FALSE;
00414
00415 if (FillToMutate->GetEndPoint2() &&
00416 *FillToMutate->GetEndPoint2() != LastNudgeEnd2)
00417 IsSame = FALSE;
00418
00419 if (IsSame)
00420 return NewFill;
00421 }
00422
00423 Node *pNode = FillToMutate;
00424 while ((pNode != NULL) && !pNode->IsSpread())
00425 pNode = pNode->FindParent();
00426
00427 if (pNode == NULL)
00428 return NewFill;
00429
00430 Spread* pSpread = (Spread*)pNode;
00431
00432 DocRect OldBounds = FillToMutate->GetBlobBoundingRect();
00433 DocRect NewBounds = NewFill->GetBlobBoundingRect();
00434
00435 DocRect Bounds = OldBounds.Union(NewBounds);
00436
00437 RenderRegion* pRegion = DocView::RenderOnTop(&Bounds, pSpread, UnclippedEOR);
00438 while (pRegion)
00439 {
00440 if (!isARampBlob)
00441 {
00442
00443 FillToMutate->RenderFillBlobs(pRegion);
00444 NewFill->RenderFillBlobs(pRegion);
00445 }
00446 else
00447 {
00448 FillToMutate->DisableRampRedraw ();
00449 FillToMutate->RenderFillBlobs(pRegion);
00450 FillToMutate->EnableRampRedraw ();
00451 NewFill->DisableRampRedraw ();
00452 NewFill->RenderFillBlobs(pRegion);
00453 NewFill->EnableRampRedraw ();
00454 }
00455
00456
00457 pRegion = DocView::GetNextOnTop(&Bounds);
00458 }
00459
00460 AttrFillGeometry::LastRenderedMesh = NULL;
00461
00462 LastNudgeType = FillToMutate->GetRuntimeClass();
00463
00464 if (FillToMutate->GetStartPoint())
00465 LastNudgeStart = *FillToMutate->GetStartPoint();
00466
00467 if (FillToMutate->GetEndPoint())
00468 LastNudgeEnd = *FillToMutate->GetEndPoint();
00469
00470 if (FillToMutate->GetEndPoint2())
00471 LastNudgeEnd2 = *FillToMutate->GetEndPoint2();
00472
00473 return NewFill;
00474 }
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486 void FillGeometryNudger::SetNudgeDistance(INT32 xOffset, INT32 yOffset)
00487 {
00488 X_NudgeDistance = xOffset;
00489 Y_NudgeDistance = yOffset;
00490 }