TGeoVolumeEditor.cxx

Go to the documentation of this file.
00001 // @(#):$Id: TGeoVolumeEditor.cxx 35642 2010-09-23 12:45:29Z agheata $
00002 // Author: M.Gheata 
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2002, 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 //  TGeoVolumeEditor                                                    //
00015 //
00016 //////////////////////////////////////////////////////////////////////////
00017 /* Editor for geometry volumes and assemblies of volumes. Besides the volume
00018    name and line attributes, a TGeoVolume has the following editable categories 
00019    splitted vertically by a shutter:
00020    - Properties: one can edit the shape and medium components from here. It is
00021    also possible to change the existing ones.
00022    - Daughters: the main category allowing defining, editing, removing or 
00023    positioning daughter volumes inside the current edited volume. To add a 
00024    daughter, one needs to select first a volume and a matrix. Currently no check
00025    is performed if the daughter volume creates an extrusion (illegal for tracking).
00026    To remove or change the position of an existing daughter, one should simply
00027    select the desired daughter from the combo box with the existing ones, then 
00028    simply click the appropriate button.
00029    - Visualization: One can set the visibility of the volume and of its daughters,
00030    set the visibility depth and the view type. Selecting "All" will draw the 
00031    volume and all visible daughters down to the selected level starting from the
00032    edited volume. Selecting "Leaves" will draw just the deepest daughters within
00033    the selected visibility level, without displaying the containers, while "Only"
00034    will just draw the edited volume.
00035    - Division: The category becomes active only if there are no daughters of the 
00036    edited volume added by normal positioning (e.g. from <Daughters> category). The
00037    minimum allowed starting value for the selected division axis is automatically 
00038    selected, while the dslicing step is set to 0 - meaning that only the number
00039    of slices matter.
00040 */
00041 
00042 #include "TGeoVolumeEditor.h"
00043 #include "TGeoVolume.h"
00044 #include "TGeoPatternFinder.h"
00045 #include "TGeoManager.h"
00046 #include "TGeoMatrix.h"
00047 #include "TVirtualPad.h"
00048 #include "TBaseClass.h"
00049 #include "TGTab.h"
00050 #include "TGComboBox.h"
00051 #include "TGButton.h"
00052 #include "TGButtonGroup.h"
00053 #include "TGTextEntry.h"
00054 #include "TGNumberEntry.h"
00055 #include "TGLabel.h"
00056 #include "TGShutter.h"
00057 #include "TG3DLine.h"
00058 #include "TGeoTabManager.h"
00059 #include "TGedEditor.h"
00060 
00061 ClassImp(TGeoVolumeEditor)
00062 
00063 enum ETGeoVolumeWid {
00064    kVOL_NAME, kVOL_TITLE, kVOL_SHAPE_SELECT, kVOL_MEDIA_SELECT, kVOL_NODE_SELECT,
00065    kVOL_VOL_SELECT, kVOL_MATRIX_SELECT, kVOL_EDIT_SHAPE, kVOL_EDIT_MEDIUM, kVOL_NODEID,
00066    kVOL_APPLY, kVOL_CANCEL, kVOL_UNDO, kVOL_VISLEVEL, kVOL_DIVSTART, kVOL_DIVEND,
00067    kVOL_DIVSTEP, kVOL_DIVN, kCAT_GENERAL, kCAT_DAUGHTERS, kCAT_DIVISION, kCAT_VIS,
00068    kDIV_NAME
00069 };
00070 
00071 //______________________________________________________________________________
00072 TGeoVolumeEditor::TGeoVolumeEditor(const TGWindow *p, Int_t width,
00073                                    Int_t height, UInt_t options, Pixel_t back)
00074    : TGeoGedFrame(p, width, height, options | kVerticalFrame, back)
00075 {
00076    // Constructor for volume editor.
00077    fGeometry = 0;
00078    fVolume   = 0;
00079    
00080    fIsModified = kFALSE;
00081    fIsAssembly = kFALSE;
00082    fIsDivided = kFALSE;
00083    
00084    // TGShutter for categories
00085    fCategories = new TGShutter(this, kSunkenFrame);
00086    TGCompositeFrame *container, *f1;
00087    Pixel_t color;
00088    TGLabel *label;
00089 
00090    // General settings
00091    TGShutterItem *si = new TGShutterItem(fCategories, new TGHotString("Properties"),kCAT_GENERAL);
00092    container = (TGCompositeFrame*)si->GetContainer();
00093    container->SetBackgroundColor(GetDefaultFrameBackground());
00094    fCategories->AddItem(si);
00095 
00096    // TextEntry for volume name
00097    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
00098    f1->AddFrame(label = new TGLabel(f1, "Volume name"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00099    f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00100    gClient->GetColorByName("#ff0000", color);
00101    label->SetTextColor(color);
00102    container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
00103    fVolumeName = new TGTextEntry(container, "", kVOL_NAME);
00104    fVolumeName->SetDefaultSize(135, fVolumeName->GetDefaultHeight());
00105    fVolumeName->SetToolTipText("Enter the volume name");
00106    container->AddFrame(fVolumeName, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 3, 1, 2, 5));
00107 
00108    // Current shape
00109    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
00110    f1->AddFrame(label = new TGLabel(f1, "Shape and medium"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00111    f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00112    gClient->GetColorByName("#ff0000", color);
00113    label->SetTextColor(color);
00114    container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 10, 0));
00115    f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame);
00116    fSelectedShape = 0;
00117    fLSelShape = new TGLabel(f1, "Select shape");
00118    gClient->GetColorByName("#0000ff", color);
00119    fLSelShape->SetTextColor(color);
00120    fLSelShape->ChangeOptions(kSunkenFrame | kDoubleBorder);
00121    f1->AddFrame(fLSelShape, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
00122    fBSelShape = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kVOL_SHAPE_SELECT);
00123    fBSelShape->SetToolTipText("Replace with one of the existing shapes");
00124    fBSelShape->Associate(this);
00125    f1->AddFrame(fBSelShape, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
00126    fEditShape = new TGTextButton(f1, "Edit");
00127    f1->AddFrame(fEditShape, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
00128    fEditShape->SetToolTipText("Edit selected shape");
00129    fEditShape->Associate(this);   
00130    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 0, 0));
00131    
00132    // Current medium
00133    f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame);
00134    fSelectedMedium = 0;
00135    fLSelMedium = new TGLabel(f1, "Select medium");
00136    gClient->GetColorByName("#0000ff", color);
00137    fLSelMedium->SetTextColor(color);
00138    fLSelMedium->ChangeOptions(kSunkenFrame | kDoubleBorder);
00139    f1->AddFrame(fLSelMedium, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
00140    fBSelMedium = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kVOL_MEDIA_SELECT);
00141    fBSelMedium->SetToolTipText("Replace with one of the existing media");
00142    fBSelMedium->Associate(this);
00143    f1->AddFrame(fBSelMedium, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
00144    fEditMedium = new TGTextButton(f1, "Edit");
00145    f1->AddFrame(fEditMedium, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2));
00146    fEditMedium->SetToolTipText("Edit selected medium");
00147    fEditMedium->Associate(this);
00148    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 2, 2, 0, 0));
00149 
00150    // List of daughters
00151    si = new TGShutterItem(fCategories, new TGHotString("Daughters"),kCAT_DAUGHTERS);
00152    container = (TGCompositeFrame*)si->GetContainer();
00153    container->SetBackgroundColor(GetDefaultFrameBackground());
00154    fCategories->AddItem(si);
00155 
00156    // Existing daughters
00157    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
00158    f1->AddFrame(label = new TGLabel(f1, "Existing daughters"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00159    f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00160    gClient->GetColorByName("#ff0000", color);
00161    label->SetTextColor(color);
00162    container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
00163 
00164    f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kRaisedFrame);
00165    fNodeList = new TGComboBox(f1, kVOL_NODE_SELECT);
00166    fNodeList->Resize(100, fVolumeName->GetDefaultHeight());
00167    fNodeList->Associate(this);
00168    f1->AddFrame(fNodeList, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
00169    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
00170    // Buttons for editing matrix and removing node
00171    f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kSunkenFrame | kFixedWidth);
00172    fEditMatrix = new TGTextButton(f1, "Position");
00173    f1->AddFrame(fEditMatrix, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
00174    fEditMatrix->SetToolTipText("Edit the position of selected node");
00175    fEditMatrix->Associate(this);
00176    fRemoveNode = new TGTextButton(f1, "Remove");
00177    f1->AddFrame(fRemoveNode, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
00178    fRemoveNode->SetToolTipText("Remove the selected node. Cannot undo !)");
00179    fRemoveNode->Associate(this);
00180    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
00181 
00182    // Adding daughters
00183    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
00184    f1->AddFrame(label = new TGLabel(f1, "Add daughter"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00185    f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00186    gClient->GetColorByName("#ff0000", color);
00187    label->SetTextColor(color);
00188    container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 10, 0));
00189 
00190    // Select from existing volumes
00191    f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
00192    fSelectedVolume = 0;
00193    fLSelVolume = new TGLabel(f1, "Select volume");
00194    gClient->GetColorByName("#0000ff", color);
00195    fLSelVolume->SetTextColor(color);
00196    fLSelVolume->ChangeOptions(kSunkenFrame | kDoubleBorder);
00197    f1->AddFrame(fLSelVolume, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
00198    fBSelVolume = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kVOL_VOL_SELECT);
00199    fBSelVolume->SetToolTipText("Select one of the existing volumes");
00200    fBSelVolume->Associate(this);
00201    f1->AddFrame(fBSelVolume, new TGLayoutHints(kLHintsRight, 1, 1, 2, 2));
00202    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));
00203 
00204    // Matrix selection for nodes 
00205    f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
00206    fSelectedMatrix = 0;
00207    fLSelMatrix = new TGLabel(f1, "Select matrix");
00208    gClient->GetColorByName("#0000ff", color);
00209    fLSelMatrix->SetTextColor(color);
00210    fLSelMatrix->ChangeOptions(kSunkenFrame | kDoubleBorder);
00211    f1->AddFrame(fLSelMatrix, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2));
00212    fBSelMatrix = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kVOL_MATRIX_SELECT);
00213    fBSelMatrix->SetToolTipText("Select one of the existing matrices");
00214    fBSelMatrix->Associate(this);
00215    f1->AddFrame(fBSelMatrix, new TGLayoutHints(kLHintsRight, 1, 1, 2, 2));
00216    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));   
00217 
00218    // Copy number
00219    f1 = new TGCompositeFrame(container, 155, 30, kHorizontalFrame | kFixedWidth);
00220    f1->AddFrame(new TGLabel(f1, "Node id"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0));
00221    fCopyNumber = new TGNumberEntry(f1, 0., 5, kVOL_NODEID);
00222    fCopyNumber->SetNumStyle(TGNumberFormat::kNESInteger);
00223    fCopyNumber->SetNumAttr(TGNumberFormat::kNEANonNegative);
00224    fCopyNumber->Resize(20,fCopyNumber->GetDefaultHeight()); 
00225    TGTextEntry *nef = (TGTextEntry*)fCopyNumber->GetNumberEntry();
00226    nef->SetToolTipText("Enter node copy number");
00227    fCopyNumber->Associate(this);
00228    f1->AddFrame(fCopyNumber, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
00229    fAddNode = new TGTextButton(f1, "Add");
00230    f1->AddFrame(fAddNode, new TGLayoutHints(kLHintsRight, 2, 2, 2, 2));
00231    fAddNode->Associate(this);
00232    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2));   
00233    
00234    // Visualization
00235    si = new TGShutterItem(fCategories, new TGHotString("Visualization"),kCAT_VIS);
00236    container = (TGCompositeFrame*)si->GetContainer();
00237    container->SetBackgroundColor(GetDefaultFrameBackground());
00238    fCategories->AddItem(si);
00239 
00240    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
00241    f1->AddFrame(label = new TGLabel(f1, "Visibility"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00242    f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00243 //   gClient->GetColorByName("#ff0000", color);
00244 //   label->SetTextColor(color);
00245    container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
00246 
00247    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame | kDoubleBorder);
00248    fBVis[0] = new TGCheckButton(f1, "Volume");
00249    fBVis[1] = new TGCheckButton(f1, "Nodes");
00250    f1->AddFrame(fBVis[0], new TGLayoutHints(kLHintsLeft, 2, 2, 0 ,0));
00251    f1->AddFrame(fBVis[1], new TGLayoutHints(kLHintsRight, 2, 2, 0 ,0));
00252    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
00253 
00254    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
00255    f1->AddFrame(new TGLabel(f1, "Depth"), new TGLayoutHints(kLHintsLeft, 2, 2, 4, 0));
00256 //   gClient->GetColorByName("#0000ff", color);
00257 //   label->SetTextColor(color);
00258    fEVisLevel = new TGNumberEntry(f1, 0, 5, kVOL_VISLEVEL);
00259    fEVisLevel->SetNumStyle(TGNumberFormat::kNESInteger);
00260    fEVisLevel->SetNumAttr(TGNumberFormat::kNEAPositive);
00261    fEVisLevel->Resize(40,fEVisLevel->GetDefaultHeight()); 
00262    nef = (TGTextEntry*)fEVisLevel->GetNumberEntry();
00263    nef->SetToolTipText("Set visibility level here");
00264    fEVisLevel->SetNumber(3);
00265    fEVisLevel->Associate(this);
00266    f1->AddFrame(fEVisLevel, new TGLayoutHints(kLHintsLeft, 2, 2, 0 ,0));
00267    fBAuto = new TGCheckButton(f1,"Auto");
00268    f1->AddFrame(fBAuto, new TGLayoutHints(kLHintsRight, 0, 0, 2, 0));
00269    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00270 
00271    TString stitle = "View";
00272    TGButtonGroup *bg = new TGVButtonGroup(container, stitle);
00273    fBView[0] = new TGRadioButton(bg, "All");
00274    fBView[1] = new TGRadioButton(bg, "Leaves");
00275    fBView[2] = new TGRadioButton(bg, "Only");
00276    bg->SetRadioButtonExclusive();
00277    bg->Show();
00278    container->AddFrame(bg, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
00279 
00280    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame | kDoubleBorder);
00281    fBRaytrace = new TGCheckButton(f1,"Raytrace");
00282    f1->AddFrame(fBRaytrace, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
00283    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00284      
00285    // Division
00286    si = new TGShutterItem(fCategories, new TGHotString("Division"),kCAT_DIVISION);
00287    container = (TGCompositeFrame*)si->GetContainer();
00288    container->SetBackgroundColor(GetDefaultFrameBackground());
00289    fCategories->AddItem(si);   
00290    // TextEntry for division name
00291    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
00292    f1->AddFrame(label = new TGLabel(f1, "Division name"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00293    f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00294    gClient->GetColorByName("#ff0000", color);
00295    label->SetTextColor(color);
00296    container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
00297    fDivName = new TGTextEntry(container, new TGTextBuffer(50), kDIV_NAME);
00298    fDivName->Resize(135, fVolumeName->GetDefaultHeight());
00299    fDivName->SetToolTipText("Enter the volume name");
00300    container->AddFrame(fDivName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5));
00301    // Axis selection
00302    stitle = "Axis";
00303    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
00304    bg = new TGVButtonGroup(f1, stitle);
00305    fBDiv[0] = new TGRadioButton(bg, "Axis 1");
00306    fBDiv[1] = new TGRadioButton(bg, "Axis 2");
00307    fBDiv[2] = new TGRadioButton(bg, "Axis 3");
00308    bg->Insert(fBDiv[0]);
00309    bg->Insert(fBDiv[1]);
00310    bg->Insert(fBDiv[2]);
00311    bg->SetRadioButtonExclusive();
00312    f1->AddFrame(bg, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
00313    fApplyDiv = new TGTextButton(f1, "Apply");
00314    fApplyDiv->SetToolTipText("Apply new division settings");
00315    f1->AddFrame(fApplyDiv, new TGLayoutHints(kLHintsRight, 0, 2, 30, 0));
00316    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
00317    // Division range
00318    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
00319    f1->AddFrame(label = new TGLabel(f1, "Division parameters"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0));
00320    f1->AddFrame(new TGHorizontal3DLine(f1), new TGLayoutHints(kLHintsExpandX, 5, 5, 7, 7));
00321 //   gClient->GetColorByName("#ff0000", color);
00322 //   label->SetTextColor(color);
00323    container->AddFrame(f1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
00324    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
00325    f1->AddFrame(label = new TGLabel(f1, "From"), new TGLayoutHints(kLHintsLeft, 2, 2, 4, 0));
00326 //   gClient->GetColorByName("#0000ff", color);
00327 //   label->SetTextColor(color);
00328    fEDivFrom = new TGNumberEntry(f1, 0, 5, kVOL_DIVSTART);
00329 //   fEDivFrom->SetNumStyle(TGNumberFormat::kNESInteger);
00330 //   fEDivFrom->SetNumAttr(TGNumberFormat::kNEAPositive);
00331    fEDivFrom->Resize(100,fEDivFrom->GetDefaultHeight()); 
00332    nef = (TGTextEntry*)fEDivFrom->GetNumberEntry();
00333    nef->SetToolTipText("Set start value");
00334    fEDivFrom->Associate(this);
00335    f1->AddFrame(fEDivFrom, new TGLayoutHints(kLHintsRight, 2, 2, 0 ,0));
00336    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00337 
00338    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth);
00339    f1->AddFrame(label = new TGLabel(f1, "Step"), new TGLayoutHints(kLHintsLeft, 2, 2, 4, 0));
00340 //   gClient->GetColorByName("#0000ff", color);
00341 //   label->SetTextColor(color);
00342    fEDivStep = new TGNumberEntry(f1, 0, 5, kVOL_DIVSTEP);
00343 //   fEDivFrom->SetNumStyle(TGNumberFormat::kNESInteger);
00344    fEDivStep->SetNumAttr(TGNumberFormat::kNEANonNegative);
00345    fEDivStep->Resize(100,fEDivStep->GetDefaultHeight()); 
00346    nef = (TGTextEntry*)fEDivStep->GetNumberEntry();
00347    nef->SetToolTipText("Set division step");
00348    fEDivStep->Associate(this);
00349    f1->AddFrame(fEDivStep, new TGLayoutHints(kLHintsRight, 2, 2, 0 ,0));
00350    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00351 
00352    f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame |kFixedWidth);
00353    f1->AddFrame(label = new TGLabel(f1, "Nslices"), new TGLayoutHints(kLHintsLeft, 2, 2, 4, 0));
00354 //   gClient->GetColorByName("#0000ff", color);
00355 //   label->SetTextColor(color);
00356    fEDivN = new TGNumberEntry(f1, 0, 5, kVOL_DIVN);
00357    fEDivN->SetNumStyle(TGNumberFormat::kNESInteger);
00358    fEDivN->SetNumAttr(TGNumberFormat::kNEAPositive);
00359    fEDivN->Resize(100,fEDivN->GetDefaultHeight()); 
00360    nef = (TGTextEntry*)fEDivN->GetNumberEntry();
00361    nef->SetToolTipText("Set number of slices");
00362    fEDivN->Associate(this);
00363    f1->AddFrame(fEDivN, new TGLayoutHints(kLHintsRight, 2, 2, 0 ,0));
00364    container->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4));
00365 
00366 
00367    fCategories->Resize(163,340);
00368    AddFrame(fCategories, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 0, 4, 4));
00369 
00370    fCategories->Layout();
00371    fCategories->SetDefaultSize(GetDefaultWidth(), GetDefaultHeight());
00372 }
00373 
00374 //______________________________________________________________________________
00375 TGeoVolumeEditor::~TGeoVolumeEditor()
00376 {
00377 // Destructor
00378    TGCompositeFrame *cont;
00379    cont = (TGCompositeFrame*)fCategories->GetItem("Properties")->GetContainer();
00380    TGeoTabManager::Cleanup(cont);
00381    fCategories->GetItem("Properties")->SetCleanup(0);
00382    cont = (TGCompositeFrame*)fCategories->GetItem("Daughters")->GetContainer();
00383    TGeoTabManager::Cleanup(cont);
00384    fCategories->GetItem("Daughters")->SetCleanup(0);
00385    cont = (TGCompositeFrame*)fCategories->GetItem("Visualization")->GetContainer();
00386    TGeoTabManager::Cleanup(cont);
00387    fCategories->GetItem("Visualization")->SetCleanup(0);
00388    cont = (TGCompositeFrame*)fCategories->GetItem("Division")->GetContainer();
00389    TGeoTabManager::Cleanup(cont);
00390    fCategories->GetItem("Division")->SetCleanup(0);
00391 
00392    delete fBView[0]; delete fBView[1]; delete fBView[2];
00393    delete fBDiv [0]; delete fBDiv [1]; delete fBDiv [2];
00394    Cleanup();
00395 }
00396 
00397 //______________________________________________________________________________
00398 void TGeoVolumeEditor::ConnectSignals2Slots()
00399 {
00400    // Connect signals to slots.
00401    fVolumeName->Connect("TextChanged(const char *)", "TGeoVolumeEditor", this, "DoVolumeName()");
00402    fDivName->Connect("TextChanged(const char *)", "TGeoVolumeEditor", this, "DoDivName()");
00403    fEditMedium->Connect("Clicked()", "TGeoVolumeEditor", this, "DoEditMedium()");
00404    fEditShape->Connect("Clicked()", "TGeoVolumeEditor", this, "DoEditShape()");
00405    fEditMatrix->Connect("Clicked()", "TGeoVolumeEditor", this, "DoEditMatrix()");
00406    fAddNode->Connect("Clicked()", "TGeoVolumeEditor", this, "DoAddNode()");
00407    fRemoveNode->Connect("Clicked()", "TGeoVolumeEditor", this, "DoRemoveNode()");
00408    fBSelShape->Connect("Clicked()", "TGeoVolumeEditor", this, "DoSelectShape()");
00409    fBSelMedium->Connect("Clicked()", "TGeoVolumeEditor", this, "DoSelectMedium()");
00410    fBSelVolume->Connect("Clicked()", "TGeoVolumeEditor", this, "DoSelectVolume()");
00411    fBSelMatrix->Connect("Clicked()", "TGeoVolumeEditor", this, "DoSelectMatrix()");
00412    fBVis[0]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoVisVolume()");
00413    fBVis[1]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoVisDaughters()");
00414    fBAuto->Connect("Clicked()", "TGeoVolumeEditor", this, "DoVisAuto()");
00415    fEVisLevel->Connect("ValueSet(Long_t)", "TGeoVolumeEditor", this, "DoVisLevel()"); 
00416    fBView[0]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoViewAll()");
00417    fBView[1]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoViewLeaves()");
00418    fBView[2]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoViewOnly()");
00419    fBDiv[0]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoDivSelAxis()");
00420    fBDiv[1]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoDivSelAxis()");
00421    fBDiv[2]->Connect("Clicked()", "TGeoVolumeEditor", this, "DoDivSelAxis()");
00422    fEDivFrom->Connect("ValueSet(Long_t)", "TGeoVolumeEditor", this, "DoDivFromTo()"); 
00423    fEDivStep->Connect("ValueSet(Long_t)", "TGeoVolumeEditor", this, "DoDivStep()"); 
00424    fEDivN->Connect("ValueSet(Long_t)", "TGeoVolumeEditor", this, "DoDivN()"); 
00425    fBRaytrace->Connect("Clicked()", "TGeoVolumeEditor", this, "DoRaytrace()");
00426    fApplyDiv->Connect("Clicked()", "TGeoVolumeEditor", this, "DoApplyDiv()");
00427 }
00428 
00429 //______________________________________________________________________________
00430 void TGeoVolumeEditor::SetModel(TObject* obj)
00431 {
00432    // Connect to the picked volume.
00433    if (obj == 0 || !obj->InheritsFrom(TGeoVolume::Class())) {
00434       SetActive(kFALSE);
00435       return;                 
00436    } 
00437    fVolume = (TGeoVolume*)obj;
00438    fGeometry = fVolume->GetGeoManager();
00439    const char *vname = fVolume->GetName();
00440    fVolumeName->SetText(vname);
00441    fSelectedShape = fVolume->GetShape();
00442    if (fSelectedShape) fLSelShape->SetText(fSelectedShape->GetName());
00443    fSelectedMedium = fVolume->GetMedium();
00444    if (fSelectedMedium) fLSelMedium->SetText(fSelectedMedium->GetName());
00445    
00446    fNodeList->RemoveEntries(0, fNodeList->GetNumberOfEntries()+1);
00447    TIter next2(fVolume->GetNodes());
00448    TGeoNode *node;
00449    Int_t icrt = 0;
00450    while ((node=(TGeoNode*)next2())) 
00451       fNodeList->AddEntry(node->GetName(), icrt++);
00452    fNodeList->Select(0);   
00453    fCopyNumber->SetNumber(fVolume->GetNdaughters()+1);
00454    if (!fVolume->GetNdaughters() || fVolume->GetFinder()) {
00455       fEditMatrix->SetEnabled(kFALSE);
00456       fRemoveNode->SetEnabled(kFALSE);
00457    } else {
00458       fEditMatrix->SetEnabled(kTRUE);
00459       fRemoveNode->SetEnabled(kTRUE);
00460    }      
00461    if (!fSelectedVolume) fAddNode->SetEnabled(kFALSE);   
00462    if (fVolume->IsAssembly()) {
00463       fBSelShape->SetEnabled(kFALSE);
00464       fBSelMedium->SetEnabled(kFALSE);
00465    }   
00466    fBVis[0]->SetState((fVolume->IsVisible())?kButtonDown:kButtonUp);
00467    fBVis[1]->SetState((fVolume->IsVisibleDaughters())?kButtonDown:kButtonUp);
00468    fBView[0]->SetState((fVolume->IsVisContainers())?kButtonDown:kButtonUp, kTRUE);
00469    fBView[1]->SetState((fVolume->IsVisLeaves())?kButtonDown:kButtonUp, kTRUE);
00470    fBView[2]->SetState((fVolume->IsVisOnly())?kButtonDown:kButtonUp, kTRUE);
00471    fBRaytrace->SetState((fVolume->IsRaytracing())?kButtonDown:kButtonUp);
00472    fBAuto->SetState((fGeometry->GetVisLevel())?kButtonUp:kButtonDown);
00473    fEVisLevel->SetNumber(fGeometry->GetVisLevel());
00474    fApplyDiv->SetEnabled(kFALSE);   
00475    if ((!fVolume->GetFinder() && fVolume->GetNdaughters()) || fVolume->IsAssembly()) {
00476       fCategories->GetItem("Division")->GetButton()->SetEnabled(kFALSE);
00477    } else {
00478       fCategories->GetItem("Division")->GetButton()->SetEnabled(kTRUE);
00479       Double_t start=0., step=0., end = 0.;
00480       Int_t ndiv = 2, iaxis = 1;
00481       TString axis_name;
00482       for (Int_t i=0; i<3; i++) {
00483          axis_name = fVolume->GetShape()->GetAxisName(i+1);
00484          fBDiv[i]->SetText(axis_name);
00485       }   
00486          
00487       if (fVolume->GetFinder()) {
00488          fDivName->SetText(fVolume->GetNode(0)->GetVolume()->GetName());
00489          iaxis = fVolume->GetFinder()->GetDivAxis();
00490          start = fVolume->GetFinder()->GetStart();
00491          step = fVolume->GetFinder()->GetStep();
00492          ndiv = fVolume->GetFinder()->GetNdiv();
00493       } else {            
00494          fDivName->SetText("Enter name");
00495          fSelectedShape->GetAxisRange(iaxis,start,end);
00496          step = 0;
00497       }
00498       fBDiv[iaxis-1]->SetState(kButtonDown, kTRUE);
00499       fEDivFrom->SetNumber(start);
00500       fEDivStep->SetNumber(step);
00501       fEDivN->SetNumber(ndiv);   
00502    }   
00503    
00504    if (fInit) ConnectSignals2Slots();
00505    SetActive();
00506    if (GetParent()==fTabMgr->GetVolumeTab()) fTab->Layout();
00507 }
00508 
00509 //______________________________________________________________________________
00510 void TGeoVolumeEditor::ActivateBaseClassEditors(TClass* cl)
00511 {
00512    // Add editors to fGedFrame and exclude TLineEditor.
00513 
00514    fGedEditor->ExcludeClassEditor(TAttFill::Class());
00515    TGedFrame::ActivateBaseClassEditors(cl);
00516 }
00517 
00518 //______________________________________________________________________________
00519 void TGeoVolumeEditor::DoVolumeName()
00520 {
00521 // Modify volume name.
00522    fVolume->SetName(fVolumeName->GetText());
00523 }
00524    
00525 //______________________________________________________________________________
00526 void TGeoVolumeEditor::DoSelectShape()
00527 {
00528 // Select a new shape.
00529    TGeoShape *shape = fSelectedShape;
00530    new TGeoShapeDialog(fBSelShape, gClient->GetRoot(), 200,300);  
00531    fSelectedShape = (TGeoShape*)TGeoShapeDialog::GetSelected();
00532    if (fSelectedShape) fLSelShape->SetText(fSelectedShape->GetName());
00533    else fSelectedShape = shape;
00534 }
00535 
00536 //______________________________________________________________________________
00537 void TGeoVolumeEditor::DoSelectMedium()
00538 {
00539 // Select a new medium.
00540    TGeoMedium *med = fSelectedMedium;
00541    new TGeoMediumDialog(fBSelMedium, gClient->GetRoot(), 200,300);  
00542    fSelectedMedium = (TGeoMedium*)TGeoMediumDialog::GetSelected();
00543    if (fSelectedMedium) fLSelMedium->SetText(fSelectedMedium->GetName());
00544    else fSelectedMedium = med;
00545 }
00546 
00547 //______________________________________________________________________________
00548 void TGeoVolumeEditor::DoSelectMatrix()
00549 {
00550 // Select a matrix for positioning.
00551    TGeoMatrix *matrix = fSelectedMatrix;
00552    new TGeoMatrixDialog(fBSelMatrix, gClient->GetRoot(), 200,300);  
00553    fSelectedMatrix = (TGeoMatrix*)TGeoMatrixDialog::GetSelected();
00554    if (fSelectedMatrix) fLSelMatrix->SetText(fSelectedMatrix->GetName());
00555    else fSelectedMatrix = matrix;
00556 }
00557 
00558 //______________________________________________________________________________
00559 void TGeoVolumeEditor::DoSelectVolume()
00560 {
00561 // Select a daughter volume.
00562    TGeoVolume *vol = fSelectedVolume;
00563    new TGeoVolumeDialog(fBSelVolume, gClient->GetRoot(), 200,300);  
00564    fSelectedVolume = (TGeoVolume*)TGeoVolumeDialog::GetSelected();
00565    if (fSelectedVolume) fLSelVolume->SetText(fSelectedVolume->GetName());
00566    else fSelectedVolume = vol;
00567    if (fSelectedVolume)
00568       fAddNode->SetEnabled(kTRUE);
00569 }
00570 
00571 
00572 //______________________________________________________________________________
00573 void TGeoVolumeEditor::DoEditShape()
00574 {
00575 // Edit the shape of the volume.
00576    fTabMgr->GetShapeEditor(fVolume->GetShape());
00577 }
00578 
00579 //______________________________________________________________________________
00580 void TGeoVolumeEditor::DoEditMedium()
00581 {
00582 // Edit the medium of the volume.
00583    fTabMgr->GetMediumEditor(fVolume->GetMedium());
00584 }
00585 
00586 //______________________________________________________________________________
00587 void TGeoVolumeEditor::DoEditMatrix()
00588 {
00589 // Edit the position of the selected node.
00590    if (!fVolume->GetNdaughters()) return;
00591    Int_t i = fNodeList->GetSelected();
00592    if (i<0) return;
00593    fTabMgr->GetMatrixEditor(fVolume->GetNode(i)->GetMatrix());
00594 }
00595 
00596 //______________________________________________________________________________
00597 void TGeoVolumeEditor::DoAddNode()
00598 {
00599 // Add a daughter.
00600    if (!fSelectedVolume || fVolume->GetFinder()) return;
00601    Int_t icopy = fCopyNumber->GetIntNumber();
00602    fVolume->AddNode(fSelectedVolume, icopy, fSelectedMatrix);
00603    Int_t nd = fVolume->GetNdaughters();
00604    fNodeList->AddEntry(fVolume->GetNode(nd-1)->GetName(), nd-1);
00605    fNodeList->Select(nd-1);
00606    fCopyNumber->SetNumber(nd+1);
00607    if (fSelectedMatrix) fEditMatrix->SetEnabled(kTRUE);
00608    fRemoveNode->SetEnabled(kTRUE);
00609    fGeometry->SetTopVisible();
00610    fEditMatrix->SetEnabled(kTRUE);
00611    fRemoveNode->SetEnabled(kTRUE);
00612    Update();
00613 }
00614 
00615 //______________________________________________________________________________
00616 void TGeoVolumeEditor::DoRemoveNode()
00617 {
00618 // Remove a daughter.
00619    if (!fVolume->GetNdaughters() || fVolume->GetFinder()) {
00620       fRemoveNode->SetEnabled(kFALSE);
00621       fEditMatrix->SetEnabled(kFALSE);
00622       return;
00623    }   
00624    Int_t i = fNodeList->GetSelected();
00625    if (i<0) return;
00626    fVolume->RemoveNode(fVolume->GetNode(i));
00627    fNodeList->RemoveEntries(0, fNodeList->GetNumberOfEntries()+1);
00628    TIter next(fVolume->GetNodes());
00629    TGeoNode *node;
00630    i = 0;
00631    while ((node=(TGeoNode*)next())) 
00632       fNodeList->AddEntry(node->GetName(), i++);
00633    fNodeList->Select(0);   
00634    fCopyNumber->SetNumber(fVolume->GetNdaughters()+1);
00635    if (!fVolume->GetNdaughters()) {
00636       fRemoveNode->SetEnabled(kFALSE);
00637       fEditMatrix->SetEnabled(kFALSE);
00638       fCategories->GetItem("Division")->GetButton()->SetEnabled(kTRUE);
00639       Double_t start=0., step=0., end=0.;
00640       Int_t ndiv = 2, iaxis = 1;
00641       fSelectedShape->GetAxisRange(iaxis,start,end);
00642       step = end-start;
00643       fBDiv[iaxis-1]->SetState(kButtonDown, kTRUE);
00644       fEDivFrom->SetNumber(start);
00645       fEDivStep->SetNumber(step);
00646       fEDivN->SetNumber(ndiv);      
00647    }
00648    Update();
00649 }
00650 
00651 //______________________________________________________________________________
00652 void TGeoVolumeEditor::DoVisVolume()
00653 {
00654 // Slot for setting volume visible/invisible.
00655    Bool_t on = (fBVis[0]->GetState()==kButtonDown)?kTRUE:kFALSE;
00656    if (fVolume->IsVisible() == on) return;
00657    fVolume->SetVisibility(on);
00658    Update();
00659 }
00660 
00661 //______________________________________________________________________________
00662 void TGeoVolumeEditor::DoVisDaughters()
00663 {
00664 // Slot for setting daughters visible/invisible.
00665    Bool_t on = (fBVis[1]->GetState()==kButtonDown)?kTRUE:kFALSE;
00666    if (fVolume->IsVisibleDaughters() == on) return;
00667    fVolume->VisibleDaughters(on);
00668    Update();
00669 }
00670 
00671 //______________________________________________________________________________
00672 void TGeoVolumeEditor::DoVisAuto()
00673 {
00674 // Slot for setting visibility depth auto.
00675    Bool_t on = (fBAuto->GetState()==kButtonDown)?kTRUE:kFALSE;
00676    if ((fGeometry->GetVisLevel()==0) == on) return;
00677    if (on) fGeometry->SetVisLevel(0);
00678    else    fGeometry->SetVisLevel(fEVisLevel->GetIntNumber());
00679    Update();
00680 }
00681 
00682 //______________________________________________________________________________
00683 void TGeoVolumeEditor::DoVisLevel()
00684 {
00685 // Slot for visibility level.
00686    fBAuto->SetState(kButtonUp);
00687    fGeometry->SetVisLevel(fEVisLevel->GetIntNumber());
00688    Update();
00689 }
00690 
00691 //______________________________________________________________________________
00692 void TGeoVolumeEditor::DoViewAll()
00693 {
00694 // Slot for viewing volume and containers.
00695    Bool_t on = (fBView[0]->GetState()==kButtonDown)?kTRUE:kFALSE;
00696    if (!on) return;
00697    if (fVolume->IsVisContainers() == on) return;
00698    if (fVolume->IsRaytracing()) {
00699       fVolume->Raytrace(kFALSE);
00700       fBRaytrace->SetState(kButtonUp);
00701    }   
00702    fVolume->SetVisContainers(on);
00703    Update();
00704 }
00705 
00706 //______________________________________________________________________________
00707 void TGeoVolumeEditor::DoViewLeaves()
00708 {
00709 // Slot for viewing last leaves only.
00710    Bool_t on = (fBView[1]->GetState()==kButtonDown)?kTRUE:kFALSE;
00711    if (!on) return;
00712    if (fVolume->IsVisLeaves() == on) return;
00713    if (fVolume->IsRaytracing()) {
00714       fVolume->Raytrace(kFALSE);
00715       fBRaytrace->SetState(kButtonUp);
00716    }   
00717    fVolume->SetVisLeaves(on);
00718    Update();
00719 }
00720 
00721 //______________________________________________________________________________
00722 void TGeoVolumeEditor::DoViewOnly()
00723 {
00724 // Slot for viewing volume only.
00725    Bool_t on = (fBView[2]->GetState()==kButtonDown)?kTRUE:kFALSE;
00726    if (!on) return;
00727    if (fVolume->IsVisOnly() == on) return;
00728    if (fVolume->IsRaytracing()) {
00729       fVolume->Raytrace(kFALSE);
00730       fBRaytrace->SetState(kButtonUp);
00731    }   
00732    fVolume->SetVisOnly(on);
00733    Update();
00734 }
00735 
00736 //______________________________________________________________________________
00737 void TGeoVolumeEditor::DoRaytrace()
00738 {
00739 // Slot for raytracing.
00740    Bool_t on = (fBRaytrace->GetState()==kButtonDown)?kTRUE:kFALSE;
00741    if (fVolume->IsRaytracing() == on) return;
00742    fVolume->Raytrace(on);
00743    Update();
00744 }
00745 
00746 //______________________________________________________________________________
00747 void TGeoVolumeEditor::DoDivName()
00748 {
00749 // Modify division name.
00750    fApplyDiv->SetEnabled(kTRUE);   
00751 }
00752 
00753 //______________________________________________________________________________
00754 void TGeoVolumeEditor::DoDivSelAxis()
00755 {
00756 // Change division axis and preserve number of slices.
00757    Int_t iaxis = 1;
00758    for (Int_t i=0; i<3; i++) {
00759       if (fBDiv[i]->GetState()!=kButtonDown) continue;
00760       iaxis = i+1;
00761       break;
00762    }   
00763    TGeoShape *shape = fVolume->GetShape();
00764    if (!shape) {
00765       fApplyDiv->SetEnabled(kFALSE);
00766       return;
00767    }   
00768    Double_t xlo, xhi;
00769    shape->GetAxisRange(iaxis, xlo, xhi);
00770    if (xhi <= xlo) {
00771       fApplyDiv->SetEnabled(kFALSE);
00772       return;
00773    }   
00774    fEDivFrom->SetNumber(xlo);
00775    fEDivStep->SetNumber(0);
00776    fApplyDiv->SetEnabled(kTRUE);
00777 }
00778 
00779 //______________________________________________________________________________
00780 void TGeoVolumeEditor::DoDivFromTo()
00781 {
00782 // Handle division range modification.
00783    Double_t min, max, xlo, xhi, step;
00784    Int_t iaxis = 1;
00785    Int_t ndiv;
00786    for (Int_t i=0; i<3; i++) {
00787       if (fBDiv[i]->GetState()!=kButtonDown) continue;
00788       iaxis = i+1;
00789       break;
00790    }   
00791    TGeoShape *shape = fVolume->GetShape();
00792    if (!shape) {
00793       fApplyDiv->SetEnabled(kFALSE);
00794       return;
00795    }   
00796    shape->GetAxisRange(iaxis, xlo, xhi);
00797    if (xhi-xlo <= 0) {
00798       fApplyDiv->SetEnabled(kFALSE);
00799       return;
00800    }
00801    min = fEDivFrom->GetNumber();
00802    step = fEDivStep->GetNumber();
00803    ndiv = fEDivN->GetIntNumber();
00804    if (min<xlo) {
00805       min = xlo;
00806       fEDivFrom->SetNumber(xlo);
00807    }   
00808    max = min + ndiv*step;
00809    if (max>xhi) {
00810       max = xhi;
00811       step = (max-min)/ndiv;
00812       fEDivStep->SetNumber(step);
00813    }   
00814    if (min>=max) {
00815       fApplyDiv->SetEnabled(kFALSE);
00816       return;
00817    }   
00818    fApplyDiv->SetEnabled(kTRUE);
00819 }
00820 
00821 //______________________________________________________________________________
00822 void TGeoVolumeEditor::DoDivStep()
00823 {
00824 // Handle division step modification.
00825    Double_t min, max, xlo, xhi;
00826    Int_t iaxis = 1;
00827    for (Int_t i=0; i<3; i++) {
00828       if (fBDiv[i]->GetState()!=kButtonDown) continue;
00829       iaxis = i+1;
00830       break;
00831    }   
00832    TGeoShape *shape = fVolume->GetShape();
00833    if (!shape) {
00834       fApplyDiv->SetEnabled(kFALSE);
00835       return;
00836    }   
00837    shape->GetAxisRange(iaxis, xlo, xhi);
00838    if (xhi-xlo <= 0) {
00839       fApplyDiv->SetEnabled(kFALSE);
00840       return;
00841    }
00842    min = fEDivFrom->GetNumber();
00843    Double_t step = fEDivStep->GetNumber();
00844    Int_t ndiv = fEDivN->GetIntNumber();
00845    max = min + ndiv*step;
00846    
00847    // Check if ndiv*step < max-min
00848    if (max <= xhi) {
00849       fApplyDiv->SetEnabled(kTRUE);
00850       return;
00851    }
00852    // Step too big - set value to fit range
00853    max = xhi;
00854    step = (max-min)/ndiv;
00855    fEDivStep->SetNumber(step);
00856    if (step < 0) {
00857       fApplyDiv->SetEnabled(kFALSE);
00858       return;
00859    }
00860    fApplyDiv->SetEnabled(kTRUE);
00861 }
00862 
00863 //______________________________________________________________________________
00864 void TGeoVolumeEditor::DoDivN()
00865 {
00866 // Handle division N modification.
00867    Double_t min, max, xlo, xhi;
00868    Int_t iaxis = 1;
00869    for (Int_t i=0; i<3; i++) {
00870       if (fBDiv[i]->GetState()!=kButtonDown) continue;
00871       iaxis = i+1;
00872       break;
00873    }   
00874    TGeoShape *shape = fVolume->GetShape();
00875    if (!shape) {
00876       fApplyDiv->SetEnabled(kFALSE);
00877       return;
00878    }   
00879    shape->GetAxisRange(iaxis, xlo, xhi);
00880    if (xhi-xlo <= 0) {
00881       fApplyDiv->SetEnabled(kFALSE);
00882       return;
00883    }
00884    Double_t step = fEDivStep->GetNumber();
00885    // If step=0 it is discounted
00886    if (step==0) {
00887       fApplyDiv->SetEnabled(kTRUE);
00888       return;
00889    }   
00890    Int_t ndiv = fEDivN->GetIntNumber();
00891    min = fEDivFrom->GetNumber();
00892    max = min + ndiv*step;
00893    // Check if ndiv*step < max-min
00894    if (max <= xhi) {
00895       fApplyDiv->SetEnabled(kTRUE);
00896       return;
00897    }
00898    max = xhi;
00899    ndiv = (Int_t)((max-min)/step);
00900    fEDivN->SetNumber(ndiv);
00901    fApplyDiv->SetEnabled(kTRUE);   
00902 }
00903 
00904 //______________________________________________________________________________
00905 void TGeoVolumeEditor::DoApplyDiv()
00906 {
00907 // Apply current division settings
00908    Double_t xlo, xhi, step;
00909    Int_t iaxis = 1;
00910    Int_t ndiv;
00911    for (Int_t i=0; i<3; i++) {
00912       if (fBDiv[i]->GetState()!=kButtonDown) continue;
00913       iaxis = i+1;
00914       break;
00915    }   
00916    TGeoShape *shape = fVolume->GetShape();
00917    if (!shape) {
00918       fApplyDiv->SetEnabled(kFALSE);
00919       return;
00920    }   
00921    shape->GetAxisRange(iaxis, xlo, xhi);
00922    if (xhi-xlo <= 0) {
00923       fApplyDiv->SetEnabled(kFALSE);
00924       return;
00925    }
00926    xlo = fEDivFrom->GetNumber();
00927    step = fEDivStep->GetNumber();
00928    ndiv = fEDivN->GetIntNumber();
00929    TGeoPatternFinder *finder = fVolume->GetFinder();
00930    if (finder) {
00931    // we have to remove first the existing division
00932       TObjArray *nodes = fVolume->GetNodes();
00933       nodes->Delete();
00934       nodes->Clear();
00935       delete finder;
00936       fVolume->SetFinder(0);
00937    }     
00938    fVolume->Divide(fDivName->GetText(), iaxis, ndiv, xlo, step);
00939    fApplyDiv->SetEnabled(kFALSE);   
00940    fGeometry->SetTopVisible();
00941    Update();
00942 //   fVolume->Draw();  
00943 }

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