1 // SALOME SUPERVGraph : build Supervisor viewer into desktop
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SUPERVGraph_ViewFrame.cxx
25 // Author : Nicolas REJNERI
30 #include "SUPERVGraph_ViewFrame.h"
32 #include "QAD_Settings.h"
33 #include "QAD_Config.h"
34 #include "QAD_Application.h"
35 #include "QAD_Desktop.h"
36 #include "SALOME_Selection.h"
38 #include "utilities.h"
42 #include <qcolordialog.h>
44 SUPERVGraph_View::SUPERVGraph_View(QWidget* theParent): QWidget(theParent){
47 SUPERVGraph_View::SUPERVGraph_View(SUPERVGraph_View* theParent): QWidget(theParent){
48 setPopupServer(theParent->getPopupServer());
51 void SUPERVGraph_View::init(QWidget* theParent){
52 if ( theParent->inherits( "QMainWindow" ) ) {
53 ( ( QMainWindow* )theParent )->setCentralWidget( this );
56 QBoxLayout* layout = new QVBoxLayout( theParent );
57 layout->addWidget( this );
61 void SUPERVGraph_View::onCreatePopup(){
64 QAD_Desktop* Desktop = (QAD_Desktop*) QAD_Application::getDesktop();
65 QAD_Study* ActiveStudy = Desktop->getActiveStudy();
66 SALOME_Selection* Sel = SALOME_Selection::Selection( ActiveStudy->getSelection() );
69 QString theParent("Viewer");
72 Desktop->definePopup( theContext, theParent, theObject );
73 Desktop->createPopup( myPopup, theContext, theParent, theObject);
74 Desktop->customPopup( myPopup, theContext, theParent, theObject );
75 if (Sel->IObjectCount() == 0 && myPopup->count()<1) {
77 myIDs.append ( id = myPopup->insertItem (tr ("MEN_VP3D_CHANGEBGR")) );
78 QAD_ASSERT ( myPopup->connectItem ( id, this, SLOT(onChangeBackgroundColor())) );
86 SUPERVGraph_ViewFrame::SUPERVGraph_ViewFrame(QWidget* parent, const char* name)
87 : QAD_ViewFrame(parent, name)
90 //myView = new SUPERVGraph_View(this);
91 // Set BackgroundColor
93 int R = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed").toInt();
94 int G = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen").toInt();
95 int B = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue").toInt();
96 setBackgroundColor(QColor(R,G,B));*/
98 SUPERVGraph_ViewFrame::~SUPERVGraph_ViewFrame(){}
101 Returns widget containing 3D-Viewer
103 SUPERVGraph_View* SUPERVGraph_ViewFrame::getViewWidget(){
108 void SUPERVGraph_ViewFrame::setViewWidget(SUPERVGraph_View* theView) {
111 myView->setPopupServer(myApp);
117 Display/hide Trihedron
119 void SUPERVGraph_ViewFrame::onViewTrihedron()
121 MESSAGE ( "SUPERVGraph_ViewFrame::onViewTrihedron" )
125 Provides top projection of the active view
127 void SUPERVGraph_ViewFrame::onViewTop()
129 MESSAGE ( "SUPERVGraph_ViewFrame::onViewTop" )
133 Provides bottom projection of the active view
135 void SUPERVGraph_ViewFrame::onViewBottom()
137 MESSAGE ( "SUPERVGraph_ViewFrame::onViewBottom" )
141 Provides left projection of the active view
143 void SUPERVGraph_ViewFrame::onViewLeft()
145 MESSAGE ( "SUPERVGraph_ViewFrame::onViewLeft" )
149 Provides right projection of the active view
151 void SUPERVGraph_ViewFrame::onViewRight()
153 MESSAGE ( "SUPERVGraph_ViewFrame::onViewRight" )
157 Provides back projection of the active view
159 void SUPERVGraph_ViewFrame::onViewBack()
161 MESSAGE ( "SUPERVGraph_ViewFrame::onViewBack" )
165 Provides front projection of the active view
167 void SUPERVGraph_ViewFrame::onViewFront()
169 MESSAGE ( "SUPERVGraph_ViewFrame::onViewFront" )
173 Reset the active view
175 void SUPERVGraph_ViewFrame::onViewReset()
177 MESSAGE ( "SUPERVGraph_ViewFrame::onViewReset" )
183 Rotates the active view
185 void SUPERVGraph_ViewFrame::onViewRotate()
187 MESSAGE ( "SUPERVGraph_ViewFrame::onViewRotate" )
191 Sets a new center of the active view
193 void SUPERVGraph_ViewFrame::onViewGlobalPan()
195 MESSAGE ( "SUPERVGraph_ViewFrame::onViewGlobalPan" )
199 Zooms the active view
201 void SUPERVGraph_ViewFrame::onViewZoom()
203 MESSAGE ( "SUPERVGraph_ViewFrame::onViewZoom" )
207 Moves the active view
209 void SUPERVGraph_ViewFrame::onViewPan()
211 MESSAGE ( "SUPERVGraph_ViewFrame::onViewPan" )
213 myView->ActivatePanning();
217 Fits all obejcts within a rectangular area of the active view
219 void SUPERVGraph_ViewFrame::onViewFitArea()
221 MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitArea" )
225 Fits all objects in the active view
227 void SUPERVGraph_ViewFrame::onViewFitAll()
229 MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitAll" )
233 Set background of the viewport
235 void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color)
238 myView->setPaletteBackgroundColor(color);
242 Returns background of the viewport
244 QColor SUPERVGraph_ViewFrame::backgroundColor() const
247 return myView->paletteBackgroundColor();
248 return QMainWindow::backgroundColor();
252 void SUPERVGraph_ViewFrame::SetSelectionMode( int mode )
254 MESSAGE ( "SUPERVGraph_ViewFrame::SetSelectionMode" )
257 void SUPERVGraph_ViewFrame::SetTrihedronSize( int dim )
259 MESSAGE ( "SUPERVGraph_ViewFrame::SetTrihedronSize" )
262 void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject,
265 MESSAGE ( "SUPERVGraph_ViewFrame::rename" )
268 void SUPERVGraph_ViewFrame::unHighlightAll()
270 MESSAGE ( "SUPERVGraph_ViewFrame::unHighlightAll" )
273 void SUPERVGraph_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject,
274 bool highlight, bool immediatly )
276 MESSAGE ( "SUPERVGraph_ViewFrame::highlight" )
279 bool SUPERVGraph_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject )
281 MESSAGE ( "SUPERVGraph_ViewFrame::isInViewer" )
285 bool SUPERVGraph_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject )
287 MESSAGE ( "SUPERVGraph_ViewFrame::isVisible" )
291 void SUPERVGraph_ViewFrame::setPopupServer( QAD_Application* App )
295 myView->setPopupServer(myApp);
299 void SUPERVGraph_ViewFrame::undo(SALOMEDS::Study_var aStudy,
300 const char* StudyFrameEntry)
302 MESSAGE ( "SUPERVGraph_ViewFrame::undo" )
305 void SUPERVGraph_ViewFrame::redo(SALOMEDS::Study_var aStudy,
306 const char* StudyFrameEntry)
308 MESSAGE ( "SUPERVGraph_ViewFrame::redo" )