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 #include "camtypes.h"
00101
00102
00103 DECLARE_SOURCE("$Revision: 1771 $");
00104
00105
00106 #include "biasdlg.h"
00107
00108
00109
00110
00111 #include "nodershp.h"
00112 #include "lineattr.h"
00113 #include "biasgdgt.h"
00114
00115
00116
00117 #include "rndrgn.h"
00118 #include "stockcol.h"
00119 #include "qualattr.h"
00120
00121
00122
00123
00124 #include "dlgmgr.h"
00125
00126
00127
00128 CC_IMPLEMENT_DYNCREATE( CBiasGainDlg, DialogOp )
00129
00130
00131 #define new CAM_DEBUG_NEW
00132
00133
00134
00135
00136
00137
00138 const UINT32 CBiasGainDlg::IDD = _R(IDD_BIASGAIN);
00139 const CDlgMode CBiasGainDlg::Mode = MODELESS;
00140
00141 const INT32 CBiasGainDlg::kSliderLength_s = INT32( 200 );
00142 const INT32 CBiasGainDlg::kSliderHalfLength_s = kSliderLength_s / INT32( 2 );
00143 const INT32 CBiasGainDlg::kSliderMin_s = -( kSliderHalfLength_s );
00144 const INT32 CBiasGainDlg::kSliderMax_s = +( kSliderHalfLength_s );
00145
00146
00147
00148
00149
00150
00151 CBiasGainDlg::CBiasGainDlg ()
00152 : DialogOp( CBiasGainDlg::IDD, CBiasGainDlg::Mode ),
00153 pOwningGadget_m( 0 ),
00154 Id_m( 0 ),
00155 BiasGain_m()
00156 {
00157 m_pobddStandardProfile = NULL;
00158 }
00159
00160
00161 CBiasGainDlg::~CBiasGainDlg ()
00162 {
00163 delete m_pobddStandardProfile;
00164
00165 }
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 BOOL CBiasGainDlg::Init()
00180 {
00181 return RegisterOpDescriptor(
00182 0,
00183 _R(IDS_BIASGAINDLG),
00184 CC_RUNTIME_CLASS( CBiasGainDlg ),
00185 OPTOKEN_BIASGAIN_DLG,
00186 CBiasGainDlg::GetState,
00187 0,
00188 _R(IDBBL_BIASGAIN),
00189 _R(IDD_BARCONTROLSTORE),
00190 0,
00191
00192
00193 SYSTEMBAR_EDIT,
00194 TRUE,
00195 FALSE,
00196 TRUE,
00197 0,
00198 0,
00199 ( DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC )
00200 );
00201 }
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 OpState CBiasGainDlg::GetState(String_256* pHelpString, OpDescriptor*)
00226 {
00227
00228 static OpState DialogState;
00229 DialogState.Greyed = FALSE;
00230
00231 return DialogState;
00232
00233 }
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246 void CBiasGainDlg::Do(OpDescriptor*)
00247 {
00248 Create();
00249 Open();
00250 }
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 void CBiasGainDlg::DoWithParam(OpDescriptor*, OpParam* OwningGadgetParams)
00273 {
00274 BOOL noProfile = FALSE;
00275
00276
00277 pOwningGadget_m = reinterpret_cast<CBiasGainGadget*>((void*)(OwningGadgetParams->Param1));
00278 pOwningGadget_m->SetCBaisGainDlg (this);
00279
00280 const CProfileBiasGain* invokeOn = reinterpret_cast<CProfileBiasGain const*>((void*)(OwningGadgetParams->Param2));
00281
00282 if (invokeOn != NULL)
00283 {
00284 BiasGain_m = *(invokeOn);
00285 }
00286 else
00287 {
00288 noProfile = TRUE;
00289 }
00290
00291
00292 if( pOwningGadget_m != 0 )
00293 {
00294 Id_m = pOwningGadget_m->GetGadgetID();
00295 }
00296
00297
00298 Create();
00299 Open();
00300
00301 if (pOwningGadget_m->GetUseFillProfile () == TRUE)
00302 {
00303 ToggleFillProfile ();
00304 }
00305
00306 if (pOwningGadget_m->GetUseTranspFillProfile () == TRUE)
00307 {
00308 ToggleTranspFillProfile ();
00309 }
00310
00311
00312
00313 if( pOwningGadget_m != 0 )
00314 {
00315 String_256 Title;
00316 pOwningGadget_m->GetDialogTitle( Title );
00317 DialogManager::SetTitlebarName( WindowID, &Title );
00318 }
00319
00320 if (noProfile == TRUE)
00321 {
00322
00323 m_pobddStandardProfile->SetSelected(-1);
00324
00325
00326 DisableAllControls ();
00327 }
00328
00329
00330 if( pOwningGadget_m != 0 )
00331 {
00332 pOwningGadget_m->DialogHasOpened();
00333 }
00334 }
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346 MsgResult CBiasGainDlg::Message(Msg* Message)
00347 {
00348 if( IS_OUR_DIALOG_MSG( Message ) )
00349 {
00350 DialogMsg* Msg = static_cast<DialogMsg*>( Message );
00351
00352 switch( Msg->DlgMsg )
00353 {
00354 case DIM_TITLEFOCUSWARN:
00355 {
00356 DialogManager::DefaultKeyboardFocus();
00357 }
00358 break;
00359
00360 case DIM_CREATE :
00361 {
00362 manyDisabledControls = FALSE;
00363 useFillProfile = FALSE;
00364 useTranspFillProfile = FALSE;
00365
00366
00367 InitSliders( BiasGain_m );
00368 InitEditBoxes( BiasGain_m );
00369 InitiProfileCombobox();
00370
00371 InitBiasGainGadget(BiasGain_m);
00372
00373 InvalidateGadget( _R(IDC_CURVE) );
00374 InvalidateGadget( _R(IDC_CURVEINTERPOLATE) );
00375
00376 DialogManager::DefaultKeyboardFocus();
00377
00378 break;
00379 }
00380
00381 case DIM_CANCEL :
00382 {
00383 if (!(IsCustomComboDropdownVisible (_R(IDC_BIASGAINCOMBO))))
00384 {
00385 Close();
00386
00387
00388
00389
00390 if( pOwningGadget_m != 0 )
00391 {
00392 pOwningGadget_m->DialogHasClosed();
00393 return DLG_EAT_IF_HUNGRY(Msg);
00394 }
00395 }
00396 else
00397 {
00398 CloseDropdown (_R(IDC_BIASGAINCOMBO), FALSE);
00399 }
00400 break;
00401 }
00402
00403 case DIM_LFT_BN_UP:
00404 DialogManager::DefaultKeyboardFocus();
00405 break;
00406
00407
00408 case DIM_SLIDER_POS_CHANGING :
00409 {
00410 BiasGain_m.SetGeneratesInfiniteUndo (TRUE);
00411 HandleSliderPosChanging( Msg->DlgMsg, BiasGain_m );
00412 break;
00413 }
00414
00415 case DIM_SLIDER_POS_SET:
00416 {
00417 BiasGain_m.SetGeneratesInfiniteUndo (FALSE);
00418 HandleSliderPosSet( Msg->DlgMsg, BiasGain_m );
00419 DialogManager::DefaultKeyboardFocus();
00420 break;
00421 }
00422
00423 case DIM_SLIDER_POS_IDLE:
00424 {
00425 BiasGain_m.SetGeneratesInfiniteUndo (FALSE);
00426 HandleSliderPosSet( Msg->DlgMsg, BiasGain_m );
00427 break;
00428 }
00429
00430
00431 case DIM_COMMIT :
00432 {
00433 HandleCommit( Msg->DlgMsg, BiasGain_m );
00434 DialogManager::DefaultKeyboardFocus();
00435
00436 break;
00437 }
00438
00439 case DIM_TEXT_CHANGED:
00440 {
00441 HandleBiasEditChange(Msg->DlgMsg, BiasGain_m);
00442 DialogManager::DefaultKeyboardFocus();
00443
00444 break;
00445 }
00446
00447 case DIM_REDRAW :
00448 {
00449 if( Msg->GadgetID == _R(IDC_CURVE) )
00450 {
00451 DrawCurve( BiasGain_m, reinterpret_cast<ReDrawInfoType*>( Msg->DlgMsgParam ) );
00452 }
00453 else if ( Msg->GadgetID == _R(IDC_CURVEINTERPOLATE))
00454 {
00455 if ((useFillProfile == FALSE) && (useTranspFillProfile == FALSE))
00456 {
00457 DrawCurveInterpolate( BiasGain_m, reinterpret_cast<ReDrawInfoType*>( Msg->DlgMsgParam ) );
00458 }
00459 else if (useFillProfile == TRUE)
00460 {
00461 DrawFillInterpolate( BiasGain_m, reinterpret_cast<ReDrawInfoType*>( Msg->DlgMsgParam ) );
00462 }
00463 else
00464 {
00465 DrawTranspFillInterpolate( BiasGain_m, reinterpret_cast<ReDrawInfoType*>( Msg->DlgMsgParam ) );
00466 }
00467 }
00468
00469 break;
00470 }
00471
00472 case DIM_SELECTION_CHANGED:
00473 {
00474 if (Msg->GadgetID == _R(IDC_BIASGAINCOMBO))
00475 {
00476
00477
00478 INT32 iSelected = m_pobddStandardProfile->GetSelected();
00479 if (iSelected == -1)
00480 break;
00481
00482 DWORD dwSelected = (DWORD)iSelected;
00483
00484 switch(dwSelected)
00485 {
00486
00487
00488 case 0 :
00489 case 1 :
00490 case 2 :
00491 case 3 :
00492 case 4 :
00493 {
00494
00495
00496 if (manyDisabledControls == TRUE)
00497 {
00498 EnableAllControls ();
00499 }
00500
00501 BiasGainGadget.GetPresetBiasGainValue(dwSelected, BiasGain_m );
00502 InitSliders( BiasGain_m );
00503 InitEditBoxes( BiasGain_m );
00504 InvalidateGadget( _R(IDC_CURVE) );
00505 InvalidateGadget( _R(IDC_CURVEINTERPOLATE) );
00506
00507
00508
00509 BiasGainGadget.SetInfobarGadgetID (pOwningGadget_m->GetGadgetID ());
00510 BiasGainGadget.Message (Msg);
00511 }
00512 HandleInput(Msg->DlgMsg, BiasGain_m);
00513 }
00514 DialogManager::DefaultKeyboardFocus();
00515 }
00516 }
00517
00518 default:
00519 break;
00520 }
00521
00522 }
00523
00524
00525 return DialogOp::Message( Message );
00526
00527 }
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543 void CBiasGainDlg::DrawCurve( const CProfileBiasGain& CurveShape, ReDrawInfoType* ExtraInfo )
00544 {
00545
00546 static const INT32 kWidth = 15000;
00547 static const INT32 kHeight = 15000;
00548 static const INT32 kStep = 20;
00549 static const INT32 kLineWidth = 500;
00550
00551 static const StockColour kBackgoundOutline = COLOUR_NONE;
00552 static const StockColour kBackgound = COLOUR_WHITE;
00553 static const StockColour kBackgoundMany = COLOUR_LTGREY;
00554 static const StockColour kCurve = COLOUR_DKGREY;
00555
00556
00557 DocRect RenderRect( 0, 0, kWidth, kHeight );
00558
00559 RenderRegion* pRenderRegion = CreateGRenderRegion( &RenderRect, ExtraInfo );
00560
00561 if( pRenderRegion != 0 )
00562 {
00563 pRenderRegion->SaveContext();
00564
00565
00566 Quality QualityThing( Quality::QualityMax );
00567 QualityAttribute AntiAliasQualityAttr( QualityThing );
00568 pRenderRegion->SetQuality( &AntiAliasQualityAttr, FALSE );
00569
00570
00571
00572
00573 pRenderRegion->SetLineColour( kBackgoundOutline );
00574 if (manyDisabledControls == FALSE)
00575 {
00576 pRenderRegion->SetFillColour( kBackgound );
00577 }
00578 else
00579 {
00580 pRenderRegion->SetFillColour( kBackgoundMany );
00581 }
00582 pRenderRegion->DrawRect( &RenderRect );
00583
00584 if (manyDisabledControls == FALSE)
00585 {
00586
00587 {
00588
00589
00590 CProfileBiasGain DiagramMapper( CurveShape );
00591 DiagramMapper.SetIntervals( AFp( 0.0 ), AFp( kWidth ) );
00592
00593
00594 Path CurvePath;
00595 CurvePath.Initialise( kWidth );
00596 CurvePath.IsFilled = FALSE;
00597 CurvePath.FindStartOfPath();
00598
00599
00600
00601 static const DocCoord StartPoint( 0, 0 );
00602 CurvePath.InsertMoveTo( StartPoint );
00603
00604
00605 for( INT32 x = kStep ; x < kWidth ; x += kStep )
00606 {
00607 const AFp CurvePointFp = DiagramMapper.MapInterval( AFp( x ) );
00608 const DocCoord CurrentPoint( x, INT32( CurvePointFp + AFp(0.5) ) );
00609
00610 CurvePath.InsertLineTo( CurrentPoint );
00611 }
00612
00613
00614 static const DocCoord EndPoint( kWidth, kWidth );
00615 CurvePath.InsertLineTo( EndPoint );
00616
00617
00618
00619 pRenderRegion->SetLineWidth( kLineWidth );
00620 pRenderRegion->SetLineColour( kCurve );
00621
00622
00623 pRenderRegion->DrawPath( &CurvePath );
00624 }
00625 }
00626
00627 pRenderRegion->RestoreContext();
00628 DestroyGRenderRegion( pRenderRegion );
00629 }
00630 }
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641 void CBiasGainDlg::DrawCurveInterpolate ( const CProfileBiasGain& CurveShape, ReDrawInfoType* ExtraInfo )
00642 {
00643
00644 static const INT32 kWidth = ExtraInfo->dx;
00645 static const INT32 kBitWidth = kWidth/14;
00646 static const INT32 kHeight = ExtraInfo->dy;
00647 static const INT32 kHalfHeight = kHeight/2;
00648 static const INT32 kQuartHeight = kHeight/4;
00649 static const INT32 kLineWidth = 1500;
00650 static const INT32 kHalfLineWidth = kLineWidth/2;
00651
00652 static const StockColour kBackgoundOutline = COLOUR_NONE;
00653 static const StockColour kBackgound = COLOUR_WHITE;
00654 static const StockColour kBackgoundMany = COLOUR_LTGREY;
00655 static const StockColour kCurve = COLOUR_BLACK;
00656
00657
00658 DocRect RenderRect( 0, 0, kWidth, kHeight );
00659
00660 RenderRegion* pRenderRegion = CreateGRenderRegion( &RenderRect, ExtraInfo );
00661
00662
00663 if( pRenderRegion != 0 )
00664 {
00665 pRenderRegion->SaveContext();
00666
00667
00668 Quality QualityThing( Quality::QualityMax );
00669 QualityAttribute AntiAliasQualityAttr( QualityThing );
00670 pRenderRegion->SetQuality( &AntiAliasQualityAttr, FALSE );
00671
00672
00673
00674 pRenderRegion->SetLineColour( kBackgoundOutline );
00675 if (manyDisabledControls == FALSE)
00676 {
00677 pRenderRegion->SetFillColour( kBackgound );
00678 }
00679 else
00680 {
00681 pRenderRegion->SetFillColour( kBackgoundMany );
00682 }
00683 pRenderRegion->DrawRect( &RenderRect );
00684
00685 if (manyDisabledControls == FALSE)
00686 {
00687
00688
00689 static const AFp xOffset = (kHalfHeight - kQuartHeight) + kHalfLineWidth;
00690
00691 CProfileBiasGain DiagramMapper( CurveShape );
00692 DiagramMapper.SetIntervals( AFp( 0.0 ), AFp( kWidth - (2*xOffset)) );
00693
00694
00695 Path CurvePath;
00696 CurvePath.Initialise( kWidth );
00697 CurvePath.IsFilled = FALSE;
00698 CurvePath.FindStartOfPath();
00699
00700
00701
00702
00703
00704
00705 static const DocCoord vc1 ( 0, kHalfHeight - kQuartHeight );
00706 static const DocCoord vc2 ( 0, kHalfHeight + kQuartHeight );
00707
00708 static DocCoord StartPoint ((INT32)xOffset, kHalfHeight - kQuartHeight);
00709 CurvePath.InsertMoveTo( StartPoint );
00710 static DocCoord EndStartPoint ((INT32)xOffset, kHalfHeight + kQuartHeight);
00711 CurvePath.InsertLineTo( EndStartPoint );
00712
00713 for (INT32 i = 1; i < 13; i++)
00714 {
00715 static DocCoord vi1;
00716 vi1 = vc1;
00717 vi1.x += (i) * kBitWidth;
00718 vi1.x = (INT32)(xOffset + DiagramMapper.MapInterval( AFp( vi1.x ) ) );
00719 CurvePath.InsertMoveTo( vi1 );
00720 static DocCoord vi2;
00721 vi2 = vc2;
00722 vi2.x += (i) * kBitWidth;
00723 vi2.x = (INT32)(xOffset + DiagramMapper.MapInterval( AFp( vi2.x ) ) );
00724 CurvePath.InsertLineTo( vi2 );
00725 }
00726
00727 static DocCoord StartEndPoint (kWidth - (INT32)xOffset, kHalfHeight - kQuartHeight);
00728 CurvePath.InsertMoveTo( StartEndPoint );
00729 static DocCoord EndPoint (kWidth - (INT32)xOffset, kHalfHeight + kQuartHeight);
00730 CurvePath.InsertLineTo( EndPoint );
00731
00732
00733 pRenderRegion->SetLineWidth( kLineWidth );
00734 pRenderRegion->SetLineColour( kCurve );
00735
00736
00737 pRenderRegion->DrawPath( &CurvePath );
00738 }
00739
00740 pRenderRegion->RestoreContext();
00741 DestroyGRenderRegion( pRenderRegion );
00742 }
00743 }
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756 void CBiasGainDlg::DrawFillInterpolate ( const CProfileBiasGain& CurveShape, ReDrawInfoType* ExtraInfo )
00757 {
00758
00759 static const INT32 kWidth = ExtraInfo->dx;
00760
00761 static const INT32 kHalfWidth = kWidth/2;
00762 static const INT32 kHeight = ExtraInfo->dy;
00763 static const INT32 kHalfHeight = kHeight/2;
00764
00765 static const INT32 kLineWidth = 2000;
00766
00767
00768 static const StockColour kBackgoundOutline = COLOUR_NONE;
00769 static const StockColour kBackgound = COLOUR_WHITE;
00770 static const StockColour kBackgoundMany = COLOUR_LTGREY;
00771
00772 static StockColour kStartColour = COLOUR_BLACK;
00773 static StockColour kEndColour = COLOUR_WHITE;
00774
00775
00776 DocRect RenderRect( 0, 0, kWidth, kHeight );
00777
00778 RenderRegion* pRenderRegion = CreateGRenderRegion( &RenderRect, ExtraInfo );
00779
00780
00781 if( pRenderRegion != 0 )
00782 {
00783 pRenderRegion->SaveContext();
00784
00785
00786 Quality QualityThing( Quality::QualityMax );
00787 QualityAttribute AntiAliasQualityAttr( QualityThing );
00788 pRenderRegion->SetQuality( &AntiAliasQualityAttr, FALSE );
00789
00790
00791
00792 pRenderRegion->SetLineColour( kBackgoundOutline );
00793 if (manyDisabledControls == FALSE)
00794 {
00795 pRenderRegion->SetFillColour( kBackgound );
00796 }
00797 else
00798 {
00799 pRenderRegion->SetFillColour( kBackgoundMany );
00800 }
00801 pRenderRegion->DrawRect( &RenderRect );
00802
00803 LinearFillAttribute DummyFillAttribute;
00804
00805 if (manyDisabledControls == FALSE)
00806 {
00807 NodeRegularShape* DummyShape = new NodeRegularShape ();
00808
00809 if (DummyShape != NULL)
00810 {
00811 DummyShape->SetUpShape ();
00812 DummyShape->MakeRectangle (kWidth, kHeight, 0);
00813 Matrix* TransformMatrix = new Matrix ();
00814 if (TransformMatrix != NULL)
00815 {
00816 TransformMatrix->SetTranslation (kHalfWidth, kHalfHeight);
00817 DummyShape->SetTransformMatrix (TransformMatrix);
00818 delete (TransformMatrix);
00819 }
00820
00821
00822
00823
00824
00825
00826
00827 DocCoord StartPoint (0, kHalfHeight);
00828 DummyFillAttribute.SetStartPoint (&StartPoint);
00829
00830 DocColour* StartColour = pOwningGadget_m->GetStartColour ();
00831 DocColour vStartColour (kStartColour);
00832 if (StartColour != NULL) { DummyFillAttribute.SetStartColour (StartColour); }
00833 else { DummyFillAttribute.SetStartColour (&vStartColour); }
00834
00835
00836
00837 DocCoord EndPoint (kWidth, kHalfHeight);
00838 DummyFillAttribute.SetEndPoint (&EndPoint);
00839
00840 DocColour* EndColour = pOwningGadget_m->GetEndColour ();
00841 DocColour vEndColour (kEndColour);
00842 if (EndColour != NULL) { DummyFillAttribute.SetEndColour (EndColour); }
00843 else { DummyFillAttribute.SetEndColour (&vEndColour); }
00844
00845
00846
00847 DummyFillAttribute.SetEndPoint2 (NULL);
00848 DummyFillAttribute.SetEndPoint3 (NULL);
00849
00850 CProfileBiasGain DiagramMapper( CurveShape );
00851 DummyFillAttribute.SetProfile (DiagramMapper);
00852
00853 pRenderRegion->SetFillGeometry((ColourFillAttribute*) &DummyFillAttribute, FALSE);
00854
00855
00856
00857 if (pOwningGadget_m->GetFillEffect () != NULL)
00858 {
00859 pRenderRegion->SetFillEffect (pOwningGadget_m->GetFillEffect (), FALSE);
00860 }
00861
00862 pRenderRegion->SetLineWidth( kLineWidth );
00863
00864
00865
00866 DummyShape->Render (pRenderRegion);
00867 delete (DummyShape);
00868 }
00869 }
00870
00871 pRenderRegion->RestoreContext();
00872 DestroyGRenderRegion( pRenderRegion );
00873 }
00874 }
00875
00876 void CBiasGainDlg::DrawTranspFillInterpolate ( const CProfileBiasGain& CurveShape, ReDrawInfoType* ExtraInfo )
00877 {
00878
00879 static const INT32 kWidth = ExtraInfo->dx;
00880
00881 static const INT32 kHalfWidth = kWidth/2;
00882 static const INT32 kHeight = ExtraInfo->dy;
00883 static const INT32 kHalfHeight = kHeight/2;
00884
00885 static const INT32 kLineWidth = 2000;
00886
00887
00888 static const StockColour kBackgoundOutline = COLOUR_NONE;
00889 static const StockColour kBackgound = COLOUR_WHITE;
00890 static const StockColour kBackgoundMany = COLOUR_LTGREY;
00891 static const StockColour kCurve = COLOUR_WHITE;
00892 static const StockColour kCurve2 = COLOUR_BLUE;
00893
00894
00895
00896
00897 DocRect RenderRect( 0, 0, kWidth, kHeight );
00898
00899 RenderRegion* pRenderRegion = CreateGRenderRegion( &RenderRect, ExtraInfo );
00900
00901
00902 if( pRenderRegion != 0 )
00903 {
00904 pRenderRegion->SaveContext();
00905
00906
00907 Quality QualityThing( Quality::QualityMax );
00908 QualityAttribute AntiAliasQualityAttr( QualityThing );
00909 pRenderRegion->SetQuality( &AntiAliasQualityAttr, FALSE );
00910
00911
00912
00913 pRenderRegion->SetLineColour( kBackgoundOutline );
00914 if (manyDisabledControls == FALSE)
00915 {
00916 pRenderRegion->SetFillColour( kBackgound );
00917 }
00918 else
00919 {
00920 pRenderRegion->SetFillColour( kBackgoundMany );
00921 }
00922 pRenderRegion->DrawRect( &RenderRect );
00923
00924 LinearTranspFillAttribute DummyFillAttribute;
00925
00926 if (manyDisabledControls == FALSE)
00927 {
00928 NodeRegularShape* DummyShape = new NodeRegularShape ();
00929
00930 if (DummyShape != NULL)
00931 {
00932 NodeRegularShape* DummyShape2 = new NodeRegularShape ();
00933
00934 if (DummyShape2 != NULL)
00935 {
00936 DummyShape->SetUpShape ();
00937 DummyShape->MakeRectangle (kWidth, kHeight, 0);
00938 Matrix* TransformMatrix = new Matrix ();
00939 TransformMatrix->SetTranslation (kHalfWidth, kHalfHeight);
00940 DummyShape->SetTransformMatrix (TransformMatrix);
00941 delete (TransformMatrix);
00942
00943 DummyShape2->SetUpShape ();
00944 DummyShape2->MakeRectangle (kWidth, kHalfHeight, 0);
00945 Matrix* TransformMatrix2 = new Matrix ();
00946 TransformMatrix2->SetTranslation (kHalfWidth, kHalfHeight);
00947 DummyShape2->SetTransformMatrix (TransformMatrix2);
00948 delete (TransformMatrix2);
00949
00950
00951
00952
00953
00954 DocCoord StartPoint (0, kHalfHeight);
00955 DummyFillAttribute.SetStartPoint (&StartPoint);
00956 DocCoord EndPoint (kWidth, kHalfHeight);
00957 DummyFillAttribute.SetEndPoint (&EndPoint);
00958 DummyFillAttribute.SetEndPoint2 (NULL);
00959 DummyFillAttribute.SetEndPoint3 (NULL);
00960
00961
00962
00963 UINT32* StartVal = pOwningGadget_m->GetStartTransp ();
00964 UINT32 vStartVal (0);
00965 if (StartVal != NULL) { DummyFillAttribute.SetStartTransp (StartVal); }
00966 else { DummyFillAttribute.SetStartTransp (&vStartVal); }
00967
00968
00969
00970 UINT32* EndVal = pOwningGadget_m->GetEndTransp ();
00971 UINT32 vEndVal (255);
00972 if (EndVal != NULL) { DummyFillAttribute.SetEndTransp (EndVal); }
00973 else { DummyFillAttribute.SetEndTransp (&vEndVal); }
00974
00975
00976
00977 DummyFillAttribute.SetEndTransp2 (NULL);
00978 DummyFillAttribute.SetEndTransp3 (NULL);
00979
00980 CProfileBiasGain DiagramMapper( CurveShape );
00981 DummyFillAttribute.SetProfile (DiagramMapper);
00982
00983 pRenderRegion->SetLineWidth( kLineWidth );
00984
00985 pRenderRegion->SetFillColour (kCurve2);
00986
00987 DummyShape2->Render (pRenderRegion);
00988
00989 pRenderRegion->SetTranspFillGeometry((TranspFillAttribute*) &DummyFillAttribute, FALSE);
00990
00991 pRenderRegion->SetFillColour (kCurve);
00992 DummyShape->Render (pRenderRegion);
00993
00994 delete (DummyShape2);
00995 delete (DummyShape);
00996 }
00997 }
00998 }
00999
01000 pRenderRegion->RestoreContext();
01001 DestroyGRenderRegion( pRenderRegion );
01002 }
01003 }
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017 void CBiasGainDlg::InitSliders(CProfileBiasGain const& BiasGain)
01018 {
01019
01020 InitOneSlider( _R(IDC_SLIDER_BIAS) );
01021 InitOneSlider( _R(IDC_SLIDER_GAIN) );
01022
01023 WriteSliders( BiasGain );
01024
01025 }
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036 void CBiasGainDlg::InitiProfileCombobox()
01037 {
01038
01039 if (m_pobddStandardProfile)
01040 {
01041 delete m_pobddStandardProfile;
01042 m_pobddStandardProfile = NULL;
01043 }
01044
01045 m_pobddStandardProfile = new CBitmapGridDropDown;
01046 m_pobddStandardProfile->Init(WindowID, _R(IDC_BIASGAINCOMBO));
01047
01048 m_pobddStandardProfile->SetColumns(1);
01049 m_pobddStandardProfile->SetItemSize(wxSize(21, 21));
01050
01051 m_pobddStandardProfile->AddItem(_R(IDB_PROFILE1));
01052 m_pobddStandardProfile->AddItem(_R(IDB_PROFILE2));
01053 m_pobddStandardProfile->AddItem(_R(IDB_PROFILE3));
01054 m_pobddStandardProfile->AddItem(_R(IDB_PROFILE4));
01055 m_pobddStandardProfile->AddItem(_R(IDB_PROFILE5));
01056
01057 m_pobddStandardProfile->SetUnselectedItem(_R(IDB_PROFILE6));
01058 }
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070 void CBiasGainDlg::InitBiasGainGadget(CProfileBiasGain const& BiasGain)
01071 {
01072 INT32 iProfileIndex = BiasGainGadget.FindPresetBiasGain(BiasGain);
01073
01074 m_pobddStandardProfile->SetSelected(iProfileIndex);
01075 }
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087 void CBiasGainDlg::WriteSliders(CProfileBiasGain const& BiasGain)
01088 {
01089
01090 WriteOneSlider( BiasGain.GetBias(), _R(IDC_SLIDER_BIAS) );
01091
01092 WriteOneSlider( BiasGain.GetGain(), _R(IDC_SLIDER_GAIN) );
01093
01094 }
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108 void CBiasGainDlg::InvokeVia(CBiasGainGadget& pInvokeWith, CProfileBiasGain* pInvokeOn, BOOL bMany)
01109 {
01110 OpDescriptor* pOpDescriptor = OpDescriptor::FindOpDescriptor( OPTOKEN_BIASGAIN_DLG );
01111 if( pOpDescriptor != 0 )
01112 {
01113 if (pInvokeOn != NULL)
01114 {
01115 OpParam Param( reinterpret_cast<void*>( &pInvokeWith ), reinterpret_cast<void*>( pInvokeOn ) );
01116 DoWithParam( pOpDescriptor, &Param );
01117 }
01118 else if (bMany == TRUE)
01119 {
01120 OpParam Param( reinterpret_cast<void*>( &pInvokeWith ), reinterpret_cast<void*>( pInvokeOn ) );
01121 DoWithParam( pOpDescriptor, &Param );
01122 }
01123 else
01124 {
01125 CProfileBiasGain defaultInvokeOn;
01126
01127 OpParam Param( reinterpret_cast<void*>( &pInvokeWith ), reinterpret_cast<void*>( &defaultInvokeOn ) );
01128 DoWithParam( pOpDescriptor, &Param );
01129 }
01130 }
01131 }
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145 void CBiasGainDlg::ReInitialiseDialog(CProfileBiasGain* ReInitOn, BOOL bMany)
01146 {
01147 if (ReInitOn != NULL)
01148 {
01149 BiasGain_m = *ReInitOn;
01150
01151
01152
01153 if (manyDisabledControls == TRUE)
01154 {
01155 EnableAllControls ();
01156 }
01157
01158
01159 InitSliders( BiasGain_m );
01160 InitEditBoxes( BiasGain_m );
01161 InitiProfileCombobox();
01162 InitBiasGainGadget ( BiasGain_m );
01163
01164
01165 InvalidateGadget( _R(IDC_CURVE) );
01166 InvalidateGadget( _R(IDC_CURVEINTERPOLATE) );
01167 }
01168 else if (bMany == TRUE)
01169 {
01170
01171 m_pobddStandardProfile->SetSelected(-1);
01172
01173
01174 DisableAllControls ();
01175 }
01176 }
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188 void CBiasGainDlg::DisableAllControls()
01189 {
01190 manyDisabledControls = TRUE;
01191
01192 EnableGadget (_R(IDC_STATIC1), FALSE);
01193 EnableGadget (_R(IDC_STATIC2), FALSE);
01194 EnableGadget (_R(IDC_STATIC3), FALSE);
01195 EnableGadget (_R(IDC_STATIC4), FALSE);
01196 EnableGadget (_R(IDC_STATIC5), FALSE);
01197 EnableGadget (_R(IDC_STATIC6), FALSE);
01198
01199 EnableGadget (_R(IDC_STATIC8), FALSE);
01200 EnableGadget (_R(IDC_STATIC9), FALSE);
01201 EnableGadget (_R(IDC_SLIDER_BIAS), FALSE);
01202 EnableGadget (_R(IDC_SLIDER_GAIN), FALSE);
01203 EnableGadget (_R(IDC_EDIT_BIAS), FALSE);
01204 EnableGadget (_R(IDC_EDIT_GAIN), FALSE);
01205
01206 InvalidateGadget( _R(IDC_CURVE) );
01207 InvalidateGadget( _R(IDC_CURVEINTERPOLATE) );
01208 }
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221 void CBiasGainDlg::EnableAllControls()
01222 {
01223 manyDisabledControls = FALSE;
01224
01225 EnableGadget (_R(IDC_STATIC1), TRUE);
01226 EnableGadget (_R(IDC_STATIC2), TRUE);
01227 EnableGadget (_R(IDC_STATIC3), TRUE);
01228 EnableGadget (_R(IDC_STATIC4), TRUE);
01229 EnableGadget (_R(IDC_STATIC5), TRUE);
01230 EnableGadget (_R(IDC_STATIC6), TRUE);
01231
01232 EnableGadget (_R(IDC_STATIC8), TRUE);
01233 EnableGadget (_R(IDC_STATIC9), TRUE);
01234 EnableGadget (_R(IDC_SLIDER_BIAS), TRUE);
01235 EnableGadget (_R(IDC_SLIDER_GAIN), TRUE);
01236 EnableGadget (_R(IDC_EDIT_BIAS), TRUE);
01237 EnableGadget (_R(IDC_EDIT_GAIN), TRUE);
01238
01239 InvalidateGadget( _R(IDC_CURVE) );
01240 InvalidateGadget( _R(IDC_CURVEINTERPOLATE) );
01241 }
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253 CProfileBiasGain CBiasGainDlg::GetCurrentDialogProfile()
01254 {
01255 return (BiasGain_m);
01256 }
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269 void CBiasGainDlg::ReadSliders(CProfileBiasGain& BiasGain)
01270 {
01271 BiasGain.SetBias( ReadOneSlider( _R(IDC_SLIDER_BIAS) ) );
01272 BiasGain.SetGain( ReadOneSlider( _R(IDC_SLIDER_GAIN) ) );
01273 }
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286 void CBiasGainDlg::InitOneSlider(CGadgetID GadgetID)
01287 {
01288
01289 SetGadgetRange( GadgetID, kSliderMin_s, kSliderMax_s );
01290 SetGadgetBitmaps( GadgetID, _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER) );
01291
01292 }
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304 void CBiasGainDlg::WriteOneSlider(AFp ValueMinus1ToPlus1, CGadgetID GadgetID)
01305 {
01306 const INT32 SliderValue = INT32( ValueMinus1ToPlus1 * AFp( kSliderHalfLength_s ) + AFp(0.5) );
01307 SetLongGadgetValue( GadgetID, SliderValue );
01308 }
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319 AFp CBiasGainDlg::ReadOneSlider(CGadgetID GadgetID)
01320 {
01321
01322 const INT32 iSliderValue = GetLongGadgetValue( GadgetID, kSliderMin_s, kSliderMax_s );
01323 const AFp ValueMinus1ToPlus1 = AFp(iSliderValue) / AFp(kSliderHalfLength_s);
01324
01325 return ValueMinus1ToPlus1;
01326
01327 }
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341 void CBiasGainDlg::InitEditBoxes(CProfileBiasGain const& BiasGain)
01342 {
01343 WriteEditBoxes( BiasGain );
01344 }
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356 void CBiasGainDlg::WriteEditBoxes(CProfileBiasGain const& BiasGain)
01357 {
01358 const AFp BiasMinus1ToPlus1 = BiasGain.GetBias();
01359 SetDoubleGadgetValue( _R(IDC_EDIT_BIAS), BiasMinus1ToPlus1 );
01360
01361 const AFp GainMinus1ToPlus1 = BiasGain.GetGain();
01362 SetDoubleGadgetValue( _R(IDC_EDIT_GAIN), GainMinus1ToPlus1 );
01363 }
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375 void CBiasGainDlg::ReadEditBoxes(CProfileBiasGain& BiasGain)
01376 {
01377
01378 const AFp BiasMinus1ToPlus1 = AFp( GetDoubleGadgetValue( _R(IDC_EDIT_BIAS), double(-1.0), double(+1.0) ) );
01379 BiasGain.SetBias( BiasMinus1ToPlus1 );
01380
01381 const AFp GainMinus1ToPlus1 = AFp( GetDoubleGadgetValue( _R(IDC_EDIT_GAIN), double(-1.0), double(+1.0) ) );
01382 BiasGain.SetGain( GainMinus1ToPlus1 );
01383
01384
01385 WriteEditBoxes( BiasGain );
01386
01387 }
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405 void CBiasGainDlg::HandleSliderPosChanging(CDlgMessage const& Message, CProfileBiasGain& BiasGain)
01406 {
01407
01408
01409 ReadSliders( BiasGain );
01410
01411
01412 WriteEditBoxes( BiasGain );
01413
01414
01415
01416
01417 m_pobddStandardProfile->SetSelected(-1);
01418
01419
01420 HandleInput( Message, BiasGain );
01421 }
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434 void CBiasGainDlg::HandleSliderPosSet(CDlgMessage const& Message, CProfileBiasGain& BiasGain)
01435 {
01436
01437 HandleSliderPosChanging( Message, BiasGain );
01438 }
01439
01440
01441
01442 void CBiasGainDlg::HandleBiasEditChange(CDlgMessage const& rDlgMessage, CProfileBiasGain& rBiasGain)
01443 {
01444
01445
01446 const AFp BiasMinus1ToPlus1 = AFp(GetDoubleGadgetValue(_R(IDC_EDIT_BIAS), double(-1.0), double(+1.0)));
01447 const AFp GainMinus1ToPlus1 = AFp(GetDoubleGadgetValue(_R(IDC_EDIT_GAIN), double(-1.0), double(+1.0)));
01448
01449 rBiasGain.SetBias(BiasMinus1ToPlus1);
01450 rBiasGain.SetGain(GainMinus1ToPlus1);
01451
01452
01453 WriteSliders(rBiasGain);
01454
01455
01456 m_pobddStandardProfile->SetSelected(-1);
01457
01458
01459 HandleInput(rDlgMessage, rBiasGain);
01460
01461 }
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473 void CBiasGainDlg::HandleCommit(CDlgMessage const& Message, CProfileBiasGain& BiasGain)
01474 {
01475
01476 ReadEditBoxes( BiasGain_m );
01477
01478
01479 WriteSliders( BiasGain_m );
01480
01481
01482 HandleInput( Message, BiasGain );
01483
01484 }
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497 void CBiasGainDlg::HandleInput(CDlgMessage const& Message, CProfileBiasGain& BiasGain)
01498 {
01499
01500
01501 InvalidateGadget( _R(IDC_CURVE) );
01502 InvalidateGadget( _R(IDC_CURVEINTERPOLATE) );
01503
01504
01505
01506 if (Message == DIM_SLIDER_POS_CHANGING || Message == DIM_TEXT_CHANGED)
01507 BroadcastMessage(DIM_PROFILE_CHANGING, BiasGain_m);
01508 else if (Message == DIM_SLIDER_POS_IDLE)
01509 BroadcastMessage(DIM_PROFILE_CHANGEIDLE, BiasGain_m);
01510 else
01511 BroadcastMessage(DIM_PROFILE_CHANGED, BiasGain_m);
01512
01513 }
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526 void CBiasGainDlg::BroadcastMessage(CDlgMessage const& Message, CProfileBiasGain const& BiasGain) const
01527 {
01528 BROADCAST_TO_CLASS(DialogMsg(0, Message, Id_m, reinterpret_cast<UINT_PTR>(&BiasGain)), DialogOp);
01529 }
01530