1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "OCCViewer_ViewModel.h"
24 #include "OCCViewer_ViewFrame.h"
25 #include "OCCViewer_VService.h"
26 #include "OCCViewer_ViewPort3d.h"
27 #include "OCCViewer_ClippingDlg.h"
28 #include "OCCViewer_Utilities.h"
30 #include "SUIT_ViewWindow.h"
31 #include "SUIT_ViewManager.h"
32 #include "SUIT_Desktop.h"
33 #include "SUIT_Session.h"
34 #include "SUIT_ResourceMgr.h"
36 #include "ViewerData_AISShape.hxx"
38 #include "QtxActionToolMgr.h"
39 #include "QtxBackgroundTool.h"
42 #include <QApplication>
43 #include <QColorDialog>
44 #include <QFileDialog>
48 #include <QMouseEvent>
50 #include <QDesktopWidget>
52 #include <AIS_Axis.hxx>
53 #include <Prs3d_Drawer.hxx>
54 #include <AIS_ListIteratorOfListOfInteractive.hxx>
55 #include <StdSelect_ViewerSelector3d.hxx>
57 #include <Graphic3d_Texture2Dmanual.hxx>
58 #include <Graphic3d_MaterialAspect.hxx>
59 #include <Graphic3d_TextureParams.hxx>
61 #include <Geom_Axis2Placement.hxx>
62 #include <Prs3d_Drawer.hxx>
63 #include <Prs3d_DatumAspect.hxx>
64 #include <Prs3d_LineAspect.hxx>
65 #include <Prs3d_TextAspect.hxx>
67 #include <V3d_DirectionalLight.hxx>
68 #include <V3d_AmbientLight.hxx>
70 #include <Basics_OCCTVersion.hxx>
74 void setCappingColor(const Handle(Graphic3d_ClipPlane)& plane, const QColor& color)
76 Quantity_Color qcolor( color.redF(), color.greenF(), color.blueF(), Quantity_TOC_RGB );
77 #if OCC_VERSION_LARGE < 0x07040000
78 Graphic3d_MaterialAspect aspect;
79 aspect.SetColor( qcolor );
80 plane->SetCappingMaterial( aspect );
82 plane->SetCappingColor( qcolor );
88 Get data for supported background modes: gradient types, identifiers and supported image formats
90 QString OCCViewer_Viewer::backgroundData( QStringList& gradList, QIntList& idList, QIntList& txtList )
92 gradList << tr("GT_HORIZONTALGRADIENT") << tr("GT_VERTICALGRADIENT") <<
93 tr("GT_FIRSTDIAGONALGRADIENT") << tr("GT_SECONDDIAGONALGRADIENT") <<
94 tr("GT_FIRSTCORNERGRADIENT") << tr("GT_SECONDCORNERGRADIENT") <<
95 tr("GT_THIRDCORNERGRADIENT") << tr("GT_FORTHCORNERGRADIENT");
96 idList << HorizontalGradient << VerticalGradient <<
97 Diagonal1Gradient << Diagonal2Gradient <<
98 Corner1Gradient << Corner2Gradient <<
99 Corner3Gradient << Corner4Gradient;
100 txtList << Qtx::CenterTexture << Qtx::TileTexture << Qtx::StretchTexture;
101 return tr("BG_IMAGE_FILES");
105 Get data for supported stereo pair modes: stereo types and identifiers
107 void OCCViewer_Viewer::stereoData( QStringList& typeList, QIntList& idList)
109 typeList << tr("ST_QUADBUFFER") << tr("ST_ANAGLYPH") <<
110 tr("ST_ROWINTERLACED") << tr("ST_COLUMNINTERLACED") <<
111 tr("ST_CHESSBOARD") << tr("ST_SIDEBYSIDE") <<
113 idList << QuadBufferType << AnaglyphType <<
114 RowInterlacedType << ColumnInterlacedType <<
115 ChessBoardType << SideBySideType <<
121 \param DisplayTrihedron - is trihedron displayed
123 OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
127 myTrihedronSize(100),
128 myBackgrounds(4, Qtx::BackgroundData(Qt::black)),
132 // init CasCade viewers
133 myV3dViewer = OCCViewer_VService::CreateViewer();
134 //myV3dViewer->Init(); // to avoid creation of the useless perspective view (see OCCT issue 0024267)
138 myAISContext = new AIS_InteractiveContext( myV3dViewer );
139 myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_LocalSelected)->SetColor( Quantity_NOC_WHITE );
140 myAISContext->HighlightStyle(Prs3d_TypeOfHighlight_Selected)->SetColor( Quantity_NOC_WHITE );
142 // display isoline on planar faces (box for ex.)
143 myAISContext->IsoOnPlane( true );
145 // create color scale
146 myColorScale = new AIS_ColorScale();
147 myColorScale->SetZLayer( Graphic3d_ZLayerId_TopOSD );
148 myColorScale->SetTransformPersistence( Graphic3d_TransformPers::FromDeprecatedParams( Graphic3d_TMF_2d, gp_Pnt(-1, -1, 0) ) );
150 /* create trihedron */
151 if ( DisplayTrihedron )
153 Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement(gp::XOY());
154 myTrihedron = new AIS_Trihedron(anAxis);
155 myTrihedron->SetInfiniteState( Standard_True );
157 Quantity_Color Col(193/255., 205/255., 193/255., Quantity_TOC_RGB);
158 //myTrihedron->SetColor( Col );
159 myTrihedron->SetArrowColor( Col.Name() );
160 myTrihedron->SetSize(100);
161 Handle(Prs3d_Drawer) drawer = myTrihedron->Attributes();
162 if (drawer->HasOwnDatumAspect()) {
163 Handle(Prs3d_DatumAspect) daspect = drawer->DatumAspect();
164 daspect->LineAspect(Prs3d_DP_XAxis)->SetColor(Quantity_Color(1.0, 0.0, 0.0, Quantity_TOC_RGB));
165 daspect->LineAspect(Prs3d_DP_YAxis)->SetColor(Quantity_Color(0.0, 1.0, 0.0, Quantity_TOC_RGB));
166 daspect->LineAspect(Prs3d_DP_ZAxis)->SetColor(Quantity_Color(0.0, 0.0, 1.0, Quantity_TOC_RGB));
170 // set interaction style to standard
171 myInteractionStyle = 0;
173 // set zooming style to standard
177 myPreselectionEnabled = true;
180 mySelectionEnabled = true;
181 myMultiSelectionEnabled = true;
183 // set projection type to orthographic
184 myProjectionType = 0;
185 mySelectionStyle = OCCViewer_ViewWindow::RectStyle;
186 // set stereo parameters
188 myAnaglyphFilter = 0;
189 myToReverseStereo = 0;
191 myQuadBufferSupport = 0;
192 myStereographicFocusType = 1;
193 myInterocularDistanceType = 1;
194 myStereographicFocusValue = 1.0;
195 myInterocularDistanceValue = 0.05;
196 //set clipping color and texture to standard
197 myClippingColor = QColor( 50, 50, 50 );
198 myDefaultTextureUsed = true;
199 myClippingTexture = QString();
200 myTextureModulated = true;
201 myClippingTextureScale = 1.0;
208 OCCViewer_Viewer::~OCCViewer_Viewer()
210 myAISContext.Nullify();
211 myV3dViewer.Nullify();
216 \return background color of viewer
218 QColor OCCViewer_Viewer::backgroundColor() const
220 return backgroundColor(0);
224 \return background data of viewer
226 Qtx::BackgroundData OCCViewer_Viewer::background() const
228 return background(0);
232 Sets background color [obsolete]
233 \param c - new background color
235 void OCCViewer_Viewer::setBackgroundColor( const QColor& c )
237 setBackgroundColor( 0, c );
242 \param d - new background data
244 void OCCViewer_Viewer::setBackground( const Qtx::BackgroundData& theBackground )
246 setBackground( 0, theBackground );
250 Start initialization of view window
251 \param view - view window to be initialized
253 void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view )
257 view->initSketchers();
258 view->setInteractionStyle( interactionStyle() );
259 view->setProjectionType( projectionType() );
260 view->setSelectionStyle( selectionStyle() );
261 view->setStereoType( stereoType() );
262 view->setAnaglyphFilter( anaglyphFilter() );
263 view->setStereographicFocus( stereographicFocusType(), stereographicFocusValue() );
264 view->setInterocularDistance( interocularDistanceType(), interocularDistanceValue() );
265 view->setReverseStereo( isReverseStereo() );
266 view->setVSync( isVSync() );
267 view->setQuadBufferSupport( isQuadBufferSupport() );
268 view->setZoomingStyle( zoomingStyle() );
269 view->enablePreselection( isPreselectionEnabled() );
270 view->enableSelection( isSelectionEnabled() );
272 OCCViewer_ViewPort3d* vp3d = view->getViewPort();
275 // connect signal from viewport
276 connect(vp3d, SIGNAL(vpClosed(OCCViewer_ViewPort3d*)), this, SLOT(onViewClosed(OCCViewer_ViewPort3d*)));
277 connect(vp3d, SIGNAL(vpMapped(OCCViewer_ViewPort3d*)), this, SLOT(onViewMapped(OCCViewer_ViewPort3d*)));
283 Creates new view window
284 \param theDesktop - main window of application
286 SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop )
289 OCCViewer_ViewFrame* view = new OCCViewer_ViewFrame(theDesktop, this);
290 // get main view window (created by view frame)
291 OCCViewer_ViewWindow* vw = view->getView(OCCViewer_ViewFrame::MAIN_VIEW);
292 // initialize main view window
294 // set default background for view window
295 vw->setBackground( background(0) ); // 0 means MAIN_VIEW (other views are not yet created here)
301 Sets new view manager
302 \param theViewManager - new view manager
304 void OCCViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
306 SUIT_ViewModel::setViewManager(theViewManager);
307 if (theViewManager) {
308 connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
309 this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
311 connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)),
312 this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
314 connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
315 this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
317 connect(theViewManager, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)),
318 this, SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*)));
323 SLOT: called on mouse button press, stores current mouse position as start point for transformations
325 void OCCViewer_Viewer::onMousePress(SUIT_ViewWindow* /*theWindow*/, QMouseEvent* theEvent)
327 myStartPnt.setX(theEvent->x()); myStartPnt.setY(theEvent->y());
331 SLOT: called on mouse move, processes transformation or hilighting
333 void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
335 if (!mySelectionEnabled) return;
336 if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
338 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
340 myCurPnt.setX(theEvent->x()); myCurPnt.setY(theEvent->y());
342 if ( isSelectionEnabled() && isPreselectionEnabled() ) {
343 if (aView->getViewPort()->isBusy()) {
344 QCoreApplication::processEvents();
345 return; // Check that the ViewPort initialization completed
346 // To Prevent call move event if the View port is not initialized
349 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
350 if ( !aView3d.IsNull() ) {
351 myAISContext->MoveTo( theEvent->x(), theEvent->y(), aView3d, Standard_True );
358 SLOT: called on mouse button release, finishes transformation or selection
360 void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent)
362 if (!mySelectionEnabled) return;
363 if (theEvent->button() != Qt::LeftButton) return;
364 if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
366 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
370 myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y());
371 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
373 if (myStartPnt == myEndPnt)
376 myAISContext->ClearCurrents( false ); // todo: ClearCurrents is deprecated
379 if ( !isPreselectionEnabled() ) {
380 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
381 if ( !aView3d.IsNull() ) {
382 myAISContext->MoveTo( myEndPnt.x(), myEndPnt.y(), aView3d, Standard_True );
386 if (aHasShift && myMultiSelectionEnabled)
387 myAISContext->ShiftSelect( Standard_True );
389 myAISContext->Select( Standard_True );
390 emit selectionChanged();
395 // if (aHasShift && myMultiSelectionEnabled)
396 // myAISContext->ShiftSelect(myStartPnt.x(), myStartPnt.y(),
397 // myEndPnt.x(), myEndPnt.y(),
398 // aView->getViewPort()->getView(), Standard_False );
400 // myAISContext->Select(myStartPnt.x(), myStartPnt.y(),
401 // myEndPnt.x(), myEndPnt.y(),
402 // aView->getViewPort()->getView(), Standard_False );
404 // int Nb = myAISContext->NbSelected();
405 // if( Nb>1 && !myMultiSelectionEnabled )
407 // myAISContext->InitSelected();
408 // Handle( SelectMgr_EntityOwner ) anOwner = myAISContext->SelectedOwner();
409 // if( !anOwner.IsNull() )
411 // myAISContext->ClearSelected( Standard_False );
412 // myAISContext->AddOrRemoveSelected( anOwner, Standard_False );
416 // myAISContext->UpdateCurrentViewer();
421 SLOT: called on key press, processes selection in "key free" interaction style
423 void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEvent)
425 if (!mySelectionEnabled) return;
427 OCCViewer_ViewWindow* aView = qobject_cast<OCCViewer_ViewWindow*>( theWindow );
428 if ( !aView ) return;
430 bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
432 switch ( theEvent->key() ) {
435 myAISContext->ClearCurrents( false ); // todo: ClearCurrents is deprecated
439 if ( !isPreselectionEnabled() ) {
440 Handle(V3d_View) aView3d = aView->getViewPort()->getView();
441 if ( !aView3d.IsNull() ) {
442 myAISContext->MoveTo(myCurPnt.x(), myCurPnt.y(), aView3d, Standard_True );
446 if (aHasShift && myMultiSelectionEnabled)
447 myAISContext->ShiftSelect( Standard_True );
449 myAISContext->Select( Standard_True );
451 emit selectionChanged();
455 if ( isPreselectionEnabled() ) {
456 getAISContext()->HilightNextDetected( aView->getViewPort()->getView() );
460 if ( isPreselectionEnabled() ) {
461 getAISContext()->HilightPreviousDetected( aView->getViewPort()->getView() );
469 void OCCViewer_Viewer::onViewClosed(OCCViewer_ViewPort3d*)
471 Standard_Integer aViewsNb = 0;
472 for ( myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews(); myV3dViewer->NextActiveViews())
474 if ( aViewsNb < 2 ) {
475 //clean up presentations before last view is closed
476 myAISContext->RemoveAll(Standard_False);
480 void OCCViewer_Viewer::onViewMapped(OCCViewer_ViewPort3d* viewPort)
482 setTrihedronShown( true );
483 bool showStaticTrihedron = true;
484 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
485 if ( resMgr ) showStaticTrihedron = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
486 viewPort->showStaticTrihedron( showStaticTrihedron );
489 int OCCViewer_Viewer::getTopLayerId()
491 if ( myTopLayerId == 0 && !myAISContext->CurrentViewer().IsNull() )
492 myAISContext->CurrentViewer()->AddZLayer( myTopLayerId );
498 \return interaction style
500 int OCCViewer_Viewer::interactionStyle() const
502 return myInteractionStyle;
506 Sets interaction style: 0 - standard, 1 - keyboard free interaction
507 \param theStyle - new interaction style
509 void OCCViewer_Viewer::setInteractionStyle( const int theStyle )
511 myInteractionStyle = theStyle;
512 //!! To be done for view windows
513 if ( !myViewManager )
516 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
517 for ( int i = 0; i < (int)wins.count(); i++ )
519 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
521 win->setInteractionStyle( theStyle );
526 \return projection type
528 int OCCViewer_Viewer::projectionType() const
530 return myProjectionType;
534 Sets projection type: 0 - orthographic, 1 - perspective
535 \param theType - new projection type
537 void OCCViewer_Viewer::setProjectionType( const int theType )
539 if ( myProjectionType != theType ) {
540 if ( theType != OCCViewer_ViewWindow::Stereo )
541 myProjectionType = theType;
543 if ( !myViewManager )
546 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
547 for ( int i = 0; i < (int)wins.count(); i++ )
549 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
551 win->setProjectionType( (OCCViewer_ViewWindow::ProjectionType)theType );
557 OCCViewer_ViewWindow::SelectionStyle OCCViewer_Viewer::selectionStyle() const
559 return mySelectionStyle;
562 void OCCViewer_Viewer::setSelectionStyle(OCCViewer_ViewWindow::SelectionStyle theMode)
564 if (mySelectionStyle != theMode) {
565 mySelectionStyle = theMode;
569 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
570 for (int i = 0; i < (int)wins.count(); i++)
572 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>(wins.at(i));
574 win->setSelectionStyle(theMode);
584 int OCCViewer_Viewer::stereoType() const
591 \param theType - new stereo type
593 void OCCViewer_Viewer::setStereoType( const int theType )
595 myStereoType = theType;
597 if ( !myViewManager )
600 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
601 for ( int i = 0; i < (int)wins.count(); i++ )
603 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
605 win->setStereoType( (OCCViewer_ViewWindow::StereoType)theType );
610 \return stereographic focus type
612 int OCCViewer_Viewer::stereographicFocusType() const
614 return myStereographicFocusType;
618 \return stereographic focus value
620 double OCCViewer_Viewer::stereographicFocusValue() const
622 return myStereographicFocusValue;
626 Sets stereographic focus parameters
627 \param theType - new stereographic focus type
628 \param theValue - new stereographic focus value
630 void OCCViewer_Viewer::setStereographicFocus( const int theType, const double theValue )
632 myStereographicFocusType = theType;
633 myStereographicFocusValue = theValue;
635 if ( !myViewManager )
638 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
639 for ( int i = 0; i < (int)wins.count(); i++ )
641 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
643 win->setStereographicFocus( (OCCViewer_ViewWindow::FocusIODType)theType, theValue );
648 \return stereographic focus type
650 int OCCViewer_Viewer::interocularDistanceType() const
652 return myInterocularDistanceType;
656 \return stereographic focus value
658 double OCCViewer_Viewer::interocularDistanceValue() const
660 return myInterocularDistanceValue;
664 Sets interocular distance parameters
665 \param theType - new IOD type
666 \param theValue - new IOD value
668 void OCCViewer_Viewer::setInterocularDistance( const int theType, const double theValue )
670 myInterocularDistanceType = theType;
671 myInterocularDistanceValue = theValue;
673 if ( !myViewManager )
676 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
677 for ( int i = 0; i < (int)wins.count(); i++ )
679 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
681 win->setInterocularDistance( (OCCViewer_ViewWindow::FocusIODType)theType, theValue );
686 \return anaglyph filter
688 int OCCViewer_Viewer::anaglyphFilter() const
690 return myAnaglyphFilter;
695 \param theType - new anaglyph filter
697 void OCCViewer_Viewer::setAnaglyphFilter( const int theType )
699 myAnaglyphFilter = theType;
701 if ( !myViewManager )
704 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
705 for ( int i = 0; i < (int)wins.count(); i++ )
707 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
709 win->setAnaglyphFilter( (OCCViewer_ViewWindow::AnaglyphFilter)theType );
714 \return reverse stereo
716 bool OCCViewer_Viewer::isReverseStereo() const
718 return myToReverseStereo;
723 \param theReverse - enable/disable reverse mode
725 void OCCViewer_Viewer::setReverseStereo( const bool theReverse )
727 myToReverseStereo = theReverse;
729 if ( !myViewManager )
732 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
733 for ( int i = 0; i < (int)wins.count(); i++ )
735 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
737 win->setReverseStereo( theReverse );
744 bool OCCViewer_Viewer::isVSync() const
751 \param theEnable - enable/disable V-Sync mode
753 void OCCViewer_Viewer::setVSync( const bool theEnable )
755 myVSyncMode = theEnable;
757 if ( !myViewManager )
760 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
761 for ( int i = 0; i < (int)wins.count(); i++ )
763 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
765 win->setVSync( theEnable );
770 \return support quad-buffered stereo
772 bool OCCViewer_Viewer::isQuadBufferSupport() const
774 return myQuadBufferSupport;
778 Set support quad-buffered stereo
779 \param theEnable - enable/disable support quad-buffered stereo
781 void OCCViewer_Viewer::setQuadBufferSupport( const bool theEnable )
783 myQuadBufferSupport = theEnable;
785 if ( !myViewManager )
788 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
789 for ( int i = 0; i < (int)wins.count(); i++ )
791 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
793 win->setQuadBufferSupport( theEnable );
798 \return zooming style
800 int OCCViewer_Viewer::zoomingStyle() const
802 return myZoomingStyle;
806 Sets zooming style: 0 - standard, 1 - advanced (at cursor)
807 \param theStyle - new zooming style
809 void OCCViewer_Viewer::setZoomingStyle( const int theStyle )
811 myZoomingStyle = theStyle;
812 //!! To be done for view windows
813 if ( !myViewManager )
816 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
817 for ( int i = 0; i < (int)wins.count(); i++ )
819 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
821 win->setZoomingStyle( theStyle );
826 \return true if preselection is enabled
828 bool OCCViewer_Viewer::isPreselectionEnabled() const
830 return myPreselectionEnabled;
834 Enables/disables preselection
835 \param isEnabled - new status
837 void OCCViewer_Viewer::enablePreselection(bool isEnabled)
839 myPreselectionEnabled = isEnabled;
841 if ( !myViewManager )
844 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
845 for ( int i = 0; i < (int)wins.count(); i++ )
847 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
849 win->enablePreselection( isEnabled );
855 \return true if selection is enabled
857 bool OCCViewer_Viewer::isSelectionEnabled() const
859 return mySelectionEnabled;
863 Enables/disables selection
864 \param isEnabled - new status
866 void OCCViewer_Viewer::enableSelection(bool isEnabled)
868 mySelectionEnabled = isEnabled;
870 //!! To be done for view windows
871 if ( !myViewManager )
874 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
875 for ( int i = 0; i < (int)wins.count(); i++ )
877 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
879 win->updateEnabledDrawMode();
880 win->enableSelection( isEnabled );
885 //clear current selection in the viewer
887 myAISContext->ClearSelected( Standard_True );
893 Sets multiselection enabled status
894 \param isEnabled - new status
896 void OCCViewer_Viewer::enableMultiselection(bool isEnable)
898 myMultiSelectionEnabled = isEnable;
899 //!! To be done for view windows
900 if ( !myViewManager )
903 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
904 for ( int i = 0; i < (int)wins.count(); i++ )
906 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
908 win->updateEnabledDrawMode();
913 Sets a color of the clipped region
914 \param theColor - a new color of the clipped region
916 void OCCViewer_Viewer::setClippingColor( const QColor& theColor )
918 myClippingColor = theColor;
920 if( myInternalClipPlanes.IsEmpty() )
923 for ( Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt ( myInternalClipPlanes ); aPlaneIt.More(); aPlaneIt.Next() )
924 setCappingColor( aPlaneIt.Value(), theColor );
930 \return clipping color
932 QColor OCCViewer_Viewer::clippingColor() const
934 return myClippingColor;
937 // initialize a texture for clipped region
938 Handle(Graphic3d_Texture2Dmanual) initClippingTexture( const bool isDefault, const QString& theTexture,
939 const bool isModulate, const double theScale )
941 QString aTextureFile = isDefault ? ":images/hatch.png" : theTexture;
942 QPixmap px( aTextureFile );
943 const Handle(Image_PixMap) aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() );
944 Handle(Graphic3d_Texture2Dmanual) aTexture = new Graphic3d_Texture2Dmanual( aPixmap );
945 if( aTexture->IsDone() ) {
946 aTexture->EnableRepeat();
947 isModulate ? aTexture->EnableModulate() : aTexture->DisableModulate();
948 aTexture->GetParams()->SetScale( Graphic3d_Vec2( 1/( theScale*100 ), -1 / ( theScale*100 ) ) );
954 Sets default texture parameters
955 \param isDefault - use/non-use default texture
956 \param theTexture - new texture of the clipped region
957 \param isModulate - enable/disable texture modulate mode
958 \param theScale - scale factor.
960 void OCCViewer_Viewer::setClippingTextureParams( const bool isDefault, const QString& theTexture,
961 const bool isModulate, const double theScale )
963 myDefaultTextureUsed = isDefault;
964 myClippingTexture = theTexture;
965 myTextureModulated = isModulate;
966 myClippingTextureScale = theScale;
968 if( myInternalClipPlanes.IsEmpty() )
971 Handle(Graphic3d_Texture2Dmanual) aTexture =
972 initClippingTexture( myDefaultTextureUsed, myClippingTexture,
973 myTextureModulated, myClippingTextureScale );
974 for ( Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt ( myInternalClipPlanes ); aPlaneIt.More(); aPlaneIt.Next() )
975 aPlaneIt.Value()->SetCappingTexture( aTexture );
981 \return true if default texture is used
983 bool OCCViewer_Viewer::isDefaultTextureUsed() const
985 return myDefaultTextureUsed;
989 \return clipping texture
991 QString OCCViewer_Viewer::clippingTexture() const
993 return myClippingTexture;
997 \return true if texture is modulated
999 bool OCCViewer_Viewer::isTextureModulated() const
1001 return myTextureModulated;
1005 \return scale factor of texture
1007 double OCCViewer_Viewer::clippingTextureScale() const
1009 return myClippingTextureScale;
1013 Builds popup for occ viewer
1015 void OCCViewer_Viewer::contextMenuPopup(QMenu* thePopup)
1017 thePopup->addAction( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
1018 thePopup->addAction( tr( "MEN_CHANGE_BACKGROUND" ), this, SLOT( onChangeBackground() ) );
1020 thePopup->addSeparator();
1022 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1024 //Support of several toolbars in the popup menu
1025 QList<QToolBar*> lst = aView->findChildren<QToolBar*>();
1026 QList<QToolBar*>::const_iterator it = lst.begin(), last = lst.end();
1027 for ( ; it!=last; it++ ) {
1028 if ( (*it)->parentWidget()->isVisible() )
1029 thePopup->addAction( (*it)->toggleViewAction() );
1034 SLOT: called on dump view operation is activated, stores scene to raster file
1036 void OCCViewer_Viewer::onDumpView()
1038 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1040 aView->onDumpView();
1044 SLOT: called if background color is to be changed changed, passes new color to view port
1046 void OCCViewer_Viewer::onChangeBackground()
1048 OCCViewer_ViewWindow* aView = dynamic_cast<OCCViewer_ViewWindow*>(myViewManager->getActiveView());
1052 // get supported gradient types
1053 QStringList gradList;
1054 QIntList idList, txtList;
1055 QString formats = backgroundData( gradList, idList, txtList );
1057 // invoke dialog box
1058 Qtx::BackgroundData bgData = QtxBackgroundDialog::getBackground( aView->background(), // initial background
1059 aView, // parent for dialog box
1060 txtList, // allowed texture modes
1061 true, // enable solid color mode
1062 true, // enable gradient mode
1063 false, // disable custom gradient mode
1064 !txtList.isEmpty(), // enable/disable texture mode
1065 gradList, // gradient names
1066 idList, // gradient identifiers
1067 formats ); // image formats
1069 // set chosen background data to the viewer
1070 if ( bgData.isValid() )
1071 aView->setBackground( bgData );
1075 Updates OCC 3D viewer
1077 void OCCViewer_Viewer::update()
1079 if (!myV3dViewer.IsNull())
1080 myV3dViewer->Update();
1082 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1084 aView->updateGravityCoords();
1088 \return objects selected in 3D viewer
1089 \param theList - list to be filled with selected objects
1091 void OCCViewer_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList)
1094 for (myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())
1095 theList.Append(myAISContext->SelectedInteractive());
1099 Selects objects in 3D viewer. Other selected objects are left as selected
1100 \param theList - list objects to be selected
1102 void OCCViewer_Viewer::setObjectsSelected(const AIS_ListOfInteractive& theList)
1104 AIS_ListIteratorOfListOfInteractive aIt;
1105 for (aIt.Initialize(theList); aIt.More(); aIt.Next())
1106 myAISContext->AddOrRemoveSelected(aIt.Value(), false);
1107 myAISContext->UpdateCurrentViewer();
1111 Auxiliary method to emit signal selectionChanged()
1113 void OCCViewer_Viewer::performSelectionChanged()
1115 emit selectionChanged();
1119 * Defines default lights
1121 void OCCViewer_Viewer::setDefaultLights()
1123 // clear all light sources
1124 myV3dViewer->InitDefinedLights();
1125 while ( myV3dViewer->MoreDefinedLights() )
1127 myV3dViewer->DelLight( myV3dViewer->DefinedLight() );
1128 myV3dViewer->InitDefinedLights();
1131 // get light source parameters from preferences
1132 QColor aColor = SUIT_Session::session()->resourceMgr()->colorValue( "OCCViewer", "light_color", QColor( 0, 0, 0 ) );
1133 double aDx = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dx", 0.0 );
1134 double aDy = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dy", 0.0 );
1135 double aDz = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dz", -1.0 );
1137 Handle(V3d_DirectionalLight) aLight =
1138 new V3d_DirectionalLight( V3d_Zneg, OCCViewer::color( aColor ).Name(), Standard_True );
1139 myV3dViewer->AddLight( aLight );
1140 if( !( aDx == 0 && aDy == 0 && aDz == 0 ) )
1141 aLight->SetDirection( aDx, aDy, aDz );
1142 myV3dViewer->SetLightOn( aLight );
1143 Handle(V3d_AmbientLight) ambLight = new V3d_AmbientLight();
1144 myV3dViewer->AddLight( ambLight );
1145 myV3dViewer->SetLightOn( ambLight );
1149 Hilights/unhilights object in viewer
1150 \param obj - object to be updated
1151 \param hilight - if it is true, object will be hilighted, otherwise it will be unhilighted
1152 \param update - update current viewer
1154 bool OCCViewer_Viewer::highlight( const Handle(AIS_InteractiveObject)& obj,
1155 bool hilight, bool update )
1157 if( !obj.IsNull() ) {
1158 if ( hilight && !myAISContext->IsSelected( obj ) )
1159 myAISContext->AddOrRemoveSelected( obj, false );
1160 else if ( !hilight && myAISContext->IsSelected( obj ) )
1161 myAISContext->AddOrRemoveSelected( obj, false );
1165 myV3dViewer->Redraw();
1171 Unhilights all objects in viewer
1172 \param updateviewer - update current viewer
1174 bool OCCViewer_Viewer::unHighlightAll( bool updateviewer, bool unselect )
1177 myAISContext->ClearSelected( updateviewer );
1179 myAISContext->UnhilightSelected( updateviewer );
1185 \return true if object is in viewer or in collector
1186 \param obj - object to be checked
1187 \param onlyInViewer - search object only in viewer (so object must be displayed)
1189 bool OCCViewer_Viewer::isInViewer( const Handle(AIS_InteractiveObject)& obj,
1190 bool /*onlyInViewer*/ )
1192 AIS_ListOfInteractive List;
1193 myAISContext->DisplayedObjects(List);
1195 AIS_ListIteratorOfListOfInteractive ite(List);
1196 for ( ; ite.More(); ite.Next() )
1197 if( ite.Value()==obj )
1204 \return true if object is displayed in viewer
1205 \param obj - object to be checked
1207 bool OCCViewer_Viewer::isVisible( const Handle(AIS_InteractiveObject)& obj )
1209 return myAISContext->IsDisplayed( obj );
1213 Sets color of object
1214 \param obj - object to be updated
1215 \param color - new color
1216 \param update - update current viewer
1218 void OCCViewer_Viewer::setColor( const Handle(AIS_InteractiveObject)& obj,
1219 const QColor& color,
1224 Quantity_Color CSFColor = Quantity_Color ( color.red() / 255.,
1225 color.green() / 255.,
1226 color.blue() / 255.,
1228 obj->SetColor( CSFColor );
1232 myV3dViewer->Update();
1236 Changes display mode of object
1237 \param obj - object to be processed
1238 \param mode - new display mode
1239 \param update - update current viewer
1241 void OCCViewer_Viewer::switchRepresentation( const Handle(AIS_InteractiveObject)& obj,
1242 int mode, bool update )
1244 myAISContext->SetDisplayMode( obj, (Standard_Integer)mode, update );
1246 myV3dViewer->Update();
1250 Changes transparency of object
1251 \param obj - object to be processed
1252 \param trans - new transparency
1253 \param update - update current viewer
1255 void OCCViewer_Viewer::setTransparency( const Handle(AIS_InteractiveObject)& obj,
1256 float trans, bool update )
1258 myAISContext->SetTransparency( obj, trans, false );
1259 myAISContext->Redisplay( obj, Standard_False, Standard_True );
1261 myV3dViewer->Update();
1264 bool OCCViewer_Viewer::isColorScaleVisible() const
1266 return !myColorScale.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myColorScale );
1269 void OCCViewer_Viewer::setColorScaleShown( const bool on )
1271 if ( myColorScale.IsNull() )
1275 if ( !myAISContext->IsDisplayed( myColorScale ) )
1276 myAISContext->Display( myColorScale, Standard_True );
1277 myAISContext->Redisplay( myColorScale, Standard_True, Standard_True );
1281 if ( myAISContext->IsDisplayed( myColorScale ) )
1282 myAISContext->Erase( myColorScale, Standard_True );
1287 Changes visibility of trihedron to opposite
1289 void OCCViewer_Viewer::toggleTrihedron()
1291 setTrihedronShown( !isTrihedronVisible() );
1295 \return true if trihedron is visible
1297 bool OCCViewer_Viewer::isTrihedronVisible() const
1299 return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myTrihedron );
1303 Sets visibility state of trihedron
1304 \param on - new state
1307 void OCCViewer_Viewer::setTrihedronShown( const bool on )
1309 if ( myTrihedron.IsNull() )
1313 myAISContext->Display( myTrihedron,
1315 -1 /* selection mode */,
1316 Standard_True /* update viewer*/,
1317 AIS_DS_Displayed /* display status */);
1318 myAISContext->Deactivate( myTrihedron );
1321 myAISContext->Erase( myTrihedron , Standard_True );
1326 \return trihedron size
1328 double OCCViewer_Viewer::trihedronSize() const
1331 if ( !myTrihedron.IsNull() )
1332 sz = myTrihedron->Size();
1337 Changes trihedron size
1338 \param sz - new size
1340 void OCCViewer_Viewer::setTrihedronSize( const double sz, bool isRelative )
1342 if ( myTrihedronSize != sz || isRelative != myIsRelative) {
1343 myTrihedronSize = sz;
1344 myIsRelative = isRelative;
1350 Set number of isolines
1351 \param u - u-isolines (first parametric co-ordinate)
1352 \param v - v-isolines (second parametric co-ordinate)
1354 void OCCViewer_Viewer::setIsos( const int u, const int v )
1356 Handle(AIS_InteractiveContext) ic = getAISContext();
1360 ic->SetIsoNumber( u, AIS_TOI_IsoU );
1361 ic->SetIsoNumber( v, AIS_TOI_IsoV );
1365 \return number of isolines
1366 \param u - to return u-isolines (first parametric co-ordinate)
1367 \param v - to return v-isolines (second parametric co-ordinate)
1369 void OCCViewer_Viewer::isos( int& u, int& v ) const
1371 Handle(AIS_InteractiveContext) ic = getAISContext();
1374 u = ic->IsoNumber( AIS_TOI_IsoU );
1375 v = ic->IsoNumber( AIS_TOI_IsoV );
1380 * Returns a new OCCViewer_ViewWindow instance which will be placed as a sub window in ViewFrame
1382 OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow()
1384 return new OCCViewer_ViewWindow(0, this);
1388 QColor OCCViewer_Viewer::backgroundColor( int theViewId ) const
1390 return background( theViewId ).color();
1393 Qtx::BackgroundData OCCViewer_Viewer::background( int theViewId ) const
1395 return ( theViewId >= 0 && theViewId < myBackgrounds.count() ) ? myBackgrounds[theViewId] : Qtx::BackgroundData();
1399 void OCCViewer_Viewer::setBackgroundColor( int theViewId, const QColor& theColor )
1401 if ( theColor.isValid() ) {
1402 Qtx::BackgroundData bg = background( theViewId );
1403 bg.setColor( theColor );
1404 setBackground( theViewId, bg );
1408 void OCCViewer_Viewer::setBackground( int theViewId, const Qtx::BackgroundData& theBackground )
1410 if ( theBackground.isValid() && theViewId >= 0 && theViewId < myBackgrounds.count() )
1411 myBackgrounds[theViewId] = theBackground;
1416 Set the show static trihedron flag
1418 void OCCViewer_Viewer::setStaticTrihedronDisplayed(const bool on)
1420 OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
1421 if ( aView ) aView->showStaticTrihedron( on );
1425 Get new and current trihedron size corresponding to the current model size
1427 bool OCCViewer_Viewer::computeTrihedronSize( double& theNewSize, double& theSize )
1432 //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization
1433 Handle(V3d_Viewer) viewer = getViewer3d();
1434 viewer->InitActiveViews();
1435 if(!viewer->MoreActiveViews()) return false;
1437 Handle(V3d_View) view3d = viewer->ActiveView();
1440 if ( view3d.IsNull() )
1443 double aMaxSide = computeSceneSize( view3d );
1446 // The boundary box of the view may be initialized but nullified
1447 // (case of infinite objects)
1448 if ( aMaxSide < Precision::Confusion() )
1451 float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("3DViewer","trihedron_size", 100.);
1453 static float EPS = 5.0E-3f;
1454 theSize = getTrihedron()->Size();
1455 theNewSize = aMaxSide*aSizeInPercents / 100.0;
1457 return fabs( theNewSize - theSize ) > theSize * EPS ||
1458 fabs( theNewSize - theSize ) > theNewSize * EPS;
1462 * Compute scene size
1464 double OCCViewer_Viewer::computeSceneSize(const Handle(V3d_View)& view3d) const
1466 double aMaxSide = 0;
1467 double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0;
1469 Bnd_Box aBox = view3d->View()->MinMaxValues();
1470 Xmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().X();
1471 Ymin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Y();
1472 Zmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Z();
1473 Xmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().X();
1474 Ymax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Y();
1475 Zmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Z();
1477 if ( Xmin != RealFirst() && Ymin != RealFirst() && Zmin != RealFirst() &&
1478 Xmax != RealLast() && Ymax != RealLast() && Zmax != RealLast() )
1480 aMaxSide = Xmax - Xmin;
1481 if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin;
1482 if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin;
1489 * Update the size of the trihedron
1491 void OCCViewer_Viewer::updateTrihedron() {
1492 if ( myTrihedron.IsNull() )
1496 double newSz, oldSz;
1498 if(computeTrihedronSize(newSz, oldSz))
1499 myTrihedron->SetSize(newSz);
1501 } else if(myTrihedron->Size() != myTrihedronSize) {
1502 myTrihedron->SetSize(myTrihedronSize);
1507 Set number of isolines
1508 \param u - u-isolines (first parametric co-ordinate)
1509 \param v - v-isolines (second parametric co-ordinate)
1511 void OCCViewer_Viewer::setSelectionOptions( bool isPreselectionEnabled, bool isSelectionEnabled )
1513 myPreselectionEnabled = isPreselectionEnabled;
1514 mySelectionEnabled = isSelectionEnabled;
1515 //clear current selection in the viewer
1517 if(!mySelectionEnabled) {
1518 myAISContext->ClearSelected( Standard_True );
1523 Creates clipping plane based on the incoming plane
1525 Handle(Graphic3d_ClipPlane) OCCViewer_Viewer::createClipPlane(const gp_Pln& thePlane, const Standard_Boolean theIsOn)
1527 Handle(Graphic3d_ClipPlane) aGraphic3dPlane = new Graphic3d_ClipPlane( thePlane );
1528 aGraphic3dPlane->SetOn( theIsOn );
1529 aGraphic3dPlane->SetCapping( Standard_True );
1531 // set capping color
1532 setCappingColor( aGraphic3dPlane, myClippingColor );
1534 // set capping texture
1535 aGraphic3dPlane->SetCappingTexture( initClippingTexture( myDefaultTextureUsed, myClippingTexture,
1536 myTextureModulated, myClippingTextureScale ) );
1538 return aGraphic3dPlane;
1541 Applies clipping planes to clippable objects
1543 void OCCViewer_Viewer::setClipPlanes(ClipPlanesList theList)
1545 // 1. Remove existing clipping planes
1546 myClipPlanes.clear();
1547 myInternalClipPlanes.Clear();
1549 // 2. Create new clipping planes
1550 ClipPlanesList::iterator inIt = theList.begin();
1551 for (;inIt != theList.end(); inIt++ )
1553 OCCViewer_ClipPlane aPlane = *inIt;
1555 double aDx = 0.0, aDy = 0.0, aDz = 0.0;
1556 aPlane.OrientationToXYZ( aDx, aDy, aDz );
1558 gp_Pnt anOrigin( aPlane.X, aPlane.Y, aPlane.Z );
1559 gp_Dir aDirection( aDx, aDy, aDz );
1561 myInternalClipPlanes.Append( createClipPlane( gp_Pln( anOrigin, aDirection ), aPlane.IsOn ) );
1562 myClipPlanes.push_back( aPlane );
1565 // 3. Apply clipping planes
1566 AIS_ListOfInteractive aList;
1567 myAISContext->DisplayedObjects (aList);
1568 for ( AIS_ListIteratorOfListOfInteractive anIter (aList); anIter.More(); anIter.Next() ) {
1569 Handle(AIS_InteractiveObject) anObj = anIter.Value();
1570 Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (anObj);
1571 if (!aShape.IsNull() && aShape->IsClippable()) {
1572 aShape->SetClipPlanes(new Graphic3d_SequenceOfHClipPlane(myInternalClipPlanes)); // todo: store clipping planes in a handle?
1578 Returns the clipping planes applied to the displayed objects.
1580 ClipPlanesList OCCViewer_Viewer::getClipPlanes() const {
1581 return myClipPlanes;
1584 Applies clipping planes to given object objects
1586 void OCCViewer_Viewer::applyExistingClipPlanesToObject (const Handle(AIS_InteractiveObject)& theObject)
1588 Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (theObject);
1589 if (!aShape.IsNull() && aShape->IsClippable())
1591 aShape->SetClipPlanes (new Graphic3d_SequenceOfHClipPlane(myInternalClipPlanes)); // todo: store clipping planes in a handle?
1596 Returns the pointer to the clipping dialog box.
1598 OCCViewer_ClippingDlg* OCCViewer_Viewer::getClippingDlg() const{
1599 return myClippingDlg;
1604 Stores pointer to the clipping dialog box.
1606 void OCCViewer_Viewer::setClippingDlg(OCCViewer_ClippingDlg* theDlg) {
1607 if(myClippingDlg != theDlg) {
1608 myClippingDlg = theDlg;
1613 bool OCCViewer_Viewer::enableDrawMode( bool on )
1615 //!! To be done for view windows
1616 if ( !myViewManager )
1620 QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
1621 for ( int i = 0; i < (int)wins.count(); i++ )
1623 OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
1625 prev = prev || win->enableDrawMode( on );