biasdlg.cpp

Go to the documentation of this file.
00001 // $Id: biasdlg.cpp 1771 2007-06-17 20:14:43Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 
00100 #include "camtypes.h"
00101 
00102 
00103 DECLARE_SOURCE("$Revision: 1771 $");
00104 
00105 
00106 #include "biasdlg.h"
00107 //#include "biasres.h"
00108 //#include "blobtab.h"      // cause our (original) _R(IDC_STATIC1) through _R(IDC_STATIC4) + _R(IDC_STATIC6)
00109                             // clashed with those in this; so we cannot have our own => use these
00110                             // values instead
00111 #include "nodershp.h"
00112 #include "lineattr.h"
00113 #include "biasgdgt.h"
00114 
00115 //#include "dialogop.h"
00116 //#include "barsdlgs.h"
00117 #include "rndrgn.h"
00118 #include "stockcol.h"
00119 #include "qualattr.h"
00120 //#include "rikdlg.h"
00121 
00122 // #include "bars.h"
00123 // #include "msg.h"
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 // statics //
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     //EndTimedProcessing();
00165 }
00166 
00167 
00168 
00169 
00170 /****************************************************************************************
00171 Function  : CBiasGainDlg::Init
00172 Author    : Mikhail Tatarnikov
00173 Purpose   : Creates an OpDescriptor for a CBiasGainDlg dialog
00174 Returns   : BOOL - TRUE if succeeded, FALSE otherwise.
00175 Exceptions: 
00176 Parameters: None
00177 Notes     : 
00178 ****************************************************************************************/
00179 BOOL CBiasGainDlg::Init()
00180 {
00181     return  RegisterOpDescriptor(
00182         0,                                  // Tool ID
00183         _R(IDS_BIASGAINDLG),                    // String resource ID
00184         CC_RUNTIME_CLASS( CBiasGainDlg ),   // Runtime class
00185         OPTOKEN_BIASGAIN_DLG,               // Token string
00186         CBiasGainDlg::GetState,             // GetState function
00187         0,                                  // Help ID
00188         _R(IDBBL_BIASGAIN),                 // Bubble ID
00189         _R(IDD_BARCONTROLSTORE),            // Resource ID
00190         0,                                  // _R(IDC_BIASGAIN) - We don't need the automatic enabling/disabling control -
00191                                             // everything can be done by the toolbar only, since no one else knows about the fill type
00192                                             // (the control state depends on in).
00193         SYSTEMBAR_EDIT,                     // Bar ID
00194         TRUE,                               // Recieve system messages
00195         FALSE,                              // Smart duplicate operation
00196         TRUE,                               // Clean operation
00197         0,                                  // No vertical counterpart
00198         0,                                  // String for one copy only
00199         ( DONT_GREY_WHEN_SELECT_INSIDE | GREY_WHEN_NO_CURRENT_DOC ) // Auto state flags
00200     );
00201 }
00202 
00203 
00204 
00205 /******************************************************************************
00206 >   OpState CBiasGainDlg::GetState(String_256* pHelpString, OpDescriptor*)
00207 
00208     Author:     Ed_Cornes (Xara Group Ltd) <camelotdev@xara.com>
00209     Created:    29/9/94
00210     Purpose:    Returns the OpState of the CBiasGainDlg dialogue operation
00211                 ie. whether or not it is greyed on the menu etc!!!
00212 ******************************************************************************/
00213 
00214 /****************************************************************************************
00215 Function  : OpStateCBiasGainDlg::GetState
00216 Author    : Mikhail Tatarnikov
00217 Purpose   : Returns the OpState of the CBiasGainDlg dialogue operation
00218             (whether or not it should be greyed on the menu etc)
00219 Returns   : void
00220 Exceptions: 
00221 Parameters: [in] String_256*   pHelpString - 
00222             [in] OpDescriptor*             - 
00223 Notes     : 
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 Function  : CBiasGainDlg::Do
00239 Author    : Mikhail Tatarnikov
00240 Purpose   : Creates and shows a CBiasGainDlg dialog
00241 Returns   : void
00242 Exceptions: 
00243 Parameters: [in/out] OpDescriptor* - 
00244 Notes     : 
00245 ****************************************************************************************/
00246 void CBiasGainDlg::Do(OpDescriptor*)
00247 {
00248     Create();
00249     Open();
00250 }
00251 
00252 
00253 //-------------------------------------------------------------------------------------------------
00254 //  Author:         Harrison Ainsworth
00255 //  Date:           07/99
00256 //  Purpose:        Creates and shows a CBiasGainDlg dialog
00257 //  Preconditions:  OpParam* OwningGadgetParams param1 is really a CBiasGainGadget* and
00258 //                  param2 is really a CProfileBiasGain*
00259 //-------------------------------------------------------------------------------------------------
00260 
00261 /****************************************************************************************
00262 Function  : CBiasGainDlg::DoWithParam
00263 Author    : Mikhail Tatarnikov
00264 Purpose   : Creates and shows a CBiasGainDlg dialog
00265 Returns   : void
00266 Exceptions: 
00267 Parameters: [in] OpDescriptor*               - 
00268             [in] OpParam*      OwningGadgetParams - the dialog parameters (param1 is a CBiasGainGadget*
00269                                                     and param2 is really a CProfileBiasGain*)
00270 Notes     : 
00271 ****************************************************************************************/
00272 void CBiasGainDlg::DoWithParam(OpDescriptor*, OpParam* OwningGadgetParams)
00273 {
00274     BOOL noProfile = FALSE;
00275     
00276     // extract the param info: an owning gadget ptr, and input biasgain value
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     // get the ID
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     // set the dialog title
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 //      SetCustomComboGadgetValue ( _R(IDC_BIASGAINCOMBO), (CustomComboBoxControlDataItem*) NULL, TRUE, -1);
00323         m_pobddStandardProfile->SetSelected(-1);
00324 
00325         // and disable all other controls ....
00326         DisableAllControls ();
00327     }
00328 
00329     // tell the owning gadget that this dialog has opened
00330     if( pOwningGadget_m != 0 )
00331     {
00332         pOwningGadget_m->DialogHasOpened();
00333     }
00334 }
00335 
00336 
00337 /****************************************************************************************
00338 Function  : CBiasGainDlg::Message
00339 Author    : Mikhail Tatarnikov
00340 Purpose   : handle messages for this dialog - including create/cancel and slider and edit
00341 Returns   : MsgResult -
00342 Exceptions: 
00343 Parameters: [in] Msg* Message - an incoming message to handle
00344 Notes     : 
00345 ****************************************************************************************/
00346 MsgResult CBiasGainDlg::Message(Msg* Message)
00347 {
00348     if( IS_OUR_DIALOG_MSG( Message ) )
00349     {
00350         DialogMsg* Msg  =  static_cast<DialogMsg*>( Message );//dynamic_cast<DialogMsg*>( Message );   // needs rtti enabled
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                 // initialise gadgets
00367                 InitSliders( BiasGain_m );
00368                 InitEditBoxes( BiasGain_m );
00369                 InitiProfileCombobox();
00370 
00371                 InitBiasGainGadget(BiasGain_m); // Setup combobox with the current bias.
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                     //End();
00387                     //DlgMgr->Delete( WindowID, this );
00388 
00389                     // tell the owning gadget that this dialog has closed
00390                     if( pOwningGadget_m != 0 )
00391                     {
00392                         pOwningGadget_m->DialogHasClosed();
00393                         return DLG_EAT_IF_HUNGRY(Msg);  // We cna't do anything else here, since the dialog has just been deleted.
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             // slider interaction messages
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             // edit box interaction messages
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 //                  WORD  DropdownListIndex;
00477 //                  GetValueIndex( _R(IDC_BIASGAINCOMBO), &DropdownListIndex );
00478                     INT32 iSelected = m_pobddStandardProfile->GetSelected();
00479                     if (iSelected == -1)
00480                         break;
00481                         
00482                     DWORD dwSelected = (DWORD)iSelected;
00483 
00484                     switch(dwSelected)
00485                     {
00486                         // get preset value to match the dropdown list index
00487                         //
00488                         case  0 :
00489                         case  1 :
00490                         case  2 :
00491                         case  3 :
00492                         case  4 :
00493                         {
00494                             // first we need to update our dialog to reflect this change
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                             // and then update all the other stuff in the document
00508 
00509                             BiasGainGadget.SetInfobarGadgetID (pOwningGadget_m->GetGadgetID ());
00510                             BiasGainGadget.Message (Msg);//pOwningGadget_m->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     // Pass all unhandled messages to base class for default processing!
00525     return  DialogOp::Message( Message );
00526 
00527 }  
00528 
00529 
00530 
00531 
00532 // protected //////////////////////////////////////////////////////////
00533 
00534 //-------------------------------------------------------------------------------------------------
00535 //  Author:         Harrison Ainsworth
00536 //  Date:           07/99
00537 //  Purpose:        Draw graph/curve illustration of the profile function
00538 //  Preconditions:  ReDrawInfoType* ExtraInfo somehow (mystery to me) refers to a dlg picture control
00539 //                  CBiasGainDlg derives from DialogOp - so that CreateGRenderRegion() is accessible
00540 //  Postconditions: the dlg control is drawn into
00541 //-------------------------------------------------------------------------------------------------
00542 
00543 void  CBiasGainDlg::DrawCurve( const CProfileBiasGain& CurveShape,  ReDrawInfoType* ExtraInfo )
00544 {
00545     // drawing constants:  overall resolution, curve steps, curve width, colors
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;  // for the MANY case
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         // set drawing quality
00566         Quality           QualityThing( Quality::QualityMax );
00567         QualityAttribute  AntiAliasQualityAttr( QualityThing );
00568         pRenderRegion->SetQuality( &AntiAliasQualityAttr, FALSE );
00569         //pRenderRegion->RRQuality.SetQuality( QUALITY_MAX );   // doesnt enable antialiasing
00570         
00571 
00572         // draw the background
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             // draw curve
00587             {
00588                 // make a copy of the biasgain object with the right scaling to calculate
00589                 // curve points for the drawing area
00590                 CProfileBiasGain  DiagramMapper( CurveShape );
00591                 DiagramMapper.SetIntervals( AFp( 0.0 ), AFp( kWidth ) );
00592 
00593                 // create a path to hold the geometry of the curve
00594                 Path  CurvePath;
00595                 CurvePath.Initialise( kWidth );
00596                 CurvePath.IsFilled  =  FALSE;
00597                 CurvePath.FindStartOfPath();
00598 
00599 
00600                 // make the first point on the curve
00601                 static const DocCoord  StartPoint( 0, 0 );
00602                 CurvePath.InsertMoveTo( StartPoint );
00603 
00604                 // step through the x axis calculating points on the curve
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                 // connect the last looped step of the curve to the corner of the diagram
00614                 static const DocCoord  EndPoint( kWidth, kWidth );
00615                 CurvePath.InsertLineTo( EndPoint );
00616 
00617 
00618                 // set some line drawing choices
00619                 pRenderRegion->SetLineWidth( kLineWidth );
00620                 pRenderRegion->SetLineColour( kCurve );
00621 
00622                 // render the path of the curve
00623                 pRenderRegion->DrawPath( &CurvePath );
00624             }
00625         }
00626 
00627         pRenderRegion->RestoreContext();
00628         DestroyGRenderRegion( pRenderRegion );
00629     }
00630 }
00631 
00632 //-------------------------------------------------------------------------------------------------
00633 //  Author:         Chris Snook
00634 //  Date:           17/1/2000
00635 //  Purpose:        Draw an (interpolated) graph/curve illustration of the profile function
00636 //  Preconditions:  ReDrawInfoType* ExtraInfo refers to a dlg picture control
00637 //                  CBiasGainDlg derives from DialogOp - so that CreateGRenderRegion() is accessible
00638 //  Postconditions: the dlg control is drawn into
00639 //-------------------------------------------------------------------------------------------------
00640 
00641 void  CBiasGainDlg::DrawCurveInterpolate ( const CProfileBiasGain& CurveShape,  ReDrawInfoType* ExtraInfo )
00642 {
00643     // drawing constants:  overall resolution, curve steps, curve width, colors
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;  // for the MANY case
00655     static const StockColour  kCurve             =  COLOUR_BLACK;//COLOUR_BLUE;
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         // set drawing quality
00668         Quality           QualityThing( Quality::QualityMax );
00669         QualityAttribute  AntiAliasQualityAttr( QualityThing );
00670         pRenderRegion->SetQuality( &AntiAliasQualityAttr, FALSE );
00671         //pRenderRegion->RRQuality.SetQuality( QUALITY_MAX );   // doesnt enable antialiasing       
00672 
00673         // draw the background
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             // render ....
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             // create a path to hold the geometry of the curve
00695             Path  CurvePath;
00696             CurvePath.Initialise( kWidth );
00697             CurvePath.IsFilled  =  FALSE;
00698             CurvePath.FindStartOfPath();
00699 
00700             // common part of -1 to +1 curve ....
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/*19*/; 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             // set some line drawing choices
00733             pRenderRegion->SetLineWidth( kLineWidth );
00734             pRenderRegion->SetLineColour( kCurve );
00735 
00736             // render the path of the curve
00737             pRenderRegion->DrawPath( &CurvePath );
00738         }
00739 
00740         pRenderRegion->RestoreContext();
00741         DestroyGRenderRegion( pRenderRegion );
00742     }
00743 }
00744 
00745 
00746 
00747 //-------------------------------------------------------------------------------------------------
00748 //  Author:         Chris Snook
00749 //  Date:           2/2/2000
00750 //  Purpose:        Draw an (interpolated) fill illustration of the profile function
00751 //  Preconditions:  ReDrawInfoType* ExtraInfo refers to a dlg picture control
00752 //                  CBiasGainDlg derives from DialogOp - so that CreateGRenderRegion() is accessible
00753 //  Postconditions: the dlg control is drawn into
00754 //-------------------------------------------------------------------------------------------------
00755 
00756 void  CBiasGainDlg::DrawFillInterpolate ( const CProfileBiasGain& CurveShape,  ReDrawInfoType* ExtraInfo )
00757 {
00758     // drawing constants:  overall resolution, curve steps, curve width, colors
00759     static const INT32  kWidth      =  ExtraInfo->dx;
00760 //  static const INT32  kBitWidth   =  kWidth/20;
00761     static const INT32  kHalfWidth  =  kWidth/2;
00762     static const INT32  kHeight     =  ExtraInfo->dy;
00763     static const INT32  kHalfHeight =  kHeight/2;
00764 //  static const INT32  kQuartHeight = kHeight/4;
00765     static const INT32  kLineWidth  =  2000;
00766 //  static const INT32  kHalfLineWidth = kLineWidth/2;
00767 
00768     static const StockColour  kBackgoundOutline  =  COLOUR_NONE;
00769     static const StockColour  kBackgound         =  COLOUR_WHITE;
00770     static const StockColour  kBackgoundMany     =  COLOUR_LTGREY;  // for the MANY case
00771 //  static const StockColour  kCurve             =  COLOUR_BLUE;
00772     static /*const*/ StockColour  kStartColour   =  COLOUR_BLACK;
00773     static /*const*/ 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         // set drawing quality
00786         Quality           QualityThing( Quality::QualityMax );
00787         QualityAttribute  AntiAliasQualityAttr( QualityThing );
00788         pRenderRegion->SetQuality( &AntiAliasQualityAttr, FALSE );
00789         //pRenderRegion->RRQuality.SetQuality( QUALITY_MAX );   // doesnt enable antialiasing       
00790 
00791         // draw the background
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;//= new LinearFillAttribute ();
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                 //JoinTypeAttribute DummyJoinType;      DummyJoinType.JoinType = MitreJoin;
00822                 //AttrJoinType* DummyJoin = (AttrJoinType*) DummyJoinType.MakeNode ();
00823                 //DummyJoin->AttachNode (DummyShape, FIRSTCHILD);
00824 
00825                 // set up the start point ....
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                 // set up the end point ....
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                 // set these guys to NULL ....
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);          // Set Grad-filled
00854 
00855                 // now lets set-up the fill effect (if there is one) ....
00856                 
00857                 if (pOwningGadget_m->GetFillEffect () != NULL)
00858                 {
00859                     pRenderRegion->SetFillEffect (pOwningGadget_m->GetFillEffect (), FALSE);
00860                 }
00861 
00862                 pRenderRegion->SetLineWidth( kLineWidth );
00863                 //pRenderRegion->SetLineColour( kCurve );
00864                 //pRenderRegion->SetFillColour (kCurve);
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     // drawing constants:  overall resolution, curve steps, curve width, colors
00879     static const INT32  kWidth      =  ExtraInfo->dx;
00880 //  static const INT32  kBitWidth   =  kWidth/20;
00881     static const INT32  kHalfWidth  =  kWidth/2;
00882     static const INT32  kHeight     =  ExtraInfo->dy;
00883     static const INT32  kHalfHeight =  kHeight/2;
00884 //  static const INT32  kQuartHeight = kHeight/4;
00885     static const INT32  kLineWidth  =  2000;
00886 //  static const INT32  kHalfLineWidth = kLineWidth/2;
00887 
00888     static const StockColour  kBackgoundOutline  =  COLOUR_NONE;
00889     static const StockColour  kBackgound         =  COLOUR_WHITE;
00890     static const StockColour  kBackgoundMany     =  COLOUR_LTGREY;  // for the MANY case
00891     static const StockColour  kCurve             =  COLOUR_WHITE;
00892     static const StockColour  kCurve2             =  COLOUR_BLUE;//COLOUR_BLACK;//COLOUR_MAGENTA;
00893 //  static /*const*/ StockColour  kStartColour   =  COLOUR_BLACK;
00894 //  static /*const*/ StockColour  kEndColour     =  COLOUR_WHITE;
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         // set drawing quality
00907         Quality           QualityThing( Quality::QualityMax );
00908         QualityAttribute  AntiAliasQualityAttr( QualityThing );
00909         pRenderRegion->SetQuality( &AntiAliasQualityAttr, FALSE );
00910         //pRenderRegion->RRQuality.SetQuality( QUALITY_MAX );   // doesnt enable antialiasing       
00911 
00912         // draw the background
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                     //JoinTypeAttribute DummyJoinType;      DummyJoinType.JoinType = MitreJoin;
00951                     //AttrJoinType* DummyJoin = (AttrJoinType*) DummyJoinType.MakeNode ();
00952                     //DummyJoin->AttachNode (DummyShape, FIRSTCHILD);
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                     // set up the start transparency ....
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                     // set up the end transparency ....
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                     // and set these guys to NULL ....
00976                     
00977                     DummyFillAttribute.SetEndTransp2 (NULL);
00978                     DummyFillAttribute.SetEndTransp3 (NULL);
00979                 
00980                     CProfileBiasGain  DiagramMapper( CurveShape );
00981                     DummyFillAttribute.SetProfile (DiagramMapper);
00982 
00983                     pRenderRegion->SetLineWidth( kLineWidth );
00984                     //pRenderRegion->SetLineColour( kCurve );
00985                     pRenderRegion->SetFillColour (kCurve2);
00986 
00987                     DummyShape2->Render (pRenderRegion);
00988 
00989                     pRenderRegion->SetTranspFillGeometry((TranspFillAttribute*) &DummyFillAttribute, FALSE);            // Set Grad-filled
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 Function  : CBiasGainDlg::InitSliders
01010 Author    : Mikhail Tatarnikov
01011 Purpose   : Initializes and updates the sliders
01012 Returns   : void
01013 Exceptions: 
01014 Parameters: [in] CProfileBiasGain const& BiasGain - a value to update sliders wiht.
01015 Notes     : 
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 Function  : CBiasGainDlg::InitiProfileCombobox
01029 Author    : Mikhail Tatarnikov
01030 Purpose   : Initializes the profile combobox
01031 Returns   : void
01032 Exceptions: 
01033 Parameters: None
01034 Notes     : 
01035 ****************************************************************************************/
01036 void CBiasGainDlg::InitiProfileCombobox()
01037 {
01038     // Check if we have already been initialized.
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 Function  : CBiasGainDlg::InitBiasGainGadget
01063 Author    : Mikhail Tatarnikov
01064 Purpose   : Updates profile combobox with a value.
01065 Returns   : void
01066 Exceptions: 
01067 Parameters: [in] CProfileBiasGain const& BiasGain - the value to initialize with
01068 Notes     : 
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 Function  : CBiasGainDlg::WriteSliders
01080 Author    : Mikhail Tatarnikov
01081 Purpose   : Updates slider to display the supplied bias/gain value
01082 Returns   : void
01083 Exceptions: 
01084 Parameters: [in] CProfileBiasGain const& BiasGain - the value to initialize sliders with.
01085 Notes     : 
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 Function  : CBiasGainDlg::InvokeVia
01099 Author    : Mikhail Tatarnikov
01100 Purpose   : Invoke the bias/gain dialog
01101 Returns   : void
01102 Exceptions: 
01103 Parameters: [in] CBiasGainGadget&  pInvokeWith - the parent control (used for routing messages);
01104             [in] CProfileBiasGain* pInvokeOn   - an initial value to display;
01105             [in] BOOL              bMany       - 
01106 Notes     : 
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)                 // we need to display the many setting ....
01119         {
01120             OpParam  Param( reinterpret_cast<void*>( &pInvokeWith ),  reinterpret_cast<void*>( pInvokeOn ) );
01121             DoWithParam( pOpDescriptor, &Param );
01122         }
01123         else    // I'm not sure if this is ever called - BUT we'd best provide a 'default' anyway
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 Function  : CBiasGainDlg::ReInitialiseDialog
01137 Author    : Mikhail Tatarnikov
01138 Purpose   : Initializes the dialog with new bias/gain value
01139 Returns   : void
01140 Exceptions: 
01141 Parameters: [in] CProfileBiasGain* ReInitOn - a bias/gain value to initialize with;
01142             [in] BOOL              bMany    - 
01143 Notes     : 
01144 ****************************************************************************************/
01145 void CBiasGainDlg::ReInitialiseDialog(CProfileBiasGain* ReInitOn, BOOL bMany)
01146 {
01147     if (ReInitOn != NULL)                   // woopey!!!!  we have a profile - lets display it ....
01148     {
01149         BiasGain_m = *ReInitOn;             // this line does everything for us!
01150 
01151         // the rest is just tidying up ....
01152 
01153         if (manyDisabledControls == TRUE)
01154         {
01155             EnableAllControls ();
01156         }
01157     
01158         // reinitialise gadgets ....
01159         InitSliders( BiasGain_m );
01160         InitEditBoxes( BiasGain_m );
01161         InitiProfileCombobox();
01162         InitBiasGainGadget ( BiasGain_m );
01163 
01164         // redraw profile ....
01165         InvalidateGadget( _R(IDC_CURVE) );
01166         InvalidateGadget( _R(IDC_CURVEINTERPOLATE) );
01167     }
01168     else if (bMany == TRUE)                 // we need to display the many setting ....
01169     {
01170 //      SetCustomComboGadgetValue ( _R(IDC_BIASGAINCOMBO), (CustomComboBoxControlDataItem*) NULL, TRUE, -1);
01171         m_pobddStandardProfile->SetSelected(-1);
01172         
01173         // and disable all other controls ....
01174         DisableAllControls ();
01175     }
01176 }
01177 
01178 
01179 /****************************************************************************************
01180 Function  : CBiasGainDlg::DisableAllControls
01181 Author    : Mikhail Tatarnikov
01182 Purpose   : Disable all dialog controls.
01183 Returns   : void
01184 Exceptions: 
01185 Parameters: None
01186 Notes     : 
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     //EnableGadget (_R(IDC_STATIC7), FALSE);
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     //EnableGadget (_R(IDC_CURVE), FALSE);
01206     InvalidateGadget( _R(IDC_CURVE) );
01207     InvalidateGadget( _R(IDC_CURVEINTERPOLATE) );
01208 }
01209 
01210 
01211 
01212 /****************************************************************************************
01213 Function  : CBiasGainDlg::EnableAllControls
01214 Author    : Mikhail Tatarnikov
01215 Purpose   : Enable all dialog controls
01216 Returns   : void
01217 Exceptions: 
01218 Parameters: None
01219 Notes     : 
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     //EnableGadget (_R(IDC_STATIC7), TRUE);
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     //EnableGadget (_R(IDC_CURVE), TRUE);
01239     InvalidateGadget( _R(IDC_CURVE) );
01240     InvalidateGadget( _R(IDC_CURVEINTERPOLATE) );
01241 }
01242 
01243 
01244 /****************************************************************************************
01245 Function  : CBiasGainDlg::GetCurrentDialogProfile
01246 Author    : Mikhail Tatarnikov
01247 Purpose   : Return the current biasgain profile
01248 Returns   : CProfileBiasGain - the current bias/gain value.
01249 Exceptions: 
01250 Parameters: None
01251 Notes     : 
01252 ****************************************************************************************/
01253 CProfileBiasGain CBiasGainDlg::GetCurrentDialogProfile()
01254 {
01255     return (BiasGain_m);
01256 }
01257 
01258 
01259 
01260 /****************************************************************************************
01261 Function  : CBiasGainDlg::ReadSliders
01262 Author    : Mikhail Tatarnikov
01263 Purpose   : Reads slider values
01264 Returns   : void
01265 Exceptions: 
01266 Parameters: [out] CProfileBiasGain& BiasGain - the bias/gain value to read from sliders to.
01267 Notes     : 
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 Function  : CBiasGainDlg::InitOneSlider
01279 Author    : Mikhail Tatarnikov
01280 Purpose   : Initialize a slider
01281 Returns   : void
01282 Exceptions: 
01283 Parameters: [in] CGadgetID GadgetID - a slider to initialize.
01284 Notes     : 
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 Function  : CBiasGainDlg::WriteOneSlider
01296 Author    : Mikhail Tatarnikov
01297 Purpose   : Set a value to a slider.
01298 Returns   : void
01299 Exceptions: 
01300 Parameters: [in] AFp       ValueMinus1ToPlus1 - a new slider value;
01301             [in] CGadgetID GadgetID           - a slider to update.
01302 Notes     : 
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 Function  : CBiasGainDlg::ReadOneSlider
01312 Author    : Mikhail Tatarnikov
01313 Purpose   : Reads the value from a slider
01314 Returns   : AFp - the slider value.
01315 Exceptions: 
01316 Parameters: [in] CGadgetID GadgetID - the slider to read from.
01317 Notes     : Return value is in the range [-1,+1]
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 Function  : CBiasGainDlg::InitEditBoxes
01334 Author    : Mikhail Tatarnikov
01335 Purpose   : initialise the dialog box edit controls, including setting values
01336 Returns   : void
01337 Exceptions: 
01338 Parameters: [in] CProfileBiasGain const& BiasGain - the value to initalize the edit boxes with.
01339 Notes     : 
01340 ****************************************************************************************/
01341 void CBiasGainDlg::InitEditBoxes(CProfileBiasGain const& BiasGain)
01342 {
01343     WriteEditBoxes( BiasGain );
01344 }
01345 
01346 
01347 /****************************************************************************************
01348 Function  : CBiasGainDlg::WriteEditBoxes
01349 Author    : Mikhail Tatarnikov
01350 Purpose   : Update the edit boxes
01351 Returns   : void
01352 Exceptions: 
01353 Parameters: [in] CProfileBiasGain const& BiasGain - the value to update the edit boxes with.
01354 Notes     : 
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 Function  : CBiasGainDlg::ReadEditBoxes
01368 Author    : Mikhail Tatarnikov
01369 Purpose   : Reads the bias/gain value from the edit box controls
01370 Returns   : void
01371 Exceptions: 
01372 Parameters: [out] CProfileBiasGain& BiasGain - the value read.
01373 Notes     : 
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     // write the clamped-into-range values back into the edit boxes
01385     WriteEditBoxes( BiasGain );
01386 
01387 }
01388 
01389 
01390 
01391 
01392 
01393 
01394 
01395 /****************************************************************************************
01396 Function  : CBiasGainDlg::HandleSliderPosChanging
01397 Author    : Mikhail Tatarnikov
01398 Purpose   : Handles slider DIM_SLIDER_POS_CHANGING messages
01399 Returns   : void
01400 Exceptions: 
01401 Parameters: [in] CDlgMessage const& Message  - a message from edit box controls;
01402             [in] CProfileBiasGain&  BiasGain - the current bias/gain value.
01403 Notes     : 
01404 ****************************************************************************************/
01405 void  CBiasGainDlg::HandleSliderPosChanging(CDlgMessage const& Message, CProfileBiasGain& BiasGain)
01406 {
01407 
01408     // read values from sliders (both (simplifies code)) into biasgain object
01409     ReadSliders( BiasGain );
01410 
01411     // make the edit boxes agree with the sliders
01412     WriteEditBoxes( BiasGain );
01413 
01414     // Make the profile control show a custom image (cause after all, now we have
01415     // a custom bias/gain).
01416     
01417     m_pobddStandardProfile->SetSelected(-1);
01418 
01419     // do general input handling
01420     HandleInput( Message,  BiasGain );
01421 }
01422 
01423 
01424 /****************************************************************************************
01425 Function  : CBiasGainDlg::HandleSliderPosSet
01426 Author    : Mikhail Tatarnikov
01427 Purpose   : Handles slider DIM_SLIDER_POS_SET messages
01428 Returns   : void
01429 Exceptions: 
01430 Parameters: [in] CDlgMessage const& Message  - a message from edit box controls;
01431             [in] CProfileBiasGain&  BiasGain - the current bias/gain value.
01432 Notes     : 
01433 ****************************************************************************************/
01434 void  CBiasGainDlg::HandleSliderPosSet(CDlgMessage const& Message, CProfileBiasGain& BiasGain)
01435 {
01436     // do the same as slider changing
01437     HandleSliderPosChanging( Message,  BiasGain );
01438 }
01439 
01440 
01441 
01442 void CBiasGainDlg::HandleBiasEditChange(CDlgMessage const& rDlgMessage,  CProfileBiasGain& rBiasGain)
01443 {
01444     // read values from edit boxes (both (simplifies code)) into biasgain object
01445 //  ReadEditBoxes(BiasGain_m);
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     // make the sliders agree with the edit boxes
01453     WriteSliders(rBiasGain);
01454     
01455     // Update the combobox as well.
01456     m_pobddStandardProfile->SetSelected(-1);
01457 
01458     // do general input handling
01459     HandleInput(rDlgMessage,  rBiasGain);
01460     
01461 }
01462 
01463 /****************************************************************************************
01464 Function  : CBiasGainDlg::HandleCommit
01465 Author    : Mikhail Tatarnikov
01466 Purpose   : Handles DIM_COMMIT message from the dialog's edit boxes
01467 Returns   : void
01468 Exceptions: 
01469 Parameters: [in] CDlgMessage const& Message  - a message from edit box controls;
01470             [in] CProfileBiasGain&  BiasGain - the current bias/gain value.
01471 Notes     : 
01472 ****************************************************************************************/
01473 void CBiasGainDlg::HandleCommit(CDlgMessage const& Message, CProfileBiasGain& BiasGain)
01474 {
01475     // read values from edit boxes (both (simplifies code)) into biasgain object
01476     ReadEditBoxes( BiasGain_m );
01477 
01478     // make the sliders agree with the edit boxes
01479     WriteSliders( BiasGain_m );
01480 
01481     // do general input handling
01482     HandleInput( Message,  BiasGain );
01483 
01484 }
01485 
01486 
01487 /****************************************************************************************
01488 Function  : CBiasGainDlg::HandleInput
01489 Author    : Mikhail Tatarnikov
01490 Purpose   : Handles a message from the dialog controls.
01491 Returns   : void
01492 Exceptions: 
01493 Parameters: [in] CDlgMessage const& Message  - an input message to handle;
01494             [in] CProfileBiasGain&  BiasGain - the current bias/gain value.
01495 Notes     : 
01496 ****************************************************************************************/
01497 void CBiasGainDlg::HandleInput(CDlgMessage const& Message, CProfileBiasGain& BiasGain)
01498 {
01499 
01500     // prompt a diagram redraw to illustrate the new values
01501     InvalidateGadget( _R(IDC_CURVE) );
01502     InvalidateGadget( _R(IDC_CURVEINTERPOLATE) );
01503 
01504     // Broadcast a special profile change message, allowing all interested parties
01505     // to handle it. Depending on the input type we send either interactive or final change.
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 Function  : CBiasGainDlg::BroadcastMessage
01518 Author    : Mikhail Tatarnikov
01519 Purpose   : Broadcasts a message to all DialogOp-derived classes, sending the current profile as parameter
01520 Returns   : void
01521 Exceptions: 
01522 Parameters: [in] CDlgMessage const&      Message  - a message to broadcast;
01523             [in] CProfileBiasGain const& BiasGain - the profile value to send with the message.
01524 Notes     : 
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 

Generated on Sat Nov 10 03:44:21 2007 for Camelot by  doxygen 1.4.4