From 05b972d55cb70f6532a2b6097fb651049cf2565e Mon Sep 17 00:00:00 2001 From: Rene Brun <Rene.Brun@cern.ch> Date: Fri, 23 Jun 2006 16:00:13 +0000 Subject: [PATCH] From Mihaela: 5 new shape editors (TGeoEltu, TGeoHype, TGeoPara, TGeoPcon, TGeoTorus) - modifying shape parameters in their editors allow painting in the same time - fixed editors destructors - fixed a seg fault in selection dialogs git-svn-id: http://root.cern.ch/svn/root/trunk@15527 27541ba8-7e3a-0410-8455-c3a389f83636 --- geombuilder/Module.mk | 3 +- geombuilder/inc/LinkDef.h | 6 +- geombuilder/inc/TGeoBBoxEditor.h | 11 +- geombuilder/inc/TGeoConeEditor.h | 8 +- geombuilder/inc/TGeoEltuEditor.h | 81 +++++ geombuilder/inc/TGeoHypeEditor.h | 87 +++++ geombuilder/inc/TGeoNodeEditor.h | 24 +- geombuilder/inc/TGeoParaEditor.h | 90 +++++ geombuilder/inc/TGeoPconEditor.h | 7 +- geombuilder/inc/TGeoSphereEditor.h | 17 +- geombuilder/inc/TGeoTabManager.h | 71 +--- geombuilder/inc/TGeoTorusEditor.h | 87 +++++ geombuilder/inc/TGeoTrd1Editor.h | 7 +- geombuilder/inc/TGeoTrd2Editor.h | 7 +- geombuilder/inc/TGeoTubeEditor.h | 8 +- geombuilder/src/TGeoBBoxEditor.cxx | 170 +++++----- geombuilder/src/TGeoConeEditor.cxx | 162 +++++---- geombuilder/src/TGeoEltuEditor.cxx | 305 +++++++++++++++++ geombuilder/src/TGeoHypeEditor.cxx | 441 +++++++++++++++++++++++++ geombuilder/src/TGeoManagerEditor.cxx | 83 +++-- geombuilder/src/TGeoMaterialEditor.cxx | 10 +- geombuilder/src/TGeoMatrixEditor.cxx | 22 +- geombuilder/src/TGeoMediumEditor.cxx | 10 +- geombuilder/src/TGeoNodeEditor.cxx | 217 ++++++------ geombuilder/src/TGeoParaEditor.cxx | 405 +++++++++++++++++++++++ geombuilder/src/TGeoPconEditor.cxx | 99 ++++-- geombuilder/src/TGeoSphereEditor.cxx | 109 +++--- geombuilder/src/TGeoTabManager.cxx | 226 +++---------- geombuilder/src/TGeoTorusEditor.cxx | 378 +++++++++++++++++++++ geombuilder/src/TGeoTrd1Editor.cxx | 105 +++--- geombuilder/src/TGeoTrd2Editor.cxx | 122 ++++--- geombuilder/src/TGeoTubeEditor.cxx | 130 ++++---- geombuilder/src/TGeoVolumeEditor.cxx | 18 +- 33 files changed, 2699 insertions(+), 827 deletions(-) create mode 100644 geombuilder/inc/TGeoEltuEditor.h create mode 100644 geombuilder/inc/TGeoHypeEditor.h create mode 100644 geombuilder/inc/TGeoParaEditor.h create mode 100644 geombuilder/inc/TGeoTorusEditor.h create mode 100644 geombuilder/src/TGeoEltuEditor.cxx create mode 100644 geombuilder/src/TGeoHypeEditor.cxx create mode 100644 geombuilder/src/TGeoParaEditor.cxx create mode 100644 geombuilder/src/TGeoTorusEditor.cxx diff --git a/geombuilder/Module.mk b/geombuilder/Module.mk index d870523923b..44f0c67e5fc 100644 --- a/geombuilder/Module.mk +++ b/geombuilder/Module.mk @@ -21,7 +21,8 @@ GEOMBUILDERH := TGeoVolumeEditor.h TGeoBBoxEditor.h TGeoMediumEditor.h \ TGeoNodeEditor.h TGeoMatrixEditor.h TGeoManagerEditor.h \ TGeoTubeEditor.h TGeoConeEditor.h TGeoTrd1Editor.h \ TGeoTrd2Editor.h TGeoMaterialEditor.h TGeoTabManager.h \ - TGeoSphereEditor.h TGeoPconEditor.h + TGeoSphereEditor.h TGeoPconEditor.h TGeoParaEditor.h \ + TGeoTorusEditor.h TGeoEltuEditor.h TGeoHypeEditor.h GEOMBUILDERH := $(patsubst %,$(MODDIRI)/%,$(GEOMBUILDERH)) GEOMBUILDERS := $(filter-out $(MODDIRS)/G__%,$(wildcard $(MODDIRS)/*.cxx)) GEOMBUILDERO := $(GEOMBUILDERS:.cxx=.o) diff --git a/geombuilder/inc/LinkDef.h b/geombuilder/inc/LinkDef.h index 1542b081ee0..c7da7f1d456 100644 --- a/geombuilder/inc/LinkDef.h +++ b/geombuilder/inc/LinkDef.h @@ -1,4 +1,4 @@ -// @(#)$Name: $:$Id: LinkDef.h,v 1.1 2006/06/13 15:27:11 brun Exp $ +// @(#)$Name: $:$Id: LinkDef.h,v 1.2 2006/06/19 14:58:48 brun Exp $ /************************************************************************* * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * * All rights reserved. * @@ -17,9 +17,13 @@ #pragma link C++ class TGeoBBoxEditor; #pragma link C++ class TGeoTubeEditor; #pragma link C++ class TGeoTubeSegEditor; +#pragma link C++ class TGeoEltuEditor; +#pragma link C++ class TGeoHypeEditor; #pragma link C++ class TGeoConeEditor; #pragma link C++ class TGeoConeSegEditor; #pragma link C++ class TGeoTrd1Editor; +#pragma link C++ class TGeoParaEditor; +#pragma link C++ class TGeoTorusEditor; #pragma link C++ class TGeoPconEditor; #pragma link C++ class TGeoPconSection; #pragma link C++ class TGeoTrd2Editor; diff --git a/geombuilder/inc/TGeoBBoxEditor.h b/geombuilder/inc/TGeoBBoxEditor.h index 27a29ade6b3..4e918f2cae7 100644 --- a/geombuilder/inc/TGeoBBoxEditor.h +++ b/geombuilder/inc/TGeoBBoxEditor.h @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: Exp $ +// @(#):$Name: $:$Id: TGeoBBoxEditor.h,v 1.1 2006/06/13 15:27:11 brun Exp $ // Author: M.Gheata /************************************************************************* * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * @@ -33,6 +33,7 @@ class TGNumberEntry; class TGTab; class TGComboBox; class TGTextButton; +class TGCheckButton; class TString; class TGeoBBoxEditor : public TGedFrame { @@ -56,10 +57,11 @@ protected: TGNumberEntry *fBoxOy; // Number entry for box OY TGNumberEntry *fBoxOz; // Number entry for box OZ TGTextButton *fApply; // Apply-Button to accept changes - TGTextButton *fCancel; // Cancel-Button TGTextButton *fUndo; // Undo-Button + TGCheckButton *fDelayed; // Check button for delayed draw virtual void ConnectSignals2Slots(); // Connect the signals to the slots + Bool_t IsDelayed() const; public: TGeoBBoxEditor(const TGWindow *p, Int_t id, @@ -72,11 +74,12 @@ public: void DoDx(); void DoDy(); void DoDz(); + void DoOx(); + void DoOy(); + void DoOz(); void DoModified(); void DoName(); - Bool_t DoBoxParameters(); void DoApply(); - void DoCancel(); void DoUndo(); ClassDef(TGeoBBoxEditor,0) // TGeoBBox editor diff --git a/geombuilder/inc/TGeoConeEditor.h b/geombuilder/inc/TGeoConeEditor.h index 4f304f043b3..16c69b7d17e 100644 --- a/geombuilder/inc/TGeoConeEditor.h +++ b/geombuilder/inc/TGeoConeEditor.h @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: Exp $ +// @(#):$Name: $:$Id: TGeoConeEditor.h,v 1.1 2006/06/13 15:27:11 brun Exp $ // Author: M.Gheata /************************************************************************* * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * @@ -34,6 +34,7 @@ class TGNumberEntry; class TGTab; class TGComboBox; class TGTextButton; +class TGCheckButton; class TString; class TGeoConeEditor : public TGedFrame { @@ -57,10 +58,11 @@ protected: TGNumberEntry *fERmax2; // Number entry for rmax2 TGNumberEntry *fEDz; // Number entry for DZ TGTextButton *fApply; // Apply-Button to accept changes - TGTextButton *fCancel; // Cancel-Button TGTextButton *fUndo; // Undo-Button + TGCheckButton *fDelayed; // Check button for delayed draw virtual void ConnectSignals2Slots(); // Connect the signals to the slots + Bool_t IsDelayed() const; public: TGeoConeEditor(const TGWindow *p, Int_t id, @@ -78,7 +80,6 @@ public: void DoModified(); void DoName(); virtual void DoApply(); - virtual void DoCancel(); virtual void DoUndo(); ClassDef(TGeoConeEditor,0) // TGeoCone editor @@ -120,7 +121,6 @@ public: void DoPhi2(); virtual void DoApply(); virtual void DoUndo(); - virtual void DoCancel(); ClassDef(TGeoConeSegEditor,0) // TGeoConeSeg editor }; diff --git a/geombuilder/inc/TGeoEltuEditor.h b/geombuilder/inc/TGeoEltuEditor.h new file mode 100644 index 00000000000..082e1504f43 --- /dev/null +++ b/geombuilder/inc/TGeoEltuEditor.h @@ -0,0 +1,81 @@ +// @(#):$Name: $:$Id: Exp $ +// Author: M.Gheata +/************************************************************************* + * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +#ifndef ROOT_TGeoEltuEditor +#define ROOT_TGeoEltuEditor + +////////////////////////////////////////////////////////////////////////// +// // +// TGeoEltuEditor // +// // +// Editor for a TGeoEltu. // +// // +////////////////////////////////////////////////////////////////////////// + +#ifndef ROOT_TGButton +#include "TGWidget.h" +#endif +#ifndef ROOT_TGedFrame +#include "TGedFrame.h" +#endif + +class TGeoEltu; +class TGeoTabManager; +class TGTextEntry; +class TGNumberEntry; +class TGTab; +class TGComboBox; +class TGTextButton; +class TGCheckButton; +class TString; + +class TGeoEltuEditor : public TGedFrame { + +protected: + + Double_t fAi; // Initial semi-axis of the ellipse along x + Double_t fBi; // Initial semi-axis of the ellipse along y + Double_t fDzi; // Initial half length in z + TString fNamei; // Initial name + TGeoEltu *fShape; // Shape object + Bool_t fIsModified; // Flag that volume was modified + Bool_t fIsShapeEditable; // Flag that the shape can be changed + TGeoTabManager *fTabMgr; // Tab manager + TGTextEntry *fShapeName; // Shape name text entry + TGNumberEntry *fEA; // Number entry for A + TGNumberEntry *fEB; // Number entry for B + TGNumberEntry *fEDz; // Number entry for DZ + TGTextButton *fApply; // Apply-Button to accept changes + TGTextButton *fUndo; // Undo-Button + TGCheckButton *fDelayed; // Check button for delayed draw + + virtual void ConnectSignals2Slots(); // Connect the signals to the slots + Bool_t IsDelayed() const; + +public: + TGeoEltuEditor(const TGWindow *p, Int_t id, + Int_t width = 140, Int_t height = 30, + UInt_t options = kChildFrame, + Pixel_t back = GetDefaultFrameBackground()); + virtual ~TGeoEltuEditor(); + virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event); + + void DoA(); + void DoB(); + void DoDz(); + void DoModified(); + void DoName(); + void DoApply(); + void DoUndo(); + + ClassDef(TGeoEltuEditor,0) // TGeoEltu editor +}; + +#endif diff --git a/geombuilder/inc/TGeoHypeEditor.h b/geombuilder/inc/TGeoHypeEditor.h new file mode 100644 index 00000000000..7646ccfcf40 --- /dev/null +++ b/geombuilder/inc/TGeoHypeEditor.h @@ -0,0 +1,87 @@ +// @(#):$Name: $:$Id: Exp $ +// Author: M.Gheata +/************************************************************************* + * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +#ifndef ROOT_TGeoHypeEditor +#define ROOT_TGeoHypeEditor + +////////////////////////////////////////////////////////////////////////// +// // +// TGeoHypeEditor // +// // +// Editor for a TGeoHype. // +// // +////////////////////////////////////////////////////////////////////////// + +#ifndef ROOT_TGButton +#include "TGWidget.h" +#endif +#ifndef ROOT_TGedFrame +#include "TGedFrame.h" +#endif + +class TGeoHype; +class TGeoTabManager; +class TGTextEntry; +class TGNumberEntry; +class TGTab; +class TGComboBox; +class TGTextButton; +class TGCheckButton; +class TString; + +class TGeoHypeEditor : public TGedFrame { + +protected: + + Double_t fRini; // Initial inner radius + Double_t fRouti; // Initial outer radius + Double_t fDzi; // Initial half length Dz + Double_t fStIni; // Initial stereo angle for inner surface + Double_t fStOuti; // Initial stereo angle for outer surface + TString fNamei; // Initial name + TGeoHype *fShape; // Shape object + Bool_t fIsModified; // Flag that volume was modified + Bool_t fIsShapeEditable; // Flag that the shape can be changed + TGeoTabManager *fTabMgr; // Tab manager + TGTextEntry *fShapeName; // Shape name text entry + TGNumberEntry *fERin; // Number entry for Rin + TGNumberEntry *fERout; // Number entry for Rout + TGNumberEntry *fEDz; // Number entry for Dz + TGNumberEntry *fEStIn; // Number entry for StIn + TGNumberEntry *fEStOut; // Number entry for StOut + TGTextButton *fApply; // Apply-Button to accept changes + TGTextButton *fUndo; // Undo-Button + TGCheckButton *fDelayed; // Check button for delayed draw + + virtual void ConnectSignals2Slots(); // Connect the signals to the slots + Bool_t IsDelayed() const; + +public: + TGeoHypeEditor(const TGWindow *p, Int_t id, + Int_t width = 140, Int_t height = 30, + UInt_t options = kChildFrame, + Pixel_t back = GetDefaultFrameBackground()); + virtual ~TGeoHypeEditor(); + virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event); + + void DoRin(); + void DoRout(); + void DoDz(); + void DoStIn(); + void DoStOut(); + void DoModified(); + void DoName(); + void DoApply(); + void DoUndo(); + + ClassDef(TGeoHypeEditor,0) // TGeoHype editor +}; + +#endif diff --git a/geombuilder/inc/TGeoNodeEditor.h b/geombuilder/inc/TGeoNodeEditor.h index 16b0bad945c..b66a54a9cdc 100644 --- a/geombuilder/inc/TGeoNodeEditor.h +++ b/geombuilder/inc/TGeoNodeEditor.h @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: Exp $ +// @(#):$Name: $:$Id: TGeoNodeEditor.h,v 1.1 2006/06/13 15:27:11 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -28,11 +28,14 @@ #endif class TGeoNode; +class TGeoVolume; +class TGeoMatrix; class TGTextEntry; class TGNumberEntry; class TGTab; class TGComboBox; class TGTextButton; +class TGPictureButton; class TGCheckButton; class TGeoTabManager; @@ -45,9 +48,15 @@ protected: Bool_t fIsEditable; // Flag that the medium can be changed TGTextEntry *fNodeName; // Node name text entry TGNumberEntry *fNodeNumber; // Copy number - TGComboBox *fVolList; // Combo box for all volumes - TGComboBox *fMotherVolList; // Combo box for all volumes - TGComboBox *fMatrixList; // Combo box for all matrices + TGeoVolume *fSelectedVolume; // Selected volume + TGLabel *fLSelVolume; // Selected volume label + TGPictureButton *fBSelVolume; // Button for selecting a volume + TGeoVolume *fSelectedMother; // Selected mother + TGLabel *fLSelMother; // Selected mother label + TGPictureButton *fBSelMother; // Button for selecting a mother volume + TGeoMatrix *fSelectedMatrix; // Selected matrix + TGLabel *fLSelMatrix; // Selected matrix label + TGPictureButton *fBSelMatrix; // Button for selecting a matrix TGTextButton *fEditMother; // Check button for editing mother volume TGTextButton *fEditVolume; // Check button for volume editing TGTextButton *fEditMatrix; // Check button for matrix editing @@ -68,13 +77,12 @@ public: void DoEditMother(); void DoEditVolume(); void DoEditMatrix(); - void DoVolumeSelect(); - void DoMotherVolumeSelect(); - void DoMatrixSelect(); + void DoSelectMother(); + void DoSelectVolume(); + void DoSelectMatrix(); void DoNodeName(); void DoNodeNumber(); void DoApply(); - void DoCancel(); void DoUndo(); ClassDef(TGeoNodeEditor,0) // TGeoNode editor diff --git a/geombuilder/inc/TGeoParaEditor.h b/geombuilder/inc/TGeoParaEditor.h new file mode 100644 index 00000000000..fe3cead84e2 --- /dev/null +++ b/geombuilder/inc/TGeoParaEditor.h @@ -0,0 +1,90 @@ +// @(#):$Name: $:$Id: Exp $ +// Author: M.Gheata +/************************************************************************* + * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +#ifndef ROOT_TGeoParaEditor +#define ROOT_TGeoParaEditor + +////////////////////////////////////////////////////////////////////////// +// // +// TGeoParaEditor // +// // +// Editor for a TGeoPara. // +// // +////////////////////////////////////////////////////////////////////////// + +#ifndef ROOT_TGButton +#include "TGWidget.h" +#endif +#ifndef ROOT_TGedFrame +#include "TGedFrame.h" +#endif + +class TGeoPara; +class TGeoTabManager; +class TGTextEntry; +class TGNumberEntry; +class TGTab; +class TGComboBox; +class TGTextButton; +class TGCheckButton; +class TString; + +class TGeoParaEditor : public TGedFrame { + +protected: + + Double_t fXi; // Initial X + Double_t fYi; // Initial Y + Double_t fZi; // Initial Z + Double_t fAlphai; // Initial alpha + Double_t fThetai; // Initial theta + Double_t fPhii; // Initial phi + TString fNamei; // Initial name + TGeoPara *fShape; // Shape object + Bool_t fIsModified; // Flag that volume was modified + Bool_t fIsShapeEditable; // Flag that the shape can be changed + TGeoTabManager *fTabMgr; // Tab manager + TGTextEntry *fShapeName; // Shape name text entry + TGNumberEntry *fEDx; // Number entry for DX2 + TGNumberEntry *fEDy; // Number entry for DY + TGNumberEntry *fEDz; // Number entry for DZ + TGNumberEntry *fEAlpha; // Number entry for Alpha + TGNumberEntry *fETheta; // Number entry for Theta + TGNumberEntry *fEPhi ; // Number entry for Theta + TGTextButton *fApply; // Apply-Button to accept changes + TGTextButton *fUndo; // Undo-Button + TGCheckButton *fDelayed; // Check button for delayed draw + + virtual void ConnectSignals2Slots(); // Connect the signals to the slots + Bool_t IsDelayed() const; + +public: + TGeoParaEditor(const TGWindow *p, Int_t id, + Int_t width = 140, Int_t height = 30, + UInt_t options = kChildFrame, + Pixel_t back = GetDefaultFrameBackground()); + virtual ~TGeoParaEditor(); + virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event); + + void DoX(); + void DoY(); + void DoZ(); + void DoAlpha(); + void DoTheta(); + void DoPhi(); + void DoModified(); + void DoName(); + void DoApply(); + void DoUndo(); + + ClassDef(TGeoParaEditor,0) // TGeoPara editor +}; + +#endif diff --git a/geombuilder/inc/TGeoPconEditor.h b/geombuilder/inc/TGeoPconEditor.h index 740c32a3bf6..927bdcca31f 100644 --- a/geombuilder/inc/TGeoPconEditor.h +++ b/geombuilder/inc/TGeoPconEditor.h @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoPconEditor.h,v 1.1 2006/06/13 15:27:11 brun Exp $ +// @(#):$Name: $:$Id: Exp $ // Author: M.Gheata /************************************************************************* * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * @@ -34,6 +34,7 @@ class TGNumberEntry; class TGTab; class TGComboBox; class TGTextButton; +class TGCheckButton; class TGCanvas; class TString; @@ -60,9 +61,11 @@ protected: TGNumberEntry *fEDPhi; // Number entry for dphi TGTextButton *fApply; // Apply-Button to accept changes TGTextButton *fUndo; // Undo-Button + TGCheckButton *fDelayed; // Check button for delayed draw virtual void ConnectSignals2Slots(); // Connect the signals to the slots - Bool_t CheckSections(); + Bool_t CheckSections(Bool_t change=kFALSE); + Bool_t IsDelayed() const; void CreateSections(Int_t inew); void UpdateSections(); diff --git a/geombuilder/inc/TGeoSphereEditor.h b/geombuilder/inc/TGeoSphereEditor.h index b1e56f2b28d..60d97948d7a 100644 --- a/geombuilder/inc/TGeoSphereEditor.h +++ b/geombuilder/inc/TGeoSphereEditor.h @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: Exp $ +// @(#):$Name: $:$Id: TGeoSphereEditor.h,v 1.1 2006/06/13 15:27:11 brun Exp $ // Author: M.Gheata /************************************************************************* * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * @@ -34,6 +34,7 @@ class TGTab; class TGComboBox; class TGDoubleVSlider; class TGTextButton; +class TGCheckButton; class TString; class TGeoSphereEditor : public TGedFrame { @@ -44,8 +45,8 @@ protected: Double_t fRmaxi; // Initial outer radius Double_t fTheta1i; // Initial lower theta limit Double_t fTheta2i; // Initial higher theta limit - Double_t fPhi1i; // Initial lower phi limit - Double_t fPhi2i; // Initial higher phi limit + Double_t fPhi1i; // Initial lower phi limit + Double_t fPhi2i; // Initial higher phi limit TString fNamei; // Initial name TGeoSphere *fShape; // Shape object Bool_t fIsModified; // Flag that volume was modified @@ -55,17 +56,18 @@ protected: TGTextEntry *fShapeName; // Shape name text entry TGNumberEntry *fERmin; // Number entry for rmin TGNumberEntry *fERmax; // Number entry for rmax - TGNumberEntry *fETheta1; // Number entry for Theta1 - TGNumberEntry *fETheta2; // Number entry for Theta2 + TGNumberEntry *fETheta1; // Number entry for Theta1 + TGNumberEntry *fETheta2; // Number entry for Theta2 TGNumberEntry *fEPhi1; // Number entry for phi1 TGNumberEntry *fEPhi2; // Number entry for phi2 - TGDoubleVSlider *fSPhi; // Phi slider + TGDoubleVSlider *fSPhi; // Phi slider TGDoubleVSlider *fSTheta; // Theta slider TGTextButton *fApply; // Apply-Button to accept changes - TGTextButton *fCancel; // Cancel-Button TGTextButton *fUndo; // Undo-Button + TGCheckButton *fDelayed; // Check button for delayed draw virtual void ConnectSignals2Slots(); // Connect the signals to the slots + Bool_t IsDelayed() const; public: TGeoSphereEditor(const TGWindow *p, Int_t id, @@ -86,7 +88,6 @@ public: void DoModified(); void DoName(); virtual void DoApply(); - virtual void DoCancel(); virtual void DoUndo(); ClassDef(TGeoSphereEditor,0) // TGeoSphere editor diff --git a/geombuilder/inc/TGeoTabManager.h b/geombuilder/inc/TGeoTabManager.h index 5ea95ba7bc3..fdd058302d0 100644 --- a/geombuilder/inc/TGeoTabManager.h +++ b/geombuilder/inc/TGeoTabManager.h @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: Exp $ +// @(#):$Name: $:$Id: TGeoTabManager.h,v 1.1 2006/06/13 15:27:11 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -34,6 +34,7 @@ class TGTab; class TGComboBox; class TGListTree; class TGListTreeItem; +class TGCanvas; class TGeoShape; class TGeoVolume; @@ -45,41 +46,17 @@ class TGeoTreeDialog; class TGeoTransientPanel; class TGeoTabManager : public TObject { -public: - enum EGeoTabType { -// kTabShape, - kTabVolume -// kTabMatrix, -// kTabMedium, -// kTabMaterial - }; + private: TVirtualPad *fPad; // Pad to which this applies TGTab *fTab; // Parent tab -// TGeoShape *fShape; // Edited shape TGeoVolume *fVolume; // Edited volume -// TGeoMedium *fMedium; // Edited medium -// TGeoMaterial *fMaterial; // Edited material -// TGeoMatrix *fMatrix; // Edited matrix -// TGCompositeFrame *fShapeTab; // Shape tab -// TGCompositeFrame *fShapeCont; // Shape tab container TGeoTransientPanel *fShapePanel; // Panel for editing shapes TGeoTransientPanel *fMediumPanel; // Panel for editing media TGeoTransientPanel *fMaterialPanel; // Panel for editing materials TGeoTransientPanel *fMatrixPanel; // Panel for editing matrices TGCompositeFrame *fVolumeTab; // Volume tab TGCompositeFrame *fVolumeCont; // Volume tab container -// TGCompositeFrame *fMatrixTab; // Matrix tab -// TGCompositeFrame *fMatrixCont; // Matrix tab container -// TGCompositeFrame *fMediumTab; // Medium tab -// TGCompositeFrame *fMediumCont; // Medium tab container -// TGCompositeFrame *fMaterialTab; // Material tab -// TGCompositeFrame *fMaterialCont; // Material tab container - TList *fShapeCombos; // List of combo boxes refering to shapes -// TList *fVolumeCombos; // List of combo boxes refering to volumes - TList *fMatrixCombos; // List of combo boxes refering to matrices - TList *fMediumCombos; // List of combo boxes refering to media - TList *fMaterialCombos; // List of combo boxes refering to materials void CreateTabs(); void GetEditors(TClass *cl, TGCompositeFrame *style); @@ -87,30 +64,15 @@ public: TGeoTabManager(TVirtualPad *pad, TGTab *tab); virtual ~TGeoTabManager(); - static TGeoTabManager *GetMakeTabManager(TVirtualPad *pad, TGTab *tab); + static TGeoTabManager *GetMakeTabManager(TVirtualPad *pad, TGTab *tab); + static void Cleanup(TGCompositeFrame *frame); TVirtualPad *GetPad() const {return fPad;} TGTab *GetTab() const {return fTab;} - Int_t GetTabIndex(EGeoTabType type) const; - void SetEnabled(EGeoTabType type, Bool_t flag=kTRUE); - void SetModel(EGeoTabType type, TObject *model, Int_t event=0); - void SetTab(EGeoTabType type); + Int_t GetTabIndex() const; + void SetVolTabEnabled(Bool_t flag=kTRUE); + void SetModel(TObject *model, Int_t event=0); + void SetTab(); - void AddComboShape(TGComboBox *combo); - void AddShape(const char *name, Int_t id); - void UpdateShape(Int_t id); -// void AddComboVolume(TGComboBox *combo); -// void AddVolume(const char *name, Int_t id); -// void UpdateVolume(Int_t id); - void AddComboMatrix(TGComboBox *combo); - void AddMatrix(const char *name, Int_t id); - void UpdateMatrix(Int_t id); - void AddComboMedium(TGComboBox *combo); - void AddMedium(const char *name, Int_t id); - void UpdateMedium(Int_t id); - void AddComboMaterial(TGComboBox *combo); - void AddMaterial(const char *name, Int_t id); - void UpdateMaterial(Int_t id); - void GetShapeEditor(TGeoShape *shape); void GetVolumeEditor(TGeoVolume *vol); void GetMatrixEditor(TGeoMatrix *matrix); @@ -118,21 +80,9 @@ public: void GetMaterialEditor(TGeoMaterial *material); -// TGCompositeFrame *GetShapeTab() const {return fShapeTab;} -// TGCompositeFrame *GetShapeCont() const {return fShapeCont;} TGCompositeFrame *GetVolumeTab() const {return fVolumeTab;} TGCompositeFrame *GetVolumeCont() const {return fVolumeCont;} -// TGCompositeFrame *GetMatrixTab() const {return fMatrixTab;} -// TGCompositeFrame *GetMatrixCont() const {return fMatrixCont;} -// TGCompositeFrame *GetMediumTab() const {return fMediumTab;} -// TGCompositeFrame *GetMediumCont() const {return fMediumCont;} -// TGCompositeFrame *GetMaterialTab() const {return fMaterialTab;} -// TGCompositeFrame *GetMaterialCont() const {return fMaterialCont;} -// TGeoShape *GetShape() const {return fShape;} TGeoVolume *GetVolume() const {return fVolume;} -// TGeoMedium *GetMedium() const {return fMedium;} -// TGeoMaterial *GetMaterial() const {return fMaterial;} -// TGeoMatrix *GetMatrix() const {return fMatrix;} ClassDef(TGeoTabManager, 0) // Tab manager for geometry editors }; @@ -141,8 +91,10 @@ class TGeoTreeDialog : public TGTransientFrame { protected: static TObject *fgSelectedObj; // Selected object + TGCanvas *fCanvas; // TGCanvas containing the list tree TGLabel *fObjLabel; // Label for selected object TGListTree *fLT; // List tree for selecting + TGCompositeFrame *f1; // Composite frame containing the selection TGTextButton *fClose; // Close button virtual void BuildListTree() = 0; @@ -246,6 +198,7 @@ public: }; class TGeoTransientPanel : public TGMainFrame { + TGCanvas *fCan; // TGCanvas containing a TGTab TGTab *fTab; //tab widget holding the editor TGCompositeFrame *fTabContainer; //main tab container TGCompositeFrame *fStyle; //style tab container frame diff --git a/geombuilder/inc/TGeoTorusEditor.h b/geombuilder/inc/TGeoTorusEditor.h new file mode 100644 index 00000000000..4c535079e62 --- /dev/null +++ b/geombuilder/inc/TGeoTorusEditor.h @@ -0,0 +1,87 @@ +// @(#):$Name: $:$Id: Exp $ +// Author: M.Gheata +/************************************************************************* + * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +#ifndef ROOT_TGeoTorusEditor +#define ROOT_TGeoTorusEditor + +////////////////////////////////////////////////////////////////////////// +// // +// TGeoTorusEditor // +// // +// Editor for a TGeoTorus. // +// // +////////////////////////////////////////////////////////////////////////// + +#ifndef ROOT_TGButton +#include "TGWidget.h" +#endif +#ifndef ROOT_TGedFrame +#include "TGedFrame.h" +#endif + +class TGeoTorus; +class TGeoTabManager; +class TGTextEntry; +class TGNumberEntry; +class TGTab; +class TGComboBox; +class TGTextButton; +class TGCheckButton; +class TString; + +class TGeoTorusEditor : public TGedFrame { + +protected: + + Double_t fRi; // Initial axial radius + Double_t fRmini; // Initial inner radius + Double_t fRmaxi; // Initial outer radius + Double_t fPhi1i; // Initial starting phi1 + Double_t fDphii; // Initial phi extent + TString fNamei; // Initial name + TGeoTorus *fShape; // Shape object + Bool_t fIsModified; // Flag that volume was modified + Bool_t fIsShapeEditable; // Flag that the shape can be changed + TGeoTabManager *fTabMgr; // Tab manager + TGTextEntry *fShapeName; // Shape name text entry + TGNumberEntry *fER; // Number entry for R + TGNumberEntry *fERmin; // Number entry for Rmin + TGNumberEntry *fERmax; // Number entry for Rmax + TGNumberEntry *fEPhi1; // Number entry for phi1 + TGNumberEntry *fEDphi; // Number entry for Dphi + TGTextButton *fApply; // Apply-Button to accept changes + TGTextButton *fUndo; // Undo-Button + TGCheckButton *fDelayed; // Check button for delayed draw + + virtual void ConnectSignals2Slots(); // Connect the signals to the slots + Bool_t IsDelayed() const; + +public: + TGeoTorusEditor(const TGWindow *p, Int_t id, + Int_t width = 140, Int_t height = 30, + UInt_t options = kChildFrame, + Pixel_t back = GetDefaultFrameBackground()); + virtual ~TGeoTorusEditor(); + virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event); + + void DoR(); + void DoRmin(); + void DoRmax(); + void DoPhi1(); + void DoDphi(); + void DoModified(); + void DoName(); + void DoApply(); + void DoUndo(); + + ClassDef(TGeoTorusEditor,0) // TGeoTorus editor +}; + +#endif diff --git a/geombuilder/inc/TGeoTrd1Editor.h b/geombuilder/inc/TGeoTrd1Editor.h index 8d833701f47..035d01644b1 100644 --- a/geombuilder/inc/TGeoTrd1Editor.h +++ b/geombuilder/inc/TGeoTrd1Editor.h @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: Exp $ +// @(#):$Name: $:$Id: TGeoTrd1Editor.h,v 1.1 2006/06/13 15:27:11 brun Exp $ // Author: M.Gheata /************************************************************************* * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * @@ -33,6 +33,7 @@ class TGNumberEntry; class TGTab; class TGComboBox; class TGTextButton; +class TGCheckButton; class TString; class TGeoTrd1Editor : public TGedFrame { @@ -54,10 +55,11 @@ protected: TGNumberEntry *fEDy; // Number entry for DY TGNumberEntry *fEDz; // Number entry for DZ TGTextButton *fApply; // Apply-Button to accept changes - TGTextButton *fCancel; // Cancel-Button TGTextButton *fUndo; // Undo-Button + TGCheckButton *fDelayed; // Check button for delayed draw virtual void ConnectSignals2Slots(); // Connect the signals to the slots + Bool_t IsDelayed() const; public: TGeoTrd1Editor(const TGWindow *p, Int_t id, @@ -74,7 +76,6 @@ public: void DoModified(); void DoName(); void DoApply(); - void DoCancel(); void DoUndo(); ClassDef(TGeoTrd1Editor,0) // TGeoTrd1 editor diff --git a/geombuilder/inc/TGeoTrd2Editor.h b/geombuilder/inc/TGeoTrd2Editor.h index 9ca1036f090..d18000f28f4 100644 --- a/geombuilder/inc/TGeoTrd2Editor.h +++ b/geombuilder/inc/TGeoTrd2Editor.h @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: Exp $ +// @(#):$Name: $:$Id: TGeoTrd2Editor.h,v 1.1 2006/06/13 15:27:11 brun Exp $ // Author: M.Gheata /************************************************************************* * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * @@ -33,6 +33,7 @@ class TGNumberEntry; class TGTab; class TGComboBox; class TGTextButton; +class TGCheckButton; class TString; class TGeoTrd2Editor : public TGedFrame { @@ -56,10 +57,11 @@ protected: TGNumberEntry *fEDy2; // Number entry for DY1 TGNumberEntry *fEDz; // Number entry for DZ TGTextButton *fApply; // Apply-Button to accept changes - TGTextButton *fCancel; // Cancel-Button TGTextButton *fUndo; // Undo-Button + TGCheckButton *fDelayed; // Check button for delayed draw virtual void ConnectSignals2Slots(); // Connect the signals to the slots + Bool_t IsDelayed() const; public: TGeoTrd2Editor(const TGWindow *p, Int_t id, @@ -77,7 +79,6 @@ public: void DoModified(); void DoName(); void DoApply(); - void DoCancel(); void DoUndo(); ClassDef(TGeoTrd2Editor,0) // TGeoTrd2 editor diff --git a/geombuilder/inc/TGeoTubeEditor.h b/geombuilder/inc/TGeoTubeEditor.h index 390ef99a3e6..606a9dc401a 100644 --- a/geombuilder/inc/TGeoTubeEditor.h +++ b/geombuilder/inc/TGeoTubeEditor.h @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: Exp $ +// @(#):$Name: $:$Id: TGeoTubeEditor.h,v 1.1 2006/06/13 15:27:11 brun Exp $ // Author: M.Gheata /************************************************************************* * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * @@ -33,6 +33,7 @@ class TGNumberEntry; class TGTab; class TGComboBox; class TGTextButton; +class TGCheckButton; class TString; class TGeoTubeEditor : public TGedFrame { @@ -52,10 +53,11 @@ protected: TGNumberEntry *fERmax; // Number entry for rmax TGNumberEntry *fEDz; // Number entry for DZ TGTextButton *fApply; // Apply-Button to accept changes - TGTextButton *fCancel; // Cancel-Button TGTextButton *fUndo; // Undo-Button + TGCheckButton *fDelayed; // Check button for delayed draw virtual void ConnectSignals2Slots(); // Connect the signals to the slots + Bool_t IsDelayed() const; public: TGeoTubeEditor(const TGWindow *p, Int_t id, @@ -71,7 +73,6 @@ public: void DoModified(); void DoName(); virtual void DoApply(); - virtual void DoCancel(); virtual void DoUndo(); ClassDef(TGeoTubeEditor,0) // TGeoTube editor @@ -113,7 +114,6 @@ public: void DoPhi2(); virtual void DoApply(); virtual void DoUndo(); - virtual void DoCancel(); ClassDef(TGeoTubeSegEditor,0) // TGeoTubeSeg editor }; diff --git a/geombuilder/src/TGeoBBoxEditor.cxx b/geombuilder/src/TGeoBBoxEditor.cxx index f323a8e5bfe..eaf5834e8a6 100644 --- a/geombuilder/src/TGeoBBoxEditor.cxx +++ b/geombuilder/src/TGeoBBoxEditor.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoBBoxEditor.cxx,v 1.1 2006/06/13 15:27:11 brun Exp $ +// @(#):$Name: $:$Id: TGeoBBoxEditor.cxx,v 1.2 2006/06/19 14:58:48 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -140,20 +140,22 @@ TGeoBBoxEditor::TGeoBBoxEditor(const TGWindow *p, Int_t id, Int_t width, compxyz->Resize(150,30); AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + // Delayed draw + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame); + fDelayed = new TGCheckButton(f1, "Delayed draw"); + f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + // Buttons - TGCompositeFrame *f23 = new TGCompositeFrame(this, 118, 20, kHorizontalFrame | kSunkenFrame | kDoubleBorder); - fApply = new TGTextButton(f23, "&Apply"); - f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + fApply = new TGTextButton(f1, "Apply"); + f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); fApply->Associate(this); - fCancel = new TGTextButton(f23, "&Cancel"); - f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4)); - fCancel->Associate(this); - fUndo = new TGTextButton(f23, " &Undo "); - f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); + fUndo = new TGTextButton(f1, "Undo"); + f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); fUndo->Associate(this); - AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); - fUndo->SetSize(fCancel->GetSize()); - fApply->SetSize(fCancel->GetSize()); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + fUndo->SetSize(fApply->GetSize()); // Initialize layout MapSubwindows(); @@ -173,12 +175,12 @@ TGeoBBoxEditor::~TGeoBBoxEditor() // Destructor TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); + TClass *cl = TGeoBBox::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; @@ -196,7 +198,6 @@ void TGeoBBoxEditor::ConnectSignals2Slots() { // Connect signals to slots. fApply->Connect("Clicked()", "TGeoBBoxEditor", this, "DoApply()"); - fCancel->Connect("Clicked()", "TGeoBBoxEditor", this, "DoCancel()"); fUndo->Connect("Clicked()", "TGeoBBoxEditor", this, "DoUndo()"); fShapeName->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()"); fBoxDx->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoDx()"); @@ -205,9 +206,12 @@ void TGeoBBoxEditor::ConnectSignals2Slots() fBoxDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()"); fBoxDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()"); fBoxDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()"); - fBoxOx->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoModified()"); - fBoxOy->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoModified()"); - fBoxOz->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoModified()"); + fBoxOx->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoOx()"); + fBoxOy->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoOy()"); + fBoxOz->Connect("ValueSet(Long_t)", "TGeoBBoxEditor", this, "DoOz()"); + fBoxOx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()"); + fBoxOy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()"); + fBoxOz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoBBoxEditor", this, "DoModified()"); fInit = kFALSE; } @@ -241,30 +245,31 @@ void TGeoBBoxEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t) fBoxOz->SetNumber(fOrigi[2]); fApply->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); if (fInit) ConnectSignals2Slots(); SetActive(); } +//______________________________________________________________________________ +Bool_t TGeoBBoxEditor::IsDelayed() const +{ +// Check if shape drawing is delayed. + return (fDelayed->GetState() == kButtonDown); +} + //______________________________________________________________________________ void TGeoBBoxEditor::DoName() { //Slot for name. - const char *name = fShapeName->GetText(); - if (!strcmp(name, "-no_name") || !strcmp(name, fShape->GetName())) return; - fShape->SetName(name); - Int_t id = gGeoManager->GetListOfShapes()->IndexOf(fShape); - fTabMgr->UpdateShape(id); - fUndo->SetEnabled(); - fCancel->SetEnabled(kFALSE); - fApply->SetEnabled(kFALSE); + DoModified(); } //______________________________________________________________________________ -Bool_t TGeoBBoxEditor::DoBoxParameters() +void TGeoBBoxEditor::DoApply() { - //Check current box parameters. + //Slot for applying current parameters. + const char *name = fShapeName->GetText(); + if (strcmp(name,fShape->GetName())) fShape->SetName(name); Double_t dx = fBoxDx->GetNumber(); Double_t dy = fBoxDy->GetNumber(); Double_t dz = fBoxDz->GetNumber(); @@ -272,72 +277,47 @@ Bool_t TGeoBBoxEditor::DoBoxParameters() orig[0] = fBoxOx->GetNumber(); orig[1] = fBoxOy->GetNumber(); orig[2] = fBoxOz->GetNumber(); - Bool_t changed = kFALSE; - if (dx != fShape->GetDX() || dy != fShape->GetDY() || dz != fShape->GetDZ()) changed = kTRUE; - if (!changed) { - if (orig[0] != fShape->GetOrigin()[0] || - orig[1] != fShape->GetOrigin()[1] || - orig[2] != fShape->GetOrigin()[2]) changed = kTRUE; - } - if (!changed) return kFALSE; - fUndo->SetEnabled(); fShape->SetBoxDimensions(dx, dy, dz, orig); + fUndo->SetEnabled(); + fApply->SetEnabled(kFALSE); if (fPad) { if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { - fShape->Draw(); - fPad->GetView()->ShowAxis(); + TView *view = fPad->GetView(); + if (!view) { + fShape->Draw(); + fPad->GetView()->ShowAxis(); + } else { + const Double_t *orig = fShape->GetOrigin(); + view->SetRange(orig[0]-fShape->GetDX(), orig[1]-fShape->GetDY(), orig[2]-fShape->GetDZ(), + orig[0]+fShape->GetDX(), orig[1]+fShape->GetDY(), orig[2]+fShape->GetDZ()); + fPad->Modified(); + fPad->Update(); + } } else { fPad->Modified(); fPad->Update(); } } - return kTRUE; } //______________________________________________________________________________ -void TGeoBBoxEditor::DoApply() +void TGeoBBoxEditor::DoModified() { - //Slot for applying current parameters. - DoName(); - if (DoBoxParameters()) { - fUndo->SetEnabled(); - fCancel->SetEnabled(kFALSE); - fApply->SetEnabled(kFALSE); - } + //Slot for modifying current parameters. + fApply->SetEnabled(); } //______________________________________________________________________________ -void TGeoBBoxEditor::DoCancel() +void TGeoBBoxEditor::DoUndo() { - // Slot for canceling current parameters. - if (!fNamei.Length()) fShapeName->SetText("-no_name"); - else fShapeName->SetText(fNamei.Data()); + // Slot for undoing last operation. fBoxDx->SetNumber(fDxi); fBoxDy->SetNumber(fDyi); fBoxDz->SetNumber(fDzi); fBoxOx->SetNumber(fOrigi[0]); fBoxOy->SetNumber(fOrigi[1]); fBoxOz->SetNumber(fOrigi[2]); - fApply->SetEnabled(kFALSE); - fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); -} - -//______________________________________________________________________________ -void TGeoBBoxEditor::DoModified() -{ - //Slot for modifying current parameters. - fApply->SetEnabled(); - if (fUndo->GetState()==kButtonDisabled) fCancel->SetEnabled(); -} - -//______________________________________________________________________________ -void TGeoBBoxEditor::DoUndo() -{ - // Slot for undoing last operation. - DoCancel(); - DoBoxParameters(); - fCancel->SetEnabled(kFALSE); + DoApply(); fUndo->SetEnabled(kFALSE); fApply->SetEnabled(kFALSE); } @@ -346,21 +326,63 @@ void TGeoBBoxEditor::DoUndo() void TGeoBBoxEditor::DoDx() { //Slot for Dx modification. + Double_t dx = fBoxDx->GetNumber(); + if (dx<=0) { + dx=0.1; + fBoxDx->SetNumber(dx); + } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ void TGeoBBoxEditor::DoDy() { //Slot for Dy modification. + Double_t dy = fBoxDy->GetNumber(); + if (dy<=0) { + dy=0.1; + fBoxDy->SetNumber(dy); + } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ void TGeoBBoxEditor::DoDz() { //Slot for Dz modification. + Double_t dz = fBoxDz->GetNumber(); + if (dz<=0) { + dz=0.1; + fBoxDz->SetNumber(dz); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoBBoxEditor::DoOx() +{ + //Slot for Ox modification. + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoBBoxEditor::DoOy() +{ + //Slot for Oy modification. + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoBBoxEditor::DoOz() +{ + //Slot for Oz modification. DoModified(); + if (!IsDelayed()) DoApply(); } diff --git a/geombuilder/src/TGeoConeEditor.cxx b/geombuilder/src/TGeoConeEditor.cxx index 44facf36fac..46dd6c21d36 100644 --- a/geombuilder/src/TGeoConeEditor.cxx +++ b/geombuilder/src/TGeoConeEditor.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoConeEditor.cxx,v 1.1 2006/06/13 15:27:11 brun Exp $ +// @(#):$Name: $:$Id: TGeoConeEditor.cxx,v 1.2 2006/06/19 14:58:48 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -34,7 +34,7 @@ ClassImp(TGeoConeEditor) enum ETGeoConeWid { kCONE_NAME, kCONE_RMIN1, kCONE_RMIN2, kCONE_RMAX1, kCONE_RMAX2, kCONE_Z, - kCONE_APPLY, kCONE_CANCEL, kCONE_UNDO + kCONE_APPLY, kCONE_UNDO }; //______________________________________________________________________________ @@ -131,20 +131,22 @@ TGeoConeEditor::TGeoConeEditor(const TGWindow *p, Int_t id, Int_t width, compxyz->Resize(150,30); AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + // Delayed draw + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame); + fDelayed = new TGCheckButton(f1, "Delayed draw"); + f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + // Buttons - TGCompositeFrame *f23 = new TGCompositeFrame(this, 118, 20, kHorizontalFrame | kSunkenFrame); - fApply = new TGTextButton(f23, "Apply"); - f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + fApply = new TGTextButton(f1, "Apply"); + f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); fApply->Associate(this); - fCancel = new TGTextButton(f23, "Cancel"); - f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4)); - fCancel->Associate(this); - fUndo = new TGTextButton(f23, " Undo "); - f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); + fUndo = new TGTextButton(f1, "Undo"); + f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); fUndo->Associate(this); - AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); - fUndo->SetSize(fCancel->GetSize()); - fApply->SetSize(fCancel->GetSize()); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + fUndo->SetSize(fApply->GetSize()); // Initialize layout MapSubwindows(); @@ -164,12 +166,12 @@ TGeoConeEditor::~TGeoConeEditor() // Destructor TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); + TClass *cl = TGeoCone::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; @@ -187,7 +189,6 @@ void TGeoConeEditor::ConnectSignals2Slots() { // Connect signals to slots. fApply->Connect("Clicked()", "TGeoConeEditor", this, "DoApply()"); - fCancel->Connect("Clicked()", "TGeoConeEditor", this, "DoCancel()"); fUndo->Connect("Clicked()", "TGeoConeEditor", this, "DoUndo()"); fShapeName->Connect("TextChanged(const char *)", "TGeoConeEditor", this, "DoModified()"); fERmin1->Connect("ValueSet(Long_t)", "TGeoConeEditor", this, "DoRmin1()"); @@ -229,12 +230,18 @@ void TGeoConeEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t) fEDz->SetNumber(fDzi); fApply->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); if (fInit) ConnectSignals2Slots(); SetActive(); } +//______________________________________________________________________________ +Bool_t TGeoConeEditor::IsDelayed() const +{ +// Check if shape drawing is delayed. + return (fDelayed->GetState() == kButtonDown); +} + //______________________________________________________________________________ void TGeoConeEditor::DoName() { @@ -246,22 +253,21 @@ void TGeoConeEditor::DoName() void TGeoConeEditor::DoApply() { //Slot for applying current parameters. + fApply->SetEnabled(kFALSE); const char *name = fShapeName->GetText(); - if (strcmp(name,fShape->GetName())) { - fShape->SetName(name); - Int_t id = gGeoManager->GetListOfShapes()->IndexOf(fShape); - fTabMgr->UpdateShape(id); - } + if (strcmp(name,fShape->GetName())) fShape->SetName(name); Double_t rmin1 = fERmin1->GetNumber(); Double_t rmin2 = fERmin2->GetNumber(); Double_t rmax1 = fERmax1->GetNumber(); Double_t rmax2 = fERmax2->GetNumber(); Double_t dz = fEDz->GetNumber(); + if (rmin1<0 || rmin1>rmax1) return; + if (rmin2<0 || rmin2>rmax2) return; + if (dz<=0) return; + if (rmin1==rmax1 && rmin2==rmax2) return; fShape->SetConeDimensions(dz, rmin1, rmax1, rmin2, rmax2); fShape->ComputeBBox(); fUndo->SetEnabled(); - fCancel->SetEnabled(kFALSE); - fApply->SetEnabled(kFALSE); if (fPad) { if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { fShape->Draw(); @@ -273,36 +279,23 @@ void TGeoConeEditor::DoApply() } } -//______________________________________________________________________________ -void TGeoConeEditor::DoCancel() -{ - //Slot for changing current parameters. - fShapeName->SetText(fNamei.Data()); - fERmin1->SetNumber(fRmini1); - fERmin2->SetNumber(fRmini2); - fERmax1->SetNumber(fRmaxi1); - fERmax2->SetNumber(fRmaxi2); - fEDz->SetNumber(fDzi); - fApply->SetEnabled(kFALSE); - fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); -} - //______________________________________________________________________________ void TGeoConeEditor::DoModified() { //Slot for modifing current parameters. fApply->SetEnabled(); - if (fUndo->GetState()==kButtonDisabled) fCancel->SetEnabled(); } //______________________________________________________________________________ void TGeoConeEditor::DoUndo() { // Slot for undoing current operation. - DoCancel(); + fERmin1->SetNumber(fRmini1); + fERmin2->SetNumber(fRmini2); + fERmax1->SetNumber(fRmaxi1); + fERmax2->SetNumber(fRmaxi2); + fEDz->SetNumber(fDzi); DoApply(); - fCancel->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); fApply->SetEnabled(kFALSE); } @@ -313,11 +306,16 @@ void TGeoConeEditor::DoRmin1() // Slot for Rmin1 Double_t rmin1 = fERmin1->GetNumber(); Double_t rmax1 = fERmax1->GetNumber(); - if (rmax1<rmin1+1.e-10) { - rmax1 = rmin1 + 0.1; - fERmax1->SetNumber(rmax1); + if (rmin1<0) { + rmin1 = 0; + fERmin1->SetNumber(rmin1); + } + if (rmin1>rmax1) { + rmin1 = rmax1; + fERmin1->SetNumber(rmin1); } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -326,12 +324,12 @@ void TGeoConeEditor::DoRmax1() // Slot for Rmax1 Double_t rmin1 = fERmin1->GetNumber(); Double_t rmax1 = fERmax1->GetNumber(); - if (rmax1<rmin1+1.e-10) { - rmin1 = rmax1 - 0.1; - if (rmin1 < 0.) rmin1 = 0.; - fERmin1->SetNumber(rmin1); + if (rmax1<rmin1) { + rmax1 = rmin1; + fERmax1->SetNumber(rmax1); } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -340,11 +338,16 @@ void TGeoConeEditor::DoRmin2() // Slot for Rmin2 Double_t rmin2 = fERmin2->GetNumber(); Double_t rmax2 = fERmax2->GetNumber(); - if (rmax2<rmin2+1.e-10) { - rmax2 = rmin2 + 0.1; - fERmax2->SetNumber(rmax2); + if (rmin2<0) { + rmin2 = 0; + fERmin2->SetNumber(rmin2); + } + if (rmin2>rmax2) { + rmin2 = rmax2; + fERmin2->SetNumber(rmin2); } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -353,19 +356,25 @@ void TGeoConeEditor::DoRmax2() // Slot for Rmax2 Double_t rmin2 = fERmin2->GetNumber(); Double_t rmax2 = fERmax2->GetNumber(); - if (rmax2<rmin2+1.e-10) { - rmin2 = rmax2 - 0.1; - if (rmin2 < 0.) rmin2 = 0.; - fERmin2->SetNumber(rmin2); + if (rmax2<rmin2) { + rmax2 = rmin2; + fERmax2->SetNumber(rmax2); } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ void TGeoConeEditor::DoDz() { // Slot for Dz + Double_t dz = fEDz->GetNumber(); + if (dz<=0) { + dz = 0.1; + fEDz->SetNumber(dz); + } DoModified(); + if (!IsDelayed()) DoApply(); } ////////////////////////////////////////////////////////////////////////// @@ -435,12 +444,12 @@ TGeoConeSegEditor::~TGeoConeSegEditor() // Destructor TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); + TClass *cl = TGeoConeSeg::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; @@ -460,10 +469,8 @@ void TGeoConeSegEditor::ConnectSignals2Slots() TGeoConeEditor::ConnectSignals2Slots(); Disconnect(fApply, "Clicked()",(TGeoConeEditor*)this, "DoApply()"); Disconnect(fUndo, "Clicked()",(TGeoConeEditor*)this, "DoUndo()"); - Disconnect(fCancel, "Clicked()",(TGeoConeEditor*)this, "DoCancel()"); fApply->Connect("Clicked()", "TGeoConeSegEditor", this, "DoApply()"); fUndo->Connect("Clicked()", "TGeoConeSegEditor", this, "DoUndo()"); - fCancel->Connect("Clicked()", "TGeoConeSegEditor", this, "DoCancel()"); fEPhi1->Connect("ValueSet(Long_t)", "TGeoConeSegEditor", this, "DoPhi1()"); fEPhi2->Connect("ValueSet(Long_t)", "TGeoConeSegEditor", this, "DoPhi2()"); // fEPhi1->GetNumberEntry()->Connect("TextChanged(const char *)","TGeoConeSegEditor", this, "DoPhi1()"); @@ -501,7 +508,6 @@ void TGeoConeSegEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t) fEDz->SetNumber(fDzi); fApply->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); if (fInit) ConnectSignals2Slots(); SetActive(); @@ -526,6 +532,7 @@ void TGeoConeSegEditor::DoPhi1() fLock = kTRUE; fSPhi->SetPosition(phi1,phi2); } else fLock = kFALSE; + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -547,6 +554,7 @@ void TGeoConeSegEditor::DoPhi2() fLock = kTRUE; fSPhi->SetPosition(phi1,phi2); } else fLock = kFALSE; + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -560,26 +568,26 @@ void TGeoConeSegEditor::DoPhi() fLock = kTRUE; fEPhi2->SetNumber(fSPhi->GetMaxPosition()); } else fLock = kFALSE; + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ void TGeoConeSegEditor::DoApply() { // Slot for applying current parameters. + fApply->SetEnabled(kFALSE); const char *name = fShapeName->GetText(); - if (strcmp(name,fShape->GetName())) { - fShape->SetName(name); - Int_t id = gGeoManager->GetListOfShapes()->IndexOf(fShape); - fTabMgr->UpdateShape(id); - } + if (strcmp(name,fShape->GetName())) fShape->SetName(name); Double_t rmin1 = fERmin1->GetNumber(); Double_t rmax1 = fERmax1->GetNumber(); + if (rmin1<0 || rmax1<rmin1) return; Double_t rmin2 = fERmin2->GetNumber(); Double_t rmax2 = fERmax2->GetNumber(); + if (rmin2<0 || rmax2<rmin2) return; Double_t dz = fEDz->GetNumber(); Double_t phi1 = fEPhi1->GetNumber(); Double_t phi2 = fEPhi2->GetNumber(); - if ((phi2-phi1) > 360.) { + if ((phi2-phi1) > 360.001) { phi1 = 0.; phi2 = 360.; fEPhi1->SetNumber(phi1); @@ -591,8 +599,6 @@ void TGeoConeSegEditor::DoApply() ((TGeoConeSeg*)fShape)->SetConsDimensions(dz, rmin1, rmax1, rmin2,rmax2, phi1, phi2); fShape->ComputeBBox(); fUndo->SetEnabled(); - fCancel->SetEnabled(kFALSE); - fApply->SetEnabled(kFALSE); if (fPad) { if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { fShape->Draw(); @@ -608,22 +614,14 @@ void TGeoConeSegEditor::DoApply() void TGeoConeSegEditor::DoUndo() { // Slot for undoing last operation. - DoCancel(); + fEPhi1->SetNumber(fPmini); + fEPhi2->SetNumber(fPmaxi); + fSPhi->SetPosition(fPmini,fPmaxi); DoApply(); - fCancel->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); fApply->SetEnabled(kFALSE); } -//______________________________________________________________________________ -void TGeoConeSegEditor::DoCancel() -{ - // Slot for cancel last operation. - fEPhi1->SetNumber(fPmini); - fEPhi2->SetNumber(fPmaxi); - fSPhi->SetPosition(fPmini,fPmaxi); - TGeoConeEditor::DoCancel(); -} diff --git a/geombuilder/src/TGeoEltuEditor.cxx b/geombuilder/src/TGeoEltuEditor.cxx new file mode 100644 index 00000000000..eed149ac8dc --- /dev/null +++ b/geombuilder/src/TGeoEltuEditor.cxx @@ -0,0 +1,305 @@ +// @(#):$Name: $:$Id: Exp $ +// Author: M.Gheata + +/************************************************************************* + * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// // +// TGeoEltuEditor // +// // +////////////////////////////////////////////////////////////////////////// + +#include "TGeoEltuEditor.h" +#include "TGeoTabManager.h" +#include "TGeoEltu.h" +#include "TGeoManager.h" +#include "TVirtualGeoPainter.h" +#include "TPad.h" +#include "TView.h" +#include "TGTab.h" +#include "TGComboBox.h" +#include "TGButton.h" +#include "TGTextEntry.h" +#include "TGNumberEntry.h" +#include "TGLabel.h" + +ClassImp(TGeoEltuEditor) + +enum ETGeoEltuWid { + kELTU_NAME, kELTU_A, kELTU_B, kELTU_DZ, + kELTU_APPLY, kELTU_UNDO +}; + +//______________________________________________________________________________ +TGeoEltuEditor::TGeoEltuEditor(const TGWindow *p, Int_t id, Int_t width, + Int_t height, UInt_t options, Pixel_t back) + : TGedFrame(p, id, width, height, options | kVerticalFrame, back) +{ + // Constructor for para editor + fShape = 0; + fAi = fBi = fDzi = 0.0; + fNamei = ""; + fIsModified = kFALSE; + fIsShapeEditable = kTRUE; + + fTabMgr = TGeoTabManager::GetMakeTabManager(gPad, fTab); + + // TextEntry for shape name + MakeTitle("Name"); + fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kELTU_NAME); + fShapeName->Resize(135, fShapeName->GetDefaultHeight()); + fShapeName->SetToolTipText("Enter the elliptical tube name"); + fShapeName->Associate(this); + AddFrame(fShapeName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5)); + + TGTextEntry *nef; + MakeTitle("Dimensions"); + // Number entry for A + TGCompositeFrame *f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "A"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fEA = new TGNumberEntry(f1, 0., 5, kELTU_A); + fEA->SetNumAttr(TGNumberFormat::kNEAPositive); + fEA->Resize(100, fEA->GetDefaultHeight()); + nef = (TGTextEntry*)fEA->GetNumberEntry(); + nef->SetToolTipText("Enter the semi-axis of the ellipse along x"); + fEA->Associate(this); + f1->AddFrame(fEA, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for B + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "B"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fEB = new TGNumberEntry(f1, 0., 5, kELTU_B); + fEB->SetNumAttr(TGNumberFormat::kNEAPositive); + fEB->Resize(100, fEB->GetDefaultHeight()); + nef = (TGTextEntry*)fEB->GetNumberEntry(); + nef->SetToolTipText("Enter the semi-axis of the ellipse along y"); + fEB->Associate(this); + f1->AddFrame(fEB, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for dz + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "Dz"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fEDz = new TGNumberEntry(f1, 0., 5, kELTU_DZ); + fEDz->SetNumAttr(TGNumberFormat::kNEAPositive); + fEDz->Resize(100, fEDz->GetDefaultHeight()); + nef = (TGTextEntry*)fEDz->GetNumberEntry(); + nef->SetToolTipText("Enter the half-lenth in Z"); + fEDz->Associate(this); + f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Delayed draw + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame); + fDelayed = new TGCheckButton(f1, "Delayed draw"); + f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + + // Buttons + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + fApply = new TGTextButton(f1, "Apply"); + f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + fApply->Associate(this); + fUndo = new TGTextButton(f1, "Undo"); + f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); + fUndo->Associate(this); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + fUndo->SetSize(fApply->GetSize()); + + // Initialize layout + MapSubwindows(); + Layout(); + MapWindow(); + + TClass *cl = TGeoEltu::Class(); + TGedElement *ge = new TGedElement; + ge->fGedFrame = this; + ge->fCanvas = 0; + cl->GetEditorList()->Add(ge); +} + +//______________________________________________________________________________ +TGeoEltuEditor::~TGeoEltuEditor() +{ +// Destructor + TGFrameElement *el; + TIter next(GetList()); + while ((el = (TGFrameElement *)next())) { + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); + } + Cleanup(); + + TClass *cl = TGeoEltu::Class(); + TIter next1(cl->GetEditorList()); + TGedElement *ge; + while ((ge=(TGedElement*)next1())) { + if (ge->fGedFrame==this) { + cl->GetEditorList()->Remove(ge); + delete ge; + next1.Reset(); + } + } +} + +//______________________________________________________________________________ +void TGeoEltuEditor::ConnectSignals2Slots() +{ + // Connect signals to slots. + fApply->Connect("Clicked()", "TGeoEltuEditor", this, "DoApply()"); + fUndo->Connect("Clicked()", "TGeoEltuEditor", this, "DoUndo()"); + fShapeName->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()"); + fEA->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoA()"); + fEB->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoB()"); + fEDz->Connect("ValueSet(Long_t)", "TGeoEltuEditor", this, "DoDz()"); + fEA->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()"); + fEB->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()"); + fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoEltuEditor", this, "DoModified()"); + fInit = kFALSE; +} + +//______________________________________________________________________________ +void TGeoEltuEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t) +{ + // Connect to the selected object. + if (obj == 0 || (obj->IsA()!=TGeoEltu::Class())) { + SetActive(kFALSE); + return; + } + fModel = obj; + fPad = pad; + fShape = (TGeoEltu*)fModel; + fAi = fShape->GetA(); + fBi = fShape->GetB(); + fDzi = fShape->GetDz(); + const char *sname = fShape->GetName(); + if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name"); + else { + fShapeName->SetText(sname); + fNamei = sname; + } + fEA->SetNumber(fAi); + fEB->SetNumber(fBi); + fEDz->SetNumber(fDzi); + fApply->SetEnabled(kFALSE); + fUndo->SetEnabled(kFALSE); + + if (fInit) ConnectSignals2Slots(); + SetActive(); +} + +//______________________________________________________________________________ +void TGeoEltuEditor::DoName() +{ +// Slot for name. + DoModified(); +} + +//______________________________________________________________________________ +Bool_t TGeoEltuEditor::IsDelayed() const +{ +// Check if shape drawing is delayed. + return (fDelayed->GetState() == kButtonDown); +} + +//______________________________________________________________________________ +void TGeoEltuEditor::DoApply() +{ +// Slot for applying current settings. + const char *name = fShapeName->GetText(); + if (strcmp(name,fShape->GetName())) fShape->SetName(name); + Double_t a = fEA->GetNumber(); + Double_t b = fEB->GetNumber(); + Double_t z = fEDz->GetNumber(); + Double_t param[3]; + param[0] = a; + param[1] = b; + param[2] = z; + fShape->SetDimensions(param); + fShape->ComputeBBox(); + fUndo->SetEnabled(); + fApply->SetEnabled(kFALSE); + if (fPad) { + if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { + TView *view = fPad->GetView(); + if (!view) { + fShape->Draw(); + fPad->GetView()->ShowAxis(); + } else { + view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(), + fShape->GetDX(), fShape->GetDY(), fShape->GetDZ()); + fPad->Modified(); + fPad->Update(); + } + } else { + fPad->Modified(); + fPad->Update(); + } + } +} + +//______________________________________________________________________________ +void TGeoEltuEditor::DoModified() +{ +// Slot for notifying modifications. + fApply->SetEnabled(); +} + +//______________________________________________________________________________ +void TGeoEltuEditor::DoUndo() +{ +// Slot for undoing last operation. + fEA->SetNumber(fAi); + fEB->SetNumber(fBi); + fEDz->SetNumber(fDzi); + DoApply(); + fUndo->SetEnabled(kFALSE); + fApply->SetEnabled(kFALSE); +} + +//______________________________________________________________________________ +void TGeoEltuEditor::DoA() +{ +// Slot for A. + Double_t a = fEA->GetNumber(); + if (a <= 0) { + a = 0.1; + fEA->SetNumber(a); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoEltuEditor::DoB() +{ +// Slot for B. + Double_t b = fEB->GetNumber(); + if (b <= 0) { + b = 0.1; + fEB->SetNumber(b); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoEltuEditor::DoDz() +{ +// Slot for Z. + Double_t z = fEDz->GetNumber(); + if (z <= 0) { + z = 0.1; + fEDz->SetNumber(z); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + diff --git a/geombuilder/src/TGeoHypeEditor.cxx b/geombuilder/src/TGeoHypeEditor.cxx new file mode 100644 index 00000000000..57477be3aa3 --- /dev/null +++ b/geombuilder/src/TGeoHypeEditor.cxx @@ -0,0 +1,441 @@ +// @(#):$Name: $:$Id: Exp $ +// Author: M.Gheata + +/************************************************************************* + * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// // +// TGeoHypeEditor // +// // +////////////////////////////////////////////////////////////////////////// + +#include "TGeoHypeEditor.h" +#include "TGeoTabManager.h" +#include "TGeoHype.h" +#include "TGeoManager.h" +#include "TVirtualGeoPainter.h" +#include "TPad.h" +#include "TView.h" +#include "TGTab.h" +#include "TGComboBox.h" +#include "TGButton.h" +#include "TGTextEntry.h" +#include "TGNumberEntry.h" +#include "TGLabel.h" + +ClassImp(TGeoHypeEditor) + +enum ETGeoHypeWid { + kHYPE_NAME, kHYPE_RIN, kHYPE_ROUT, kHYPE_DZ, kHYPE_STIN, + kHYPE_STOUT, kHYPE_APPLY, kHYPE_UNDO +}; + +//______________________________________________________________________________ +TGeoHypeEditor::TGeoHypeEditor(const TGWindow *p, Int_t id, Int_t width, + Int_t height, UInt_t options, Pixel_t back) + : TGedFrame(p, id, width, height, options | kVerticalFrame, back) +{ + // Constructor for Hype editor + fShape = 0; + fRini = fRouti = fStIni = fStOuti = 0.0; + fNamei = ""; + fIsModified = kFALSE; + fIsShapeEditable = kTRUE; + + fTabMgr = TGeoTabManager::GetMakeTabManager(gPad, fTab); + + // TextEntry for shape name + MakeTitle("Name"); + fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kHYPE_NAME); + fShapeName->Resize(135, fShapeName->GetDefaultHeight()); + fShapeName->SetToolTipText("Enter the hyperboloid name"); + fShapeName->Associate(this); + AddFrame(fShapeName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5)); + + TGTextEntry *nef; + MakeTitle("Dimensions"); + // Number entry for Rin + TGCompositeFrame *f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "Rin"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fERin = new TGNumberEntry(f1, 0., 5, kHYPE_RIN); + fERin->SetNumAttr(TGNumberFormat::kNEAPositive); + fERin->Resize(100, fERin->GetDefaultHeight()); + nef = (TGTextEntry*)fERin->GetNumberEntry(); + nef->SetToolTipText("Enter the inner radius "); + fERin->Associate(this); + f1->AddFrame(fERin, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for Rout + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "Rout"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fERout = new TGNumberEntry(f1, 0., 5, kHYPE_ROUT); + fERout->SetNumAttr(TGNumberFormat::kNEAPositive); + fERout->Resize(100, fERout->GetDefaultHeight()); + nef = (TGTextEntry*)fERout->GetNumberEntry(); + nef->SetToolTipText("Enter the outer radius"); + fERout->Associate(this); + f1->AddFrame(fERout, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for Dz + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "Dz"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fEDz = new TGNumberEntry(f1, 0., 5, kHYPE_DZ); + fEDz->SetNumAttr(TGNumberFormat::kNEAPositive); + fEDz->Resize(100, fEDz->GetDefaultHeight()); + nef = (TGTextEntry*)fEDz->GetNumberEntry(); + nef->SetToolTipText("Enter the half-lenth in Dz"); + fEDz->Associate(this); + f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for StIn. + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "StIn"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fEStIn = new TGNumberEntry(f1, 0., 5, kHYPE_STIN); + fEStIn->Resize(100, fEStIn->GetDefaultHeight()); + nef = (TGTextEntry*)fEStIn->GetNumberEntry(); + nef->SetToolTipText("Enter the stereo angle for inner surface"); + fEStIn->Associate(this); + f1->AddFrame(fEStIn, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for StOut. + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "StOut"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fEStOut = new TGNumberEntry(f1, 0., 5, kHYPE_STOUT); + fEStOut->SetNumAttr(TGNumberFormat::kNEAPositive); + fEStOut->Resize(100, fEStOut->GetDefaultHeight()); + nef = (TGTextEntry*)fEStOut->GetNumberEntry(); + nef->SetToolTipText("Enter the stereo angle for outer surface"); + fEStOut->Associate(this); + f1->AddFrame(fEStOut, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Delayed draw + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame); + fDelayed = new TGCheckButton(f1, "Delayed draw"); + f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + + // Buttons + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + fApply = new TGTextButton(f1, "Apply"); + f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + fApply->Associate(this); + fUndo = new TGTextButton(f1, "Undo"); + f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); + fUndo->Associate(this); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + fUndo->SetSize(fApply->GetSize()); + + // Initialize layout + MapSubwindows(); + Layout(); + MapWindow(); + + TClass *cl = TGeoHype::Class(); + TGedElement *ge = new TGedElement; + ge->fGedFrame = this; + ge->fCanvas = 0; + cl->GetEditorList()->Add(ge); +} + +//______________________________________________________________________________ +TGeoHypeEditor::~TGeoHypeEditor() +{ +// Destructor + TGFrameElement *el; + TIter next(GetList()); + while ((el = (TGFrameElement *)next())) { + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); + } + Cleanup(); + + TClass *cl = TGeoHype::Class(); + TIter next1(cl->GetEditorList()); + TGedElement *ge; + while ((ge=(TGedElement*)next1())) { + if (ge->fGedFrame==this) { + cl->GetEditorList()->Remove(ge); + delete ge; + next1.Reset(); + } + } +} + +//______________________________________________________________________________ +void TGeoHypeEditor::ConnectSignals2Slots() +{ + // Connect signals to slots. + fApply->Connect("Clicked()", "TGeoHypeEditor", this, "DoApply()"); + fUndo->Connect("Clicked()", "TGeoHypeEditor", this, "DoUndo()"); + fShapeName->Connect("TextChanged(const char *)", "TGeoHypeEditor", this, "DoModified()"); + fERin->Connect("ValueSet(Long_t)", "TGeoHypeEditor", this, "DoRin()"); + fERout->Connect("ValueSet(Long_t)", "TGeoHypeEditor", this, "DoRout()"); + fEDz->Connect("ValueSet(Long_t)", "TGeoHypeEditor", this, "DoDz()"); + fEStIn->Connect("ValueSet(Long_t)", "TGeoHypeEditor", this, "DoStIn()"); + fEStOut->Connect("ValueSet(Long_t)", "TGeoHypeEditor", this, "DoStOut()"); + fERin->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoHypeEditor", this, "DoModified()"); + fERout->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoHypeEditor", this, "DoModified()"); + fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoHypeEditor", this, "DoModified()"); + fEStIn->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoHypeEditor", this, "DoModified()"); + fEStOut->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoHypeEditor", this, "DoModified()"); + fInit = kFALSE; +} + + +//______________________________________________________________________________ +void TGeoHypeEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t) +{ + // Connect to the selected object. + if (obj == 0 || (obj->IsA()!=TGeoHype::Class())) { + SetActive(kFALSE); + return; + } + fModel = obj; + fPad = pad; + fShape = (TGeoHype*)fModel; + fRini = fShape->GetRmin(); + fRouti = fShape->GetRmax(); + fDzi = fShape->GetDz(); + fStIni = fShape->GetStIn(); + fStOuti = fShape->GetStOut(); + const char *sname = fShape->GetName(); + if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name"); + else { + fShapeName->SetText(sname); + fNamei = sname; + } + fERin->SetNumber(fRini); + fERout->SetNumber(fRouti); + fEDz->SetNumber(fDzi); + fEStIn->SetNumber(fStIni); + fEStOut->SetNumber(fStOuti); + fApply->SetEnabled(kFALSE); + fUndo->SetEnabled(kFALSE); + + if (fInit) ConnectSignals2Slots(); + SetActive(); +} + +//______________________________________________________________________________ +Bool_t TGeoHypeEditor::IsDelayed() const +{ +// Check if shape drawing is delayed. + return (fDelayed->GetState() == kButtonDown); +} + +//______________________________________________________________________________ +void TGeoHypeEditor::DoName() +{ +// Slot for name. + DoModified(); +} + +//______________________________________________________________________________ +void TGeoHypeEditor::DoApply() +{ +// Slot for applying current settings. + const char *name = fShapeName->GetText(); + if (strcmp(name,fShape->GetName())) fShape->SetName(name); + Double_t rin = fERin->GetNumber(); + Double_t rout = fERout->GetNumber(); + Double_t dz = fEDz->GetNumber(); + Double_t stin = fEStIn->GetNumber(); + Double_t stout = fEStOut->GetNumber(); + Double_t tin = TMath::Tan(stin*TMath::DegToRad()); + Double_t tout = TMath::Tan(stout*TMath::DegToRad()); + if ((dz<=0) || (rin<0) || (rin>rout) || + (rin*rin+tin*tin*dz*dz > rout*rout+tout*tout*dz*dz)) { + fUndo->SetEnabled(); + fApply->SetEnabled(kFALSE); + return; + } + Double_t param[5]; + param[0] = dz; + param[1] = rin; + param[2] = stin; + param[3] = rout; + param[4] = stout; + fShape->SetDimensions(param); + fShape->ComputeBBox(); + fUndo->SetEnabled(); + fApply->SetEnabled(kFALSE); + if (fPad) { + if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { + TView *view = fPad->GetView(); + if (!view) { + fShape->Draw(); + fPad->GetView()->ShowAxis(); + } else { + view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(), + fShape->GetDX(), fShape->GetDY(), fShape->GetDZ()); + fPad->Modified(); + fPad->Update(); + } + } else { + fPad->Modified(); + fPad->Update(); + } + } +} + +//______________________________________________________________________________ +void TGeoHypeEditor::DoModified() +{ +// Slot for notifying modifications. + fApply->SetEnabled(); +} + +//______________________________________________________________________________ +void TGeoHypeEditor::DoUndo() +{ +// Slot for undoing last operation. + fERin->SetNumber(fRini); + fERout->SetNumber(fRouti); + fEDz->SetNumber(fDzi); + fEStIn->SetNumber(fStIni); + fEStOut->SetNumber(fStOuti); + DoApply(); + fUndo->SetEnabled(kFALSE); + fApply->SetEnabled(kFALSE); +} + +//______________________________________________________________________________ +void TGeoHypeEditor::DoRin() +{ +// Slot for Rin. + Double_t rin = fERin->GetNumber(); + Double_t rout = fERout->GetNumber(); + Double_t dz = fEDz->GetNumber(); + Double_t stin = fEStIn->GetNumber(); + Double_t stout = fEStOut->GetNumber(); + Double_t tin = TMath::Tan(stin*TMath::DegToRad()); + Double_t tout = TMath::Tan(stout*TMath::DegToRad()); + if (rin<0) { + rin = 0; + fERin->SetNumber(rin); + } + Double_t rinmax = TMath::Sqrt((rout*rout+tout*tout*dz*dz)/(tin*tin*dz*dz)); + rinmax = TMath::Min(rinmax, rout); + if (rin > rinmax) { + rin = rinmax-1.e-6; + fERin->SetNumber(rin); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoHypeEditor::DoRout() +{ +// Slot for Rout. + Double_t rin = fERin->GetNumber(); + Double_t rout = fERout->GetNumber(); + Double_t dz = fEDz->GetNumber(); + Double_t stin = fEStIn->GetNumber(); + Double_t stout = fEStOut->GetNumber(); + Double_t tin = TMath::Tan(stin*TMath::DegToRad()); + Double_t tout = TMath::Tan(stout*TMath::DegToRad()); + Double_t routmin = TMath::Sqrt((rin*rin+tin*tin*dz*dz)/(tout*tout*dz*dz)); + routmin = TMath::Max(routmin,rin); + if (rout < routmin) { + rout = routmin+1.e-6; + fERout->SetNumber(rout); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoHypeEditor::DoDz() +{ +// Slot for Z. + Double_t rin = fERin->GetNumber(); + Double_t rout = fERout->GetNumber(); + Double_t dz = fEDz->GetNumber(); + Double_t stin = fEStIn->GetNumber(); + Double_t stout = fEStOut->GetNumber(); + if (TMath::Abs(stin-stout)<1.e-6) { + stin = stout+1.; + fEStIn->SetNumber(stin); + } + Double_t tin = TMath::Tan(stin*TMath::DegToRad()); + Double_t tout = TMath::Tan(stout*TMath::DegToRad()); + if (dz<=0) { + dz = 0.1; + fEDz->SetNumber(dz); + } + Double_t dzmax = TMath::Sqrt((rout*rout-rin*rin)/(tin*tin-tout*tout)); + if (dz>dzmax) { + dz = dzmax; + fEDz->SetNumber(dz); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoHypeEditor::DoStIn() +{ +// Slot for StIn. + Double_t rin = fERin->GetNumber(); + Double_t rout = fERout->GetNumber(); + Double_t dz = fEDz->GetNumber(); + Double_t stin = fEStIn->GetNumber(); + Double_t stout = fEStOut->GetNumber(); + if (stin >= 90) { + stin = 89.; + fEStIn->SetNumber(stin); + } + Double_t tin = TMath::Tan(stin*TMath::DegToRad()); + Double_t tout = TMath::Tan(stout*TMath::DegToRad()); + Double_t tinmax = TMath::Sqrt(tout*tout+(rout*rout-rin*rin)/(dz*dz)); + if (tin>tinmax) { + tin = tinmax-1.e-6; + stin = TMath::RadToDeg()*TMath::ATan(tin); + fEStIn->SetNumber(stin); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoHypeEditor::DoStOut() +{ +// Slot for StOut. + Double_t rin = fERin->GetNumber(); + Double_t rout = fERout->GetNumber(); + Double_t dz = fEDz->GetNumber(); + Double_t stin = fEStIn->GetNumber(); + Double_t stout = fEStOut->GetNumber(); + if (stout > 90) { + stout = 89; + fEStOut->SetNumber(stout); + } + Double_t tin = TMath::Tan(stin*TMath::DegToRad()); + Double_t tout = TMath::Tan(stout*TMath::DegToRad()); + Double_t tinmin = TMath::Sqrt((rout*rout-rin*rin)/(dz*dz)); + if (tin < tinmin) { + tin = tinmin; + stin = TMath::RadToDeg()*TMath::ATan(tin); + fEStIn->SetNumber(stin); + } + Double_t toutmin = TMath::Sqrt(tin*tin -tinmin*tinmin); + if (tout < toutmin) { + tout = toutmin+1.e-6; + stout = TMath::RadToDeg()*TMath::ATan(tout); + fEStOut->SetNumber(stout); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} diff --git a/geombuilder/src/TGeoManagerEditor.cxx b/geombuilder/src/TGeoManagerEditor.cxx index 6d17349a789..987cae55e5a 100644 --- a/geombuilder/src/TGeoManagerEditor.cxx +++ b/geombuilder/src/TGeoManagerEditor.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoManagerEditor.cxx,v 1.1 2006/06/13 15:27:11 brun Exp $ +// @(#):$Name: $:$Id: TGeoManagerEditor.cxx,v 1.2 2006/06/19 14:58:48 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -65,7 +65,11 @@ #include "TGeoVolume.h" #include "TGeoManager.h" #include "TGeoBBox.h" +#include "TGeoPara.h" #include "TGeoTube.h" +#include "TGeoEltu.h" +#include "TGeoHype.h" +#include "TGeoTorus.h" #include "TGeoTrd1.h" #include "TGeoTrd2.h" #include "TGeoCone.h" @@ -121,6 +125,7 @@ TGeoManagerEditor::TGeoManagerEditor(const TGWindow *p, Int_t id, Int_t width, TGShutterItem *si = new TGShutterItem(fCategories, new TGHotString("General"),kCAT_GENERAL); container = (TGCompositeFrame*)si->GetContainer(); container->SetBackgroundColor(GetDefaultFrameBackground()); + fCategories->AddItem(si); // TextEntry for manager name f1 = new TGCompositeFrame(container, 155, 10, kHorizontalFrame | kFixedWidth); f1->AddFrame(label = new TGLabel(f1, "Name/Title"), new TGLayoutHints(kLHintsLeft, 1, 1, 0, 0)); @@ -180,7 +185,6 @@ TGeoManagerEditor::TGeoManagerEditor(const TGWindow *p, Int_t id, Int_t width, f7->AddFrame(f1, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0)); container->AddFrame(f7, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0)); - fCategories->AddItem(si); si = new TGShutterItem(fCategories, new TGHotString("Shapes"),kCAT_SHAPES); container = (TGCompositeFrame*)si->GetContainer(); @@ -607,15 +611,26 @@ TGeoManagerEditor::TGeoManagerEditor(const TGWindow *p, Int_t id, Int_t width, TGeoManagerEditor::~TGeoManagerEditor() { // Destructor. - TGFrameElement *el; - TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); - } - Cleanup(); - if (fTabMgr) delete fTabMgr; - TClass *cl = TGeoVolume::Class(); + TGCompositeFrame *cont; + cont = (TGCompositeFrame*)fCategories->GetItem("General")->GetContainer(); + TGeoTabManager::Cleanup(cont); + cont = (TGCompositeFrame*)fCategories->GetItem("Shapes")->GetContainer(); + TGeoTabManager::Cleanup(cont); + cont = (TGCompositeFrame*)fCategories->GetItem("Volumes")->GetContainer(); + TGeoTabManager::Cleanup(cont); + cont = (TGCompositeFrame*)fCategories->GetItem("Materials")->GetContainer(); + TGeoTabManager::Cleanup(cont); + cont = (TGCompositeFrame*)fCategories->GetItem("Media")->GetContainer(); + TGeoTabManager::Cleanup(cont); + cont = (TGCompositeFrame*)fCategories->GetItem("Matrices")->GetContainer(); + TGeoTabManager::Cleanup(cont); + Cleanup(); + + if (fTabMgr) { + fTabMgr->GetVolumeTab()->Cleanup(); + delete fTabMgr; + } + TClass *cl = TGeoManager::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; while ((ge=(TGedElement*)next1())) { @@ -766,7 +781,6 @@ void TGeoManagerEditor::DoCreateBox() // Create a box. Int_t id = gGeoManager->GetListOfShapes()->GetEntries(); fSelectedShape = new TGeoBBox(Form("box_%i",id), 1., 1., 1.); - fTabMgr->AddShape(fSelectedShape->GetName(), id); ShowSelectShape(); // Check if volumes category can be activated if (fGeometry->GetListOfMedia()->GetSize()) @@ -778,6 +792,12 @@ void TGeoManagerEditor::DoCreateBox() void TGeoManagerEditor::DoCreatePara() { // Create a parallelipiped. + Int_t id = gGeoManager->GetListOfShapes()->GetEntries(); + fSelectedShape = new TGeoPara(Form("para_%i",id), 1., 1., 1., 30., 20., 45.); + ShowSelectShape(); + if (fGeometry->GetListOfMedia()->GetSize()) + fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE); + DoEditShape(); } //______________________________________________________________________________ @@ -786,7 +806,6 @@ void TGeoManagerEditor::DoCreateTrd1() // Create a Trd1. Int_t id = gGeoManager->GetListOfShapes()->GetEntries(); fSelectedShape = new TGeoTrd1(Form("trd1_%i",id), 0.5, 1., 1., 1.); - fTabMgr->AddShape(fSelectedShape->GetName(), id); ShowSelectShape(); if (fGeometry->GetListOfMedia()->GetSize()) fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE); @@ -799,7 +818,6 @@ void TGeoManagerEditor::DoCreateTrd2() // Create a Trd2. Int_t id = gGeoManager->GetListOfShapes()->GetEntries(); fSelectedShape = new TGeoTrd2(Form("trd2_%i",id), 0.5, 1., 0.5, 1., 1.); - fTabMgr->AddShape(fSelectedShape->GetName(), id); ShowSelectShape(); if (fGeometry->GetListOfMedia()->GetSize()) fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE); @@ -837,7 +855,6 @@ void TGeoManagerEditor::DoCreateTube() // Create a tube. Int_t id = gGeoManager->GetListOfShapes()->GetEntries(); fSelectedShape = new TGeoTube(Form("tube_%i",id), 0.5, 1., 1.); - fTabMgr->AddShape(fSelectedShape->GetName(), id); ShowSelectShape(); if (fGeometry->GetListOfMedia()->GetSize()) fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE); @@ -850,7 +867,6 @@ void TGeoManagerEditor::DoCreateTubs() // Create a tube segment. Int_t id = gGeoManager->GetListOfShapes()->GetEntries(); fSelectedShape = new TGeoTubeSeg(Form("tubs_%i",id), 0.5, 1., 1.,0.,45.); - fTabMgr->AddShape(fSelectedShape->GetName(), id); ShowSelectShape(); if (fGeometry->GetListOfMedia()->GetSize()) fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE); @@ -863,7 +879,6 @@ void TGeoManagerEditor::DoCreateCone() // Create a cone. Int_t id = gGeoManager->GetListOfShapes()->GetEntries(); fSelectedShape = new TGeoCone(Form("cone_%i",id), 0.5, 0.5, 1., 1.5, 2.); - fTabMgr->AddShape(fSelectedShape->GetName(), id); ShowSelectShape(); if (fGeometry->GetListOfMedia()->GetSize()) fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE); @@ -876,7 +891,6 @@ void TGeoManagerEditor::DoCreateCons() // Create a cone segment. Int_t id = gGeoManager->GetListOfShapes()->GetEntries(); fSelectedShape = new TGeoConeSeg(Form("cons_%i",id), 0.5, 0.5, 1., 1.5, 2.,0.,45.); - fTabMgr->AddShape(fSelectedShape->GetName(), id); ShowSelectShape(); if (fGeometry->GetListOfMedia()->GetSize()) fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE); @@ -889,7 +903,6 @@ void TGeoManagerEditor::DoCreateSphe() // Create a sphere. Int_t id = gGeoManager->GetListOfShapes()->GetEntries(); fSelectedShape = new TGeoSphere(Form("sphere_%i",id), 0.5, 1., 0., 180., 0.,360.); - fTabMgr->AddShape(fSelectedShape->GetName(), id); ShowSelectShape(); if (fGeometry->GetListOfMedia()->GetSize()) fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE); @@ -906,12 +919,25 @@ void TGeoManagerEditor::DoCreateCtub() void TGeoManagerEditor::DoCreateEltu() { // Create an eliptical tube. + Int_t id = gGeoManager->GetListOfShapes()->GetEntries(); + fSelectedShape = new TGeoEltu(Form("para_%i",id), 1., 2., 1.5 ); + ShowSelectShape(); + if (fGeometry->GetListOfMedia()->GetSize()) + fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE); + DoEditShape(); } //______________________________________________________________________________ void TGeoManagerEditor::DoCreateTorus() { -// Create a torus phi segment with rmin and rmax. +// Create a torus shape. + Int_t id = gGeoManager->GetListOfShapes()->GetEntries(); + fSelectedShape = new TGeoTorus(Form("torus_%i",id), 10., 1., 1.5, 0, 360.); + ShowSelectShape(); + if (fGeometry->GetListOfMedia()->GetSize()) + fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE); + DoEditShape(); + } //______________________________________________________________________________ @@ -922,7 +948,6 @@ void TGeoManagerEditor::DoCreatePcon() fSelectedShape = new TGeoPcon(Form("pcon_%i",id), 0., 360., 2); ((TGeoPcon*)fSelectedShape)->DefineSection(0, -1, 0.5, 1.); ((TGeoPcon*)fSelectedShape)->DefineSection(1, 1, 0.2, 0.5); - fTabMgr->AddShape(fSelectedShape->GetName(), id); ShowSelectShape(); if (fGeometry->GetListOfMedia()->GetSize()) fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE); @@ -939,6 +964,12 @@ void TGeoManagerEditor::DoCreatePgon() void TGeoManagerEditor::DoCreateHype() { // Create a hyperboloid. + Int_t id = gGeoManager->GetListOfShapes()->GetEntries(); + fSelectedShape = new TGeoHype(Form("hype_%i",id), 1., 15., 2., 30., 5.); + ShowSelectShape(); + if (fGeometry->GetListOfMedia()->GetSize()) + fCategories->GetItem("Volumes")->GetButton()->SetEnabled(kTRUE); + DoEditShape(); } //______________________________________________________________________________ @@ -1078,16 +1109,12 @@ void TGeoManagerEditor::DoEditVolume() { // Slot for editing selected volume. if (!fSelectedVolume) { - fTabMgr->SetEnabled(TGeoTabManager::kTabVolume, kFALSE); + fTabMgr->SetVolTabEnabled(kFALSE); return; } - fTabMgr->SetEnabled(TGeoTabManager::kTabVolume); + fTabMgr->SetVolTabEnabled(); fTabMgr->GetVolumeEditor(fSelectedVolume); - fTabMgr->SetTab(TGeoTabManager::kTabVolume); -// fGeometry->SetTopVisible(); -// fGeometry->SetVisLevel(1); -// volume->SetVisContainers(); -// volume->SetVisibility(kTRUE); + fTabMgr->SetTab(); fSelectedVolume->Draw(); } diff --git a/geombuilder/src/TGeoMaterialEditor.cxx b/geombuilder/src/TGeoMaterialEditor.cxx index c5337fca98f..c2aff55e6e2 100644 --- a/geombuilder/src/TGeoMaterialEditor.cxx +++ b/geombuilder/src/TGeoMaterialEditor.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoMaterialEditor.cxx,v 1.1 2006/06/13 15:27:11 brun Exp $ +// @(#):$Name: $:$Id: TGeoMaterialEditor.cxx,v 1.2 2006/06/19 14:58:48 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -150,12 +150,12 @@ TGeoMaterialEditor::~TGeoMaterialEditor() // Destructor TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); + TClass *cl = TGeoMaterial::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; @@ -261,8 +261,6 @@ void TGeoMaterialEditor::DoApply() // Slot for applying modifications. const char *name = fMaterialName->GetText(); fMaterial->SetName(name); - Int_t id = gGeoManager->GetListOfMaterials()->IndexOf(fMaterial); - fTabMgr->UpdateMaterial(id); fMatA->SetNumber(fAi); fMatZ->SetNumber(fZi); fMatDensity->SetNumber(fDensityi); diff --git a/geombuilder/src/TGeoMatrixEditor.cxx b/geombuilder/src/TGeoMatrixEditor.cxx index 95813ad412e..c66b907c3e7 100644 --- a/geombuilder/src/TGeoMatrixEditor.cxx +++ b/geombuilder/src/TGeoMatrixEditor.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoMatrixEditor.cxx,v 1.1 2006/06/13 15:27:11 brun Exp $ +// @(#):$Name: $:$Id: TGeoMatrixEditor.cxx,v 1.2 2006/06/19 14:58:48 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -16,7 +16,7 @@ ////////////////////////////////////////////////////////////////////////// #include "TGeoMatrixEditor.h" -#include "TGeoNodeEditor.h" +#include "TGeoTabManager.h" #include "TGeoMatrix.h" #include "TPad.h" #include "TGTab.h" @@ -127,12 +127,12 @@ TGeoTranslationEditor::~TGeoTranslationEditor() // Destructor. TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); + TClass *cl = TGeoTranslation::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; @@ -425,12 +425,12 @@ TGeoRotationEditor::~TGeoRotationEditor() // Destructor TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); + TClass *cl = TGeoRotation::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; @@ -786,12 +786,12 @@ TGeoCombiTransEditor::~TGeoCombiTransEditor() // Destructor TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); + TClass *cl = TGeoCombiTrans::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; diff --git a/geombuilder/src/TGeoMediumEditor.cxx b/geombuilder/src/TGeoMediumEditor.cxx index f0966078081..d48c5f2497b 100644 --- a/geombuilder/src/TGeoMediumEditor.cxx +++ b/geombuilder/src/TGeoMediumEditor.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoMediumEditor.cxx,v 1.1 2006/06/13 15:27:11 brun Exp $ +// @(#):$Name: $:$Id: TGeoMediumEditor.cxx,v 1.2 2006/06/19 14:58:48 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -223,12 +223,14 @@ TGeoMediumEditor::~TGeoMediumEditor() // Destructor TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsA() == TGCompositeFrame::Class() || + el->fFrame->IsA() == TGHorizontalFrame::Class() || + el->fFrame->IsA() == TGVerticalFrame::Class()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); + TClass *cl = TGeoMedium::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; diff --git a/geombuilder/src/TGeoNodeEditor.cxx b/geombuilder/src/TGeoNodeEditor.cxx index fab220bd2d6..5753123e227 100644 --- a/geombuilder/src/TGeoNodeEditor.cxx +++ b/geombuilder/src/TGeoNodeEditor.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoNodeEditor.cxx,v 1.1 2006/06/13 15:27:11 brun Exp $ +// @(#):$Name: $:$Id: TGeoNodeEditor.cxx,v 1.2 2006/06/19 14:58:48 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -32,8 +32,7 @@ ClassImp(TGeoNodeEditor) enum ETGeoNodeWid { kNODE_NAME, kNODE_ID, kNODE_VOLSEL, kNODE_MVOLSEL, - kNODE_MATRIX, kNODE_EDIT_VOL, kNODE_EDIT_MATRIX, - kNODE_APPLY, kNODE_CANCEL, kNODE_UNDO + kNODE_MATRIX, kNODE_EDIT_VOL, kNODE_EDIT_MATRIX }; //______________________________________________________________________________ @@ -46,6 +45,7 @@ TGeoNodeEditor::TGeoNodeEditor(const TGWindow *p, Int_t id, Int_t width, fNode = 0; fTabMgr = TGeoTabManager::GetMakeTabManager(gPad, fTab); fIsEditable = kTRUE; + Pixel_t color; // TextEntry for medium name TGTextEntry *nef; @@ -65,59 +65,70 @@ TGeoNodeEditor::TGeoNodeEditor(const TGWindow *p, Int_t id, Int_t width, AddFrame(f1, new TGLayoutHints(kLHintsLeft, 3, 3, 2, 5)); -// Combo box for mother volume selection +// Mother volume selection MakeTitle("Mother volume"); - f1 = new TGCompositeFrame(this, 140, 30, kHorizontalFrame | kRaisedFrame); - fMotherVolList = new TGComboBox(f1, kNODE_MVOLSEL); -// fTabMgr->AddComboVolume(fMotherVolList); - fMotherVolList->Resize(100, fNodeName->GetDefaultHeight()); - fMotherVolList->Associate(this); - f1->AddFrame(fMotherVolList, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 5)); + f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame | kFixedWidth); + fSelectedMother = 0; + fLSelMother = new TGLabel(f1, "Select mother"); + gClient->GetColorByName("#0000ff", color); + fLSelMother->SetTextColor(color); + fLSelMother->ChangeOptions(kSunkenFrame | kDoubleBorder); + f1->AddFrame(fLSelMother, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2)); + fBSelMother = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kNODE_MVOLSEL); + fBSelMother->SetToolTipText("Select one of the existing volumes"); + fBSelMother->Associate(this); + f1->AddFrame(fBSelMother, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2)); fEditMother = new TGTextButton(f1, "Edit"); + f1->AddFrame(fEditMother, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1)); fEditMother->Associate(this); - f1->AddFrame(fEditMother, new TGLayoutHints(kLHintsRight, 2, 2, 2, 5)); - AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 5)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2)); -// Combo box for volume selection +// Volume selection MakeTitle("Volume"); - f1 = new TGCompositeFrame(this, 140, 30, kHorizontalFrame | kRaisedFrame); - fVolList = new TGComboBox(f1, kNODE_VOLSEL); -// fTabMgr->AddComboVolume(fVolList); - fVolList->Resize(100, fNodeName->GetDefaultHeight()); - fVolList->Associate(this); - f1->AddFrame(fVolList, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5)); + f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame | kFixedWidth); + fSelectedVolume = 0; + fLSelVolume = new TGLabel(f1, "Select volume"); + gClient->GetColorByName("#0000ff", color); + fLSelVolume->SetTextColor(color); + fLSelVolume->ChangeOptions(kSunkenFrame | kDoubleBorder); + f1->AddFrame(fLSelVolume, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2)); + fBSelVolume = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kNODE_VOLSEL); + fBSelVolume->SetToolTipText("Select one of the existing volumes"); + fBSelVolume->Associate(this); + f1->AddFrame(fBSelVolume, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2)); fEditVolume = new TGTextButton(f1, "Edit"); + f1->AddFrame(fEditVolume, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1)); fEditVolume->Associate(this); - f1->AddFrame(fEditVolume, new TGLayoutHints(kLHintsRight, 2, 2, 2, 5)); - AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 5)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2)); -// Combo box for matrix selection +// Matrix selection MakeTitle("Matrix"); - f1 = new TGCompositeFrame(this, 140, 30, kHorizontalFrame | kRaisedFrame); - fMatrixList = new TGComboBox(f1, kNODE_MATRIX); - fTabMgr->AddComboMatrix(fMatrixList); - fMatrixList->Resize(100, fNodeName->GetDefaultHeight()); - fMatrixList->Associate(this); - f1->AddFrame(fMatrixList, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5)); + f1 = new TGCompositeFrame(this, 155, 30, kHorizontalFrame | kFixedWidth); + fSelectedMatrix = 0; + fLSelMatrix = new TGLabel(f1, "Select matrix"); + gClient->GetColorByName("#0000ff", color); + fLSelMatrix->SetTextColor(color); + fLSelMatrix->ChangeOptions(kSunkenFrame | kDoubleBorder); + f1->AddFrame(fLSelMatrix, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 1, 1, 2, 2)); + fBSelMatrix = new TGPictureButton(f1, fClient->GetPicture("rootdb_t.xpm"), kNODE_MATRIX); + fBSelMatrix->SetToolTipText("Select one of the existing matrices"); + fBSelMatrix->Associate(this); + f1->AddFrame(fBSelMatrix, new TGLayoutHints(kLHintsLeft, 1, 1, 2, 2)); fEditMatrix = new TGTextButton(f1, "Edit"); + f1->AddFrame(fEditMatrix, new TGLayoutHints(kLHintsRight, 1, 1, 1, 1)); fEditMatrix->Associate(this); - f1->AddFrame(fEditMatrix, new TGLayoutHints(kLHintsRight, 2, 2, 2, 5)); - AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 5)); - + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 0, 2)); + // Buttons - TGCompositeFrame *f23 = new TGCompositeFrame(this, 118, 20, kHorizontalFrame | kSunkenFrame | kDoubleBorder); - fApply = new TGTextButton(f23, "&Apply"); - f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + fApply = new TGTextButton(f1, "Apply"); + f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); fApply->Associate(this); - fCancel = new TGTextButton(f23, "&Cancel"); - f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4)); - fCancel->Associate(this); - fUndo = new TGTextButton(f23, " &Undo "); - f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); + fUndo = new TGTextButton(f1, "Undo"); + f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); fUndo->Associate(this); - AddFrame(f23, new TGLayoutHints(kLHintsLeft, 2, 2, 6, 6)); - fUndo->SetSize(fCancel->GetSize()); - fApply->SetSize(fCancel->GetSize()); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + fUndo->SetSize(fApply->GetSize()); // Initialize layout MapSubwindows(); @@ -137,12 +148,12 @@ TGeoNodeEditor::~TGeoNodeEditor() // Destructor TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); + TClass *cl = TGeoNode::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; @@ -159,8 +170,10 @@ TGeoNodeEditor::~TGeoNodeEditor() void TGeoNodeEditor::ConnectSignals2Slots() { // Connect signals to slots. + fBSelMother->Connect("Clicked()", "TGeoNodeEditor", this, "DoSelectMother()"); + fBSelVolume->Connect("Clicked()", "TGeoNodeEditor", this, "DoSelectVolume()"); + fBSelMatrix->Connect("Clicked()", "TGeoNodeEditor", this, "DoSelectMatrix()"); fApply->Connect("Clicked()", "TGeoNodeEditor", this, "DoApply()"); - fCancel->Connect("Clicked()", "TGeoNodeEditor", this, "DoCancel()"); fUndo->Connect("Clicked()", "TGeoNodeEditor", this, "DoUndo()"); fEditMother->Connect("Clicked()", "TGeoNodeEditor", this, "DoEditMother()"); fEditVolume->Connect("Clicked()", "TGeoNodeEditor", this, "DoEditVolume()"); @@ -186,61 +199,87 @@ void TGeoNodeEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t /*event*/) fNodeNumber->SetNumber(fNode->GetNumber()); - TGeoVolume *vol; - TObjArray *list = gGeoManager->GetListOfVolumes(); - Int_t nobj = list->GetEntriesFast(); - Int_t i, icrt1=0, icrt2=0; - for (i=0; i<nobj; i++) { - vol = (TGeoVolume*)list->At(i); - if (fNode->GetMotherVolume() == vol) icrt1 = i; - if (fNode->GetVolume() == vol) icrt2 = i; - } - fMotherVolList->Select(icrt1); - fVolList->Select(icrt2); - - list = gGeoManager->GetListOfMatrices(); - nobj = list->GetEntriesFast(); - TGeoMatrix *matrix; - icrt1 = 1; - for (i=0; i<nobj; i++) { - matrix = (TGeoMatrix*)list->At(i); - if (fNode->GetMatrix() == matrix) icrt1 = i; - } - fMatrixList->Select(icrt1); + fSelectedMother = fNode->GetMotherVolume(); + if (fSelectedMother) fLSelMother->SetText(fSelectedMother->GetName()); + fSelectedVolume = fNode->GetVolume(); + if (fSelectedVolume) fLSelVolume->SetText(fSelectedVolume->GetName()); + fSelectedMatrix = fNode->GetMatrix(); + if (fSelectedMatrix) fLSelMatrix->SetText(fSelectedMatrix->GetName()); fApply->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); if (fInit) ConnectSignals2Slots(); SetActive(); } +//______________________________________________________________________________ +void TGeoNodeEditor::DoSelectMother() +{ +// Select the mother volume. + TGeoVolume *vol = fSelectedMother; + new TGeoVolumeDialog(fBSelMother, gClient->GetRoot(), 200,300); + fSelectedMother = (TGeoVolume*)TGeoVolumeDialog::GetSelected(); + if (fSelectedMother) fLSelMother->SetText(fSelectedMother->GetName()); + else fSelectedMother = vol; +} + +//______________________________________________________________________________ +void TGeoNodeEditor::DoSelectVolume() +{ +// Select the volume. + TGeoVolume *vol = fSelectedVolume; + new TGeoVolumeDialog(fBSelVolume, gClient->GetRoot(), 200,300); + fSelectedVolume = (TGeoVolume*)TGeoVolumeDialog::GetSelected(); + if (fSelectedVolume) fLSelVolume->SetText(fSelectedVolume->GetName()); + else fSelectedVolume = vol; +} + +//______________________________________________________________________________ +void TGeoNodeEditor::DoSelectMatrix() +{ +// Select the matrix. + TGeoMatrix *matrix = fSelectedMatrix; + new TGeoMatrixDialog(fBSelMatrix, gClient->GetRoot(), 200,300); + fSelectedMatrix = (TGeoMatrix*)TGeoMatrixDialog::GetSelected(); + if (fSelectedMatrix) fLSelMatrix->SetText(fSelectedMatrix->GetName()); + else fSelectedMatrix = matrix; +} + //______________________________________________________________________________ void TGeoNodeEditor::DoEditMother() { // Edit the mother volume. - fTabMgr->SetEnabled(TGeoTabManager::kTabVolume); - fTabMgr->GetVolumeEditor(fNode->GetMotherVolume()); - fTabMgr->SetTab(TGeoTabManager::kTabVolume); + if (!fSelectedMother) { + fTabMgr->SetVolTabEnabled(kFALSE); + return; + } + fTabMgr->SetVolTabEnabled(); + fTabMgr->GetVolumeEditor(fSelectedMother); + fTabMgr->SetTab(); + fSelectedMother->Draw(); } //______________________________________________________________________________ void TGeoNodeEditor::DoEditVolume() { // Edit selected volume. - fTabMgr->SetEnabled(TGeoTabManager::kTabVolume); - fTabMgr->GetVolumeEditor(fNode->GetVolume()); - fTabMgr->SetTab(TGeoTabManager::kTabVolume); + if (!fSelectedVolume) { + fTabMgr->SetVolTabEnabled(kFALSE); + return; + } + fTabMgr->SetVolTabEnabled(); + fTabMgr->GetVolumeEditor(fSelectedVolume); + fTabMgr->SetTab(); + fSelectedVolume->Draw(); } //______________________________________________________________________________ void TGeoNodeEditor::DoEditMatrix() { // Edit selected material. -// fTabMgr->SetEnabled(TGeoTabManager::kTabMatrix); - fTabMgr->GetMatrixEditor(fNode->GetMatrix()); -// fTabMgr->SetTab(TGeoTabManager::kTabMatrix); + if (!fSelectedMatrix) return; + fTabMgr->GetMatrixEditor(fSelectedMatrix); } //______________________________________________________________________________ @@ -259,36 +298,12 @@ void TGeoNodeEditor::DoNodeNumber() } -//______________________________________________________________________________ -void TGeoNodeEditor::DoVolumeSelect() -{ -// Select the volume for the node. -} - -//______________________________________________________________________________ -void TGeoNodeEditor::DoMotherVolumeSelect() -{ -// Select the mother volume for the node. -} - -//______________________________________________________________________________ -void TGeoNodeEditor::DoMatrixSelect() -{ -// Select the matrix for the node. -} - //______________________________________________________________________________ void TGeoNodeEditor::DoApply() { // Slot for applying modifications. } -//______________________________________________________________________________ -void TGeoNodeEditor::DoCancel() -{ -// Slot for cancelling current modifications. -} - //______________________________________________________________________________ void TGeoNodeEditor::DoUndo() { diff --git a/geombuilder/src/TGeoParaEditor.cxx b/geombuilder/src/TGeoParaEditor.cxx new file mode 100644 index 00000000000..51c241b0eb8 --- /dev/null +++ b/geombuilder/src/TGeoParaEditor.cxx @@ -0,0 +1,405 @@ +// @(#):$Name: $:$Id: Exp $ +// Author: M.Gheata + +/************************************************************************* + * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// // +// TGeoParaEditor // +// // +////////////////////////////////////////////////////////////////////////// + +#include "TGeoParaEditor.h" +#include "TGeoTabManager.h" +#include "TGeoPara.h" +#include "TGeoManager.h" +#include "TVirtualGeoPainter.h" +#include "TPad.h" +#include "TView.h" +#include "TGTab.h" +#include "TGComboBox.h" +#include "TGButton.h" +#include "TGTextEntry.h" +#include "TGNumberEntry.h" +#include "TGLabel.h" + +ClassImp(TGeoParaEditor) + +enum ETGeoParaWid { + kPARA_NAME, kPARA_X, kPARA_Y, kPARA_Z, kPARA_ALPHA, + kPARA_THETA, kPARA_PHI, kPARA_APPLY, kPARA_UNDO +}; + +//______________________________________________________________________________ +TGeoParaEditor::TGeoParaEditor(const TGWindow *p, Int_t id, Int_t width, + Int_t height, UInt_t options, Pixel_t back) + : TGedFrame(p, id, width, height, options | kVerticalFrame, back) +{ + // Constructor for para editor + fShape = 0; + fXi = fYi = fZi = fAlphai = fThetai = fPhii = 0.0; + fNamei = ""; + fIsModified = kFALSE; + fIsShapeEditable = kTRUE; + + fTabMgr = TGeoTabManager::GetMakeTabManager(gPad, fTab); + + // TextEntry for shape name + MakeTitle("Name"); + fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kPARA_NAME); + fShapeName->Resize(135, fShapeName->GetDefaultHeight()); + fShapeName->SetToolTipText("Enter the parallelipiped name"); + fShapeName->Associate(this); + AddFrame(fShapeName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5)); + + TGTextEntry *nef; + MakeTitle("Dimensions"); + // Number entry for dx + TGCompositeFrame *f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "DX"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fEDx = new TGNumberEntry(f1, 0., 5, kPARA_X); + fEDx->SetNumAttr(TGNumberFormat::kNEAPositive); + fEDx->Resize(100, fEDx->GetDefaultHeight()); + nef = (TGTextEntry*)fEDx->GetNumberEntry(); + nef->SetToolTipText("Enter the half-lenth in X"); + fEDx->Associate(this); + f1->AddFrame(fEDx, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for dy + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "DY"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fEDy = new TGNumberEntry(f1, 0., 5, kPARA_Y); + fEDy->SetNumAttr(TGNumberFormat::kNEAPositive); + fEDy->Resize(100, fEDy->GetDefaultHeight()); + nef = (TGTextEntry*)fEDy->GetNumberEntry(); + nef->SetToolTipText("Enter the half-lenth in Y"); + fEDy->Associate(this); + f1->AddFrame(fEDy, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for dz + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "Dz"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fEDz = new TGNumberEntry(f1, 0., 5, kPARA_Z); + fEDz->SetNumAttr(TGNumberFormat::kNEAPositive); + fEDz->Resize(100, fEDz->GetDefaultHeight()); + nef = (TGTextEntry*)fEDz->GetNumberEntry(); + nef->SetToolTipText("Enter the half-lenth in Z"); + fEDz->Associate(this); + f1->AddFrame(fEDz, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for Alpha + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "Alpha"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fEAlpha = new TGNumberEntry(f1, 0., 5, kPARA_ALPHA); + fEAlpha->Resize(100, fEAlpha->GetDefaultHeight()); + nef = (TGTextEntry*)fEAlpha->GetNumberEntry(); + nef->SetToolTipText("Enter the angle with respect to Y axis [deg]"); + fEAlpha->Associate(this); + f1->AddFrame(fEAlpha, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for Theta + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "Theta"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fETheta = new TGNumberEntry(f1, 0., 5, kPARA_THETA); + fETheta->SetNumAttr(TGNumberFormat::kNEAPositive); + fETheta->Resize(100, fETheta->GetDefaultHeight()); + nef = (TGTextEntry*)fETheta->GetNumberEntry(); + nef->SetToolTipText("Enter the theta angle of the para axis [deg]"); + fETheta->Associate(this); + f1->AddFrame(fETheta, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for Phi + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "Phi"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fEPhi = new TGNumberEntry(f1, 0., 5, kPARA_PHI); + fEPhi->SetNumAttr(TGNumberFormat::kNEAPositive); + fEPhi->Resize(100, fEPhi->GetDefaultHeight()); + nef = (TGTextEntry*)fEPhi->GetNumberEntry(); + nef->SetToolTipText("Enter the phi angle of the para axis [deg]"); + fEPhi->Associate(this); + f1->AddFrame(fEPhi, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Delayed draw + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame); + fDelayed = new TGCheckButton(f1, "Delayed draw"); + f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + + // Buttons + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + fApply = new TGTextButton(f1, "Apply"); + f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + fApply->Associate(this); + fUndo = new TGTextButton(f1, "Undo"); + f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); + fUndo->Associate(this); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + fUndo->SetSize(fApply->GetSize()); + + // Initialize layout + MapSubwindows(); + Layout(); + MapWindow(); + + TClass *cl = TGeoPara::Class(); + TGedElement *ge = new TGedElement; + ge->fGedFrame = this; + ge->fCanvas = 0; + cl->GetEditorList()->Add(ge); +} + +//______________________________________________________________________________ +TGeoParaEditor::~TGeoParaEditor() +{ +// Destructor + TGFrameElement *el; + TIter next(GetList()); + while ((el = (TGFrameElement *)next())) { + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); + } + Cleanup(); + + TClass *cl = TGeoPara::Class(); + TIter next1(cl->GetEditorList()); + TGedElement *ge; + while ((ge=(TGedElement*)next1())) { + if (ge->fGedFrame==this) { + cl->GetEditorList()->Remove(ge); + delete ge; + next1.Reset(); + } + } +} + +//______________________________________________________________________________ +void TGeoParaEditor::ConnectSignals2Slots() +{ + // Connect signals to slots. + fApply->Connect("Clicked()", "TGeoParaEditor", this, "DoApply()"); + fUndo->Connect("Clicked()", "TGeoParaEditor", this, "DoUndo()"); + fShapeName->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()"); + fEDx->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoX()"); + fEDy->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoY()"); + fEDz->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoZ()"); + fEAlpha->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoAlpha()"); + fETheta->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoTheta()"); + fEPhi->Connect("ValueSet(Long_t)", "TGeoParaEditor", this, "DoPhi()"); + fEDx->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()"); + fEDy->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()"); + fEDz->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()"); + fEAlpha->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()"); + fETheta->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()"); + fEPhi->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoParaEditor", this, "DoModified()"); + fInit = kFALSE; +} + + +//______________________________________________________________________________ +void TGeoParaEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t) +{ + // Connect to the selected object. + if (obj == 0 || (obj->IsA()!=TGeoPara::Class())) { + SetActive(kFALSE); + return; + } + fModel = obj; + fPad = pad; + fShape = (TGeoPara*)fModel; + fXi = fShape->GetX(); + fYi = fShape->GetY(); + fZi = fShape->GetZ(); + fAlphai = fShape->GetAlpha(); + fThetai = fShape->GetTheta(); + fPhii = fShape->GetPhi(); + const char *sname = fShape->GetName(); + if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name"); + else { + fShapeName->SetText(sname); + fNamei = sname; + } + fEDx->SetNumber(fXi); + fEDy->SetNumber(fYi); + fEDz->SetNumber(fZi); + fEAlpha->SetNumber(fAlphai); + fETheta->SetNumber(fThetai); + fEPhi->SetNumber(fPhii); + fApply->SetEnabled(kFALSE); + fUndo->SetEnabled(kFALSE); + + if (fInit) ConnectSignals2Slots(); + SetActive(); +} + +//______________________________________________________________________________ +Bool_t TGeoParaEditor::IsDelayed() const +{ +// Check if shape drawing is delayed. + return (fDelayed->GetState() == kButtonDown); +} + +//______________________________________________________________________________ +void TGeoParaEditor::DoName() +{ +// Slot for name. + DoModified(); +} + +//______________________________________________________________________________ +void TGeoParaEditor::DoApply() +{ +// Slot for applying current settings. + const char *name = fShapeName->GetText(); + if (strcmp(name,fShape->GetName())) fShape->SetName(name); + Double_t dx = fEDx->GetNumber(); + Double_t dy = fEDy->GetNumber(); + Double_t dz = fEDz->GetNumber(); + Double_t alpha = fEAlpha->GetNumber(); + Double_t theta = fETheta->GetNumber(); + Double_t phi = fEPhi->GetNumber(); + Double_t param[6]; + param[0] = dx; + param[1] = dy; + param[2] = dz; + param[3] = alpha; + param[4] = theta; + param[5] = phi; + fShape->SetDimensions(param); + fShape->ComputeBBox(); + fUndo->SetEnabled(); + fApply->SetEnabled(kFALSE); + if (fPad) { + if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { + TView *view = fPad->GetView(); + if (!view) { + fShape->Draw(); + fPad->GetView()->ShowAxis(); + } else { + view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(), + fShape->GetDX(), fShape->GetDY(), fShape->GetDZ()); + fPad->Modified(); + fPad->Update(); + } + } else { + fPad->Modified(); + fPad->Update(); + } + } +} + +//______________________________________________________________________________ +void TGeoParaEditor::DoModified() +{ +// Slot for notifying modifications. + fApply->SetEnabled(); +} + +//______________________________________________________________________________ +void TGeoParaEditor::DoUndo() +{ +// Slot for undoing last operation. + fEDx->SetNumber(fXi); + fEDy->SetNumber(fYi); + fEDz->SetNumber(fZi); + fEAlpha->SetNumber(fAlphai); + fETheta->SetNumber(fThetai); + fEPhi->SetNumber(fPhii); + DoApply(); + fUndo->SetEnabled(kFALSE); + fApply->SetEnabled(kFALSE); +} + +//______________________________________________________________________________ +void TGeoParaEditor::DoX() +{ +// Slot for X. + Double_t dx = fEDx->GetNumber(); + if (dx<=0) { + dx = 0.1; + fEDx->SetNumber(dx); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoParaEditor::DoY() +{ +// Slot for Y. + Double_t dy = fEDy->GetNumber(); + if (dy<=0) { + dy = 0.1; + fEDy->SetNumber(dy); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoParaEditor::DoZ() +{ +// Slot for Z. + Double_t dz = fEDz->GetNumber(); + if (dz<=0) { + dz = 0.1; + fEDz->SetNumber(dz); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoParaEditor::DoAlpha() +{ +// Slot for alpha. + Double_t alpha = fEAlpha->GetNumber(); + if (TMath::Abs(alpha)>=90) { + alpha = 89.9*TMath::Sign(1.,alpha); + fEAlpha->SetNumber(alpha); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoParaEditor::DoTheta() +{ +// Slot for theta. + Double_t theta = fETheta->GetNumber(); + if (theta<0) { + theta = 0; + fETheta->SetNumber(theta); + } + if (theta>180) { + theta = 180; + fETheta->SetNumber(theta); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoParaEditor::DoPhi() +{ +// Slot for phi. + Double_t phi = fEPhi->GetNumber(); + if (phi<0 || phi>360) { + phi = 0; + fEPhi->SetNumber(phi); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + diff --git a/geombuilder/src/TGeoPconEditor.cxx b/geombuilder/src/TGeoPconEditor.cxx index 947ab9dc0ee..329ee4e4ac2 100644 --- a/geombuilder/src/TGeoPconEditor.cxx +++ b/geombuilder/src/TGeoPconEditor.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoPconEditor.cxx,v 1.1 2006/06/19 14:58:48 brun Exp $ +// @(#):$Name: $:$Id: Exp $ // Author: M.Gheata /************************************************************************* @@ -117,17 +117,22 @@ TGeoPconEditor::TGeoPconEditor(const TGWindow *p, Int_t id, Int_t width, AddFrame(fCan, new TGLayoutHints(kLHintsLeft, 0, 0, 4, 4)); + // Delayed draw + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame); + fDelayed = new TGCheckButton(f1, "Delayed draw"); + f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + // Buttons - TGCompositeFrame *f23 = new TGCompositeFrame(this, 118, 20, kHorizontalFrame | kSunkenFrame | kDoubleBorder); - fApply = new TGTextButton(f23, "Apply"); - f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + fApply = new TGTextButton(f1, "Apply"); + f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); fApply->Associate(this); - fUndo = new TGTextButton(f23, " Undo "); - f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); + fUndo = new TGTextButton(f1, "Undo"); + f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); fUndo->Associate(this); - AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); -// fUndo->SetSize(fCancel->GetSize()); -// fApply->SetSize(fCancel->GetSize()); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + fUndo->SetSize(fApply->GetSize()); // Initialize layout MapSubwindows(); @@ -151,12 +156,12 @@ TGeoPconEditor::~TGeoPconEditor() if (fRmaxi) delete [] fRmaxi; TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); + TClass *cl = TGeoPcon::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; @@ -228,7 +233,7 @@ void TGeoPconEditor::CreateSections(Int_t inew) if (inew>fNsections) { for (isect=fNsections; isect<inew; isect++) { sect = new TGeoPconSection(cont, 150, 10, isect); - fSections->AddAt(sect, isect); + fSections->Add(sect); cont->AddFrame(sect, fLHsect); sect->Connect("Changed(Int_t)", "TGeoPconEditor", this, "DoSectionChange(Int_t)"); } @@ -252,16 +257,27 @@ void TGeoPconEditor::CreateSections(Int_t inew) } //______________________________________________________________________________ -Bool_t TGeoPconEditor::CheckSections() +Bool_t TGeoPconEditor::CheckSections(Bool_t change) { // Check validity of sections TGeoPconSection *sect; Double_t zmin = 0; + Double_t rmin = 0, rmax = 1.; for (Int_t isect=0; isect<fNsections; isect++) { sect = (TGeoPconSection*)fSections->At(isect); - if (isect && (sect->GetZ()<zmin)) return kFALSE; + if (isect && (sect->GetZ()<zmin)) { + if (!change) return kFALSE; + sect->SetZ(zmin+1.); + } zmin = sect->GetZ(); - if (sect->GetRmin()<0 || sect->GetRmin()>sect->GetRmax()) return kFALSE; + if (sect->GetRmin()<0 || sect->GetRmin()>sect->GetRmax() || + (change && sect->GetRmin()*sect->GetRmax()==0)) { + if (!change) return kFALSE; + sect->SetRmin(rmin); + sect->SetRmax(rmax); + } + rmin = sect->GetRmin(); + rmax = sect->GetRmax(); } return kTRUE; } @@ -288,11 +304,18 @@ void TGeoPconEditor::UpdateSections() } } +//______________________________________________________________________________ +Bool_t TGeoPconEditor::IsDelayed() const +{ +// Check if shape drawing is delayed. + return (fDelayed->GetState() == kButtonDown); +} + //______________________________________________________________________________ void TGeoPconEditor::DoName() { - // Perform name change - DoModified(); + // Perform name change + DoModified(); } //______________________________________________________________________________ @@ -300,11 +323,7 @@ void TGeoPconEditor::DoApply() { // Slot for applying modifications. const char *name = fShapeName->GetText(); - if (strcmp(name,fShape->GetName())) { - fShape->SetName(name); - Int_t id = gGeoManager->GetListOfShapes()->IndexOf(fShape); - fTabMgr->UpdateShape(id); - } + if (strcmp(name,fShape->GetName())) fShape->SetName(name); fApply->SetEnabled(kFALSE); fUndo->SetEnabled(); if (!CheckSections()) return; @@ -330,13 +349,22 @@ void TGeoPconEditor::DoApply() fShape->SetDimensions(array); if (fPad) { if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { - fShape->Draw(); - fPad->GetView()->ShowAxis(); + TView *view = fPad->GetView(); + if (!view) { + fShape->Draw(); + fPad->GetView()->ShowAxis(); + } else { + const Double_t *orig = fShape->GetOrigin(); + view->SetRange(orig[0]-fShape->GetDX(), orig[1]-fShape->GetDY(), orig[2]-fShape->GetDZ(), + orig[0]+fShape->GetDX(), orig[1]+fShape->GetDY(), orig[2]+fShape->GetDZ()); + fPad->Modified(); + fPad->Update(); + } } else { fPad->Modified(); fPad->Update(); } - } + } return; } // No need to call SetDimensions @@ -351,8 +379,17 @@ void TGeoPconEditor::DoApply() fShape->ComputeBBox(); if (fPad) { if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { - fShape->Draw(); - fPad->GetView()->ShowAxis(); + TView *view = fPad->GetView(); + if (!view) { + fShape->Draw(); + fPad->GetView()->ShowAxis(); + } else { + const Double_t *orig = fShape->GetOrigin(); + view->SetRange(orig[0]-fShape->GetDX(), orig[1]-fShape->GetDY(), orig[2]-fShape->GetDZ(), + orig[0]+fShape->GetDX(), orig[1]+fShape->GetDY(), orig[2]+fShape->GetDZ()); + fPad->Modified(); + fPad->Update(); + } } else { fPad->Modified(); fPad->Update(); @@ -378,6 +415,7 @@ void TGeoPconEditor::DoSectionChange(Int_t isect) sect->SetZ(z); } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -390,7 +428,9 @@ void TGeoPconEditor::DoNz() fENz->SetNumber(nz); } CreateSections(nz); - if (CheckSections()) DoModified(); + CheckSections(kTRUE); + DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -402,6 +442,7 @@ void TGeoPconEditor::DoPhi() if (TMath::Abs(phi1)>360) fEPhi1->SetNumber(0); if (dphi>360) fEDPhi->SetNumber(360); DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ diff --git a/geombuilder/src/TGeoSphereEditor.cxx b/geombuilder/src/TGeoSphereEditor.cxx index 5fcf61cb2dd..4b842d6ca0f 100644 --- a/geombuilder/src/TGeoSphereEditor.cxx +++ b/geombuilder/src/TGeoSphereEditor.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoSphereEditor.cxx,v 1.2 2006/06/19 14:58:48 brun Exp $ +// @(#):$Name: $:$Id: TGeoSphereEditor.cxx,v 1.3 2006/06/20 06:33:20 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -35,7 +35,7 @@ ClassImp(TGeoSphereEditor) enum ETGeoSphereWid { kSPHERE_NAME, kSPHERE_RMIN, kSPHERE_RMAX, kSPHERE_THETA1, kSPHERE_THETA2, kSPHERE_PHI1, kSPHERE_PHI2, kSPHERE_PHI, kSPHERE_THETA, - kSPHERE_APPLY, kSPHERE_CANCEL, kSPHERE_UNDO + kSPHERE_APPLY, kSPHERE_UNDO }; //______________________________________________________________________________ @@ -152,20 +152,22 @@ TGeoSphereEditor::TGeoSphereEditor(const TGWindow *p, Int_t id, Int_t width, AddFrame(f11, new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0)); + // Delayed draw + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame); + fDelayed = new TGCheckButton(f1, "Delayed draw"); + f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + // Buttons - TGCompositeFrame *f23 = new TGCompositeFrame(this, 118, 20, kHorizontalFrame | kSunkenFrame); - fApply = new TGTextButton(f23, "Apply"); - f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + fApply = new TGTextButton(f1, "Apply"); + f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); fApply->Associate(this); - fCancel = new TGTextButton(f23, "Cancel"); - f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4)); - fCancel->Associate(this); - fUndo = new TGTextButton(f23, " Undo "); - f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); + fUndo = new TGTextButton(f1, "Undo"); + f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); fUndo->Associate(this); - AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); - fUndo->SetSize(fCancel->GetSize()); - fApply->SetSize(fCancel->GetSize()); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + fUndo->SetSize(fApply->GetSize()); // Initialize layout MapSubwindows(); @@ -185,12 +187,12 @@ TGeoSphereEditor::~TGeoSphereEditor() // Destructor. TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); + TClass *cl = TGeoSphere::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; @@ -208,7 +210,6 @@ void TGeoSphereEditor::ConnectSignals2Slots() { // Connect signals to slots. fApply->Connect("Clicked()", "TGeoSphereEditor", this, "DoApply()"); - fCancel->Connect("Clicked()", "TGeoSphereEditor", this, "DoCancel()"); fUndo->Connect("Clicked()", "TGeoSphereEditor", this, "DoUndo()"); fShapeName->Connect("TextChanged(const char *)", "TGeoSphereEditor", this, "DoModified()"); fERmin->Connect("ValueSet(Long_t)", "TGeoSphereEditor", this, "DoRmin()"); @@ -253,12 +254,18 @@ void TGeoSphereEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t) fApply->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); if (fInit) ConnectSignals2Slots(); SetActive(); } +//______________________________________________________________________________ +Bool_t TGeoSphereEditor::IsDelayed() const +{ +// Check if shape drawing is delayed. + return (fDelayed->GetState() == kButtonDown); +} + //______________________________________________________________________________ void TGeoSphereEditor::DoName() { @@ -271,16 +278,12 @@ void TGeoSphereEditor::DoApply() { // Slot for applying modifications. const char *name = fShapeName->GetText(); - if (strcmp(name,fShape->GetName())) { - fShape->SetName(name); -// Int_t id = gGeoManager->GetListOfShapes()->IndexOf(fShape); -// fTabMgr->UpdateShape(id); - } + if (strcmp(name,fShape->GetName())) fShape->SetName(name); Double_t rmin = fERmin->GetNumber(); Double_t rmax = fERmax->GetNumber(); Double_t phi1 = fEPhi1->GetNumber(); Double_t phi2 = fEPhi2->GetNumber(); - if ((phi2-phi1) > 360.) { + if ((phi2-phi1) > 360.001) { phi1 = 0.; phi2 = 360.; fEPhi1->SetNumber(phi1); @@ -294,7 +297,6 @@ void TGeoSphereEditor::DoApply() fShape->SetSphDimensions(rmin, rmax, theta1,theta2,phi1,phi2); fShape->ComputeBBox(); fUndo->SetEnabled(); - fCancel->SetEnabled(kFALSE); fApply->SetEnabled(kFALSE); if (fPad) { if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { @@ -307,39 +309,26 @@ void TGeoSphereEditor::DoApply() } } -//______________________________________________________________________________ -void TGeoSphereEditor::DoCancel() -{ -// Slot for cancelling current modifications. - fShapeName->SetText(fNamei.Data()); - fERmin->SetNumber(fRmini); - fERmax->SetNumber(fRmaxi); - fEPhi1->SetNumber(fPhi1i); - fEPhi2->SetNumber(fPhi2i); - fSPhi->SetPosition(fPhi1i,fPhi2i); - fETheta1->SetNumber(fTheta1i); - fETheta2->SetNumber(fTheta2i); - fSTheta->SetPosition(fTheta1i,fTheta2i); - fApply->SetEnabled(kFALSE); - fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); -} - //______________________________________________________________________________ void TGeoSphereEditor::DoModified() { // Slot for signaling modifications. fApply->SetEnabled(); - if (fUndo->GetState()==kButtonDisabled) fCancel->SetEnabled(); } //______________________________________________________________________________ void TGeoSphereEditor::DoUndo() { // Slot for undoing last operation. - DoCancel(); + fERmin->SetNumber(fRmini); + fERmax->SetNumber(fRmaxi); + fEPhi1->SetNumber(fPhi1i); + fEPhi2->SetNumber(fPhi2i); + fSPhi->SetPosition(fPhi1i,fPhi2i); + fETheta1->SetNumber(fTheta1i); + fETheta2->SetNumber(fTheta2i); + fSTheta->SetPosition(fTheta1i,fTheta2i); DoApply(); - fCancel->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); fApply->SetEnabled(kFALSE); } @@ -350,11 +339,16 @@ void TGeoSphereEditor::DoRmin() // Slot for Rmin. Double_t rmin = fERmin->GetNumber(); Double_t rmax = fERmax->GetNumber(); - if (rmax<rmin+1.e-10) { - rmax = rmin + 0.1; - fERmax->SetNumber(rmax); + if (rmin <= 0.) { + rmin = 0.; + fERmin->SetNumber(rmin); + } + if (rmin >= rmax) { + rmin = rmax - 0.1; + fERmin->SetNumber(rmin); } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -363,12 +357,17 @@ void TGeoSphereEditor::DoRmax() // Slot for Rmax. Double_t rmin = fERmin->GetNumber(); Double_t rmax = fERmax->GetNumber(); - if (rmax<rmin+1.e-10) { - rmin = rmax - 0.1; + if (rmax <= 0.) { + rmax = 0.1; + fERmax->SetNumber(rmax); + } + if (rmax < rmin+1.e-10) { + rmax = rmin + 0.1; if (rmin < 0.) rmin = 0.; - fERmin->SetNumber(rmin); + fERmax->SetNumber(rmax); } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -390,6 +389,7 @@ void TGeoSphereEditor::DoPhi1() fLock = kTRUE; fSPhi->SetPosition(phi1,phi2); } else fLock = kFALSE; + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -411,6 +411,7 @@ void TGeoSphereEditor::DoPhi2() fLock = kTRUE; fSPhi->SetPosition(phi1,phi2); } else fLock = kFALSE; + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -424,6 +425,7 @@ void TGeoSphereEditor::DoPhi() fLock = kTRUE; fEPhi2->SetNumber(fSPhi->GetMaxPosition()); } else fLock = kFALSE; + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -441,6 +443,7 @@ void TGeoSphereEditor::DoTheta1() fLock = kTRUE; fSTheta->SetPosition(theta1,theta2); } else fLock = kFALSE; + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -458,6 +461,7 @@ void TGeoSphereEditor::DoTheta2() fLock = kTRUE; fSTheta->SetPosition(theta1,theta2); } else fLock = kFALSE; + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -471,4 +475,5 @@ void TGeoSphereEditor::DoTheta() fLock = kTRUE; fETheta2->SetNumber(fSTheta->GetMaxPosition()); } else fLock = kFALSE; + if (!IsDelayed()) DoApply(); } diff --git a/geombuilder/src/TGeoTabManager.cxx b/geombuilder/src/TGeoTabManager.cxx index 2a174babc11..9853599758e 100644 --- a/geombuilder/src/TGeoTabManager.cxx +++ b/geombuilder/src/TGeoTabManager.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoTabManager.cxx,v 1.2 2006/06/19 14:58:48 brun Exp $ +// @(#):$Name: $:$Id: TGeoTabManager.cxx,v 1.3 2006/06/20 06:33:20 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -43,25 +43,15 @@ TGeoTabManager::TGeoTabManager(TVirtualPad *pad, TGTab *tab) // Ctor. fPad = pad; fTab = tab; -// fShape = 0; fVolume = 0; -// fMedium = 0; -// fMaterial = 0; -// fMatrix = 0; - fShapeCombos = new TList(); fShapePanel = 0; fMediumPanel = 0; fMaterialPanel = 0; fMatrixPanel = 0; -// fVolumeCombos = new TList(); - fMatrixCombos = new TList(); - fMediumCombos = new TList(); - fMaterialCombos = new TList(); CreateTabs(); fTab->MapSubwindows(); fTab->Layout(); fTab->MapWindow(); -// AppendPad(); TClass *cl = TGeoTabManager::Class(); cl->GetEditorList()->Add(this); } @@ -70,144 +60,28 @@ TGeoTabManager::TGeoTabManager(TVirtualPad *pad, TGTab *tab) TGeoTabManager::~TGeoTabManager() { // Dtor. - printf("deleting TGeoTabManager\n"); if (fShapePanel) delete fShapePanel; if (fMaterialPanel) delete fMaterialPanel; if (fMatrixPanel) delete fMatrixPanel; if (fMediumPanel) delete fMediumPanel; - delete fShapeCombos; -// delete fVolumeCombos; - delete fMatrixCombos; - delete fMediumCombos; - delete fMaterialCombos; } //______________________________________________________________________________ -void TGeoTabManager::AddComboShape(TGComboBox *combo) +void TGeoTabManager::Cleanup(TGCompositeFrame *frame) { -// Add an element to the list. - fShapeCombos->Add(combo); - TIter next(gGeoManager->GetListOfShapes()); - TNamed *obj; - Int_t id = 0; - while ((obj=(TNamed*)next())) combo->AddEntry(obj->GetName(), id++); -} - -//______________________________________________________________________________ -void TGeoTabManager::AddShape(const char *name, Int_t id) -{ -// Add an element to the list. - TIter next(fShapeCombos); - TGComboBox *combo; - while ((combo=(TGComboBox*)next())) combo->AddEntry(name, id); -} - -//______________________________________________________________________________ -void TGeoTabManager::UpdateShape(Int_t id) -{ -// Update an element from the list. - TIter next(fShapeCombos); - TGComboBox *combo; - TNamed *obj = (TNamed*)gGeoManager->GetListOfShapes()->At(id); - while ((combo=(TGComboBox*)next())) { - ((TGTextLBEntry*)combo->GetListBox()->GetEntry(id))->SetText(new TGString(obj->GetName())); - } -} - -//______________________________________________________________________________ -void TGeoTabManager::AddComboMatrix(TGComboBox *combo) -{ -// Add an element to the list. - fMatrixCombos->Add(combo); - TIter next(gGeoManager->GetListOfMatrices()); - TNamed *obj; - Int_t id = 0; - while ((obj=(TNamed*)next())) combo->AddEntry(obj->GetName(), id++); -} - -//______________________________________________________________________________ -void TGeoTabManager::AddMatrix(const char *name, Int_t id) -{ -// Add an element to the list. - TIter next(fMatrixCombos); - TGComboBox *combo; - while ((combo=(TGComboBox*)next())) combo->AddEntry(name, id); -} - -//______________________________________________________________________________ -void TGeoTabManager::UpdateMatrix(Int_t id) -{ -// Update an element from the list. - TIter next(fMatrixCombos); - TGComboBox *combo; - TNamed *obj = (TNamed*)gGeoManager->GetListOfMatrices()->At(id); - while ((combo=(TGComboBox*)next())) { - ((TGTextLBEntry*)combo->GetListBox()->GetEntry(id))->SetText(new TGString(obj->GetName())); - } -} - -//______________________________________________________________________________ -void TGeoTabManager::AddComboMedium(TGComboBox *combo) -{ -// Add an element to the list. - fMediumCombos->Add(combo); - TIter next(gGeoManager->GetListOfMedia()); - TNamed *obj; - Int_t id = 0; - while ((obj=(TNamed*)next())) combo->AddEntry(obj->GetName(), id++); -} - -//______________________________________________________________________________ -void TGeoTabManager::AddMedium(const char *name, Int_t id) -{ -// Add an element to the list. - TIter next(fMediumCombos); - TGComboBox *combo; - while ((combo=(TGComboBox*)next())) combo->AddEntry(name, id); -} - -//______________________________________________________________________________ -void TGeoTabManager::UpdateMedium(Int_t id) -{ -// Update an element from the list. - TIter next(fMediumCombos); - TGComboBox *combo; - TNamed *obj = (TNamed*)gGeoManager->GetListOfMedia()->At(id); - while ((combo=(TGComboBox*)next())) { - ((TGTextLBEntry*)combo->GetListBox()->GetEntry(id))->SetText(new TGString(obj->GetName())); - } -} - -//______________________________________________________________________________ -void TGeoTabManager::AddComboMaterial(TGComboBox *combo) -{ -// Add an element to the list. - fMaterialCombos->Add(combo); - TIter next(gGeoManager->GetListOfMaterials()); - TNamed *obj; - Int_t id = 0; - while ((obj=(TNamed*)next())) combo->AddEntry(obj->GetName(), id++); -} - -//______________________________________________________________________________ -void TGeoTabManager::AddMaterial(const char *name, Int_t id) -{ -// Add an element to the list. - TIter next(fMaterialCombos); - TGComboBox *combo; - while ((combo=(TGComboBox*)next())) combo->AddEntry(name, id); -} - -//______________________________________________________________________________ -void TGeoTabManager::UpdateMaterial(Int_t id) -{ -// Update an element from the list. - TIter next(fMaterialCombos); - TGComboBox *combo; - TNamed *obj = (TNamed*)gGeoManager->GetListOfMaterials()->At(id); - while ((combo=(TGComboBox*)next())) { - ((TGTextLBEntry*)combo->GetListBox()->GetEntry(id))->SetText(new TGString(obj->GetName())); +// Static method to cleanup hirarchically all daughters of a composite frame. +// Does not remove the frame itself. + TGFrameElement *el; + TList *list = frame->GetList(); + Int_t nframes = list->GetSize(); + TClass *cl; + for (Int_t i=0; i<nframes; i++) { + el = (TGFrameElement *)list->At(i); + cl = el->fFrame->IsA(); + if (cl==TGCompositeFrame::Class() || cl==TGHorizontalFrame::Class() || cl==TGVerticalFrame::Class()) + Cleanup((TGCompositeFrame*)el->fFrame); } + frame->Cleanup(); } //______________________________________________________________________________ @@ -217,7 +91,7 @@ void TGeoTabManager::CreateTabs() fVolumeCont = fTab->AddTab("Volume"); fVolumeTab = new TGCompositeFrame(fVolumeCont, 110, 30, kVerticalFrame); fVolumeCont->AddFrame(fVolumeTab, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2)); - fTab->SetEnabled(GetTabIndex(kTabVolume), kFALSE); + fTab->SetEnabled(kFALSE); } //______________________________________________________________________________ @@ -239,7 +113,7 @@ void TGeoTabManager::GetVolumeEditor(TGeoVolume *volume) if (!volume || !fVolumeTab) return; GetEditors(TAttLine::Class(), fVolumeTab); GetEditors(TGeoVolume::Class(), fVolumeTab); - SetModel(kTabVolume, volume, 0); + SetModel(volume, 0); } //______________________________________________________________________________ @@ -338,18 +212,11 @@ TGeoTabManager *TGeoTabManager::GetMakeTabManager(TVirtualPad *pad, TGTab *tab) } //______________________________________________________________________________ -Int_t TGeoTabManager::GetTabIndex(EGeoTabType type) const +Int_t TGeoTabManager::GetTabIndex() const { // Get index for a given tab element. Int_t ntabs = fTab->GetNumberOfTabs(); - TString tabname; - switch (type) { - case kTabVolume: - tabname = "Volume"; - break; - default: - return 0; - } + TString tabname = "Volume"; TGTabElement *tel; for (Int_t i=0; i<ntabs; i++) { @@ -360,25 +227,18 @@ Int_t TGeoTabManager::GetTabIndex(EGeoTabType type) const } //______________________________________________________________________________ -void TGeoTabManager::SetEnabled(EGeoTabType type, Bool_t flag) +void TGeoTabManager::SetVolTabEnabled(Bool_t flag) { // Enable/disable tabs - fTab->SetEnabled(GetTabIndex(type), flag); + fTab->SetEnabled(GetTabIndex(), flag); } //______________________________________________________________________________ -void TGeoTabManager::SetModel(EGeoTabType type, TObject *model, Int_t event) +void TGeoTabManager::SetModel(TObject *model, Int_t event) { // Send the SetModel signal to all editors in the tab TYPE. - TGCompositeFrame *tab; - switch (type) { - case kTabVolume: - tab = fVolumeTab; - fVolume = (TGeoVolume*)model; - break; - default: - tab = (TGCompositeFrame*)((TGFrameElement*)fTab->GetTabContainer(0)->GetList()->At(0))->fFrame; - } + TGCompositeFrame *tab = fVolumeTab; + fVolume = (TGeoVolume*)model; TGFrameElement *el; TIter next(tab->GetList()); while ((el = (TGFrameElement *) next())) { @@ -390,10 +250,10 @@ void TGeoTabManager::SetModel(EGeoTabType type, TObject *model, Int_t event) } //______________________________________________________________________________ -void TGeoTabManager::SetTab(EGeoTabType type) +void TGeoTabManager::SetTab() { // Set a given tab element as active one. - fTab->SetTab(GetTabIndex(type)); + fTab->SetTab(GetTabIndex()); } ClassImp(TGeoTreeDialog) @@ -406,12 +266,12 @@ TGeoTreeDialog::TGeoTreeDialog(TGFrame *caller, const TGWindow *main, UInt_t w, { // Constructor fgSelectedObj = 0; - TGCanvas *tgcv = new TGCanvas(this, 100, 200, kSunkenFrame | kDoubleBorder); - fLT = new TGListTree(tgcv->GetViewPort(), 100, 200); + fCanvas = new TGCanvas(this, 100, 200, kSunkenFrame | kDoubleBorder); + fLT = new TGListTree(fCanvas->GetViewPort(), 100, 200); fLT->Associate(this); - tgcv->SetContainer(fLT); - AddFrame(tgcv, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 2,2,2,2)); - TGCompositeFrame *f1 = new TGCompositeFrame(this, 100, 10, kHorizontalFrame | kLHintsExpandX); + fCanvas->SetContainer(fLT); + AddFrame(fCanvas, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 2,2,2,2)); + f1 = new TGCompositeFrame(this, 100, 10, kHorizontalFrame | kLHintsExpandX); fObjLabel = new TGLabel(f1, "Selected: -none-"); Pixel_t color; gClient->GetColorByName("#0000ff", color); @@ -436,6 +296,11 @@ TGeoTreeDialog::TGeoTreeDialog(TGFrame *caller, const TGWindow *main, UInt_t w, TGeoTreeDialog::~TGeoTreeDialog() { // Destructor + delete fClose; + delete fObjLabel; + delete f1; + delete fLT; + delete fCanvas; } //______________________________________________________________________________ @@ -463,7 +328,6 @@ TGeoVolumeDialog::TGeoVolumeDialog(TGFrame *caller, const TGWindow *main, UInt_t :TGeoTreeDialog(caller, main, w, h) { // Ctor. - SetCleanup(kDeepCleanup); BuildListTree(); ConnectSignalsToSlots(); MapSubwindows(); @@ -572,7 +436,6 @@ TGeoShapeDialog::TGeoShapeDialog(TGFrame *caller, const TGWindow *main, UInt_t w :TGeoTreeDialog(caller, main, w, h) { // Ctor. - SetCleanup(kDeepCleanup); BuildListTree(); ConnectSignalsToSlots(); MapSubwindows(); @@ -627,7 +490,6 @@ void TGeoShapeDialog::DoItemClick(TGListTreeItem *item, Int_t btn) if (btn!=kButton1) return; DoSelect(item); if (!item || !item->GetUserData()) return; - //gClient->NeedRedraw(fLT); } //______________________________________________________________________________ @@ -646,7 +508,6 @@ TGeoMediumDialog::TGeoMediumDialog(TGFrame *caller, const TGWindow *main, UInt_t :TGeoTreeDialog(caller, main, w, h) { // Ctor. - SetCleanup(kDeepCleanup); BuildListTree(); ConnectSignalsToSlots(); MapSubwindows(); @@ -705,7 +566,6 @@ TGeoMaterialDialog::TGeoMaterialDialog(TGFrame *caller, const TGWindow *main, UI :TGeoTreeDialog(caller, main, w, h) { // Ctor. - SetCleanup(kDeepCleanup); BuildListTree(); ConnectSignalsToSlots(); MapSubwindows(); @@ -764,7 +624,6 @@ TGeoMatrixDialog::TGeoMatrixDialog(TGFrame *caller, const TGWindow *main, UInt_t :TGeoTreeDialog(caller, main, w, h) { // Ctor. - SetCleanup(kDeepCleanup); BuildListTree(); ConnectSignalsToSlots(); MapSubwindows(); @@ -852,11 +711,11 @@ TGeoTransientPanel::TGeoTransientPanel(const char *name, TObject *obj) { // Transient panel ctor. fModel = obj; - TGCanvas *can = new TGCanvas(this, 170, 100); - fTab = new TGTab(can->GetViewPort(), 10, 10); - can->SetContainer(fTab); - AddFrame(can, new TGLayoutHints(kLHintsExpandY | kLHintsExpandX)); - fTab->Associate(can); + fCan = new TGCanvas(this, 170, 100); + fTab = new TGTab(fCan->GetViewPort(), 10, 10); + fCan->SetContainer(fTab); + AddFrame(fCan, new TGLayoutHints(kLHintsExpandY | kLHintsExpandX)); + fTab->Associate(fCan); fTabContainer = fTab->AddTab(name); fStyle = new TGCompositeFrame(fTabContainer, 110, 30, kVerticalFrame); fTabContainer->AddFrame(fStyle, new TGLayoutHints(kLHintsTop | kLHintsExpandX,\ @@ -879,8 +738,10 @@ TGeoTransientPanel::TGeoTransientPanel(const char *name, TObject *obj) TGeoTransientPanel::~TGeoTransientPanel() { // Destructor. + DeleteEditors(); + delete fTab; + delete fCan; gROOT->GetListOfCleanups()->Remove(this); - Cleanup(); } //______________________________________________________________________________ @@ -967,6 +828,7 @@ void TGeoTransientPanel::Show() void TGeoTransientPanel::DeleteEditors() { // Delete editors. + fStyle->Cleanup(); } diff --git a/geombuilder/src/TGeoTorusEditor.cxx b/geombuilder/src/TGeoTorusEditor.cxx new file mode 100644 index 00000000000..93d37ab1795 --- /dev/null +++ b/geombuilder/src/TGeoTorusEditor.cxx @@ -0,0 +1,378 @@ +// @(#):$Name: $:$Id: Exp $ +// Author: M.Gheata + +/************************************************************************* + * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// // +// TGeoTorusEditor // +// // +////////////////////////////////////////////////////////////////////////// + +#include "TGeoTorusEditor.h" +#include "TGeoTabManager.h" +#include "TGeoTorus.h" +#include "TGeoManager.h" +#include "TVirtualGeoPainter.h" +#include "TPad.h" +#include "TView.h" +#include "TGTab.h" +#include "TGComboBox.h" +#include "TGButton.h" +#include "TGTextEntry.h" +#include "TGNumberEntry.h" +#include "TGLabel.h" + +ClassImp(TGeoTorusEditor) + +enum ETGeoTorusWid { + kTORUS_NAME, kTORUS_R, kTORUS_RMIN, kTORUS_RMAX, kTORUS_PHI1, + kTORUS_DPHI, kTORUS_APPLY, kTORUS_UNDO +}; + +//______________________________________________________________________________ +TGeoTorusEditor::TGeoTorusEditor(const TGWindow *p, Int_t id, Int_t width, + Int_t height, UInt_t options, Pixel_t back) + : TGedFrame(p, id, width, height, options | kVerticalFrame, back) +{ + // Constructor for torus editor + fShape = 0; + fRi = fRmini = fRmaxi = fPhi1i = fDphii = 0.0; + fNamei = ""; + fIsModified = kFALSE; + fIsShapeEditable = kTRUE; + + fTabMgr = TGeoTabManager::GetMakeTabManager(gPad, fTab); + + // TextEntry for shape name + MakeTitle("Name"); + fShapeName = new TGTextEntry(this, new TGTextBuffer(50), kTORUS_NAME); + fShapeName->Resize(135, fShapeName->GetDefaultHeight()); + fShapeName->SetToolTipText("Enter the torus name"); + fShapeName->Associate(this); + AddFrame(fShapeName, new TGLayoutHints(kLHintsLeft, 3, 1, 2, 5)); + + TGTextEntry *nef; + MakeTitle("Dimensions"); + // Number entry for R. + TGCompositeFrame *f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "R"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fER = new TGNumberEntry(f1, 0., 5, kTORUS_R); + fER->SetNumAttr(TGNumberFormat::kNEAPositive); + fER->Resize(100, fER->GetDefaultHeight()); + nef = (TGTextEntry*)fER->GetNumberEntry(); + nef->SetToolTipText("Enter the axial radius R"); + fER->Associate(this); + f1->AddFrame(fER, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for rmin. + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "Rmin"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fERmin = new TGNumberEntry(f1, 0., 5, kTORUS_RMIN); + fERmin->SetNumAttr(TGNumberFormat::kNEAPositive); + fERmin->Resize(100, fERmin->GetDefaultHeight()); + nef = (TGTextEntry*)fERmin->GetNumberEntry(); + nef->SetToolTipText("Enter the inner radius Rmin"); + fERmin->Associate(this); + f1->AddFrame(fERmin, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for rmax + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "Rmax"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fERmax = new TGNumberEntry(f1, 0., 5, kTORUS_RMAX); + fERmax->SetNumAttr(TGNumberFormat::kNEAPositive); + fERmax->Resize(100, fERmax->GetDefaultHeight()); + nef = (TGTextEntry*)fERmax->GetNumberEntry(); + nef->SetToolTipText("Enter the outer radius Rmax"); + fERmax->Associate(this); + f1->AddFrame(fERmax, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for Phi1 + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "Phi1"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fEPhi1 = new TGNumberEntry(f1, 0., 5, kTORUS_PHI1); + fEPhi1->SetNumAttr(TGNumberFormat::kNEANonNegative); + fEPhi1->Resize(100, fEPhi1->GetDefaultHeight()); + nef = (TGTextEntry*)fEPhi1->GetNumberEntry(); + nef->SetToolTipText("Enter the starting phi angle[deg]"); + fEPhi1->Associate(this); + f1->AddFrame(fEPhi1, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Number entry for Dphi + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + f1->AddFrame(new TGLabel(f1, "Dphi"), new TGLayoutHints(kLHintsLeft, 1, 1, 6, 0)); + fEDphi = new TGNumberEntry(f1, 0., 5, kTORUS_DPHI); + fEDphi->SetNumAttr(TGNumberFormat::kNEAPositive); + fEDphi->Resize(100, fEDphi->GetDefaultHeight()); + nef = (TGTextEntry*)fEDphi->GetNumberEntry(); + nef->SetToolTipText("Enter the extent phi Dphi [deg]"); + fEDphi->Associate(this); + f1->AddFrame(fEDphi, new TGLayoutHints(kLHintsRight, 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + + // Delayed draw + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame); + fDelayed = new TGCheckButton(f1, "Delayed draw"); + f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + + // Buttons + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + fApply = new TGTextButton(f1, "Apply"); + f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + fApply->Associate(this); + fUndo = new TGTextButton(f1, "Undo"); + f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); + fUndo->Associate(this); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + fUndo->SetSize(fApply->GetSize()); + + // Initialize layout + MapSubwindows(); + Layout(); + MapWindow(); + + TClass *cl = TGeoTorus::Class(); + TGedElement *ge = new TGedElement; + ge->fGedFrame = this; + ge->fCanvas = 0; + cl->GetEditorList()->Add(ge); +} + +//______________________________________________________________________________ +TGeoTorusEditor::~TGeoTorusEditor() +{ +// Destructor + TGFrameElement *el; + TIter next(GetList()); + while ((el = (TGFrameElement *)next())) { + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); + } + Cleanup(); + + TClass *cl = TGeoTorus::Class(); + TIter next1(cl->GetEditorList()); + TGedElement *ge; + while ((ge=(TGedElement*)next1())) { + if (ge->fGedFrame==this) { + cl->GetEditorList()->Remove(ge); + delete ge; + next1.Reset(); + } + } +} + +//______________________________________________________________________________ +void TGeoTorusEditor::ConnectSignals2Slots() +{ + // Connect signals to slots. + fApply->Connect("Clicked()", "TGeoTorusEditor", this, "DoApply()"); + fUndo->Connect("Clicked()", "TGeoTorusEditor", this, "DoUndo()"); + fShapeName->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()"); + fER->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoR()"); + fERmin->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoRmin()"); + fERmax->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoRmax()"); + fEPhi1->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoPhi1()"); + fEDphi->Connect("ValueSet(Long_t)", "TGeoTorusEditor", this, "DoDphi()"); + fER->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()"); + fERmin->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()"); + fERmax->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()"); + fEPhi1->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()"); + fEDphi->GetNumberEntry()->Connect("TextChanged(const char *)", "TGeoTorusEditor", this, "DoModified()"); + fInit = kFALSE; +} + + +//______________________________________________________________________________ +void TGeoTorusEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t) +{ + // Connect to the selected object. + if (obj == 0 || (obj->IsA()!=TGeoTorus::Class())) { + SetActive(kFALSE); + return; + } + fModel = obj; + fPad = pad; + fShape = (TGeoTorus*)fModel; + fRi = fShape->GetR(); + fRmini = fShape->GetRmin(); + fRmaxi = fShape->GetRmax(); + fPhi1i = fShape->GetPhi1(); + fDphii = fShape->GetDphi(); + const char *sname = fShape->GetName(); + if (!strcmp(sname, fShape->ClassName())) fShapeName->SetText("-no_name"); + else { + fShapeName->SetText(sname); + fNamei = sname; + } + fER->SetNumber(fRi); + fERmin->SetNumber(fRmini); + fERmax->SetNumber(fRmaxi); + fEPhi1->SetNumber(fPhi1i); + fEDphi->SetNumber(fDphii); + fApply->SetEnabled(kFALSE); + fUndo->SetEnabled(kFALSE); + + if (fInit) ConnectSignals2Slots(); + SetActive(); +} + +//______________________________________________________________________________ +Bool_t TGeoTorusEditor::IsDelayed() const +{ +// Check if shape drawing is delayed. + return (fDelayed->GetState() == kButtonDown); +} + +//______________________________________________________________________________ +void TGeoTorusEditor::DoName() +{ +// Slot for name. + DoModified(); +} + +//______________________________________________________________________________ +void TGeoTorusEditor::DoApply() +{ +// Slot for applying current settings. + const char *name = fShapeName->GetText(); + if (strcmp(name,fShape->GetName())) fShape->SetName(name); + Double_t r = fER->GetNumber(); + Double_t rmax = fERmax->GetNumber(); + Double_t rmin = fERmin->GetNumber(); + Double_t phi = fEPhi1->GetNumber(); + Double_t dphi = fEDphi->GetNumber(); + Double_t param[5]; + param[0] = r; + param[1] = rmin; + param[2] = rmax; + param[3] = phi; + param[4] = dphi; + fShape->SetDimensions(param); + fShape->ComputeBBox(); + fUndo->SetEnabled(); + fApply->SetEnabled(kFALSE); + if (fPad) { + if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { + TView *view = fPad->GetView(); + if (!view) { + fShape->Draw(); + fPad->GetView()->ShowAxis(); + } else { + view->SetRange(-fShape->GetDX(), -fShape->GetDY(), -fShape->GetDZ(), + fShape->GetDX(), fShape->GetDY(), fShape->GetDZ()); + fPad->Modified(); + fPad->Update(); + } + } else { + fPad->Modified(); + fPad->Update(); + } + } +} + +//______________________________________________________________________________ +void TGeoTorusEditor::DoModified() +{ +// Slot for notifying modifications. + fApply->SetEnabled(); +} + +//______________________________________________________________________________ +void TGeoTorusEditor::DoUndo() +{ +// Slot for undoing last operation. + fER->SetNumber(fRi); + fERmin->SetNumber(fRmini); + fERmax->SetNumber(fRmaxi); + fEPhi1->SetNumber(fPhi1i); + fEDphi->SetNumber(fDphii); + DoApply(); + fUndo->SetEnabled(kFALSE); + fApply->SetEnabled(kFALSE); +} + +//______________________________________________________________________________ +void TGeoTorusEditor::DoR() +{ +// Slot for R. + Double_t r = fER->GetNumber(); + Double_t rmax = fERmax->GetNumber(); + if (r<rmax) { + r = rmax; + fER->SetNumber(r); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoTorusEditor::DoRmin() +{ +// Slot for Rmin. + Double_t rmin = fERmin->GetNumber(); + Double_t rmax = fERmax->GetNumber(); + if (rmin>rmax) { + rmin = rmax-0.1; + fERmin->SetNumber(rmin); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoTorusEditor::DoRmax() +{ +// Slot for Rmax. + Double_t r = fER->GetNumber(); + Double_t rmin = fERmin->GetNumber(); + Double_t rmax = fERmax->GetNumber(); + if (rmax<=rmin) { + rmax = rmin+0.1; + fERmax->SetNumber(rmax); + } + if (rmax>r) { + rmax = r; + fERmax->SetNumber(rmax); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoTorusEditor::DoPhi1() +{ +// Slot for phi. + Double_t phi = fEPhi1->GetNumber(); + if (phi<0 || phi>360) { + phi = 0; + fEPhi1->SetNumber(phi); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + +//______________________________________________________________________________ +void TGeoTorusEditor::DoDphi() +{ +// Slot for Dphi. + Double_t dphi = fEDphi->GetNumber(); + if (dphi<=0 || dphi>360) { + dphi = 1; + fEDphi->SetNumber(dphi); + } + DoModified(); + if (!IsDelayed()) DoApply(); +} + diff --git a/geombuilder/src/TGeoTrd1Editor.cxx b/geombuilder/src/TGeoTrd1Editor.cxx index 8ab14732d5b..fbb3f1c7745 100644 --- a/geombuilder/src/TGeoTrd1Editor.cxx +++ b/geombuilder/src/TGeoTrd1Editor.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoTrd1Editor.cxx,v 1.1 2006/06/13 15:27:11 brun Exp $ +// @(#):$Name: $:$Id: TGeoTrd1Editor.cxx,v 1.2 2006/06/19 14:58:48 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -33,7 +33,7 @@ ClassImp(TGeoTrd1Editor) enum ETGeoTrd1Wid { kTRD1_NAME, kTRD1_X1, kTRD1_X2, kTRD1_Y, kTRD1_Z, - kTRD1_APPLY, kTRD1_CANCEL, kTRD1_UNDO + kTRD1_APPLY, kTRD1_UNDO }; //______________________________________________________________________________ @@ -113,20 +113,22 @@ TGeoTrd1Editor::TGeoTrd1Editor(const TGWindow *p, Int_t id, Int_t width, compxyz->Resize(150,30); AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + // Delayed draw + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame); + fDelayed = new TGCheckButton(f1, "Delayed draw"); + f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + // Buttons - TGCompositeFrame *f23 = new TGCompositeFrame(this, 118, 20, kHorizontalFrame | kSunkenFrame | kDoubleBorder); - fApply = new TGTextButton(f23, "&Apply"); - f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + fApply = new TGTextButton(f1, "Apply"); + f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); fApply->Associate(this); - fCancel = new TGTextButton(f23, "&Cancel"); - f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4)); - fCancel->Associate(this); - fUndo = new TGTextButton(f23, " &Undo "); - f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); + fUndo = new TGTextButton(f1, "Undo"); + f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); fUndo->Associate(this); - AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); - fUndo->SetSize(fCancel->GetSize()); - fApply->SetSize(fCancel->GetSize()); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + fUndo->SetSize(fApply->GetSize()); // Initialize layout MapSubwindows(); @@ -146,10 +148,9 @@ TGeoTrd1Editor::~TGeoTrd1Editor() // Destructor TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); TClass *cl = TGeoTrd1::Class(); @@ -169,7 +170,6 @@ void TGeoTrd1Editor::ConnectSignals2Slots() { // Connect signals to slots. fApply->Connect("Clicked()", "TGeoTrd1Editor", this, "DoApply()"); - fCancel->Connect("Clicked()", "TGeoTrd1Editor", this, "DoCancel()"); fUndo->Connect("Clicked()", "TGeoTrd1Editor", this, "DoUndo()"); fShapeName->Connect("TextChanged(const char *)", "TGeoTrd1Editor", this, "DoModified()"); fEDx1->Connect("ValueSet(Long_t)", "TGeoTrd1Editor", this, "DoDx1()"); @@ -211,12 +211,19 @@ void TGeoTrd1Editor::SetModel(TVirtualPad* pad, TObject* obj, Int_t) fEDz->SetNumber(fDzi); fApply->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); + if (fInit) ConnectSignals2Slots(); SetActive(); } +//______________________________________________________________________________ +Bool_t TGeoTrd1Editor::IsDelayed() const +{ +// Check if shape drawing is delayed. + return (fDelayed->GetState() == kButtonDown); +} + //______________________________________________________________________________ void TGeoTrd1Editor::DoName() { @@ -229,11 +236,7 @@ void TGeoTrd1Editor::DoApply() { // Slot for applying modifications. const char *name = fShapeName->GetText(); - if (strcmp(name,fShape->GetName())) { - fShape->SetName(name); - Int_t id = gGeoManager->GetListOfShapes()->IndexOf(fShape); - fTabMgr->UpdateShape(id); - } + if (strcmp(name,fShape->GetName())) fShape->SetName(name); Double_t dx1 = fEDx1->GetNumber(); Double_t dx2 = fEDx2->GetNumber(); Double_t dy = fEDy->GetNumber(); @@ -246,7 +249,6 @@ void TGeoTrd1Editor::DoApply() fShape->SetDimensions(param); fShape->ComputeBBox(); fUndo->SetEnabled(); - fCancel->SetEnabled(kFALSE); fApply->SetEnabled(kFALSE); if (fPad) { if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { @@ -259,35 +261,22 @@ void TGeoTrd1Editor::DoApply() } } -//______________________________________________________________________________ -void TGeoTrd1Editor::DoCancel() -{ -// Slot for cancelling current modifications. - fShapeName->SetText(fNamei.Data()); - fEDx1->SetNumber(fDxi1); - fEDx2->SetNumber(fDxi2); - fEDy->SetNumber(fDyi); - fEDz->SetNumber(fDzi); - fApply->SetEnabled(kFALSE); - fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); -} - //______________________________________________________________________________ void TGeoTrd1Editor::DoModified() { // Slot for signaling modifications. fApply->SetEnabled(); - if (fUndo->GetState()==kButtonDisabled) fCancel->SetEnabled(); } //______________________________________________________________________________ void TGeoTrd1Editor::DoUndo() { // Slot for undoing last operation. - DoCancel(); + fEDx1->SetNumber(fDxi1); + fEDx2->SetNumber(fDxi2); + fEDy->SetNumber(fDyi); + fEDz->SetNumber(fDzi); DoApply(); - fCancel->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); fApply->SetEnabled(kFALSE); } @@ -296,28 +285,62 @@ void TGeoTrd1Editor::DoUndo() void TGeoTrd1Editor::DoDx1() { // Slot for dx1. + Double_t dx1 = fEDx1->GetNumber(); + Double_t dx2 = fEDx2->GetNumber(); + if (dx1<0) { + dx1 = 0; + fEDx1->SetNumber(dx1); + } + if (dx1<1.e-6 && dx2<1.e-6) { + dx1 = 0.1; + fEDx1->SetNumber(dx1); + } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ void TGeoTrd1Editor::DoDx2() { // Slot for dx2. + Double_t dx1 = fEDx1->GetNumber(); + Double_t dx2 = fEDx2->GetNumber(); + if (dx2<0) { + dx2 = 0; + fEDx2->SetNumber(dx2); + } + if (dx1<1.e-6 && dx2<1.e-6) { + dx2 = 0.1; + fEDx2->SetNumber(dx2); + } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ void TGeoTrd1Editor::DoDy() { // Slot for dy. + Double_t dy = fEDy->GetNumber(); + if (dy<=0) { + dy = 0.1; + fEDy->SetNumber(dy); + } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ void TGeoTrd1Editor::DoDz() { // Slot for dz. + Double_t dz = fEDz->GetNumber(); + if (dz<=0) { + dz = 0.1; + fEDz->SetNumber(dz); + } DoModified(); + if (!IsDelayed()) DoApply(); } diff --git a/geombuilder/src/TGeoTrd2Editor.cxx b/geombuilder/src/TGeoTrd2Editor.cxx index e12aa11e894..dc10ad23df3 100644 --- a/geombuilder/src/TGeoTrd2Editor.cxx +++ b/geombuilder/src/TGeoTrd2Editor.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoTrd2Editor.cxx,v 1.1 2006/06/13 15:27:11 brun Exp $ +// @(#):$Name: $:$Id: TGeoTrd2Editor.cxx,v 1.2 2006/06/19 14:58:48 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -33,7 +33,7 @@ ClassImp(TGeoTrd2Editor) enum ETGeoTrd2Wid { kTRD2_NAME, kTRD2_X1, kTRD2_X2, kTRD2_Y1, kTRD2_Y2, kTRD2_Z, - kTRD2_APPLY, kTRD2_CANCEL, kTRD2_UNDO + kTRD2_APPLY, kTRD2_UNDO }; //______________________________________________________________________________ @@ -125,20 +125,22 @@ TGeoTrd2Editor::TGeoTrd2Editor(const TGWindow *p, Int_t id, Int_t width, compxyz->Resize(150,30); AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + // Delayed draw + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame); + fDelayed = new TGCheckButton(f1, "Delayed draw"); + f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + // Buttons - TGCompositeFrame *f23 = new TGCompositeFrame(this, 118, 20, kHorizontalFrame | kSunkenFrame | kDoubleBorder); - fApply = new TGTextButton(f23, "&Apply"); - f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + fApply = new TGTextButton(f1, "Apply"); + f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); fApply->Associate(this); - fCancel = new TGTextButton(f23, "&Cancel"); - f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4)); - fCancel->Associate(this); - fUndo = new TGTextButton(f23, " &Undo "); - f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); + fUndo = new TGTextButton(f1, "Undo"); + f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); fUndo->Associate(this); - AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); - fUndo->SetSize(fCancel->GetSize()); - fApply->SetSize(fCancel->GetSize()); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + fUndo->SetSize(fApply->GetSize()); // Initialize layout MapSubwindows(); @@ -158,10 +160,9 @@ TGeoTrd2Editor::~TGeoTrd2Editor() // Destructor. TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); TClass *cl = TGeoTrd2::Class(); @@ -181,7 +182,6 @@ void TGeoTrd2Editor::ConnectSignals2Slots() { // Connect signals to slots. fApply->Connect("Clicked()", "TGeoTrd2Editor", this, "DoApply()"); - fCancel->Connect("Clicked()", "TGeoTrd2Editor", this, "DoCancel()"); fUndo->Connect("Clicked()", "TGeoTrd2Editor", this, "DoUndo()"); fShapeName->Connect("TextChanged(const char *)", "TGeoTrd2Editor", this, "DoModified()"); fEDx1->Connect("ValueSet(Long_t)", "TGeoTrd2Editor", this, "DoDx1()"); @@ -227,12 +227,18 @@ void TGeoTrd2Editor::SetModel(TVirtualPad* pad, TObject* obj, Int_t) fEDz->SetNumber(fDzi); fApply->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); if (fInit) ConnectSignals2Slots(); SetActive(); } +//______________________________________________________________________________ +Bool_t TGeoTrd2Editor::IsDelayed() const +{ +// Check if shape drawing is delayed. + return (fDelayed->GetState() == kButtonDown); +} + //______________________________________________________________________________ void TGeoTrd2Editor::DoName() { @@ -245,11 +251,7 @@ void TGeoTrd2Editor::DoApply() { // Slot for applying modifications. const char *name = fShapeName->GetText(); - if (strcmp(name,fShape->GetName())) { - fShape->SetName(name); - Int_t id = gGeoManager->GetListOfShapes()->IndexOf(fShape); - fTabMgr->UpdateShape(id); - } + if (strcmp(name,fShape->GetName())) fShape->SetName(name); Double_t dx1 = fEDx1->GetNumber(); Double_t dx2 = fEDx2->GetNumber(); Double_t dy1 = fEDy1->GetNumber(); @@ -264,7 +266,6 @@ void TGeoTrd2Editor::DoApply() fShape->SetDimensions(param); fShape->ComputeBBox(); fUndo->SetEnabled(); - fCancel->SetEnabled(kFALSE); fApply->SetEnabled(kFALSE); if (fPad) { if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { @@ -277,36 +278,23 @@ void TGeoTrd2Editor::DoApply() } } -//______________________________________________________________________________ -void TGeoTrd2Editor::DoCancel() -{ -// Slot for cancelling current modifications. - fShapeName->SetText(fNamei.Data()); - fEDx1->SetNumber(fDxi1); - fEDx2->SetNumber(fDxi2); - fEDy1->SetNumber(fDyi1); - fEDy2->SetNumber(fDyi2); - fEDz->SetNumber(fDzi); - fApply->SetEnabled(kFALSE); - fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); -} - //______________________________________________________________________________ void TGeoTrd2Editor::DoModified() { // Slot for signaling modifications. fApply->SetEnabled(); - if (fUndo->GetState()==kButtonDisabled) fCancel->SetEnabled(); } //______________________________________________________________________________ void TGeoTrd2Editor::DoUndo() { // Slot for undoing last operation. - DoCancel(); + fEDx1->SetNumber(fDxi1); + fEDx2->SetNumber(fDxi2); + fEDy1->SetNumber(fDyi1); + fEDy2->SetNumber(fDyi2); + fEDz->SetNumber(fDzi); DoApply(); - fCancel->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); fApply->SetEnabled(kFALSE); } @@ -315,35 +303,85 @@ void TGeoTrd2Editor::DoUndo() void TGeoTrd2Editor::DoDx1() { // Slot for dx1. + Double_t dx1 = fEDx1->GetNumber(); + Double_t dx2 = fEDx2->GetNumber(); + if (dx1<0) { + dx1 = 0; + fEDx1->SetNumber(dx1); + } + if (dx1<1.e-6 && dx2<1.e-6) { + dx1 = 0.1; + fEDx1->SetNumber(dx1); + } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ void TGeoTrd2Editor::DoDx2() { // Slot for dx2. + Double_t dx1 = fEDx1->GetNumber(); + Double_t dx2 = fEDx2->GetNumber(); + if (dx2<0) { + dx2 = 0; + fEDx2->SetNumber(dx2); + } + if (dx1<1.e-6 && dx2<1.e-6) { + dx2 = 0.1; + fEDx2->SetNumber(dx2); + } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ void TGeoTrd2Editor::DoDy1() { // Slot for dy1. + Double_t dy1 = fEDy1->GetNumber(); + Double_t dy2 = fEDy2->GetNumber(); + if (dy1<0) { + dy1 = 0; + fEDy1->SetNumber(dy1); + } + if (dy1<1.e-6 && dy2<1.e-6) { + dy1 = 0.1; + fEDy1->SetNumber(dy1); + } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ void TGeoTrd2Editor::DoDy2() { // Slot for dy2. + Double_t dy1 = fEDy1->GetNumber(); + Double_t dy2 = fEDy2->GetNumber(); + if (dy2<0) { + dy2 = 0; + fEDy2->SetNumber(dy2); + } + if (dy1<1.e-6 && dy2<1.e-6) { + dy2 = 0.1; + fEDy2->SetNumber(dy2); + } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ void TGeoTrd2Editor::DoDz() { // Slot for dz. + Double_t dz = fEDz->GetNumber(); + if (dz<=0) { + dz = 0.1; + fEDz->SetNumber(dz); + } DoModified(); + if (!IsDelayed()) DoApply(); } diff --git a/geombuilder/src/TGeoTubeEditor.cxx b/geombuilder/src/TGeoTubeEditor.cxx index 3e9710f433e..8c204c7e1a9 100644 --- a/geombuilder/src/TGeoTubeEditor.cxx +++ b/geombuilder/src/TGeoTubeEditor.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoTubeEditor.cxx,v 1.2 2006/06/19 14:58:48 brun Exp $ +// @(#):$Name: $:$Id: TGeoTubeEditor.cxx,v 1.3 2006/06/20 06:33:20 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -34,7 +34,7 @@ ClassImp(TGeoTubeEditor) enum ETGeoTubeWid { kTUBE_NAME, kTUBE_RMIN, kTUBE_RMAX, kTUBE_Z, - kTUBE_APPLY, kTUBE_CANCEL, kTUBE_UNDO + kTUBE_APPLY, kTUBE_UNDO }; //______________________________________________________________________________ @@ -104,21 +104,23 @@ TGeoTubeEditor::TGeoTubeEditor(const TGWindow *p, Int_t id, Int_t width, compxyz->Resize(150,30); AddFrame(compxyz, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + // Delayed draw + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth | kSunkenFrame); + fDelayed = new TGCheckButton(f1, "Delayed draw"); + f1->AddFrame(fDelayed, new TGLayoutHints(kLHintsLeft , 2, 2, 4, 4)); + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + // Buttons - TGCompositeFrame *f23 = new TGCompositeFrame(this, 118, 20, kHorizontalFrame | kSunkenFrame); - fApply = new TGTextButton(f23, "Apply"); - f23->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); + f1 = new TGCompositeFrame(this, 155, 10, kHorizontalFrame | kFixedWidth); + fApply = new TGTextButton(f1, "Apply"); + f1->AddFrame(fApply, new TGLayoutHints(kLHintsLeft, 2, 2, 4, 4)); fApply->Associate(this); - fCancel = new TGTextButton(f23, "Cancel"); - f23->AddFrame(fCancel, new TGLayoutHints(kLHintsCenterX, 2, 2, 4, 4)); - fCancel->Associate(this); - fUndo = new TGTextButton(f23, " Undo "); - f23->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); + fUndo = new TGTextButton(f1, "Undo"); + f1->AddFrame(fUndo, new TGLayoutHints(kLHintsRight , 2, 2, 4, 4)); fUndo->Associate(this); - AddFrame(f23, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); - fUndo->SetSize(fCancel->GetSize()); - fApply->SetSize(fCancel->GetSize()); - + AddFrame(f1, new TGLayoutHints(kLHintsLeft, 6, 6, 4, 4)); + fUndo->SetSize(fApply->GetSize()); + // Initialize layout MapSubwindows(); Layout(); @@ -137,12 +139,12 @@ TGeoTubeEditor::~TGeoTubeEditor() // Destructor TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); + TClass *cl = TGeoTube::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; @@ -160,7 +162,6 @@ void TGeoTubeEditor::ConnectSignals2Slots() { // Connect signals to slots. fApply->Connect("Clicked()", "TGeoTubeEditor", this, "DoApply()"); - fCancel->Connect("Clicked()", "TGeoTubeEditor", this, "DoCancel()"); fUndo->Connect("Clicked()", "TGeoTubeEditor", this, "DoUndo()"); fShapeName->Connect("TextChanged(const char *)", "TGeoTubeEditor", this, "DoModified()"); fERmin->Connect("ValueSet(Long_t)", "TGeoTubeEditor", this, "DoRmin()"); @@ -194,12 +195,18 @@ void TGeoTubeEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t) fEDz->SetNumber(fDzi); fApply->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); if (fInit) ConnectSignals2Slots(); SetActive(); } +//______________________________________________________________________________ +Bool_t TGeoTubeEditor::IsDelayed() const +{ +// Check if shape drawing is delayed. + return (fDelayed->GetState() == kButtonDown); +} + //______________________________________________________________________________ void TGeoTubeEditor::DoName() { @@ -212,18 +219,13 @@ void TGeoTubeEditor::DoApply() { // Slot for applying modifications. const char *name = fShapeName->GetText(); - if (strcmp(name,fShape->GetName())) { - fShape->SetName(name); - Int_t id = gGeoManager->GetListOfShapes()->IndexOf(fShape); - fTabMgr->UpdateShape(id); - } + if (strcmp(name,fShape->GetName())) fShape->SetName(name); Double_t rmin = fERmin->GetNumber(); Double_t rmax = fERmax->GetNumber(); Double_t dz = fEDz->GetNumber(); fShape->SetTubeDimensions(rmin, rmax, dz); fShape->ComputeBBox(); fUndo->SetEnabled(); - fCancel->SetEnabled(kFALSE); fApply->SetEnabled(kFALSE); if (fPad) { if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { @@ -236,34 +238,21 @@ void TGeoTubeEditor::DoApply() } } -//______________________________________________________________________________ -void TGeoTubeEditor::DoCancel() -{ -// Slot for cancelling current modifications. - fShapeName->SetText(fNamei.Data()); - fERmin->SetNumber(fRmini); - fERmax->SetNumber(fRmaxi); - fEDz->SetNumber(fDzi); - fApply->SetEnabled(kFALSE); - fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); -} - //______________________________________________________________________________ void TGeoTubeEditor::DoModified() { // Slot for signaling modifications. fApply->SetEnabled(); - if (fUndo->GetState()==kButtonDisabled) fCancel->SetEnabled(); } //______________________________________________________________________________ void TGeoTubeEditor::DoUndo() { // Slot for undoing last operation. - DoCancel(); + fERmin->SetNumber(fRmini); + fERmax->SetNumber(fRmaxi); + fEDz->SetNumber(fDzi); DoApply(); - fCancel->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); fApply->SetEnabled(kFALSE); } @@ -275,10 +264,11 @@ void TGeoTubeEditor::DoRmin() Double_t rmin = fERmin->GetNumber(); Double_t rmax = fERmax->GetNumber(); if (rmax<rmin+1.e-10) { - rmax = rmin + 0.1; - fERmax->SetNumber(rmax); + rmin = rmax - 0.1; + fERmin->SetNumber(rmin); } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -287,19 +277,29 @@ void TGeoTubeEditor::DoRmax() // Slot for rmax. Double_t rmin = fERmin->GetNumber(); Double_t rmax = fERmax->GetNumber(); + if (rmax <= 0.) { + rmax = 0.1; + fERmax->SetNumber(rmax); + } if (rmax<rmin+1.e-10) { - rmin = rmax - 0.1; - if (rmin < 0.) rmin = 0.; - fERmin->SetNumber(rmin); + rmax = rmin + 0.1; + fERmax->SetNumber(rmax); } DoModified(); + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ void TGeoTubeEditor::DoDz() { // Slot for dz. + Double_t dz = fEDz->GetNumber(); + if (dz<=0) { + dz = 0.1; + fEDz->SetNumber(dz); + } DoModified(); + if (!IsDelayed()) DoApply(); } ////////////////////////////////////////////////////////////////////////// @@ -369,12 +369,12 @@ TGeoTubeSegEditor::~TGeoTubeSegEditor() // Destructor TGFrameElement *el; TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); + if (el->fFrame->IsComposite()) + TGeoTabManager::Cleanup((TGCompositeFrame*)el->fFrame); } Cleanup(); + TClass *cl = TGeoTubeSeg::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; @@ -394,10 +394,8 @@ void TGeoTubeSegEditor::ConnectSignals2Slots() TGeoTubeEditor::ConnectSignals2Slots(); Disconnect(fApply, "Clicked()",(TGeoTubeEditor*)this, "DoApply()"); Disconnect(fUndo, "Clicked()",(TGeoTubeEditor*)this, "DoUndo()"); - Disconnect(fCancel, "Clicked()",(TGeoTubeEditor*)this, "DoCancel()"); fApply->Connect("Clicked()", "TGeoTubeSegEditor", this, "DoApply()"); fUndo->Connect("Clicked()", "TGeoTubeSegEditor", this, "DoUndo()"); - fCancel->Connect("Clicked()", "TGeoTubeSegEditor", this, "DoCancel()"); fEPhi1->Connect("ValueSet(Long_t)", "TGeoTubeSegEditor", this, "DoPhi1()"); fEPhi2->Connect("ValueSet(Long_t)", "TGeoTubeSegEditor", this, "DoPhi2()"); // fEPhi1->GetNumberEntry()->Connect("TextChanged(const char *)","TGeoTubeSegEditor", this, "DoPhi1()"); @@ -431,7 +429,6 @@ void TGeoTubeSegEditor::SetModel(TVirtualPad* pad, TObject* obj, Int_t) fEDz->SetNumber(fDzi); fApply->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); - fCancel->SetEnabled(kFALSE); if (fInit) ConnectSignals2Slots(); SetActive(); @@ -456,6 +453,7 @@ void TGeoTubeSegEditor::DoPhi1() fLock = kTRUE; fSPhi->SetPosition(phi1,phi2); } else fLock = kFALSE; + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -477,6 +475,7 @@ void TGeoTubeSegEditor::DoPhi2() fLock = kTRUE; fSPhi->SetPosition(phi1,phi2); } else fLock = kFALSE; + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ @@ -490,24 +489,23 @@ void TGeoTubeSegEditor::DoPhi() fLock = kTRUE; fEPhi2->SetNumber(fSPhi->GetMaxPosition()); } else fLock = kFALSE; + if (!IsDelayed()) DoApply(); } //______________________________________________________________________________ void TGeoTubeSegEditor::DoApply() { // Slot for applying modifications. + fApply->SetEnabled(kFALSE); const char *name = fShapeName->GetText(); - if (strcmp(name,fShape->GetName())) { - fShape->SetName(name); - Int_t id = gGeoManager->GetListOfShapes()->IndexOf(fShape); - fTabMgr->UpdateShape(id); - } + if (strcmp(name,fShape->GetName())) fShape->SetName(name); Double_t rmin = fERmin->GetNumber(); Double_t rmax = fERmax->GetNumber(); + if (rmin<0 || rmax<rmin) return; Double_t dz = fEDz->GetNumber(); Double_t phi1 = fEPhi1->GetNumber(); Double_t phi2 = fEPhi2->GetNumber(); - if ((phi2-phi1) > 360.) { + if ((phi2-phi1) > 360.001) { phi1 = 0.; phi2 = 360.; fEPhi1->SetNumber(phi1); @@ -519,8 +517,6 @@ void TGeoTubeSegEditor::DoApply() ((TGeoTubeSeg*)fShape)->SetTubsDimensions(rmin, rmax, dz, phi1, phi2); fShape->ComputeBBox(); fUndo->SetEnabled(); - fCancel->SetEnabled(kFALSE); - fApply->SetEnabled(kFALSE); if (fPad) { if (gGeoManager && gGeoManager->GetPainter() && gGeoManager->GetPainter()->IsPaintingShape()) { fShape->Draw(); @@ -536,22 +532,14 @@ void TGeoTubeSegEditor::DoApply() void TGeoTubeSegEditor::DoUndo() { // Slot for undoing last operation. - DoCancel(); + fEPhi1->SetNumber(fPmini); + fEPhi2->SetNumber(fPmaxi); + fSPhi->SetPosition(fPmini,fPmaxi); DoApply(); - fCancel->SetEnabled(kFALSE); fUndo->SetEnabled(kFALSE); fApply->SetEnabled(kFALSE); } -//______________________________________________________________________________ -void TGeoTubeSegEditor::DoCancel() -{ -// Slot for cancelling current modifications. - fEPhi1->SetNumber(fPmini); - fEPhi2->SetNumber(fPmaxi); - fSPhi->SetPosition(fPmini,fPmaxi); - TGeoTubeEditor::DoCancel(); -} diff --git a/geombuilder/src/TGeoVolumeEditor.cxx b/geombuilder/src/TGeoVolumeEditor.cxx index 7967571562c..a0a56221321 100644 --- a/geombuilder/src/TGeoVolumeEditor.cxx +++ b/geombuilder/src/TGeoVolumeEditor.cxx @@ -1,4 +1,4 @@ -// @(#):$Name: $:$Id: TGeoVolumeEditor.cxx,v 1.1 2006/06/13 15:27:12 brun Exp $ +// @(#):$Name: $:$Id: TGeoVolumeEditor.cxx,v 1.2 2006/06/19 14:58:48 brun Exp $ // Author: M.Gheata /************************************************************************* @@ -382,13 +382,17 @@ TGeoVolumeEditor::TGeoVolumeEditor(const TGWindow *p, Int_t id, Int_t width, TGeoVolumeEditor::~TGeoVolumeEditor() { // Destructor - TGFrameElement *el; - TIter next(GetList()); - while ((el = (TGFrameElement *)next())) { - if (!strcmp(el->fFrame->ClassName(), "TGCompositeFrame")) - ((TGCompositeFrame *)el->fFrame)->Cleanup(); - } + TGCompositeFrame *cont; + cont = (TGCompositeFrame*)fCategories->GetItem("Properties")->GetContainer(); + TGeoTabManager::Cleanup(cont); + cont = (TGCompositeFrame*)fCategories->GetItem("Daughters")->GetContainer(); + TGeoTabManager::Cleanup(cont); + cont = (TGCompositeFrame*)fCategories->GetItem("Visualization")->GetContainer(); + TGeoTabManager::Cleanup(cont); + cont = (TGCompositeFrame*)fCategories->GetItem("Division")->GetContainer(); + TGeoTabManager::Cleanup(cont); Cleanup(); + TClass *cl = TGeoVolume::Class(); TIter next1(cl->GetEditorList()); TGedElement *ge; -- GitLab