TCurlyArcEditor.cxx

Go to the documentation of this file.
00001 // @(#)root/ged:$Id: TCurlyArcEditor.cxx 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Ilka Antcheva, Otto Schaile 15/12/04
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 //  TCurlyArcEditor                                                     //
00015 //                                                                      //
00016 //  Implements GUI for editing CurlyArc attributes: radius, phi1, phi2. //                                             //
00017 //                                                                      //
00018 //////////////////////////////////////////////////////////////////////////
00019 //Begin_Html
00020 /*
00021 <img src="gif/TCurlyArcEditor.gif">
00022 */
00023 //End_Html
00024 
00025 
00026 #include "TCurlyArcEditor.h"
00027 #include "TGLabel.h"
00028 #include "TGNumberEntry.h"
00029 #include "TCurlyArc.h"
00030 #include "iostream"
00031 
00032 ClassImp(TCurlyArcEditor)
00033 
00034 enum ECurlyArcWid {
00035    kCRLA_RAD,
00036    kCRLA_FMIN,
00037    kCRLA_FMAX,
00038    kCRLA_CX,
00039    kCRLA_CY
00040 };
00041 
00042 //______________________________________________________________________________
00043 TCurlyArcEditor::TCurlyArcEditor(const TGWindow *p, Int_t width,
00044                            Int_t height, UInt_t options, Pixel_t back)
00045    : TGedFrame(p, width, height, options | kVerticalFrame, back)
00046 {
00047    // Constructor of CurlyArc GUI.
00048 
00049    fCurlyArc = 0;
00050 
00051    MakeTitle("Curly Arc");
00052 
00053    TGCompositeFrame *f3 = new TGCompositeFrame(this, 80, 20, kHorizontalFrame);
00054    AddFrame(f3, new TGLayoutHints(kLHintsTop, 1, 1, 2, 0));
00055 
00056    TGCompositeFrame *f3a = new TGCompositeFrame(f3, 80, 20);
00057    f3->AddFrame(f3a, new TGLayoutHints(kLHintsTop, 1, 1, 0, 0));
00058 
00059    TGLabel *fRadiusLabel = new TGLabel(f3a, "Radius:");
00060    f3a->AddFrame(fRadiusLabel, new TGLayoutHints(kLHintsNormal, 8, 0, 5, 5));
00061 
00062    TGLabel *fPhiminLabel = new TGLabel(f3a, "Phimin:");
00063    f3a->AddFrame(fPhiminLabel, new TGLayoutHints(kLHintsNormal, 8, 0, 5, 5));
00064 
00065    TGLabel *fPhimaxLabel = new TGLabel(f3a, "Phimax:");
00066    f3a->AddFrame(fPhimaxLabel, new TGLayoutHints(kLHintsNormal, 8, 0, 5, 5));
00067 
00068    TGLabel *fCenterXLabel = new TGLabel(f3a, "Center X:");
00069    f3a->AddFrame(fCenterXLabel, new TGLayoutHints(kLHintsNormal, 8, 0, 6, 5));
00070 
00071    TGLabel *fCenterYLabel = new TGLabel(f3a, "Y:");
00072    f3a->AddFrame(fCenterYLabel, new TGLayoutHints(kLHintsNormal, 49, 0, 6, 0));
00073 
00074    TGCompositeFrame *f3b = new TGCompositeFrame(f3, 80, 20);
00075    f3->AddFrame(f3b, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
00076 
00077    fRadiusEntry = new TGNumberEntry(f3b, 0.02, 7, kCRLA_RAD,
00078                                     TGNumberFormat::kNESRealThree,
00079                                     TGNumberFormat::kNEANonNegative,
00080                                     TGNumberFormat::kNELNoLimits);
00081    fRadiusEntry->GetNumberEntry()->SetToolTipText("Set radius of arc.");
00082    f3b->AddFrame(fRadiusEntry, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 1));
00083 
00084    fPhiminEntry = new TGNumberEntry(f3b, 0, 7, kCRLA_FMIN,
00085                                     TGNumberFormat::kNESInteger,
00086                                     TGNumberFormat::kNEANonNegative,
00087                                     TGNumberFormat::kNELLimitMinMax, 0, 360);
00088    fPhiminEntry->GetNumberEntry()->SetToolTipText("Set Phimin in degrees.");
00089    f3b->AddFrame(fPhiminEntry, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 1));
00090 
00091    fPhimaxEntry = new TGNumberEntry(f3b, 0, 7, kCRLA_FMAX,
00092                                     TGNumberFormat::kNESInteger,
00093                                     TGNumberFormat::kNEANonNegative,
00094                                     TGNumberFormat::kNELLimitMinMax, 0, 360);
00095    fPhimaxEntry->GetNumberEntry()->SetToolTipText("Set Phimax in degrees.");
00096    f3b->AddFrame(fPhimaxEntry, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 1));
00097 
00098    fCenterXEntry = new TGNumberEntry(f3b, 0.0, 7, kCRLA_CX,
00099                                      TGNumberFormat::kNESRealThree,
00100                                      TGNumberFormat::kNEANonNegative,
00101                                      TGNumberFormat::kNELNoLimits);
00102    fCenterXEntry->GetNumberEntry()->SetToolTipText("Set center X coordinate.");
00103    f3b->AddFrame(fCenterXEntry, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 1));
00104 
00105    fCenterYEntry = new TGNumberEntry(f3b, 0.0, 7, kCRLA_CY,
00106                                      TGNumberFormat::kNESRealThree,
00107                                      TGNumberFormat::kNEANonNegative,
00108                                      TGNumberFormat::kNELNoLimits);
00109    fCenterYEntry->GetNumberEntry()->SetToolTipText("Set center Y coordinate.");
00110    f3b->AddFrame(fCenterYEntry, new TGLayoutHints(kLHintsLeft, 6, 1, 3, 1));
00111 
00112 }
00113 
00114 //______________________________________________________________________________
00115 TCurlyArcEditor::~TCurlyArcEditor()
00116 {
00117    // Destructor of CurlyArc editor.
00118 }
00119 
00120 //______________________________________________________________________________
00121 void TCurlyArcEditor::ConnectSignals2Slots()
00122 {
00123    // Connect signals to slots.
00124  
00125    fCenterXEntry->Connect("ValueSet(Long_t)", "TCurlyArcEditor", this, "DoCenterXY()");
00126    (fCenterXEntry->GetNumberEntry())->Connect("ReturnPressed()", "TCurlyArcEditor", this, "DoCenterXY()");
00127    fCenterYEntry->Connect("ValueSet(Long_t)", "TCurlyArcEditor", this, "DoCenterXY()");
00128    (fCenterYEntry->GetNumberEntry())->Connect("ReturnPressed()", "TCurlyArcEditor", this, "DoCenterXY()");
00129    fRadiusEntry->Connect("ValueSet(Long_t)", "TCurlyArcEditor", this, "DoRadius()");
00130    (fRadiusEntry->GetNumberEntry())->Connect("ReturnPressed()", "TCurlyArcEditor", this, "DoRadius()");
00131    fPhiminEntry->Connect("ValueSet(Long_t)", "TCurlyArcEditor", this, "DoPhimin()");
00132    (fPhiminEntry->GetNumberEntry())->Connect("ReturnPressed()", "TCurlyArcEditor", this, "DoPhimin()");
00133    fPhimaxEntry->Connect("ValueSet(Long_t)", "TCurlyArcEditor", this, "DoPhimax()");
00134    (fPhimaxEntry->GetNumberEntry())->Connect("ReturnPressed()", "TCurlyArcEditor", this, "DoPhimax()");
00135 
00136    fInit = kFALSE;
00137 }
00138 
00139 //______________________________________________________________________________
00140 void TCurlyArcEditor::SetModel(TObject* obj)
00141 {
00142    // Pick up the used curly arc attributes.
00143 
00144    fCurlyArc = (TCurlyArc *)obj;
00145    fAvoidSignal = kTRUE;
00146 
00147    Double_t val = fCurlyArc->GetRadius();
00148    fRadiusEntry->SetNumber(val);
00149 
00150    val = fCurlyArc->GetPhimin();
00151    fPhiminEntry->SetNumber(val);
00152 
00153    val = fCurlyArc->GetPhimax();
00154    fPhimaxEntry->SetNumber(val);
00155 
00156    val = fCurlyArc->GetStartX();
00157    fCenterXEntry->SetNumber(val);
00158 
00159    val = fCurlyArc->GetStartY();
00160    fCenterYEntry->SetNumber(val);
00161 
00162    if (fInit) ConnectSignals2Slots();
00163 
00164    fAvoidSignal = kFALSE;
00165 }
00166 
00167 //______________________________________________________________________________
00168 void TCurlyArcEditor::DoCenterXY()
00169 {
00170    // Slot connected to set center .
00171 
00172    if (fAvoidSignal) return;
00173    fCurlyArc->SetCenter((Double_t)fCenterXEntry->GetNumber(), (Double_t)fCenterYEntry->GetNumber());
00174    fCurlyArc->Paint(fCurlyArc->GetDrawOption());
00175    Update();
00176 }
00177 
00178 //______________________________________________________________________________
00179 void TCurlyArcEditor::DoRadius()
00180 {
00181    // Slot connected to the radius setting.
00182 
00183    if (fAvoidSignal) return;
00184    fCurlyArc->SetRadius((Double_t)fRadiusEntry->GetNumber());
00185    fCurlyArc->Paint(fCurlyArc->GetDrawOption());
00186    Update();
00187 }
00188 
00189 //______________________________________________________________________________
00190 void TCurlyArcEditor::DoPhimin()
00191 {
00192    // Slot connected to the phimin setting.
00193 
00194    if (fAvoidSignal) return;
00195    fCurlyArc->SetPhimin((Double_t)fPhiminEntry->GetNumber());
00196    fCurlyArc->Paint(fCurlyArc->GetDrawOption());
00197    Update();
00198 }
00199 
00200 //______________________________________________________________________________
00201 void TCurlyArcEditor::DoPhimax()
00202 {
00203    // Slot connected to the phimax setting.
00204 
00205    if (fAvoidSignal) return;
00206    fCurlyArc->SetPhimax((Double_t)fPhimaxEntry->GetNumber());
00207    fCurlyArc->Paint(fCurlyArc->GetDrawOption());
00208    Update();
00209 }

Generated on Tue Jul 5 14:19:45 2011 for ROOT_528-00b_version by  doxygen 1.5.1