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 "tracedlg.h"
00105
00106 #include "tracectl.h"
00107
00108
00109
00110
00111
00112
00113 #include "menuops.h"
00114
00115 #include "oilprog.h"
00116
00117 #include "ccdc.h"
00118 #include "dlgcol.h"
00119
00120 #include "grnddib.h"
00121
00122
00123
00124 #include "nodebmp.h"
00125 #include "bitmpinf.h"
00126 #include "chapter.h"
00127
00128 #include "page.h"
00129 #include "noderend.h"
00130
00131
00132
00133
00134
00135 #include "progress.h"
00136
00137
00138 #include "bubbleid.h"
00139
00140
00141 #include "bmpcomp.h"
00142 #include "wrkrect.h"
00143
00144 #include "mrhbits.h"
00145 #include "keypress.h"
00146 #include "fillattr2.h"
00147
00148
00149
00150 DECLARE_SOURCE("$Revision: 1334 $");
00151
00152
00153
00154 CC_IMPLEMENT_DYNAMIC(TraceMsg, Msg)
00155 CC_IMPLEMENT_DYNCREATE(TraceDlg, DialogOp)
00156 CC_IMPLEMENT_DYNCREATE(TraceOp, SelOperation)
00157 CC_IMPLEMENT_MEMDUMP(TraceOpParam, OpParam)
00158
00159
00160
00161 #define new CAM_DEBUG_NEW
00162
00163
00164
00165 const CDlgMode TraceDlg::Mode = MODELESS;
00166 const UINT32 TraceDlg::IDD = _R(IDD_TRACEDLG);
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 #define TRACER_FACTORY_SETTINGS {\
00178 {1, 50, 25, 50, 50, 80, 15}, \
00179 {1, 50, 25, 50, 50, 50, 50}, \
00180 {1, 50, 25, 65, 65, 50, 50}, \
00181 {1, 50, 25, 25, 25, 50, 50} \
00182 }
00183
00184 INT32 TraceDlg::DefaultMode=(INT32)TRACEMETHOD_TRUECOL;
00185 INT32 TraceDlg::DefaultSetting[NUM_TRACEMETHOD][NUM_TRACESETTING] = TRACER_FACTORY_SETTINGS;
00186 INT32 TraceDlg::FactorySetting[NUM_TRACEMETHOD][NUM_TRACESETTING] = TRACER_FACTORY_SETTINGS;
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203 BOOL TraceDlg::OriginalChanged()
00204 {
00205 if (pPrevOriginal==pOriginal) return TRUE;
00206 pPrevOriginal=pOriginal;
00207 if (pTraceControl) pTraceControl->InitBitmap(pOriginal);
00208 InvalidateGadget(_R(IDC_TRACER_ORIGREDRAW));
00209 return FixOriginalComboBox() && SetStatus() && DestinationChanged();
00210 }
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227 BOOL TraceDlg::DestinationChanged()
00228 {
00229 InvalidateGadget(_R(IDC_TRACER_DESTREDRAW));
00230 return TRUE;
00231 }
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 TraceDlg::TraceDlg() : DialogOp(TraceDlg::IDD, TraceDlg::Mode)
00245 {
00246
00247 pOriginal = NULL;
00248 pPrevOriginal=NULL;
00249 pTraceControl = new TraceControl;
00250 }
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264 TraceDlg::~TraceDlg()
00265 {
00266 pOriginal = NULL;
00267
00268 if(!m_p24BitCopyNames.empty())
00269 {
00270 Remove24BitTempCopy();
00271 }
00272
00273 if (pTraceControl)
00274 {
00275 pTraceControl->InitBitmap(pOriginal);
00276 delete pTraceControl;
00277 pTraceControl = NULL;
00278 }
00279 }
00280
00281 void TraceDlg::Remove24BitTempCopy()
00282 {
00283
00284 Document * pDoc = Document::GetSelected();
00285
00286
00287 BitmapList* Bitmaps = NULL;
00288 if (pDoc)
00289 {
00290 Bitmaps = pDoc->GetBitmapList();
00291 }
00292
00293
00294 KernelBitmap * pBmp = (KernelBitmap *)(Bitmaps->GetHead());
00295 KernelBitmap * pTemp = NULL;
00296
00297 BOOL DeleteThisBMP = FALSE;
00298
00299
00300 while (pBmp != NULL)
00301 {
00302
00303 std::list< String_256 >::iterator Pos = m_p24BitCopyNames.begin();
00304
00305
00306 while(Pos != m_p24BitCopyNames.end() && pBmp != NULL)
00307 {
00308
00309 if (pBmp->GetName().CompareTo(*Pos) == 0)
00310 {
00311
00312 DeleteThisBMP = TRUE;
00313
00314
00315 break;
00316 }
00317
00318
00319 Pos++;
00320 }
00321
00322
00323 pTemp = (KernelBitmap *) Bitmaps->GetNext(pBmp);
00324
00325
00326 if(DeleteThisBMP)
00327 {
00328
00329 Bitmaps->RemoveItem(pBmp);
00330 pBmp->Detach();
00331 delete pBmp;
00332 pBmp = NULL;
00333
00334
00335 DeleteThisBMP = FALSE;
00336 }
00337
00338
00339 pBmp = pTemp;
00340 }
00341
00342
00343 m_p24BitCopyNames.clear();
00344 }
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362 BOOL TraceDlg::CheckOriginalBitmap()
00363 {
00364 Document * pDoc = Document::GetSelected();
00365
00366
00367 BitmapList* Bitmaps = NULL;
00368 if (pDoc) Bitmaps = pDoc->GetBitmapList();
00369
00370 if (Bitmaps == NULL)
00371 {
00372 pOriginal = NULL;
00373 return OriginalChanged();
00374 }
00375
00376 KernelBitmap * pBmp = NULL;
00377
00378 pBmp = (KernelBitmap *)(Bitmaps->GetHead());
00379
00380 while (pBmp != NULL)
00381 {
00382 if (pBmp == pOriginal) return OriginalChanged();
00383 pBmp = (KernelBitmap *) Bitmaps->GetNext(pBmp);
00384 }
00385
00386 pOriginal = (KernelBitmap *)(Bitmaps->GetHead());
00387 return OriginalChanged();
00388 }
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407 BOOL TraceDlg::FixOriginalComboBox()
00408 {
00409
00410 Document * pDoc = Document::GetSelected();
00411
00412
00413 BitmapList* Bitmaps = NULL;
00414 if (pDoc) Bitmaps = pDoc->GetBitmapList();
00415
00416 if (Bitmaps == NULL)
00417 return TRUE;
00418
00419 String_256 Str;
00420
00421 DeleteAllValues(_R(IDC_TRACER_BITMAP));
00422
00423 BOOL DoneMain = FALSE;
00424 INT32 SelIndex = 0;
00425
00426 BOOL IsMono = FALSE;
00427 if ((pOriginal) && (pOriginal->GetBPP()==1)) IsMono=TRUE;
00428
00429 EnableGadget(_R(IDC_TRACER_BLURNUM), !IsMono);
00430 EnableGadget(_R(IDC_TRACER_BLURSLIDER), !IsMono);
00431 EnableGadget(_R(IDC_TRACER_BLURTXT), !IsMono);
00432
00433 if (Bitmaps->GetCount() > 0)
00434 {
00435 INT32 Index = 0;
00436
00437 ListItem* pBmp = Bitmaps->GetHead();
00438
00439 while (pBmp != NULL)
00440 {
00441 Str = ((KernelBitmap*)pBmp)->ActualBitmap->GetName();
00442 if (((KernelBitmap*)(pBmp)) == pOriginal)
00443 {
00444 SetStringGadgetValue(_R(IDC_TRACER_BITMAP),Str, FALSE, -1);
00445 DoneMain = TRUE;
00446 SelIndex=Index;
00447 }
00448 SetStringGadgetValue(_R(IDC_TRACER_BITMAP),Str,FALSE, Index++);
00449 pBmp = Bitmaps->GetNext(pBmp);
00450 }
00451 }
00452 else
00453 {
00454 Str.Load(_R(IDS_K_BFXDLG_DEFAULT));
00455 SetStringGadgetValue(_R(IDC_TRACER_BITMAP),Str,TRUE, 0);
00456 }
00457
00458 Str.Load(_R(IDS_K_BFXDLG_DEFAULT));
00459 SetComboListLength(_R(IDC_TRACER_BITMAP));
00460 if (!DoneMain)
00461 {
00462 SetStringGadgetValue(_R(IDC_TRACER_BITMAP),Str, FALSE, -1);
00463 SetSelectedValueIndex(_R(IDC_TRACER_BITMAP), 0);
00464 }
00465 else
00466 {
00467 SetSelectedValueIndex(_R(IDC_TRACER_BITMAP), SelIndex);
00468 }
00469 return TRUE;
00470 }
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490 BOOL TraceDlg::ReadOriginalComboBox()
00491 {
00492 Document * pDoc = Document::GetSelected();
00493
00494
00495 BitmapList* Bitmaps = NULL;
00496 if (pDoc) Bitmaps = pDoc->GetBitmapList();
00497
00498 if (Bitmaps == NULL)
00499 return TRUE;
00500
00501 ListItem* pBmp = Bitmaps->GetHead();
00502
00503 WORD Index;
00504 GetValueIndex(_R(IDC_TRACER_BITMAP),&Index);
00505
00506 for (INT32 i = 0; i < Index; i++)
00507 {
00508 if (pBmp == NULL)
00509 break;
00510
00511 pBmp = Bitmaps->GetNext(pBmp);
00512 }
00513
00514 pOriginal = (KernelBitmap*)pBmp;
00515 return CheckOriginalBitmap();
00516 }
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535 BOOL TraceDlg::SetStatus(BOOL Tracing)
00536 {
00537 UINT32 theID = _R(IDS_TRACER_PROGRESSSTRING_BLANK);
00538 INT32 NumPaths=0;
00539 INT32 NumPoints=0;
00540 INT32 Percent=0;
00541 BOOL Done=FALSE;
00542 String_256 Temp;
00543 if (pTraceControl && pTraceControl->GetProgress(&Percent, &NumPaths, NULL, &NumPoints, &Done) && Percent)
00544 {
00545 if (Done)
00546 {
00547 theID = _R(IDS_TRACER_PROGRESSSTRING_DONE);
00548 Tracing=FALSE;
00549 }
00550 else
00551 {
00552 if (Tracing)
00553 theID = _R(IDS_TRACER_PROGRESSSTRING_TRACING);
00554 else
00555 theID = _R(IDS_TRACER_PROGRESSSTRING_ABORTED);
00556 }
00557 }
00558 Temp.MakeMsg(theID, NumPaths, NumPoints);
00559 SetStringGadgetValue(_R(IDC_TRACER_STATUSTEXT), Temp);
00560 EnableGadget(_R(IDOK), Done && (!Tracing));
00561 EnableGadget(_R(IDCANCEL), !Tracing);
00562 EnableGadget(_R(IDC_TRACER_TRACEBTN), !Tracing);
00563 EnableGadget(_R(IDC_TRACER_HELP), !Tracing);
00564 return TRUE;
00565 }
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581 BOOL TraceDlg::LoadSettings(INT32 * pSettings)
00582 {
00583 SetLongGadgetValue(_R(IDC_TRACER_PASSESNUM), pSettings[0]);
00584 SetLongGadgetValue(_R(IDC_TRACER_BLURSLIDER), pSettings[1]);
00585 SetLongGadgetValue(_R(IDC_TRACER_MINAREASLIDER), pSettings[2]);
00586 SetLongGadgetValue(_R(IDC_TRACER_ICTSLIDER), pSettings[3]);
00587 SetLongGadgetValue(_R(IDC_TRACER_FCTSLIDER), pSettings[4]);
00588 SetLongGadgetValue(_R(IDC_TRACER_ACCURACYSLIDER), pSettings[5]);
00589 SetLongGadgetValue(_R(IDC_TRACER_SMOOTHSLIDER), pSettings[6]);
00590 return ReadParams();
00591 }
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607 BOOL TraceDlg::SaveSettings(INT32 * pSettings)
00608 {
00609 pSettings[0]=(INT32)GetLongGadgetValue(_R(IDC_TRACER_PASSESNUM) ,0, 100, 0, NULL);
00610 pSettings[1]=(INT32)GetLongGadgetValue(_R(IDC_TRACER_BLURSLIDER) ,0, 100, 0, NULL);
00611 pSettings[2]=(INT32)GetLongGadgetValue(_R(IDC_TRACER_MINAREASLIDER) ,0, 100, 0, NULL);
00612 pSettings[3]=(INT32)GetLongGadgetValue(_R(IDC_TRACER_ICTSLIDER) ,0, 100, 0, NULL);
00613 pSettings[4]=(INT32)GetLongGadgetValue(_R(IDC_TRACER_FCTSLIDER) ,0, 100, 0, NULL);
00614 pSettings[5]=(INT32)GetLongGadgetValue(_R(IDC_TRACER_ACCURACYSLIDER) ,0, 100, 0, NULL);
00615 pSettings[6]=(INT32)GetLongGadgetValue(_R(IDC_TRACER_SMOOTHSLIDER) ,0, 100, 0, NULL);
00616 return TRUE;
00617 }
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634 TraceMethod TraceDlg::GetTraceMethod()
00635 {
00636 TraceMethod Method;
00637 switch (GetSelectedValueIndex(_R(IDC_TRACER_METHOD)))
00638 {
00639 case 0:
00640 Method=TRACEMETHOD_MONO;
00641 break;
00642 case 1:
00643 Method=TRACEMETHOD_GREYSCALE;
00644 break;
00645 case 2:
00646 Method=TRACEMETHOD_256COL;
00647 break;
00648 case 3:
00649 default:
00650 Method=TRACEMETHOD_TRUECOL;
00651 break;
00652 }
00653 return Method;
00654 }
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671 BOOL TraceDlg::SetTraceMethod(TraceMethod Method)
00672 {
00673 switch (Method)
00674 {
00675 case TRACEMETHOD_MONO:
00676 SetSelectedValueIndex(_R(IDC_TRACER_METHOD), 0);
00677 break;
00678 case TRACEMETHOD_GREYSCALE:
00679 SetSelectedValueIndex(_R(IDC_TRACER_METHOD), 1);
00680 break;
00681 case TRACEMETHOD_256COL:
00682 SetSelectedValueIndex(_R(IDC_TRACER_METHOD), 2);
00683 break;
00684 case TRACEMETHOD_TRUECOL:
00685 default:
00686 SetSelectedValueIndex(_R(IDC_TRACER_METHOD), 3);
00687 break;
00688 }
00689 return TRUE;
00690 }
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703 BOOL TraceDlg::ReadParams()
00704 {
00705 SetLongGadgetValue(_R(IDC_TRACER_BLURNUM), GetLongGadgetValue(_R(IDC_TRACER_BLURSLIDER), 0, 100, 0, NULL));
00706 SetLongGadgetValue(_R(IDC_TRACER_MINAREANUM), GetLongGadgetValue(_R(IDC_TRACER_MINAREASLIDER), 0, 100, 0, NULL));
00707 SetLongGadgetValue(_R(IDC_TRACER_ACCURACYNUM),GetLongGadgetValue(_R(IDC_TRACER_ACCURACYSLIDER), 0, 100, 0, NULL));
00708 SetLongGadgetValue(_R(IDC_TRACER_ICTNUM), GetLongGadgetValue(_R(IDC_TRACER_ICTSLIDER), 0, 100, 0, NULL));
00709 SetLongGadgetValue(_R(IDC_TRACER_FCTNUM), GetLongGadgetValue(_R(IDC_TRACER_FCTSLIDER), 0, 100, 0, NULL));
00710 SetLongGadgetValue(_R(IDC_TRACER_SMOOTHNUM), GetLongGadgetValue(_R(IDC_TRACER_SMOOTHSLIDER), 0, 100, 0, NULL));
00711 TraceMethod Method=GetTraceMethod();
00712 BOOL Mono=(Method == TRACEMETHOD_MONO);
00713
00714 BOOL TrueCol=(Method == TRACEMETHOD_TRUECOL);
00715 INT32 Passes = GetLongGadgetValue (_R(IDC_TRACER_PASSESNUM), 0, 100, 0, NULL);
00716 if (Method != TRACEMETHOD_TRUECOL) Passes=1;
00717
00718 EnableGadget(_R(IDC_TRACER_FCTNUM), !Mono);
00719 EnableGadget(_R(IDC_TRACER_FCTSLIDER), !Mono);
00720 EnableGadget(_R(IDC_TRACER_FCTTXT), !Mono);
00721
00722 EnableGadget(_R(IDC_TRACER_ICTNUM), Passes>1);
00723 EnableGadget(_R(IDC_TRACER_ICTSLIDER), Passes>1);
00724 EnableGadget(_R(IDC_TRACER_ICTTXT), Passes>1);
00725
00726 EnableGadget(_R(IDC_TRACER_PASSESNUM), TrueCol);
00727 EnableGadget(_R(IDC_TRACER_PASSESTXT), TrueCol);
00728
00729 return TRUE;
00730 }
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743 BOOL TraceDlg::WriteParams()
00744 {
00745 ERROR2IF((!pTraceControl), FALSE, "No TraceControl in WriteParams()");
00746
00747 TraceMethod Method = TRACEMETHOD_TRUECOL;
00748 INT32 MinimumArea = 0;
00749 double MaximumInitialAreaErrorThreshold=0.0;
00750 double MinimumInitialAreaErrorThreshold=0.0;
00751 double InitialAreaErrorRatio=0.0;
00752 double MinGradFillError=0.0;
00753 double GradFillErrorRatio=0.0;
00754 double MinPixelError=0.0;
00755 double MaxPixelError=0.0;
00756 double PixelErrorRatio=0.0;
00757 double QuantColours=0.0;
00758 double Blur = 0.0;
00759 double Smooth=0.0;
00760
00761 pTraceControl->GetParams( &Method,
00762 &MinimumArea,
00763 &MaximumInitialAreaErrorThreshold,
00764 &MinimumInitialAreaErrorThreshold,
00765 &InitialAreaErrorRatio,
00766 &MinGradFillError,
00767 &GradFillErrorRatio,
00768 &MinPixelError,
00769 &MaxPixelError,
00770 &PixelErrorRatio,
00771 &QuantColours,
00772 &Blur,
00773 &Smooth
00774 );
00775
00776
00777 MinimumArea = GetLongGadgetValue (_R(IDC_TRACER_MINAREASLIDER), 0, 100, 0, NULL);
00778 MaximumInitialAreaErrorThreshold = 0.01+0.003*(double)(GetLongGadgetValue(_R(IDC_TRACER_ICTSLIDER), 0, 100, 0, NULL));
00779 MinimumInitialAreaErrorThreshold = 0.01+0.003*(double)(GetLongGadgetValue(_R(IDC_TRACER_FCTSLIDER), 0, 100, 0, NULL));
00780 MaxPixelError = 0.45+0.16*(double)(100-GetLongGadgetValue(_R(IDC_TRACER_ACCURACYSLIDER), 0, 100, 0, NULL));
00781 MinPixelError = MaxPixelError;
00782 Blur = (double)(GetLongGadgetValue(_R(IDC_TRACER_BLURSLIDER), 0, 100, 0, NULL));
00783 Smooth = (double)(GetLongGadgetValue(_R(IDC_TRACER_SMOOTHSLIDER), 0, 100, 0, NULL));
00784 QuantColours = 0.01*(double)(GetLongGadgetValue(_R(IDC_TRACER_FCTSLIDER), 0, 100, 0, NULL));
00785
00786 if (QuantColours<0) QuantColours=0;
00787 QuantColours=QuantColours*QuantColours;
00788
00789 INT32 Passes = GetLongGadgetValue (_R(IDC_TRACER_PASSESNUM), 0, 100, 0, NULL);
00790 Method = GetTraceMethod();
00791 if (Method != TRACEMETHOD_TRUECOL) Passes=1;
00792
00793 if (Passes<1) Passes=1;
00794 if (Passes>5) Passes=5;
00795 if (MaximumInitialAreaErrorThreshold<MinimumInitialAreaErrorThreshold*1.05)
00796 MaximumInitialAreaErrorThreshold=MinimumInitialAreaErrorThreshold*1.05;
00797 if (Passes==1)
00798 {
00799 MaximumInitialAreaErrorThreshold=MinimumInitialAreaErrorThreshold;
00800 InitialAreaErrorRatio = 0.5;
00801 }
00802 else
00803 {
00804 InitialAreaErrorRatio = exp ((1.0/(double)(Passes-1))*(log(MinimumInitialAreaErrorThreshold)-log(MaximumInitialAreaErrorThreshold)));
00805 }
00806 MinimumInitialAreaErrorThreshold *= 1.000000001;
00807
00808
00809 TRACEUSER( "Alex", _T("MinimumArea=%d, MaxIE=%f, MinIE=%f, IEAR=%f, MaxPE=%f, Passes=%d\n"),
00810 MinimumArea,
00811 MaximumInitialAreaErrorThreshold,
00812 MinimumInitialAreaErrorThreshold,
00813 InitialAreaErrorRatio,
00814 MaxPixelError,
00815 Passes);
00816
00817 pTraceControl->SetParams( &Method,
00818 &MinimumArea,
00819 &MaximumInitialAreaErrorThreshold,
00820 &MinimumInitialAreaErrorThreshold,
00821 &InitialAreaErrorRatio,
00822 &MinGradFillError,
00823 &GradFillErrorRatio,
00824 &MinPixelError,
00825 &MaxPixelError,
00826 &PixelErrorRatio,
00827 &QuantColours,
00828 &Blur,
00829 &Smooth
00830 );
00831
00832 return TRUE;
00833 }
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854 BOOL TraceDlg::FindBitmap()
00855 {
00856
00857
00858 Range Sel(*(GetApplication()->FindSelection()));
00859
00860 Node* FirstSelectedNode = Sel.FindFirst();
00861 if (FirstSelectedNode != NULL)
00862 {
00863 Node* CurrentNode = FirstSelectedNode;
00864 Node* NextCurrent;
00865
00866
00867 while (CurrentNode != NULL)
00868 {
00869 NextCurrent = Sel.FindNext(CurrentNode);
00870 if ( (CurrentNode->IsSelected()) && (CurrentNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodeBitmap)) )
00871 {
00872 pOriginal = ((NodeBitmap *)(CurrentNode))->GetBitmap();
00873 return CheckOriginalBitmap();
00874 }
00875 CurrentNode = NextCurrent;
00876 }
00877
00878 }
00879
00880
00881 AttrFillGeometry* pAttrNode = AttrFillGeometry::FindFirstSelectedAttr();
00882
00883 while (pAttrNode != NULL)
00884 {
00885 if (pAttrNode->IsKindOf(CC_RUNTIME_CLASS(AttrBitmapColourFill)))
00886 {
00887 pOriginal = pAttrNode->GetBitmap();
00888 return CheckOriginalBitmap();
00889 }
00890
00891
00892 pAttrNode = AttrFillGeometry::FindNextSelectedAttr();
00893 }
00894
00895 return CheckOriginalBitmap();
00896 }
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908 BOOL TraceDlg::DoTrace(BOOL SingleStep)
00909 {
00910 if (pTraceControl && pOriginal)
00911 {
00912 WriteParams();
00913 KernelBitmap * pDestination;
00914 KernelBitmap * pTemp;
00915 pTraceControl->GetBitmaps(NULL, &pDestination, &pTemp);
00916 if ((!SingleStep) || (!pDestination) || (!pTemp))
00917 pTraceControl->InitBitmap(pOriginal);
00918
00919 MonotonicTime MT;
00920
00921 BOOL Done = FALSE;
00922 BOOL Abort = FALSE;
00923
00924 String_64 ProcessMessage(_R(IDS_TRACEDLG_PREPROCESSING));
00925 BeginSlowJob(100, FALSE, &ProcessMessage);
00926 ContinueSlowJob();
00927
00928 while ((!Done) && (!Abort))
00929 {
00930 Abort = !(pTraceControl->Trace(&Done));
00931
00932
00933 if (!Abort)
00934 {
00935 if ((Abort = (KeyPress::IsEscapePressed() ==TRUE) ))
00936 {
00937 ERROR1RAW(_R(IDE_TRACER_ABORT));
00938 }
00939 }
00940
00941 if (Done || Abort || SingleStep || MT.Elapsed(1000, TRUE))
00942 {
00943 InvalidateGadget(_R(IDC_TRACER_DESTREDRAW));
00944 PaintGadgetNow(_R(IDC_TRACER_DESTREDRAW));
00945
00946 INT32 Percent;
00947 INT32 NumPaths;
00948 INT32 NumCusps;
00949 INT32 NumPoints;
00950
00951 if ((pTraceControl->GetProgress(&Percent, &NumPaths, &NumCusps, &NumPoints))&& !Abort)
00952 {
00953 Abort = !ContinueSlowJob(Percent);
00954 if (Abort) ERROR1RAW(_R(IDE_TRACER_ABORT));
00955 }
00956 SetStatus(TRUE);
00957
00958
00959 }
00960
00961 if (SingleStep)
00962 {
00963 EndSlowJob();
00964 SetStatus();
00965 return !Abort;
00966 }
00967
00968 }
00969 EndSlowJob();
00970 SetStatus();
00971 return (!Abort);
00972 }
00973 return SetStatus();
00974 }
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992 BOOL TraceDlg::RenderBitmap(ReDrawInfoType* ExtraInfo, KernelBitmap * BitmapToUse)
00993 {
00994
00995 DocRect VirtualSize(0, 0, ExtraInfo->dx, ExtraInfo->dy);
00996 RenderRegion* pRender = CreateGRenderRegion(&VirtualSize, ExtraInfo);
00997 if (pRender!=NULL)
00998 {
00999 DialogColourInfo RedrawColours;
01000
01001
01002 DocColour Grey(255,200,0);
01003
01004
01005 pRender->SaveContext();
01006 pRender->SetLineColour(COLOUR_TRANS);
01007
01008
01009 pRender->SetFillColour(RedrawColours.DialogBack());
01010 pRender->DrawRect(&VirtualSize);
01011
01012 if (BitmapToUse)
01013 {
01014
01015 NodeBitmap NB;
01016 NodeBitmap * pNodeBitmap = &NB;
01017
01018 if (!((pNodeBitmap == NULL) || (!pNodeBitmap->SetUpPath(12,12))))
01019 {
01020
01021 pNodeBitmap->GetBitmapRef()->SetBitmap(BitmapToUse);
01022
01023 ENSURE(pNodeBitmap->GetBitmap()->ActualBitmap != NULL, "No bitmap object found!");
01024
01025 DocRect BitmapSize(VirtualSize);
01026 BitmapInfo BMInfo;
01027 BitmapToUse->ActualBitmap->GetInfo(&BMInfo);
01028 if (BMInfo.PixelWidth==0) BMInfo.PixelWidth=1;
01029 if (BMInfo.PixelHeight==0) BMInfo.PixelHeight=1;
01030
01031 double BMAspect = ((double)(BMInfo.PixelWidth))/((double)(BMInfo.PixelHeight));
01032 double RedrawAspect = ((double)(ExtraInfo->dx))/((double)(ExtraInfo->dy));
01033
01034 if (BMAspect>RedrawAspect)
01035 {
01036
01037 INT32 NewHeight = (INT32)( 0.5 + ((double)(VirtualSize.Width()))/BMAspect);
01038 if (NewHeight<1) NewHeight = 1;
01039 BitmapSize.lo.y = (VirtualSize.Height()-NewHeight)/2;
01040 BitmapSize.hi.y = BitmapSize.lo.y + NewHeight;
01041 }
01042 else
01043 {
01044
01045 INT32 NewWidth = (INT32)( 0.5 + ((double)(VirtualSize.Height()))*BMAspect);
01046 if (NewWidth<1) NewWidth = 1;
01047 BitmapSize.lo.x = (VirtualSize.Width()-NewWidth)/2;
01048 BitmapSize.hi.x = BitmapSize.lo.x + NewWidth;
01049 }
01050
01051
01052 pNodeBitmap->CreateShape(BitmapSize);
01053
01054 pNodeBitmap->Render(pRender);
01055 }
01056 }
01057
01058 pRender->RestoreContext();
01059
01060
01061 DestroyGRenderRegion(pRender);
01062 }
01063 return TRUE;
01064 }
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090 MsgResult TraceDlg::Message( Msg* Message)
01091 {
01092 static INT32 OurMessage = 0;
01093 if (IS_OUR_DIALOG_MSG(Message))
01094 {
01095 DialogMsg* Msg = ((DialogMsg*) Message);
01096
01097 BOOL EndDialog = FALSE;
01098 BOOL CommitValues = FALSE;
01099
01100 switch (Msg->DlgMsg)
01101 {
01102 case DIM_CREATE:
01103 {
01104
01105 SetGadgetRange (_R(IDC_TRACER_BLURSLIDER), 0, 100, 1);
01106 SetGadgetBitmaps (_R(IDC_TRACER_BLURSLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01107
01108
01109 SetGadgetRange (_R(IDC_TRACER_ACCURACYSLIDER), 0, 100, 1);
01110 SetGadgetBitmaps (_R(IDC_TRACER_ACCURACYSLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01111
01112
01113 SetGadgetRange (_R(IDC_TRACER_MINAREASLIDER), 0, 50, 1);
01114 SetGadgetBitmaps (_R(IDC_TRACER_MINAREASLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01115
01116
01117 SetGadgetRange (_R(IDC_TRACER_ICTSLIDER), 0, 100, 1);
01118 SetGadgetBitmaps (_R(IDC_TRACER_ICTSLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01119
01120
01121 SetGadgetRange (_R(IDC_TRACER_FCTSLIDER), 0, 100, 1);
01122 SetGadgetBitmaps (_R(IDC_TRACER_FCTSLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01123
01124
01125 SetGadgetRange (_R(IDC_TRACER_SMOOTHSLIDER), 0, 100, 1);
01126 SetGadgetBitmaps (_R(IDC_TRACER_SMOOTHSLIDER), _R(IDB_QUALITYBASE), _R(IDB_QUALITYSLIDER));
01127
01128
01129
01130
01131 pOriginal=NULL;
01132 pPrevOriginal=NULL;
01133 OurMessage=0;
01134 FindBitmap();
01135
01136 DeleteAllValues(_R(IDC_TRACER_METHOD));
01137
01138 String_256 Str0(_R(IDS_TRACER_MONOCHROME));
01139 String_256 Str1(_R(IDS_TRACER_GREYSCALE));
01140 String_256 Str2(_R(IDS_TRACER_256COL));
01141 String_256 Str3(_R(IDS_TRACER_TRUECOL));
01142
01143 SetStringGadgetValue(_R(IDC_TRACER_METHOD),Str0,FALSE, 0);
01144 SetStringGadgetValue(_R(IDC_TRACER_METHOD),Str1,FALSE, 1);
01145 SetStringGadgetValue(_R(IDC_TRACER_METHOD),Str2,FALSE, 2);
01146 SetStringGadgetValue(_R(IDC_TRACER_METHOD),Str3,FALSE, 3);
01147
01148
01149 SetComboListLength(_R(IDC_TRACER_METHOD));
01150 SetTraceMethod((TraceMethod)DefaultMode);
01151 DefaultSetting[TRACEMETHOD_MONO][0]=1;
01152 DefaultSetting[TRACEMETHOD_256COL][0]=1;
01153 DefaultSetting[TRACEMETHOD_GREYSCALE][0]=1;
01154 LoadSettings(DefaultSetting[(INT32)DefaultMode]);
01155
01156
01157 WriteParams();
01158
01159
01160 break;
01161 }
01162
01163 case DIM_SLIDER_POS_CHANGING:
01164 case DIM_SLIDER_POS_IDLE:
01165 case DIM_SLIDER_POS_SET:
01166 {
01167 INT32 Passes = GetLongGadgetValue (_R(IDC_TRACER_PASSESNUM), 0, 100, 0, NULL);
01168 if (GetTraceMethod() != TRACEMETHOD_TRUECOL) Passes=1;
01169
01170 if (!OurMessage && (Msg->GadgetID == _R(IDC_TRACER_ICTSLIDER) || Msg->GadgetID == _R(IDC_TRACER_FCTSLIDER)))
01171 {
01172
01173 INT32 CurrentInit = GetLongGadgetValue (_R(IDC_TRACER_ICTSLIDER), 0, 100, 0, NULL);
01174 INT32 CurrentFinal = GetLongGadgetValue (_R(IDC_TRACER_FCTSLIDER), 0, 100, 0, NULL);
01175
01176 OurMessage++;
01177
01178 if (Msg->GadgetID == _R(IDC_TRACER_FCTSLIDER))
01179 {
01180 if (Passes<=1)
01181 {
01182 SetLongGadgetValue(_R(IDC_TRACER_ICTSLIDER), CurrentFinal);
01183 }
01184 else if (CurrentInit<=CurrentFinal)
01185 {
01186 SetLongGadgetValue(_R(IDC_TRACER_ICTSLIDER), ((CurrentFinal>=100)?100:CurrentFinal+1));
01187 }
01188 }
01189 else
01190 {
01191 if (Passes<=1)
01192 {
01193 SetLongGadgetValue(_R(IDC_TRACER_FCTSLIDER), CurrentInit);
01194 }
01195 else if (CurrentInit<=CurrentFinal)
01196 {
01197 SetLongGadgetValue(_R(IDC_TRACER_FCTSLIDER), ((CurrentInit<=0)?0:CurrentInit-1));
01198 }
01199 }
01200
01201 OurMessage--;
01202 }
01203 ReadParams();
01204 }
01205 break;
01206
01207 case DIM_TEXT_CHANGED:
01208 if (Msg->GadgetID == _R(IDC_TRACER_PASSESNUM)) ReadParams();
01209 break;
01210
01211 case DIM_COMMIT:
01212 EndDialog = TRUE;
01213 CommitValues = TRUE;
01214 break;
01215
01216 case DIM_SOFT_COMMIT:
01217 CommitValues = TRUE;
01218 break;
01219
01220 case DIM_CANCEL:
01221 EndDialog = TRUE;
01222 break;
01223
01224 case DIM_LFT_BN_CLICKED :
01225 {
01226 TraceMethod Method = GetTraceMethod();
01227
01228 if (Msg->GadgetID == _R(IDC_TRACER_TRACEBTN))
01229 {
01230 if (!DoTrace(FALSE)) InformError();
01231 }
01232 else if (Msg->GadgetID == _R(IDC_TRACER_RESET))
01233 {
01234 LoadSettings(DefaultSetting[(INT32)Method]);
01235 }
01236 else if (Msg->GadgetID == _R(IDC_TRACER_SAVE))
01237 {
01238 DefaultMode=Method;
01239 SaveSettings(DefaultSetting[(INT32)Method]);
01240 }
01241 else if (Msg->GadgetID == _R(IDC_TRACER_DEFAULT))
01242 {
01243 LoadSettings(FactorySetting[(INT32)Method]);
01244 }
01245 break;
01246 }
01247
01248 case DIM_REDRAW :
01249 {
01250
01251
01252
01253 KernelBitmap * pDestination;
01254 KernelBitmap * pTemp;
01255 pTraceControl->GetBitmaps(NULL, &pDestination, &pTemp);
01256
01257
01258 if (Msg->GadgetID == _R(IDC_TRACER_ORIGREDRAW))
01259 {
01260 RenderBitmap((ReDrawInfoType*) Msg->DlgMsgParam, pOriginal);
01261 }
01262 else if (Msg->GadgetID == _R(IDC_TRACER_DESTREDRAW))
01263 {
01264 RenderBitmap((ReDrawInfoType*) Msg->DlgMsgParam, pDestination);
01265 }
01266 break;
01267 }
01268
01269 case DIM_SELECTION_CHANGED:
01270 {
01271 if (Msg->GadgetID == _R(IDC_TRACER_BITMAP))
01272 {
01273 ReadOriginalComboBox();
01274 }
01275 else if (Msg->GadgetID == _R(IDC_TRACER_METHOD))
01276 {
01277 LoadSettings(DefaultSetting[(INT32)GetTraceMethod()]);
01278 }
01279 break;
01280 }
01281
01282 default:
01283 break;
01284 }
01285
01286
01287 if (EndDialog)
01288 {
01289 if (pTraceControl)
01290 {
01291 BOOL Done;
01292 pTraceControl->GetProgress(NULL,NULL,NULL,NULL,&Done);
01293 if (CommitValues && pOriginal && Done)
01294 {
01295 TraceOpParam param;
01296 param.pTraceControl = pTraceControl;
01297
01298 OpDescriptor* pOpDesc=OpDescriptor::FindOpDescriptor(_T("TraceOp"));
01299 ERROR3IF_PF(pOpDesc==NULL,("Couldn't find OPTOKEN_OPTRACEOP op descriptor"));
01300 pOpDesc->Invoke((OpParam*)¶m);
01301 }
01302
01303 pTraceControl->InitBitmap(NULL);
01304 pOriginal = NULL;
01305 pTraceControl->RemoveTree(TRUE );
01306 }
01307
01308 Close();
01309 TRACEUSER( "Alex", _T("Calling End()\n"));
01310 End();
01311
01312 return OK;
01313 }
01314
01315 } else if (MESSAGE_IS_A(Message, SelChangingMsg))
01316 {
01317 SelChangingMsg *Msg = (SelChangingMsg *) Message;
01318 switch ( Msg->State )
01319 {
01320 case SelChangingMsg::SELECTIONCHANGED:
01321 case SelChangingMsg::NODECHANGED:
01322
01323 FindBitmap();
01324 break;
01325 default:
01326 break;
01327 }
01328 } else if (MESSAGE_IS_A(Message, BitmapListChangedMsg))
01329 {
01330 CheckOriginalBitmap();
01331 FixOriginalComboBox();
01332 } else if (MESSAGE_IS_A(Message, TraceMsg))
01333 {
01334 pOriginal=((TraceMsg*)(Message))->pBitmap;
01335 CheckOriginalBitmap();
01336 }
01337
01338 return DialogOp::Message(Message);
01339 }
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351 OpState TraceDlg::GetState(String_256*, OpDescriptor*)
01352 {
01353 return OpState(FALSE, FALSE);
01354 }
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368 BOOL TraceDlg::Init()
01369 {
01370 INT32 Mode;
01371 INT32 Setting;
01372 GetApplication()->DeclareSection( _T("Tracer"), 40);
01373 GetApplication()->DeclarePref( _T("Tracer"), _T("DefaultMode"), &DefaultMode, 0, ((INT32)TRACEMETHOD_ILLEGAL)-1);
01374 String_256 PrefName;
01375 String_256 PrefBase(_T("Tracer mode #1%d setting #2%d"));
01376
01377 for (Mode=0; Mode<(INT32)NUM_TRACEMETHOD; Mode++) for (Setting=0; Setting<(INT32)NUM_TRACESETTING; Setting++)
01378 {
01379 PrefName._MakeMsg(PrefBase, Mode, Setting);
01380 GetApplication()->DeclarePref( _T("Tracer"), PrefName, &(DefaultSetting[Mode][Setting]), 0, 100);
01381 }
01382
01383 return (RegisterOpDescriptor(0,
01384 _R(IDS_TRACEDLG),
01385 CC_RUNTIME_CLASS(TraceDlg),
01386 OPTOKEN_TRACEDLG,
01387 TraceDlg::GetState,
01388 0,
01389 _R(IDBBL_BITMAPTRACER),
01390 _R(IDD_BARCONTROLSTORE),
01391 _R(IDC_BITMAPTRACER),
01392 SYSTEMBAR_UTILITIES,
01393 TRUE,
01394 FALSE,
01395 TRUE,
01396 0,
01397 _R(IDS_TRACER_ONE),
01398 GREY_WHEN_NO_CURRENT_DOC | DONT_GREY_WHEN_SELECT_INSIDE)
01399 && TraceOp::Init());
01400 }
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414 void TraceDlg::Do(OpDescriptor*)
01415 {
01416
01417 if (Create())
01418 Open();
01419 else
01420 TRACE( _T("Failed to create Render Demo Dialog\n"));
01421 }
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440 void TraceDlg::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
01441 {
01442 Do(pOp);
01443 KernelBitmap * pBitmap = NULL;
01444 if (pParam) pBitmap = (KernelBitmap *)(void *)(pParam->Param1);
01445 if (pBitmap && pBitmap->IsKindOf(CC_RUNTIME_CLASS(KernelBitmap)))
01446 {
01447 pOriginal=pBitmap;
01448 OriginalChanged();
01449 }
01450 return;
01451 }
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469 TraceOp::TraceOp(): SelOperation()
01470 {
01471 }
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491 BOOL TraceOp::Init()
01492 {
01493 return (SelOperation::RegisterOpDescriptor(
01494 0,
01495 _R(IDS_TRACEOP),
01496 CC_RUNTIME_CLASS(TraceOp),
01497 OPTOKEN_TRACEOP,
01498 TraceOp::GetState,
01499 0,
01500 0,
01501 0 ));
01502 }
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519 OpState TraceOp::GetState(String_256*, OpDescriptor*)
01520 {
01521 OpState OpSt;
01522 return(OpSt);
01523 }
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542 void TraceOp::DoWithParam(OpDescriptor* pOp, OpParam* pParam)
01543 {
01544 DocCoord DropPos;
01545 Spread * pSpread;
01546
01547 if (!GetWorkingDoc()) return;
01548
01549 if (!FindCentreInsertionPosition(&pSpread, &DropPos))
01550 {
01551 InformError();
01552 FailAndExecute();
01553 End();
01554 return;
01555 }
01556
01557
01558 BeginSlowJob(100, FALSE);
01559 TraceControl * pTraceControl = (((TraceOpParam *)(pParam))->pTraceControl);
01560 if (!pTraceControl) return;
01561
01562 KernelBitmap * pKB = NULL;
01563 Node * pXNode = pTraceControl->GetPaths();
01564 if (!pXNode || !pXNode->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableBounded))) return;
01565 NodeRenderableBounded *pNodeRenderableBounded = (NodeRenderableBounded *)pXNode;
01566
01567 if (!pTraceControl->GetBitmaps(&pKB, NULL, NULL))
01568 {
01569 InformError();
01570 FailAndExecute();
01571 End();
01572 return;
01573 }
01574
01575 if (!pKB)
01576 {
01577 ERROR2RAW("Where did that DropPos go then?");
01578 InformError();
01579 FailAndExecute();
01580 End();
01581 return;
01582 }
01583
01584
01585 BitmapInfo BMInfo;
01586 pKB->ActualBitmap->GetInfo(&BMInfo);
01587
01588 DocRect BoundsRect;
01589 BoundsRect.lo.x = DropPos.x - (BMInfo.RecommendedWidth/2);
01590 BoundsRect.lo.y = DropPos.y - (BMInfo.RecommendedHeight/2);
01591 BoundsRect.hi.x = BoundsRect.lo.x + BMInfo.RecommendedWidth;
01592 BoundsRect.hi.y = BoundsRect.lo.y + BMInfo.RecommendedHeight;
01593 DocCoord Point1 = DocCoord(BoundsRect.hi.x, BoundsRect.lo.y);
01594 DocCoord Point2 = DocCoord(BoundsRect.lo.x, BoundsRect.hi.y);
01595
01596 pTraceControl->RemoveTree(FALSE);
01597 pTraceControl->InitBitmap();
01598
01599 Matrix tMatrix(Div32By32(Point1.x-BoundsRect.lo.x,BMInfo.PixelWidth<<8),
01600 Div32By32(Point2.x-BoundsRect.lo.x,BMInfo.PixelWidth<<8),
01601 Div32By32(Point1.y-BoundsRect.lo.y,BMInfo.PixelHeight<<8),
01602 Div32By32(Point2.y-BoundsRect.lo.y,BMInfo.PixelHeight<<8),
01603 BoundsRect.lo.x,BoundsRect.lo.y);
01604 Trans2DMatrix Trans(tMatrix);
01605
01606 pNodeRenderableBounded->Transform(Trans);
01607
01608
01609 if (!DoInsertNewNode(pNodeRenderableBounded, pSpread, TRUE))
01610 {
01611 Node * pFirstChild = pNodeRenderableBounded->FindFirstChild();
01612 if (pFirstChild) pNodeRenderableBounded->DeleteChildren(pFirstChild);
01613 delete pNodeRenderableBounded;
01614
01615 EndSlowJob();
01616 FailAndExecute();
01617 InformError();
01618 End();
01619 return;
01620 }
01621
01622
01623 EndSlowJob();
01624 End();
01625 return;
01626
01627 }
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645
01646 BOOL TraceOp::FindCentreInsertionPosition(Spread** Spread, DocCoord* Position)
01647 {
01648
01649
01650
01651
01652 ERROR2IF((!Spread)||(!Position),FALSE,"Invalid call to FindCentreInsertionPoint()");
01653
01654 DocView* CurDocView = GetWorkingDocView();
01655
01656 ERROR2IF(!CurDocView, FALSE, "The current DocView is NULL");
01657
01658 WorkRect WrkViewRect = CurDocView->GetViewRect();
01659
01660 ERROR2IF((WrkViewRect.IsEmpty() || (!WrkViewRect.IsValid()) ), FALSE, "Invalid WorkRect");
01661
01662
01663 WorkCoord WrkCentreOfView;
01664 WrkCentreOfView.x = WrkViewRect.lo.x + (WrkViewRect.Width()/2);
01665 WrkCentreOfView.y = WrkViewRect.lo.y + (WrkViewRect.Height()/2);
01666
01667
01668 OilCoord OilCentreOfView = WrkCentreOfView.ToOil(CurDocView->GetScrollOffsets());
01669
01670
01671 (*Spread) = CurDocView->FindEnclosingSpread(OilCentreOfView);
01672 ERROR2IF(!(*Spread), FALSE, "No spread?!");
01673
01674
01675
01676
01677 DocRect DocViewRect = CurDocView->GetDocViewRect(*Spread);
01678
01679 ERROR2IF( ( (DocViewRect.IsEmpty()) || !(DocViewRect.IsValid())), FALSE, "DocViewRect is invalid" );
01680
01681
01682 DocCoord DocCentreOfView;
01683 DocCentreOfView.x = DocViewRect.lo.x + (DocViewRect.Width()/2);
01684 DocCentreOfView.y = DocViewRect.lo.y + (DocViewRect.Height()/2);
01685
01686
01687 (*Spread)->DocCoordToSpreadCoord(&DocCentreOfView);
01688
01689
01690 *Position = DocCentreOfView;
01691
01692 return TRUE;
01693 }
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711 void TraceMsg::OpenOrUse(KernelBitmap * pBitmap)
01712 {
01713
01714 OpDescriptor* OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(TraceDlg));
01715 if (!OpDesc) return;
01716
01717
01718 if (!MessageHandler::MessageHandlerExists(CC_RUNTIME_CLASS(TraceDlg)))
01719 {
01720 OpParam param((void *)pBitmap,(void *)NULL);
01721 OpDesc->Invoke(¶m);
01722 }
01723 else
01724 {
01725 BROADCAST_TO_CLASS(TraceMsg(pBitmap),DialogOp);
01726 }
01727 return;
01728 }
01729
01730