Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-08 09:26:10

0001 // @(#)root/x3d:$Id$
0002 // Author: Rene Brun   05/09/99
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TViewerX3D
0013 #define ROOT_TViewerX3D
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TViewerX3D                                                           //
0019 //                                                                      //
0020 // C++ interface to the X3D viewer                                      //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TX3DFrame.h"
0025 #include "TVirtualViewer3D.h"
0026 
0027 class TVirtualPad;
0028 class TGCanvas;
0029 class TGMenuBar;
0030 class TGPopupMenu;
0031 class TGLayoutHints;
0032 class TX3DContainer;
0033 
0034 class TViewerX3D : public TVirtualViewer3D
0035 {
0036 
0037 friend class TX3DContainer;
0038 
0039 private:
0040    TX3DFrame      *fMainFrame;          // the main GUI frame
0041    TString         fOption;             // option string to be passed to X3D
0042    TString         fTitle;              // viewer title
0043    Window_t        fX3DWin;             // X3D window
0044    TGCanvas       *fCanvas;             // canvas widget
0045    TX3DContainer  *fContainer;          // container containing X3D window
0046    TGMenuBar      *fMenuBar;            // menubar
0047    TGPopupMenu    *fFileMenu;           // file menu
0048    TGPopupMenu    *fHelpMenu;           // help menu
0049    TGLayoutHints  *fMenuBarLayout;      // menubar layout hints
0050    TGLayoutHints  *fMenuBarItemLayout;  // layout hints for menu in menubar
0051    TGLayoutHints  *fMenuBarHelpLayout;  // layout hint for help menu in menubar
0052    TGLayoutHints  *fCanvasLayout;       // layout for canvas widget
0053    UInt_t          fWidth;              // viewer width
0054    UInt_t          fHeight;             // viewer height
0055    Int_t           fXPos;               // viewer X position
0056    Int_t           fYPos;               // viewer Y position
0057    TVirtualPad    *fPad;                // pad we are attached to
0058    Bool_t          fBuildingScene;      // Rebuilding 3D scene
0059    enum EPass {
0060 // clang++ <v20 (-Wshadow) complains about shadowing TStructNode.h global enum EScalingType. Let's silence warning:
0061 #if defined(__clang__) && __clang_major__ < 20
0062 #pragma clang diagnostic push
0063 #pragma clang diagnostic ignored "-Wshadow"
0064 #endif
0065       kSize,
0066 #if defined(__clang__) && __clang_major__ < 20
0067 #pragma clang diagnostic pop
0068 #endif
0069       kDraw };                          // Multi-pass build : size then draw
0070    EPass           fPass;
0071 
0072    void     CreateViewer(const char *name);
0073    void     InitX3DWindow();
0074    void     DeleteX3DWindow();
0075 
0076    Bool_t   HandleContainerButton(Event_t *ev);
0077 
0078    static Bool_t fgCreated;    // TViewerX3D is a singleton
0079 
0080 public:
0081    TViewerX3D(TVirtualPad *pad);
0082    TViewerX3D(TVirtualPad *pad, Option_t *option, const char *title="X3D Viewer",
0083               UInt_t width = 800, UInt_t height = 600);
0084    TViewerX3D(TVirtualPad *pad, Option_t *option, const char *title,
0085               Int_t x, Int_t y, UInt_t width, UInt_t height);
0086    ~TViewerX3D() override;
0087 
0088    Int_t    ExecCommand(Int_t px, Int_t py, char command);
0089    void     GetPosition(Float_t &longitude, Float_t &latitude, Float_t &psi);
0090    void     Iconify() { }
0091    void     Show() { fMainFrame->MapRaised(); }
0092    void     Close();
0093    void     Update();
0094 
0095    void     PaintPolyMarker(const TBuffer3D & buffer) const;
0096 
0097    // TVirtualViewer3D interface
0098    Bool_t PreferLocalFrame() const override { return kFALSE; }
0099    void   BeginScene() override;
0100    Bool_t BuildingScene()    const override { return fBuildingScene; }
0101    void   EndScene() override;
0102    Int_t  AddObject(const TBuffer3D & buffer, Bool_t * addChildren = nullptr) override;
0103    Int_t  AddObject(UInt_t placedID, const TBuffer3D & buffer, Bool_t * addChildren = nullptr) override;
0104 
0105    // Composite shapes not supported on this viewer currently - ignore.
0106    // Will result in a set of component shapes
0107    Bool_t OpenComposite(const TBuffer3D & /*buffer*/, Bool_t * = nullptr) override { return kTRUE; }
0108    void   CloseComposite() override {};
0109    void   AddCompositeOp(UInt_t /*operation*/) override {};
0110 
0111    Bool_t   ProcessFrameMessage(Long_t msg, Long_t parm1, Long_t parm2);
0112 
0113    ClassDefOverride(TViewerX3D,0)  //Interface to the X3D viewer
0114 };
0115 
0116 #endif