From fbbb44cd18e679638cda88faa8d8d21afbd46c18 Mon Sep 17 00:00:00 2001 From: san Date: Thu, 25 Dec 2008 12:16:01 +0000 Subject: [PATCH] IMP 16551 (show static trihedron) --- src/OCCViewer/Makefile.am | 3 +- src/OCCViewer/OCCViewer.cxx | 102 ------------------------- src/OCCViewer/OCCViewer_ViewModel.cxx | 13 +--- src/OCCViewer/OCCViewer_ViewModel.h | 3 + src/OCCViewer/OCCViewer_ViewPort3d.cxx | 13 ++++ 5 files changed, 19 insertions(+), 115 deletions(-) delete mode 100644 src/OCCViewer/OCCViewer.cxx diff --git a/src/OCCViewer/Makefile.am b/src/OCCViewer/Makefile.am index 8f9f71a47..7e77377e2 100755 --- a/src/OCCViewer/Makefile.am +++ b/src/OCCViewer/Makefile.am @@ -45,7 +45,6 @@ salomeinclude_HEADERS = \ OCCViewer_Trihedron.h dist_libOCCViewer_la_SOURCES = \ - OCCViewer.cxx \ OCCViewer_AISSelector.cxx \ OCCViewer_ViewManager.cxx \ OCCViewer_ViewModel.cxx \ @@ -108,5 +107,5 @@ nodist_salomeres_DATA = \ libOCCViewer_la_CPPFLAGS = $(QT_INCLUDES) $(OGL_INCLUDES) $(CAS_CPPFLAGS) \ -I$(srcdir)/../SUIT -I$(srcdir)/../Qtx -libOCCViewer_la_LDFLAGS = $(OGL_LIBS) $(QT_MT_LIBS) $(CAS_KERNEL) $(CAS_VIEWER) -lTKOpenGl +libOCCViewer_la_LDFLAGS = $(OGL_LIBS) $(QT_MT_LIBS) $(CAS_KERNEL) $(CAS_VIEWER) libOCCViewer_la_LIBADD = ../Qtx/libqtx.la ../SUIT/libsuit.la diff --git a/src/OCCViewer/OCCViewer.cxx b/src/OCCViewer/OCCViewer.cxx deleted file mode 100644 index 74d917fd5..000000000 --- a/src/OCCViewer/OCCViewer.cxx +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "OCCViewer_Trihedron.h" - -#include -#include - -void OCCViewer_Init(); - -extern "C" -{ -#ifdef WIN32 /* disable MS VC++ warning on C-style function returning C++ object */ -#pragma warning(push) -#pragma warning(disable:4190) -#endif - Standard_EXPORT Handle( Graphic3d_GraphicDriver ) MetaGraphicDriverFactory( const Standard_CString AShrName ) - { - OCCViewer_Init(); - Handle( OpenGl_GraphicDriver ) aDriver = new OpenGl_GraphicDriver( AShrName ); - return aDriver; - } -#ifdef WIN32 -#pragma warning(pop) -#endif - -#include -#include -#include -#include -#include - - TStatus OCCViewer_DisplayTrihedron ( TSM_ELEM_DATA, Tint, cmn_key* ); - TStatus OCCViewer_AddTrihedron ( TSM_ELEM_DATA, Tint, cmn_key* ); - TStatus OCCViewer_DeleteTrihedron ( TSM_ELEM_DATA, Tint, cmn_key* ); -} - - -TStatus OCCViewer_AddTrihedron( TSM_ELEM_DATA d, Tint n, cmn_key* k ) -{ - // Retrieve the userdraw structure - Graphic3d_CUserDraw *userdraw = ( Graphic3d_CUserDraw* )( k[0]->data.pdata ); - if ( !userdraw ) - return TFailure; - - // Retrieve the user structure - OCCViewer_Trihedron* userdata = ( OCCViewer_Trihedron* )( userdraw->Data ); - if ( !userdata ) - return TFailure; - - ( ( tsm_elem_data )( d.pdata ) )->pdata = ( void* )userdata; - - // Evaluate minmax if needed - if( userdraw->Bounds && userdata ) - userdata->bounds( *( userdraw->Bounds ) ); - - return TSuccess; -} - -TStatus OCCViewer_DeleteTrihedron( TSM_ELEM_DATA d, Tint n, cmn_key* k ) -{ - delete ( OCCViewer_Trihedron* )( d.pdata ); - return TSuccess; -} - -TStatus OCCViewer_DisplayTrihedron( TSM_ELEM_DATA d, Tint n, cmn_key* k ) -{ - ( ( OCCViewer_Trihedron* )( d.pdata ) )->display(); - return TSuccess; -} - -void OCCViewer_Init() -{ - //PickTraverse=0 - //DisplayTraverse=1 - //Add=2 - //Delete=3 - //Print=4 - //Inquire=5 - MtblPtr theCallbacks = GetCallbackTable(); - theCallbacks[DisplayTraverse] = OCCViewer_DisplayTrihedron; - theCallbacks[Add] = OCCViewer_AddTrihedron; - theCallbacks[Delete] = OCCViewer_DeleteTrihedron; -} diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index b47d3f232..78b825cb4 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -23,7 +23,6 @@ #include "OCCViewer_ViewWindow.h" #include "OCCViewer_VService.h" #include "OCCViewer_ViewPort3d.h" -#include "OCCViewer_Trihedron.h" #include "SUIT_ViewWindow.h" #include "SUIT_ViewManager.h" @@ -60,7 +59,8 @@ */ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron, bool DisplayStaticTrihedron ) : SUIT_ViewModel(), -myBgColor( Qt::black ) + myBgColor( Qt::black ), + myShowStaticTrihedron( DisplayStaticTrihedron ) { // init CasCade viewers myV3dViewer = OCCViewer_VService::Viewer3d( "", (short*) "Viewer3d", "", 1000., @@ -114,15 +114,6 @@ myBgColor( Qt::black ) myAISContext->Deactivate(myTrihedron); } - /* create static trihedron (16551: EDF PAL 501) */ - if( DisplayStaticTrihedron ) - { - Handle(OCCViewer_Trihedron) aTrihedron = new OCCViewer_Trihedron(); - myAISContext->Display(aTrihedron); - myAISContext->Deactivate(aTrihedron); - aTrihedron->SetTransformPersistence(Graphic3d_TMF_TriedronPers, gp_Pnt(-1, -1, 200)); - } - // selection mySelectionEnabled = true; myMultiSelectionEnabled = true; diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 9d9704f5a..9e6510f6a 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -129,6 +129,7 @@ public: bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; } int getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; } + bool isStaticTrihedronDisplayed() { return myShowStaticTrihedron; } /* Selection management */ bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true ); @@ -171,6 +172,8 @@ private: QColor myBgColor; QPoint myStartPnt, myEndPnt; + + bool myShowStaticTrihedron; }; #ifdef WIN32 diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 1710bdcaa..10e01347e 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -23,6 +23,9 @@ #include "OCCViewer_VService.h" #include "OCCViewer_ViewWindow.h" +#include "OCCViewer_ViewModel.h" + +#include #include #include @@ -112,6 +115,16 @@ bool OCCViewer_ViewPort3d::mapView( const Handle(V3d_View)& view ) if ( view != activeView() ) view->View()->Deactivate(); } + + /* create static trihedron (16551: EDF PAL 501) */ + OCCViewer_ViewWindow* aVW = dynamic_cast( parentWidget() ); + if ( aVW ){ + OCCViewer_Viewer* aViewModel = dynamic_cast( aVW->getViewManager()->getViewModel() ); + if ( aViewModel && aViewModel->isStaticTrihedronDisplayed() ){ + view->ZBufferTriedronSetup(); + view->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER ); + } + } return true; } -- 2.39.2