Salome HOME
8f5dc645cef71bd668a9d1bbd8912ee780ad479b
[modules/gui.git] / src / SUPERVGraph / SUPERVGraph_ViewFrame.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SALOME SUPERVGraph : build Supervisor viewer into desktop
23 //  File   : SUPERVGraph_ViewFrame.h
24 //  Author : Nicolas REJNERI
25 //  Module : SALOME
26 //  $Header$
27 //
28 #ifndef SUPERVGraph_ViewFrame_H
29 #define SUPERVGraph_ViewFrame_H
30
31 #include "SUPERVGraph.h"
32
33 #include "SALOME_InteractiveObject.hxx"
34 #include "SUIT_PopupClient.h"
35 #include "SUIT_ViewWindow.h"
36
37 #include <QtxAction.h>
38
39 #ifdef WIN32
40 #pragma warning ( disable:4251 )
41 #endif
42
43 class SUPERVGRAPH_EXPORT SUPERVGraph_View: public QWidget, public SUIT_PopupClient {
44   Q_OBJECT;
45  public:
46   static QString Type() { return "SUPERVGraphViewer"; }
47
48   SUPERVGraph_View(QWidget* theParent);
49   SUPERVGraph_View(SUPERVGraph_View* theParent);
50
51   virtual void ActivatePanning() = 0;
52   virtual void ResetView() = 0;
53
54   /* redefine functions from SUIT_PopupClient */
55   virtual QString popupClientType() const { return Type(); }
56   virtual void    contextMenuPopup( QMenu* );
57   
58   virtual void resizeView( QResizeEvent* theEvent ) {};
59   
60  protected:
61   void init(QWidget* theParent);
62   
63 };
64
65 class SUPERVGRAPH_EXPORT SUPERVGraph_ViewFrame : public SUIT_ViewWindow {
66   Q_OBJECT
67
68     public:
69   SUPERVGraph_ViewFrame(SUIT_Desktop* theDesktop );
70   ~SUPERVGraph_ViewFrame();
71
72   SUPERVGraph_View*              getViewWidget();
73   void                           setViewWidget(SUPERVGraph_View* theView);
74
75   void                           setBackgroundColor( const QColor& );
76   QColor                         backgroundColor() const;
77   
78   void                           onAdjustTrihedron( );
79   
80   /*  interactive object management */
81   void                           highlight( const Handle(SALOME_InteractiveObject)& IObject, 
82                                             bool highlight, bool immediatly = true );
83   void                           unHighlightAll();
84   void                           rename( const Handle(SALOME_InteractiveObject)& IObject,
85                                          QString newName );
86   bool                           isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
87   bool                           isVisible( const Handle(SALOME_InteractiveObject)& IObject );
88   
89   /* selection */
90   Handle(SALOME_InteractiveObject) FindIObject(const char* Entry) { Handle(SALOME_InteractiveObject) o; return o; };
91
92   /* display */         
93   void           Display(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true){};
94   void           DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject){};
95   void           Erase(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true){};
96   void           DisplayAll(){};
97   void           EraseAll(){};
98   void           Repaint() {};
99
100   QToolBar*      getToolBar() { return myToolBar; }
101
102  public slots:
103   void           onViewPan(); 
104   void           onViewZoom();
105   void           onViewFitAll();
106   void           onViewFitArea();
107   void           onViewGlobalPan(); 
108   void           onViewRotate();
109   void           onViewReset();     
110   void           onViewFront(); 
111   void           onViewBack(); 
112   void           onViewRight(); 
113   void           onViewLeft();     
114   void           onViewBottom();
115   void           onViewTop();
116   void           onViewTrihedron(); 
117
118  protected:
119   void           resizeEvent( QResizeEvent* theEvent );
120   
121  private:
122   void           createActions();
123   void           createToolBar();
124
125   //! Actions ID
126   enum { PanId, ResetId };
127   typedef QMap<int, QtxAction*> ActionsMap;
128
129   ActionsMap       myActionsMap;
130   QToolBar*        myToolBar;
131
132   SUPERVGraph_View* myView;
133 };
134
135 #ifdef WIN32
136 #pragma warning ( default:4251 )
137 #endif
138
139 #endif