From: rnv Date: Fri, 22 Nov 2013 13:59:51 +0000 (+0000) Subject: Implementation of the following issues: X-Git-Tag: V7_3_0a1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fb6bb99036f71260be8090f7107f2ddbe275d839;p=modules%2Fgui.git Implementation of the following issues: 1) 0022385: [CEA 975] The icon "Clipping" is missing in OCC view 2) 0021793: [CEA 625] Clipping : from coordinates or from bounding box 3) 0021792: [CEA 624] Keep the clipping --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f93c72005..b536f06ee 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,8 +224,8 @@ INCLUDE(CMakePackageConfigHelpers) # List of targets in this project we want to make visible to the rest of the world. # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup" SET(_${PROJECT_NAME}_exposed_targets - caf CAM CASCatch DDS Event LightApp LogWindow ObjBrowser OpenGLUtils - QDS qtx SalomeIDLGUI SalomePrs SalomeStyle std SUITApp suit ViewerTools + caf CAM CASCatch DDS Event LightApp LogWindow ObjBrowser OpenGLUtils + QDS qtx SalomeIDLGUI SalomePrs SalomeStyle std SUITApp suit ViewerTools ViewerData vtkTools vtkEDFOverloads ImageComposer ) diff --git a/SalomeGUIConfig.cmake.in b/SalomeGUIConfig.cmake.in index 9fada3517..22754b5a3 100644 --- a/SalomeGUIConfig.cmake.in +++ b/SalomeGUIConfig.cmake.in @@ -169,6 +169,7 @@ SET(GUI_suit suit) SET(GUI_SVTK SVTK) SET(GUI_ToolsGUI ToolsGUI) SET(GUI_ViewerTools ViewerTools) +SET(GUI_ViewerData ViewerData) SET(GUI_VTKViewer VTKViewer) SET(GUI_vtkEDFOverloads vtkEDFOverloads) SET(GUI_vtkTools vtkTools) diff --git a/adm_local/cmake_files/FindGUI.cmake b/adm_local/cmake_files/FindGUI.cmake index 66b579550..4f3cf2406 100644 --- a/adm_local/cmake_files/FindGUI.cmake +++ b/adm_local/cmake_files/FindGUI.cmake @@ -58,6 +58,7 @@ FIND_LIBRARY(suit suit ${GUI_ROOT_DIR}/lib/salome) FIND_LIBRARY(SVTK SVTK ${GUI_ROOT_DIR}/lib/salome) FIND_LIBRARY(ToolsGUI ToolsGUI ${GUI_ROOT_DIR}/lib/salome) FIND_LIBRARY(ViewerTools ViewerTools ${GUI_ROOT_DIR}/lib/salome) +FIND_LIBRARY(ViewerData ViewerData ${GUI_ROOT_DIR}/lib/salome) FIND_LIBRARY(VTKViewer VTKViewer ${GUI_ROOT_DIR}/lib/salome) FIND_LIBRARY(vtkEDFOverloads vtkEDFOverloads ${GUI_ROOT_DIR}/lib/paraview) FIND_LIBRARY(vtkTools vtkTools ${GUI_ROOT_DIR}/lib/salome) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7c665128a..3dd3631cf 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,7 +22,7 @@ ## SET(SUBDIRS_COMMON CASCatch Qtx Style DDS QDS ObjBrowser SUIT SUITApp STD CAF - CAM LogWindow Prs Event OpenGLUtils ViewerTools ImageComposer GUI_PY + CAM LogWindow Prs Event OpenGLUtils ViewerData ViewerTools ImageComposer GUI_PY ) ## diff --git a/src/OBJECT/CMakeLists.txt b/src/OBJECT/CMakeLists.txt index f4be0d7dd..276f15541 100755 --- a/src/OBJECT/CMakeLists.txt +++ b/src/OBJECT/CMakeLists.txt @@ -22,13 +22,14 @@ # additional include directories INCLUDE_DIRECTORIES( ${CAS_INCLUDE_DIRS} + ${PROJECT_SOURCE_DIR}/src/ViewerData ) # additional preprocessor / compiler flags ADD_DEFINITIONS(${QT_DEFINITIONS} ${CAS_DEFINITIONS}) # libraries to link to -SET(_link_LIBRARIES ${QT_LIBRARIES} ${CAS_LDPATH} ${CAS_KERNEL} ${CAS_TKV3d}) +SET(_link_LIBRARIES ${QT_LIBRARIES} ${CAS_LDPATH} ${CAS_KERNEL} ${CAS_TKV3d} ViewerData) # --- headers --- diff --git a/src/OBJECT/Handle_SALOME_AISShape.hxx b/src/OBJECT/Handle_SALOME_AISShape.hxx index b38439e3f..b97c641df 100755 --- a/src/OBJECT/Handle_SALOME_AISShape.hxx +++ b/src/OBJECT/Handle_SALOME_AISShape.hxx @@ -37,8 +37,8 @@ // #ifndef _Handle_AIS_Shape_HeaderFile // #include // #endif -#ifndef _AIS_TexturedShape_HeaderFile -#include +#ifndef _ViewerData_AISShape_HeaderFile +#include #endif class Standard_Transient; @@ -48,7 +48,7 @@ class Handle_Standard_Type; Smart pointer (handle) to AIS_Shape */ // class Handle(AIS_Shape); -class Handle(AIS_TexturedShape); +class Handle(ViewerData_AISShape); class SALOME_AISShape; Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOME_AISShape); @@ -56,7 +56,7 @@ Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOME_AISShape); \class Handle(SALOME_AISShape) Smart pointer (handle) to SALOME_AISShape */ -class Handle(SALOME_AISShape) : public Handle(AIS_TexturedShape) { +class Handle(SALOME_AISShape) : public Handle(ViewerData_AISShape) { public: inline void* operator new(size_t,void* anAddress) { @@ -74,12 +74,12 @@ class Handle(SALOME_AISShape) : public Handle(AIS_TexturedShape) { // { // if (anAddress) Standard::Free((Standard_Address&)anAddress,size); // } - Handle(SALOME_AISShape)():Handle(AIS_TexturedShape)() {} - Handle(SALOME_AISShape)(const Handle(SALOME_AISShape)& aHandle) : Handle(AIS_TexturedShape)(aHandle) + Handle(SALOME_AISShape)():Handle(ViewerData_AISShape)() {} + Handle(SALOME_AISShape)(const Handle(SALOME_AISShape)& aHandle) : Handle(ViewerData_AISShape)(aHandle) { } - Handle(SALOME_AISShape)(const SALOME_AISShape* anItem) : Handle(AIS_TexturedShape)((AIS_TexturedShape *)anItem) + Handle(SALOME_AISShape)(const SALOME_AISShape* anItem) : Handle(ViewerData_AISShape)((ViewerData_AISShape *)anItem) { } diff --git a/src/OBJECT/SALOME_AISShape.cxx b/src/OBJECT/SALOME_AISShape.cxx index 8ef3553db..6001fd7a4 100755 --- a/src/OBJECT/SALOME_AISShape.cxx +++ b/src/OBJECT/SALOME_AISShape.cxx @@ -31,7 +31,6 @@ \param shape - TopoDS shape */ SALOME_AISShape::SALOME_AISShape(const TopoDS_Shape& shape) -: AIS_TexturedShape(shape) +: ViewerData_AISShape(shape) { } - diff --git a/src/OBJECT/SALOME_AISShape.hxx b/src/OBJECT/SALOME_AISShape.hxx index de6037739..aab00b7da 100755 --- a/src/OBJECT/SALOME_AISShape.hxx +++ b/src/OBJECT/SALOME_AISShape.hxx @@ -43,8 +43,11 @@ // #ifndef _AIS_Shape_HeaderFile // #include // #endif -#ifndef _AIS_TexturedShape_HeaderFile -#include +//#ifndef _AIS_TexturedShape_HeaderFile +//#include +//#endif +#ifndef _ViewerData_AISShape_HeaderFile +#include #endif #ifndef _Standard_Boolean_HeaderFile #include @@ -55,7 +58,7 @@ class TopoDS_Shape; class TColStd_IndexedMapOfInteger; -class SALOME_AISShape : public AIS_TexturedShape { +class SALOME_AISShape : public ViewerData_AISShape { public: diff --git a/src/OBJECT/SALOME_AISShape.ixx b/src/OBJECT/SALOME_AISShape.ixx index 7593d0f5a..bbc4b7c15 100755 --- a/src/OBJECT/SALOME_AISShape.ixx +++ b/src/OBJECT/SALOME_AISShape.ixx @@ -37,21 +37,23 @@ SALOME_AISShape::~SALOME_AISShape() {} Standard_EXPORT Handle_Standard_Type& SALOME_AISShape_Type_() { - static Handle_Standard_Type aType1 = STANDARD_TYPE(AIS_TexturedShape); - if ( aType1.IsNull()) aType1 = STANDARD_TYPE(AIS_TexturedShape); - static Handle_Standard_Type aType2 = STANDARD_TYPE(AIS_InteractiveObject); - if ( aType2.IsNull()) aType2 = STANDARD_TYPE(AIS_InteractiveObject); - static Handle_Standard_Type aType3 = STANDARD_TYPE(SelectMgr_SelectableObject); - if ( aType3.IsNull()) aType3 = STANDARD_TYPE(SelectMgr_SelectableObject); - static Handle_Standard_Type aType4 = STANDARD_TYPE(PrsMgr_PresentableObject); - if ( aType4.IsNull()) aType4 = STANDARD_TYPE(PrsMgr_PresentableObject); - static Handle_Standard_Type aType5 = STANDARD_TYPE(MMgt_TShared); - if ( aType5.IsNull()) aType5 = STANDARD_TYPE(MMgt_TShared); - static Handle_Standard_Type aType6 = STANDARD_TYPE(Standard_Transient); - if ( aType6.IsNull()) aType6 = STANDARD_TYPE(Standard_Transient); + static Handle_Standard_Type aType1 = STANDARD_TYPE(ViewerData_AISShape); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(ViewerData_AISShape); + static Handle_Standard_Type aType2 = STANDARD_TYPE(AIS_TexturedShape); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(AIS_TexturedShape); + static Handle_Standard_Type aType3 = STANDARD_TYPE(AIS_InteractiveObject); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(AIS_InteractiveObject); + static Handle_Standard_Type aType4 = STANDARD_TYPE(SelectMgr_SelectableObject); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(SelectMgr_SelectableObject); + static Handle_Standard_Type aType5 = STANDARD_TYPE(PrsMgr_PresentableObject); + if ( aType5.IsNull()) aType5 = STANDARD_TYPE(PrsMgr_PresentableObject); + static Handle_Standard_Type aType6 = STANDARD_TYPE(MMgt_TShared); + if ( aType6.IsNull()) aType6 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType7 = STANDARD_TYPE(Standard_Transient); + if ( aType7.IsNull()) aType7 = STANDARD_TYPE(Standard_Transient); - static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,aType5,aType6,NULL}; + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,aType5,aType6,aType7,NULL}; static Handle_Standard_Type _aType = new Standard_Type("SALOME_AISShape", sizeof(SALOME_AISShape), 1, diff --git a/src/OCCViewer/CMakeLists.txt b/src/OCCViewer/CMakeLists.txt index b0644ce2a..8a8c28b05 100755 --- a/src/OCCViewer/CMakeLists.txt +++ b/src/OCCViewer/CMakeLists.txt @@ -34,6 +34,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/Qtx ${PROJECT_SOURCE_DIR}/src/OpenGLUtils ${PROJECT_SOURCE_DIR}/src/SUIT + ${PROJECT_SOURCE_DIR}/src/ViewerData ${PROJECT_SOURCE_DIR}/src/ViewerTools ) @@ -70,6 +71,7 @@ SET(_moc_HEADERS # header files / no moc processing SET(_other_HEADERS OCCViewer.h + OCCViewer_ClipPlane.h OCCViewer_Trihedron.h OCCViewer_VService.h ) @@ -140,6 +142,7 @@ SET(_other_SOURCES OCCViewer_AISSelector.cxx OCCViewer_AxialScaleDlg.cxx OCCViewer_ClippingDlg.cxx + OCCViewer_ClipPlane.cxx OCCViewer_CreateRestoreViewDlg.cxx OCCViewer_CubeAxesDlg.cxx OCCViewer_FontWidget.cxx diff --git a/src/OCCViewer/OCCViewer.h b/src/OCCViewer/OCCViewer.h index 9c4269ad7..464514a00 100755 --- a/src/OCCViewer/OCCViewer.h +++ b/src/OCCViewer/OCCViewer.h @@ -20,6 +20,9 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#ifndef OCCVIEWER_H +#define OCCVIEWER_H + #ifdef WIN32 #if defined OCCVIEWER_EXPORTS || defined OCCViewer_EXPORTS #define OCCVIEWER_EXPORT __declspec(dllexport) @@ -33,3 +36,5 @@ #if defined WIN32 #pragma warning ( disable: 4251 ) #endif + +#endif //OCCVIEWER_H diff --git a/src/OCCViewer/OCCViewer_ClipPlane.cxx b/src/OCCViewer/OCCViewer_ClipPlane.cxx new file mode 100644 index 000000000..f94721663 --- /dev/null +++ b/src/OCCViewer/OCCViewer_ClipPlane.cxx @@ -0,0 +1,80 @@ +// Copyright (C) 2007-2013 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_ClipPlane.h" + +#include + +/*! + Constructor of class OrientedPlane + */ +OrientedPlane::OrientedPlane(): + Orientation (0), + Distance (0.5), + Rotation1 (0), + Rotation2 (0) +{ +} + +/*! + Operator of another OrientedPlane assignment. + @param other the OrientedPlane to assign. + @return the assigned OrientedPlane. +*/ +OrientedPlane& OrientedPlane::operator = ( const OrientedPlane& other ) +{ + Orientation = other.Orientation; + Distance = other.Distance; + Rotation1 = other.Rotation1; + Rotation2 = other.Rotation2; +} + +OCCViewer_ClipPlane::OCCViewer_ClipPlane() : + RelativeMode(), + X (0.0), Y (0.0), Z (0.0), + Dx(1.0), Dy(1.0), Dz(1.0), + Orientation (0), + IsInvert (false), + PlaneMode (Absolute), + IsOn(true) +{ +} + +/*! + Operator of another OCCViewer_ClipPlane assignment. + @param other the OCCViewer_ClipPlane to assign. + @return the assigned OCCViewer_ClipPlane. +*/ +OCCViewer_ClipPlane& OCCViewer_ClipPlane::operator = ( const OCCViewer_ClipPlane& other ) +{ + RelativeMode = other.RelativeMode; + X = other.X; + Y = other.Y; + Z = other.Z; + Dx = other.Dx; + Dy = other.Dy; + Dz = other.Dz; + Orientation = other.Orientation; + IsInvert = other.IsInvert; + PlaneMode = other.PlaneMode; + IsOn = other.IsOn; +} diff --git a/src/OCCViewer/OCCViewer_ClipPlane.h b/src/OCCViewer/OCCViewer_ClipPlane.h new file mode 100644 index 000000000..8b5906f03 --- /dev/null +++ b/src/OCCViewer/OCCViewer_ClipPlane.h @@ -0,0 +1,74 @@ +// Copyright (C) 2007-2013 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 +// + +#ifndef _OCCViewer_ClipPlane_HeaderFile +#define _OCCViewer_ClipPlane_HeaderFile + +#include "OCCViewer.h" + +#include +#include + +enum ClipPlaneMode { Absolute, Relative }; + +/*! + \class OrientedPlane + \brief Parameters of clipping plane in relative mode +*/ +class OCCVIEWER_EXPORT OrientedPlane { + + public: + OrientedPlane(); + OrientedPlane& operator =(const OrientedPlane& other); + + public: + Standard_Integer Orientation; + Standard_Real Distance; + Standard_Real Rotation1; + Standard_Real Rotation2; +}; + +class OCCVIEWER_EXPORT OCCViewer_ClipPlane +{ + + public: + OCCViewer_ClipPlane(); + OCCViewer_ClipPlane& operator =(const OCCViewer_ClipPlane& other); + + public: + OrientedPlane RelativeMode; + Standard_Real X; + Standard_Real Y; + Standard_Real Z; + Standard_Real Dx; + Standard_Real Dy; + Standard_Real Dz; + Standard_Integer Orientation; + bool IsInvert; + bool IsOn; + ClipPlaneMode PlaneMode; + +}; + +typedef std::vector ClipPlanesList; + +#endif diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.cxx b/src/OCCViewer/OCCViewer_ClippingDlg.cxx index 065ef91f2..56c428eca 100644 --- a/src/OCCViewer/OCCViewer_ClippingDlg.cxx +++ b/src/OCCViewer/OCCViewer_ClippingDlg.cxx @@ -28,6 +28,7 @@ #include "SUIT_Session.h" #include "SUIT_ViewWindow.h" #include "SUIT_ViewManager.h" +#include "OCCViewer_ClipPlane.h" #include "OCCViewer_ViewWindow.h" #include "OCCViewer_ViewPort3d.h" #include "OCCViewer_ViewModel.h" @@ -59,35 +60,52 @@ #include #include -/*! - Constructor of class ClipPlane - */ -ClipPlane::ClipPlane(): - RelativeMode(), - X(0.0), Y(0.0), Z(0.0), - Dx(1.0), Dy(1.0), Dz(1.0), - Orientation(0), - IsActive( true ), - IsInvert( false ), - PlaneMode( Absolute ) -{ -} - -/*! - Constructor of class OrientedPlane - */ -OrientedPlane::OrientedPlane(): - Orientation(0), - Distance(0.5), - Rotation1(0), - Rotation2(0) -{ -} - /********************************************************************************** ************************ Internal functions ************************ *********************************************************************************/ +void getMinMaxFromContext( Handle(AIS_InteractiveContext) ic, + double theDefaultSize, + double& theXMin, + double& theYMin, + double& theZMin, + double& theXMax, + double& theYMax, + double& theZMax) { + + double aXMin, aYMin, aZMin, aXMax, aYMax, aZMax; + aXMin = aYMin = aZMin = DBL_MAX; + aXMax = aYMax = aZMax = -DBL_MAX; + + bool isFound = false; + AIS_ListOfInteractive aList; + ic->DisplayedObjects( aList ); + for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() ) { + Handle(AIS_InteractiveObject) anObj = it.Value(); + if ( !anObj.IsNull() && anObj->HasPresentation() && + !anObj->IsKind( STANDARD_TYPE(AIS_Plane) ) ) { + Handle(Prs3d_Presentation) aPrs = anObj->Presentation(); + if ( !aPrs->IsEmpty() && !aPrs->IsInfinite() ) { + isFound = true; + double xmin, ymin, zmin, xmax, ymax, zmax; + aPrs->MinMaxValues( xmin, ymin, zmin, xmax, ymax, zmax ); + aXMin = qMin( aXMin, xmin ); aXMax = qMax( aXMax, xmax ); + aYMin = qMin( aYMin, ymin ); aYMax = qMax( aYMax, ymax ); + aZMin = qMin( aZMin, zmin ); aZMax = qMax( aZMax, zmax ); + } + } + } + + if(!isFound) { + if(theDefaultSize == 0.0) + theDefaultSize = 100.; + aXMin = aYMin = aZMin = -theDefaultSize; + aXMax = aYMax = aZMax = theDefaultSize; + } + theXMin = aXMin;theYMin = aYMin;theZMin = aZMin; + theXMax = aXMax;theYMax = aYMax;theZMax = aZMax; +} + /*! Compute the point of bounding box and current clipping plane */ @@ -156,24 +174,12 @@ void DistanceToPosition( double theBounds[6], */ bool ComputeClippingPlaneParameters( double theNormal[3], double theDist, - double theBounds[6], double theOrigin[3], - Handle(V3d_View) theView3d ) + Handle(AIS_InteractiveContext) ic, + double theDefaultSize) { - bool anIsOk = false; - theBounds[0] = theBounds[2] = theBounds[4] = 999.99; - theBounds[1] = theBounds[3] = theBounds[5] = -999.99; double aBounds[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; - - theView3d->View()->MinMaxValues( aBounds[0], aBounds[2], aBounds[4], aBounds[1], aBounds[3], aBounds[5]); - if ( !theView3d->View()->ContainsFacet() ) { - aBounds[0] = aBounds[2] = aBounds[4] = 0.0; - aBounds[1] = aBounds[3] = aBounds[5] = 100.0; - } - anIsOk = true; - - if( !anIsOk ) - return false; + getMinMaxFromContext(ic,theDefaultSize,aBounds[0], aBounds[2], aBounds[4], aBounds[1], aBounds[3], aBounds[5]); DistanceToPosition( aBounds, theNormal, theDist, theOrigin ); return true; @@ -192,19 +198,19 @@ void Cross(const double first[3], const double second[3], double result[3]) /*! Compute relative clipping plane in absolute coordinates */ -void RelativePlaneToAbsolute ( ClipPlane* thePlane, Handle(V3d_View) theView3d ) +void RelativePlaneToAbsolute (OCCViewer_ClipPlane& thePlane, Handle(AIS_InteractiveContext) ic, double theDefaultSize ) { double aNormal[3]; double aDir[2][3] = { { 0, 0, 0 }, { 0, 0, 0 } }; { static double aCoeff = M_PI/180.0; - double anU[2] = { cos( aCoeff * thePlane->RelativeMode.Rotation1 ), cos( aCoeff * thePlane->RelativeMode.Rotation2 ) }; + double anU[2] = { cos( aCoeff * thePlane.RelativeMode.Rotation1 ), cos( aCoeff * thePlane.RelativeMode.Rotation2 ) }; double aV[2] = { sqrt( 1.0 - anU[0]*anU[0] ), sqrt( 1.0 - anU[1] * anU[1] ) }; - aV[0] = thePlane->RelativeMode.Rotation1 > 0? aV[0]: -aV[0]; - aV[1] = thePlane->RelativeMode.Rotation2 > 0? aV[1]: -aV[1]; + aV[0] = thePlane.RelativeMode.Rotation1 > 0? aV[0]: -aV[0]; + aV[1] = thePlane.RelativeMode.Rotation2 > 0? aV[1]: -aV[1]; - switch ( thePlane->RelativeMode.Orientation ) { + switch ( thePlane.RelativeMode.Orientation ) { case 0: aDir[0][1] = anU[0]; aDir[0][2] = aV[0]; @@ -237,32 +243,62 @@ void RelativePlaneToAbsolute ( ClipPlane* thePlane, Handle(V3d_View) theView3d ) Cross( aNormal, aDir[1], aDir[0] ); } - double aBounds[6]; double anOrigin[3]; - bool anIsOk = false; - anOrigin[0] = anOrigin[1] = anOrigin[2] = 0; - aBounds[0] = aBounds[2] = aBounds[4] = 0; - aBounds[1] = aBounds[3] = aBounds[5] = 0; - anIsOk = true; + bool anIsOk = true; anIsOk = ComputeClippingPlaneParameters( aNormal, - thePlane->RelativeMode.Distance, - aBounds, + thePlane.RelativeMode.Distance, anOrigin, - theView3d ); + ic, + theDefaultSize ); if( !anIsOk ) return; + thePlane.X = anOrigin[0]; + thePlane.Y = anOrigin[1]; + thePlane.Z = anOrigin[2]; + thePlane.Dx = aNormal[0]; + thePlane.Dy = aNormal[1]; + thePlane.Dz = aNormal[2]; +} + +/*! + Compute clipping plane size base point and normal + */ + +void clipPlaneParams(OCCViewer_ClipPlane& theClipPlane, Handle(AIS_InteractiveContext) theContext, + double& theSize, gp_Pnt& theBasePnt, gp_Dir& theNormal, double defaultSize) { + double aXMin, aYMin, aZMin, aXMax, aYMax, aZMax; + aXMin = aYMin = aZMin = DBL_MAX; + aXMax = aYMax = aZMax = -DBL_MAX; + + getMinMaxFromContext(theContext,defaultSize,aXMin, aYMin, aZMin, aXMax, aYMax, aZMax); + double aSize = 50; + + + gp_Pnt aBasePnt(theClipPlane.X , theClipPlane.Y , theClipPlane.Z); + gp_Dir aNormal(theClipPlane.Dx, theClipPlane.Dy, theClipPlane.Dz ); + + // compute clipping plane size + gp_Pnt aCenter = gp_Pnt( ( aXMin + aXMax ) / 2, ( aYMin + aYMax ) / 2, ( aZMin + aZMax ) / 2 ); + double aDiag = aCenter.Distance( gp_Pnt( aXMax, aYMax, aZMax ) )*2; + aSize = aDiag * 1.1; + + // compute clipping plane center ( redefine the base point ) + IntAna_IntConicQuad intersector = IntAna_IntConicQuad(); + + intersector.Perform( gp_Lin( aCenter, aNormal), gp_Pln( aBasePnt, aNormal), Precision::Confusion() ); - thePlane->Dx = aNormal[0]; - thePlane->Dy = aNormal[1]; - thePlane->Dz = aNormal[2]; - thePlane->X = anOrigin[0]; - thePlane->Y = anOrigin[1]; - thePlane->Z = anOrigin[2]; + if ( intersector.IsDone() && intersector.NbPoints() == 1 ) + aBasePnt = intersector.Point( 1 ); + + theSize = aSize; + theBasePnt = aBasePnt; + theNormal = aNormal; } + /********************************************************************************* ********************* class OCCViewer_ClippingDlg ********************* *********************************************************************************/ @@ -270,18 +306,17 @@ void RelativePlaneToAbsolute ( ClipPlane* thePlane, Handle(V3d_View) theView3d ) Constructor \param view - view window \param parent - parent widget - \param name - dialog name - \param modal - is this dialog modal - \param fl - flags */ -OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, const char* name, bool modal, Qt::WindowFlags fl ) -: QDialog( view, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), - myView( view ) +OCCViewer_ClippingDlg::OCCViewer_ClippingDlg(OCCViewer_ViewWindow* parent , OCCViewer_Viewer* model) + : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), + myCurrentClipPlaneMode (Absolute) { setObjectName( "OCCViewer_ClippingDlg" ); - setModal( modal ); + setModal( false ); setWindowTitle( tr( "Clipping" ) ); + + setAttribute (Qt::WA_DeleteOnClose, true); QVBoxLayout* topLayout = new QVBoxLayout( this ); topLayout->setMargin( 11 ); topLayout->setSpacing( 6 ); @@ -299,7 +334,6 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, const MenuMode->addAction( tr( "ABSOLUTE" ), this, SLOT( onModeAbsolute() ) ); MenuMode->addAction( tr( "RELATIVE" ), this, SLOT( onModeRelative() ) ); buttonNew->setMenu( MenuMode ); - CurrentMode = Absolute; GroupPlanesLayout->addWidget( ComboBoxPlanes ); GroupPlanesLayout->addWidget( isActivePlane ); @@ -603,14 +637,15 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, const connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) ); - - connect(view, SIGNAL(Show( QShowEvent* ) ), this, SLOT( onViewShow() ) ); - connect(view, SIGNAL(Hide( QHideEvent* ) ), this, SLOT( onViewHide() ) ); myBusy = false; myIsSelectPlane = false; - myView3d = myView->getViewPort()->getView(); + myIsPlaneCreation = false; + myModel = model; + myModel->getViewer3d()->InitActiveViews(); + + myLocalPlanes = myModel->getClipPlanes(); synchronize(); } @@ -618,11 +653,9 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, const Destructor Destroys the object and frees any allocated resources */ -OCCViewer_ClippingDlg::~ OCCViewer_ClippingDlg() +OCCViewer_ClippingDlg::~OCCViewer_ClippingDlg() { - // no need to delete child widgets, Qt does it all for us - foreach( ClipPlane* aPlane, myClippingPlanes ) - delete aPlane; + myLocalPlanes.clear(); } /*! @@ -631,8 +664,10 @@ OCCViewer_ClippingDlg::~ OCCViewer_ClippingDlg() void OCCViewer_ClippingDlg::closeEvent( QCloseEvent* e ) { erasePreview(); - myAction->setChecked( false ); QDialog::closeEvent( e ); + OCCViewer_ViewWindow* v = qobject_cast(parent()); + if(v) + v->onClipping(false); } /*! @@ -651,6 +686,10 @@ void OCCViewer_ClippingDlg::hideEvent( QHideEvent* e ) { erasePreview(); QDialog::hideEvent( e ); + OCCViewer_ViewWindow* v = qobject_cast(parent()); + if(v) + v->onClipping(false); + } /*! @@ -668,7 +707,7 @@ void OCCViewer_ClippingDlg::initParam() CBAbsoluteOrientation->setCurrentIndex(0); - TLValueDistance->setText( "0" ); + TLValueDistance->setText( "0.5" ); TLValueRotation1->setText( "0\xB0" ); TLValueRotation2->setText( "0\xB0" ); CBRelativeOrientation->setCurrentIndex( 0 ); @@ -683,7 +722,7 @@ void OCCViewer_ClippingDlg::initParam() void OCCViewer_ClippingDlg::synchronize() { ComboBoxPlanes->clear(); - int aNbPlanesAbsolute = myClippingPlanes.size(); + int aNbPlanesAbsolute = myLocalPlanes.size(); QString aName; for(int i = 1; i<=aNbPlanesAbsolute; i++ ) { @@ -701,9 +740,8 @@ void OCCViewer_ClippingDlg::synchronize() else { ComboBoxPlanes->addItem( tr( "NO_PLANES" ) ); initParam(); - ClickOnDisableAll(); } - if ( CurrentMode == Absolute ) { + if ( myCurrentClipPlaneMode == Absolute ) { SpinBox_X->setEnabled( anIsControlsEnable ); SpinBox_Y->setEnabled( anIsControlsEnable ); SpinBox_Z->setEnabled( anIsControlsEnable ); @@ -714,7 +752,7 @@ void OCCViewer_ClippingDlg::synchronize() invertButton->setEnabled( anIsControlsEnable ); resetButton->setEnabled( anIsControlsEnable ); } - else if( CurrentMode == Relative ) { + else if( myCurrentClipPlaneMode == Relative ) { CBRelativeOrientation->setEnabled( anIsControlsEnable ); SliderDistance->setEnabled( anIsControlsEnable ); SliderRotation1->setEnabled( anIsControlsEnable ); @@ -729,85 +767,92 @@ void OCCViewer_ClippingDlg::synchronize() */ void OCCViewer_ClippingDlg::displayPreview() { - if ( myBusy || !isValid() ) + if ( myBusy || !isValid() || !myModel) return; - OCCViewer_Viewer* anOCCViewer = (OCCViewer_Viewer*)myView->getViewManager()->getViewModel(); - if ( !anOCCViewer ) - return; - - Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext(); - - double aXMin, aYMin, aZMin, aXMax, aYMax, aZMax; - aXMin = aYMin = aZMin = DBL_MAX; - aXMax = aYMax = aZMax = -DBL_MAX; + Handle(AIS_InteractiveContext) ic = myModel->getAISContext(); + + int aCurPlaneIndex = ComboBoxPlanes->currentIndex(); - bool isFound = false; - AIS_ListOfInteractive aList; - ic->DisplayedObjects( aList ); - for ( AIS_ListIteratorOfListOfInteractive it( aList ); it.More(); it.Next() ) - { - Handle(AIS_InteractiveObject) anObj = it.Value(); - if ( !anObj.IsNull() && anObj->HasPresentation() && - !anObj->IsKind( STANDARD_TYPE(AIS_Plane) ) ) { - Handle(Prs3d_Presentation) aPrs = anObj->Presentation(); - if ( !aPrs->IsEmpty() && !aPrs->IsInfinite() ) { - isFound = true; - double xmin, ymin, zmin, xmax, ymax, zmax; - aPrs->MinMaxValues( xmin, ymin, zmin, xmax, ymax, zmax ); - aXMin = qMin( aXMin, xmin ); aXMax = qMax( aXMax, xmax ); - aYMin = qMin( aYMin, ymin ); aYMax = qMax( aYMax, ymax ); - aZMin = qMin( aZMin, zmin ); aZMax = qMax( aZMax, zmax ); - } + for ( int i=0; i < clipPlanesCount(); i++ ) { + OCCViewer_ClipPlane& aClipPlane = getClipPlane(i); + if ( aClipPlane.IsOn ) { + Handle(AIS_Plane) myPreviewPlane; + double aSize; + gp_Pnt aBasePnt; + gp_Dir aNormal; + clipPlaneParams(aClipPlane, ic, aSize, aBasePnt, aNormal, myModel->trihedronSize()); + myPreviewPlane = new AIS_Plane( new Geom_Plane( aBasePnt, aNormal ) ); + myPreviewPlane->SetSize( aSize, aSize ); + ic->Display( myPreviewPlane, 1, -1, false ); + ic->SetWidth( myPreviewPlane, 10, false ); + ic->SetMaterial( myPreviewPlane, Graphic3d_NOM_PLASTIC, false ); + ic->SetTransparency( myPreviewPlane, 0.5, false ); + Quantity_Color c = (aCurPlaneIndex == i) ? Quantity_Color( 255. / 255., 70. / 255., 0. / 255., Quantity_TOC_RGB ) : Quantity_Color( 85 / 255., 85 / 255., 255 / 255., Quantity_TOC_RGB ); + ic->SetColor( myPreviewPlane, c , false ); + myPreviewPlaneVector.push_back( myPreviewPlane ); } } + myModel->update(); +} - double aSize = 50; - - ClipPlane* aClipPlane; - for ( int i=0; i < myClippingPlanes.size(); i++ ) { - Pnt_ClipPlane aPlane = myClippingPlanes[i]; - aClipPlane = aPlane; - - double Epsilon = 0.0001; - double Epsilon_Dx = ( aClipPlane->Dx > 0 ) ? Epsilon: -Epsilon; - double Epsilon_Dy = ( aClipPlane->Dy > 0 ) ? Epsilon: -Epsilon; - double Epsilon_Dz = ( aClipPlane->Dz > 0 ) ? Epsilon: -Epsilon; - - gp_Pnt aBasePnt( aClipPlane->X + Epsilon_Dx, aClipPlane->Y + Epsilon_Dy, aClipPlane->Z + Epsilon_Dz ); - gp_Dir aNormal( aClipPlane->Dx, aClipPlane->Dy, aClipPlane->Dz ); - gp_Pnt aCenter = aBasePnt; - - if ( isFound ) - { - // compute clipping plane size - aCenter = gp_Pnt( ( aXMin + aXMax ) / 2, ( aYMin + aYMax ) / 2, ( aZMin + aZMax ) / 2 ); - double aDiag = aCenter.Distance( gp_Pnt( aXMax, aYMax, aZMax ) )*2; - aSize = aDiag * 1.1; - - // compute clipping plane center ( redefine the base point ) - IntAna_IntConicQuad intersector = IntAna_IntConicQuad(); - - intersector.Perform( gp_Lin( aCenter, aNormal), gp_Pln( aBasePnt, aNormal), Precision::Confusion() ); - if ( intersector.IsDone() && intersector.NbPoints() == 1 ) - aBasePnt = intersector.Point( 1 ); +void OCCViewer_ClippingDlg::updatePreview() { + int aCurPlaneIndex = ComboBoxPlanes->currentIndex(); + int count = clipPlanesCount(); + if ( myBusy || + !isValid() || + myIsPlaneCreation || + !myModel || + count == 0 || + (aCurPlaneIndex +1 > count) || + !PreviewCheckBox->isChecked()) + return; + + Handle(AIS_InteractiveContext) ic = myModel->getAISContext(); + + OCCViewer_ClipPlane& aClipPlane = getClipPlane(aCurPlaneIndex); + Handle(AIS_Plane) myPreviewPlane; + + if (aClipPlane.IsOn) { + double aSize; + gp_Pnt aBasePnt; + gp_Dir aNormal; + clipPlaneParams(aClipPlane, ic, aSize, aBasePnt, aNormal, myModel->trihedronSize()); + if(myPreviewPlaneVector.size() < clipPlanesCount()) { + myPreviewPlaneVector.resize(clipPlanesCount()); } - - if ( aClipPlane->IsActive == true ) { - Handle(AIS_Plane) myPreviewPlane; + myPreviewPlane = myPreviewPlaneVector[aCurPlaneIndex]; + if(myPreviewPlane.IsNull()) { + //Plane was not created myPreviewPlane = new AIS_Plane( new Geom_Plane( aBasePnt, aNormal ) ); myPreviewPlane->SetSize( aSize, aSize ); - ic->Display( myPreviewPlane, 1, -1, false ); ic->SetWidth( myPreviewPlane, 10, false ); ic->SetMaterial( myPreviewPlane, Graphic3d_NOM_PLASTIC, false ); ic->SetTransparency( myPreviewPlane, 0.5, false ); - ic->SetColor( myPreviewPlane, Quantity_Color( 85 / 255., 85 / 255., 255 / 255., Quantity_TOC_RGB ), false ); + myPreviewPlaneVector[aCurPlaneIndex] = myPreviewPlane; + } else { + myPreviewPlane->SetComponent(new Geom_Plane( aBasePnt, aNormal )); + myPreviewPlane->SetSize( aSize, aSize ); + } - myPreviewPlaneVector.push_back( myPreviewPlane ); + ic->SetColor( myPreviewPlane, Quantity_Color( 255. / 255., 70. / 255., 0. / 255., Quantity_TOC_RGB ), false ); + } else { + if(myPreviewPlaneVector.size() > aCurPlaneIndex ) { + myPreviewPlane = myPreviewPlaneVector[aCurPlaneIndex]; + if(ic->IsDisplayed(myPreviewPlane)) { + ic->Erase( myPreviewPlane, false ); + ic->Remove( myPreviewPlane, false ); + } + myPreviewPlaneVector[aCurPlaneIndex].Nullify(); } } - anOCCViewer->update(); + for(int i = 0; i < myPreviewPlaneVector.size(); i++) { + if( i == aCurPlaneIndex ) continue; + if(!myPreviewPlaneVector[i].IsNull()) + ic->SetColor( myPreviewPlaneVector[i], Quantity_Color( 85 / 255., 85 / 255., 255 / 255., Quantity_TOC_RGB ), false ); + } + myModel->update(); } /*! @@ -815,12 +860,11 @@ void OCCViewer_ClippingDlg::displayPreview() */ void OCCViewer_ClippingDlg::erasePreview() { - OCCViewer_Viewer* anOCCViewer = (OCCViewer_Viewer*)myView->getViewManager()->getViewModel(); - if ( !anOCCViewer ) + if ( !myModel ) return; - - Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext(); - + + Handle(AIS_InteractiveContext) ic = myModel->getAISContext(); + for ( int i=0; i < myPreviewPlaneVector.size(); i++ ) { Handle(AIS_Plane) myPreviewPlane = myPreviewPlaneVector[i]; if ( !myPreviewPlane.IsNull() && ic->IsDisplayed( myPreviewPlane ) ) { @@ -829,7 +873,8 @@ void OCCViewer_ClippingDlg::erasePreview() myPreviewPlane.Nullify(); } } - anOCCViewer->update(); + myPreviewPlaneVector.clear(); + myModel->update(); } /*! @@ -843,14 +888,18 @@ bool OCCViewer_ClippingDlg::isValid() /*! Update view after changes */ -void OCCViewer_ClippingDlg::updateView() +void OCCViewer_ClippingDlg::updateClipping() { - if ( PreviewCheckBox->isChecked() || AutoApplyCheckBox->isChecked() ) { - erasePreview(); - if ( AutoApplyCheckBox->isChecked() ) + if (PreviewCheckBox->isChecked() || AutoApplyCheckBox->isChecked()) + { + if (AutoApplyCheckBox->isChecked()) { onApply(); - if ( PreviewCheckBox->isChecked() && !isRestore ) - displayPreview(); + } + + if (!PreviewCheckBox->isChecked()) + myModel->update(); + else + updatePreview(); } } @@ -859,9 +908,10 @@ void OCCViewer_ClippingDlg::updateView() */ void OCCViewer_ClippingDlg::ClickOnNew() { - ClipPlane* aPlane = new ClipPlane(); - aPlane->PlaneMode = CurrentMode; - myClippingPlanes.push_back( aPlane ); + + OCCViewer_ClipPlane aPlane; + aPlane.PlaneMode = (ClipPlaneMode )myCurrentClipPlaneMode; + myLocalPlanes.push_back(aPlane); synchronize(); } @@ -870,15 +920,27 @@ void OCCViewer_ClippingDlg::ClickOnNew() */ void OCCViewer_ClippingDlg::ClickOnDelete() { - if ( myClippingPlanes.empty() ) + int aPlaneIndex = ComboBoxPlanes->currentIndex(); + if ( (clipPlanesCount() == 0) || (aPlaneIndex+1 > clipPlanesCount())) return; - int aPlaneIndex = ComboBoxPlanes->currentIndex(); + myLocalPlanes.erase(myLocalPlanes.begin() + aPlaneIndex); + + Handle(AIS_InteractiveContext) ic = myModel->getAISContext(); - ClipPlaneVector::iterator anIter = myClippingPlanes.begin() + aPlaneIndex; - myClippingPlanes.erase( anIter ); - updateView(); + if(aPlaneIndex+1 <= myPreviewPlaneVector.size()) { + Handle(AIS_Plane) myPreviewPlane = myPreviewPlaneVector[aPlaneIndex]; + if ( !myPreviewPlane.IsNull() && ic->IsDisplayed( myPreviewPlane ) ) { + ic->Erase( myPreviewPlane, false ); + ic->Remove( myPreviewPlane, false ); + } + myPreviewPlaneVector.erase(myPreviewPlaneVector.begin() + aPlaneIndex); + } synchronize(); + if (AutoApplyCheckBox->isChecked()) { + onApply(); + } + myModel->update(); } /*! @@ -887,15 +949,17 @@ void OCCViewer_ClippingDlg::ClickOnDelete() */ void OCCViewer_ClippingDlg::ClickOnDisableAll() { - AutoApplyCheckBox->setChecked( false ); - Graphic3d_SetOfHClipPlane aPlanes = myView3d->GetClipPlanes(); - Graphic3d_SetOfHClipPlane::Iterator anIter (aPlanes); - for( ;anIter.More();anIter.Next() ){ - Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value(); - aClipPlane->SetOn(Standard_False); + AutoApplyCheckBox->setChecked (false); + int aClipPlanesCount = clipPlanesCount(); + for ( int anIndex = 0; anIndex < aClipPlanesCount; anIndex++) + { + OCCViewer_ClipPlane& aPlane = getClipPlane(anIndex); + aPlane.IsOn = false; } - myView3d->Update(); - myView3d->Redraw(); + erasePreview(); + isActivePlane->setChecked(false); + myModel->setClipPlanes(myLocalPlanes); + myModel->update(); } /*! @@ -904,8 +968,7 @@ void OCCViewer_ClippingDlg::ClickOnDisableAll() void OCCViewer_ClippingDlg::ClickOnOk() { onApply(); - erasePreview(); - myAction->setChecked( false ); + ClickOnClose(); } /*! @@ -914,8 +977,7 @@ void OCCViewer_ClippingDlg::ClickOnOk() void OCCViewer_ClippingDlg::ClickOnApply() { onApply(); - myView3d->Update(); - myView3d->Redraw(); + myModel->update(); } /*! @@ -924,7 +986,9 @@ void OCCViewer_ClippingDlg::ClickOnApply() void OCCViewer_ClippingDlg::ClickOnClose() { erasePreview(); - myAction->setChecked( false ); + OCCViewer_ViewWindow* v = qobject_cast(parent()); + if(v) + v->onClipping(false); } /*! @@ -942,10 +1006,12 @@ void OCCViewer_ClippingDlg::ClickOnHelp() */ void OCCViewer_ClippingDlg::onModeAbsolute() { + myIsPlaneCreation = true; ModeStackedLayout->setCurrentIndex(0); - CurrentMode = Absolute; + myCurrentClipPlaneMode = Absolute; ClickOnNew(); - onValueChanged(); + myIsPlaneCreation = false; + updateClipping(); } /*! @@ -953,10 +1019,13 @@ void OCCViewer_ClippingDlg::onModeAbsolute() */ void OCCViewer_ClippingDlg::onModeRelative() { + myIsPlaneCreation = true; ModeStackedLayout->setCurrentIndex(1); - CurrentMode = Relative; + myCurrentClipPlaneMode = Relative; ClickOnNew(); - onValueChanged(); + myIsPlaneCreation = false; + SetCurrentPlaneParam(); + updateClipping(); } /*! @@ -967,7 +1036,7 @@ void OCCViewer_ClippingDlg::onValueChanged() SetCurrentPlaneParam(); if ( myIsSelectPlane ) return; - updateView(); + updateClipping(); } /*! @@ -975,44 +1044,43 @@ void OCCViewer_ClippingDlg::onValueChanged() */ void OCCViewer_ClippingDlg::onSelectPlane ( int theIndex ) { - if ( myClippingPlanes.empty() ) + if ( clipPlanesCount() == 0 ) return; - Pnt_ClipPlane aPlane = myClippingPlanes[theIndex]; - ClipPlane* aClipPlane = aPlane; + OCCViewer_ClipPlane& aClipPlane = getClipPlane (theIndex); myIsSelectPlane = true; - if ( aClipPlane->PlaneMode == Absolute ) { + if ( aClipPlane.PlaneMode == Absolute ) { ModeStackedLayout->setCurrentIndex( 0 ); - CurrentMode = Absolute; - int anOrientation = aClipPlane->Orientation; + myCurrentClipPlaneMode = Absolute; + int anOrientation = aClipPlane.Orientation; // Set plane parameters in the dialog - SpinBox_X->setValue( aClipPlane->X ); - SpinBox_Y->setValue( aClipPlane->Y ); - SpinBox_Z->setValue( aClipPlane->Z ); - SpinBox_Dx->setValue( aClipPlane->Dx ); - SpinBox_Dy->setValue( aClipPlane->Dy ); - SpinBox_Dz->setValue( aClipPlane->Dz ); + SpinBox_X->setValue( aClipPlane.X ); + SpinBox_Y->setValue( aClipPlane.Y ); + SpinBox_Z->setValue( aClipPlane.Z ); + SpinBox_Dx->setValue( aClipPlane.Dx ); + SpinBox_Dy->setValue( aClipPlane.Dy ); + SpinBox_Dz->setValue( aClipPlane.Dz ); CBAbsoluteOrientation->setCurrentIndex( anOrientation ); onOrientationAbsoluteChanged( anOrientation ); } - else if( aClipPlane->PlaneMode == Relative ) { + else if( aClipPlane.PlaneMode == Relative ) { ModeStackedLayout->setCurrentIndex( 1 ); - CurrentMode = Relative; - int anOrientation = aClipPlane->RelativeMode.Orientation; + myCurrentClipPlaneMode = Relative; + int anOrientation = aClipPlane.RelativeMode.Orientation; // Set plane parameters in the dialog - SliderDistance->setValue( aClipPlane->RelativeMode.Distance*100 ); - TLValueDistance->setText( QString::number(aClipPlane->RelativeMode.Distance ) ); - SliderRotation1->setValue( aClipPlane->RelativeMode.Rotation1 ); - TLValueRotation1->setText( QString( "%1\xB0" ).arg( aClipPlane->RelativeMode.Rotation1 ) ); - SliderRotation2->setValue( aClipPlane->RelativeMode.Rotation2 ); - TLValueRotation2->setText( QString( "%1\xB0" ).arg( aClipPlane->RelativeMode.Rotation2 ) ); + SliderDistance->setValue( aClipPlane.RelativeMode.Distance*100 ); + TLValueDistance->setText( QString::number(aClipPlane.RelativeMode.Distance ) ); + SliderRotation1->setValue( aClipPlane.RelativeMode.Rotation1 ); + TLValueRotation1->setText( QString( "%1\xB0" ).arg( aClipPlane.RelativeMode.Rotation1 ) ); + SliderRotation2->setValue( aClipPlane.RelativeMode.Rotation2 ); + TLValueRotation2->setText( QString( "%1\xB0" ).arg( aClipPlane.RelativeMode.Rotation2 ) ); CBRelativeOrientation->setCurrentIndex( anOrientation ); onOrientationRelativeChanged( anOrientation ); } - isActivePlane->setChecked( aClipPlane->IsActive ); + + isActivePlane->setChecked( aClipPlane.IsOn ); ComboBoxPlanes->setCurrentIndex( theIndex ); - myIsSelectPlane = false; } @@ -1021,32 +1089,30 @@ void OCCViewer_ClippingDlg::onSelectPlane ( int theIndex ) */ void OCCViewer_ClippingDlg::SetCurrentPlaneParam() { - if ( myClippingPlanes.empty() || myIsSelectPlane ) + if ( clipPlanesCount() == 0 || myIsSelectPlane ) return; int aCurPlaneIndex = ComboBoxPlanes->currentIndex(); - Pnt_ClipPlane aPlane = myClippingPlanes[aCurPlaneIndex]; - ClipPlane* aPlaneData = aPlane; - - if ( aPlaneData->PlaneMode == Absolute ) { - aPlaneData->Orientation = CBAbsoluteOrientation->currentIndex(); - aPlaneData->X = SpinBox_X->value(); - aPlaneData->Y = SpinBox_Y->value(); - aPlaneData->Z = SpinBox_Z->value(); - aPlaneData->Dx = SpinBox_Dx->value(); - aPlaneData->Dy = SpinBox_Dy->value(); - aPlaneData->Dz = SpinBox_Dz->value(); + OCCViewer_ClipPlane& aPlane = getClipPlane (aCurPlaneIndex); + + if ( aPlane.PlaneMode == Absolute ) { + aPlane.Orientation = CBAbsoluteOrientation->currentIndex(); + aPlane.X = SpinBox_X->value(); + aPlane.Y = SpinBox_Y->value(); + aPlane.Z = SpinBox_Z->value(); + aPlane.Dx = SpinBox_Dx->value(); + aPlane.Dy = SpinBox_Dy->value(); + aPlane.Dz = SpinBox_Dz->value(); } - else if( aPlaneData->PlaneMode == Relative ) { - aPlaneData->RelativeMode.Orientation = CBRelativeOrientation->currentIndex(); - aPlaneData->RelativeMode.Distance = TLValueDistance->text().toDouble(); - aPlaneData->RelativeMode.Rotation1 = TLValueRotation1->text().remove("\xB0").toInt(); - aPlaneData->RelativeMode.Rotation2 = TLValueRotation2->text().remove("\xB0").toInt(); - erasePreview(); - RelativePlaneToAbsolute( aPlane, myView3d ); + else if( aPlane.PlaneMode == Relative ) { + aPlane.RelativeMode.Orientation = CBRelativeOrientation->currentIndex(); + aPlane.RelativeMode.Distance = TLValueDistance->text().toDouble(); + aPlane.RelativeMode.Rotation1 = TLValueRotation1->text().remove("\xB0").toInt(); + aPlane.RelativeMode.Rotation2 = TLValueRotation2->text().remove("\xB0").toInt(); + RelativePlaneToAbsolute (aPlane, myModel->getAISContext(),myModel->trihedronSize() ); } - aPlaneData->IsActive = isActivePlane->isChecked(); + aPlane.IsOn = isActivePlane->isChecked(); } /*! @@ -1060,7 +1126,7 @@ void OCCViewer_ClippingDlg::onReset() SpinBox_Z->setValue(0); myBusy = false; - updateView(); + updateClipping(); } /*! @@ -1078,13 +1144,12 @@ void OCCViewer_ClippingDlg::onInvert() SpinBox_Dz->setValue( -Dz ); myBusy = false; - if ( !myClippingPlanes.empty() ) { + if ( clipPlanesCount() != 0 ) { int aCurPlaneIndex = ComboBoxPlanes->currentIndex(); - Pnt_ClipPlane aPlane = myClippingPlanes[aCurPlaneIndex]; - ClipPlane* aPlaneData = aPlane; - aPlaneData->IsInvert = !aPlaneData->IsInvert; + OCCViewer_ClipPlane& aPlane = getClipPlane (aCurPlaneIndex); + aPlane.IsInvert = !aPlane.IsInvert; } - updateView(); + updateClipping(); } /*! @@ -1110,48 +1175,46 @@ void OCCViewer_ClippingDlg::onOrientationAbsoluteChanged( int mode ) SpinBox_Dy->setEnabled( isUserMode ); SpinBox_Dz->setEnabled( isUserMode ); - if ( isUserMode ) - return; + if ( !isUserMode ) { - double aDx = 0, aDy = 0, aDz = 0; + double aDx = 0, aDy = 0, aDz = 0; - if ( mode == 1 ) - { - aDz = 1; - TextLabelZ->setEnabled( true ); - SpinBox_Z->setEnabled( true ); - SpinBox_Z->setFocus(); - } - else if ( mode == 2 ) - { - aDx = 1; - TextLabelX->setEnabled( true ); - SpinBox_X->setEnabled( true ); - SpinBox_X->setFocus(); - } - else if ( mode == 3 ) - { - aDy = 1; - TextLabelY->setEnabled( true ); - SpinBox_Y->setEnabled( true ); - SpinBox_Y->setFocus(); - } - - int aCurPlaneIndex = ComboBoxPlanes->currentIndex(); - Pnt_ClipPlane aPlane = myClippingPlanes[aCurPlaneIndex]; - ClipPlane* aPlaneData = aPlane; - if ( aPlaneData->IsInvert == true ) { - aDx = -aDx; aDy = -aDy; aDz = -aDz; + if ( mode == 1 ) + { + aDz = 1; + TextLabelZ->setEnabled( true ); + SpinBox_Z->setEnabled( true ); + SpinBox_Z->setFocus(); + } + else if ( mode == 2 ) + { + aDx = 1; + TextLabelX->setEnabled( true ); + SpinBox_X->setEnabled( true ); + SpinBox_X->setFocus(); + } + else if ( mode == 3 ) + { + aDy = 1; + TextLabelY->setEnabled( true ); + SpinBox_Y->setEnabled( true ); + SpinBox_Y->setFocus(); + } + + int aCurPlaneIndex = ComboBoxPlanes->currentIndex(); + OCCViewer_ClipPlane& aPlane = getClipPlane (aCurPlaneIndex); + if ( aPlane.IsInvert == true ) { + aDx = -aDx; aDy = -aDy; aDz = -aDz; + } + + myBusy = true; + SpinBox_Dx->setValue( aDx ); + SpinBox_Dy->setValue( aDy ); + SpinBox_Dz->setValue( aDz ); + myBusy = false; } - - myBusy = true; - SpinBox_Dx->setValue( aDx ); - SpinBox_Dy->setValue( aDy ); - SpinBox_Dz->setValue( aDz ); - myBusy = false; - SetCurrentPlaneParam(); - updateView(); + updateClipping(); } /*! @@ -1159,9 +1222,9 @@ void OCCViewer_ClippingDlg::onOrientationAbsoluteChanged( int mode ) */ void OCCViewer_ClippingDlg::onOrientationRelativeChanged (int theItem) { - if ( myClippingPlanes.empty() ) + if ( clipPlanesCount() == 0 ) return; - + if ( theItem == 0 ) { TextLabelRotation1->setText( tr( "ROTATION_AROUND_X_Y2Z" ) ); TextLabelRotation2->setText( tr( "ROTATION_AROUND_Y_X2Z" ) ); @@ -1177,7 +1240,7 @@ void OCCViewer_ClippingDlg::onOrientationRelativeChanged (int theItem) if( (QComboBox*)sender() == CBRelativeOrientation ) SetCurrentPlaneParam(); - updateView(); + updateClipping(); } /*! @@ -1195,9 +1258,10 @@ void OCCViewer_ClippingDlg::onPreview( bool on ) */ void OCCViewer_ClippingDlg::onAutoApply( bool toggled ) { - if ( toggled ) onApply(); - myView3d->Update(); - myView3d->Redraw(); + if ( toggled ) { + onApply(); + myModel->update(); + } } /*! @@ -1208,42 +1272,17 @@ void OCCViewer_ClippingDlg::onApply() if ( myBusy ) return; myIsSelectPlane = true; - Graphic3d_SetOfHClipPlane aPlanes = myView3d->GetClipPlanes(); - Graphic3d_SetOfHClipPlane::Iterator anIter (aPlanes); - for( ;anIter.More();anIter.Next() ){ - Handle(Graphic3d_ClipPlane) aClipPlane = anIter.Value(); - aClipPlane->SetOn(Standard_False); - } qApp->processEvents(); QApplication::setOverrideCursor( Qt::WaitCursor ); qApp->processEvents(); - for ( int i=0;iIsActive == true ) - myView->setCuttingPlane( true, aClipPlane->X , aClipPlane->Y , aClipPlane->Z, - aClipPlane->Dx, aClipPlane->Dy, aClipPlane->Dz ); - } + myModel->setClipPlanes(myLocalPlanes); QApplication::restoreOverrideCursor(); myIsSelectPlane = false; } -void OCCViewer_ClippingDlg::onViewShow() -{ - if(myAction->isChecked()) - show(); - else - hide(); -} - -void OCCViewer_ClippingDlg::onViewHide() -{ - hide(); -} - /*! SLOT: Called when value of slider distance change */ @@ -1271,3 +1310,11 @@ void OCCViewer_ClippingDlg::SliderRotation2HasMoved( int value ) TLValueRotation2->setText( QString("%1\xB0").arg( value ) ); onValueChanged(); } + +OCCViewer_ClipPlane& OCCViewer_ClippingDlg::getClipPlane (int theIndex) { + return myLocalPlanes[theIndex]; +} + +int OCCViewer_ClippingDlg::clipPlanesCount() { + return myLocalPlanes.size(); +} diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.h b/src/OCCViewer/OCCViewer_ClippingDlg.h index 63ee8d84f..934cefb6b 100644 --- a/src/OCCViewer/OCCViewer_ClippingDlg.h +++ b/src/OCCViewer/OCCViewer_ClippingDlg.h @@ -24,6 +24,7 @@ #define OCCVIEWER_CLIPPINGDLG_H #include "OCCViewer.h" +#include "OCCViewer_ClipPlane.h" #include @@ -36,63 +37,27 @@ class QPushButton; class QComboBox; class QCheckBox; class QtxDoubleSpinBox; -class QtxAction; class QStackedLayout; class QSlider; class QMenu; +class OCCViewer_Viewer; class OCCViewer_ViewWindow; -enum Mode { Absolute, Relative }; - -/*! - \class OrientedPlane - \brief Parameters of clipping plane in relative mode -*/ -class OrientedPlane { -public: - int Orientation; - double Distance; - double Rotation1; - double Rotation2; - OrientedPlane(); -}; - -/*! - \class ClipPlane - \brief Parameters of clipping plane -*/ -class ClipPlane { -public: - OrientedPlane RelativeMode; - double X,Y,Z,Dx,Dy,Dz; - int Orientation; - bool IsActive; - bool IsInvert; - Mode PlaneMode; - ClipPlane(); -}; -typedef ClipPlane* Pnt_ClipPlane; -typedef std::vector ClipPlaneVector; - /*! \class OCCViewer_ClippingDlg \brief Dialog allowing to assign parameters of clipping plane */ -class OCCViewer_ClippingDlg : public QDialog +class OCCVIEWER_EXPORT OCCViewer_ClippingDlg : public QDialog { Q_OBJECT - + public: - OCCViewer_ClippingDlg(OCCViewer_ViewWindow* , const char* name = 0, bool modal = FALSE, Qt::WindowFlags fl = 0); + OCCViewer_ClippingDlg(OCCViewer_ViewWindow* parrent, OCCViewer_Viewer* model); ~OCCViewer_ClippingDlg(); - void SetAction( QtxAction* theAction ) { myAction = theAction; } void synchronize(); void SetCurrentPlaneParam(); - - ClipPlaneVector myClippingPlanes; - bool isRestore; private : @@ -102,8 +67,12 @@ private : void initParam(); void displayPreview(); void erasePreview(); + void updatePreview(); bool isValid(); - void updateView(); + void updateClipping(); + + OCCViewer_ClipPlane& getClipPlane (int theIndex); + int clipPlanesCount(); QComboBox* ComboBoxPlanes; QCheckBox* isActivePlane; @@ -122,7 +91,7 @@ private : QtxDoubleSpinBox* SpinBox_Y; QtxDoubleSpinBox* SpinBox_Z; QPushButton* resetButton; - + QGroupBox* GroupAbsoluteDirection; QLabel* TextLabelDx; QLabel* TextLabelDy; @@ -132,7 +101,7 @@ private : QtxDoubleSpinBox* SpinBox_Dz; QPushButton* invertButton; QComboBox* CBAbsoluteOrientation; - + QGroupBox* GroupRelative; QLabel* TextLabelOrientation; QLabel* TextLabelDistance; @@ -152,22 +121,22 @@ private : QPushButton* buttonOk; QPushButton* buttonApply; QPushButton* buttonClose; - - OCCViewer_ViewWindow* myView; + + OCCViewer_Viewer* myModel; Handle(V3d_View) myView3d; + Standard_Integer myCurrentClipPlaneMode; std::vector myPreviewPlaneVector; bool myIsSelectPlane; bool myBusy; + bool myIsPlaneCreation; - Mode CurrentMode; - - QtxAction* myAction; - + ClipPlanesList myLocalPlanes; + public slots: void onApply(); - + private slots: void ClickOnNew(); @@ -192,9 +161,6 @@ private slots: void onPreview( bool on ); void onAutoApply(bool); - void onViewShow(); - void onViewHide(); - void SliderDistanceHasMoved(int); void SliderRotation1HasMoved(int); void SliderRotation2HasMoved(int); diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index 3ddc7b5d3..3735978ed 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -25,6 +25,7 @@ #include "OCCViewer_ViewFrame.h" #include "OCCViewer_VService.h" #include "OCCViewer_ViewPort3d.h" +#include "OCCViewer_ClippingDlg.h" #include "SUIT_ViewWindow.h" #include "SUIT_ViewManager.h" @@ -32,6 +33,8 @@ #include "SUIT_Session.h" #include "SUIT_ResourceMgr.h" +#include "ViewerData_AISShape.hxx" + #include "QtxActionToolMgr.h" #include "QtxBackgroundTool.h" @@ -93,7 +96,8 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) myBackgrounds(4, Qtx::BackgroundData( Qt::black )), myIsRelative(true), myTopLayerId( 0 ), - myTrihedronSize(100) + myTrihedronSize(100), + myClippingDlg (NULL) { // init CasCade viewers myV3dViewer = OCCViewer_VService::CreateViewer( TCollection_ExtendedString("Viewer3d").ToExtString() ); @@ -1012,3 +1016,74 @@ void OCCViewer_Viewer::setSelectionOptions( bool isPreselectionEnabled, bool isS myPreselectionEnabled = isPreselectionEnabled; mySelectionEnabled = isSelectionEnabled; } + + +/*! + Applies clipping planes to clippable objects +*/ +void OCCViewer_Viewer::setClipPlanes(ClipPlanesList theList) +{ + // 1. Remove existing clipping planes + myClipPlanes.clear(); + myInternalClipPlanes.Clear(); + + // 2. Create new clipping planes + ClipPlanesList::iterator inIt = theList.begin(); + for (;inIt != theList.end(); inIt++ ) { + OCCViewer_ClipPlane plane; + plane = (*inIt); + myClipPlanes.push_back(plane); + gp_Pln aPln (gp_Pnt (plane.X, plane.Y, plane.Z), + gp_Dir (plane.Dx, plane.Dy, plane.Dz)); + Handle(Graphic3d_ClipPlane) aGraphic3dPlane = new Graphic3d_ClipPlane(); + aGraphic3dPlane->SetEquation (aPln); + aGraphic3dPlane->SetOn(plane.IsOn); + myInternalClipPlanes.Add(aGraphic3dPlane); + } + + // 3. Apply clipping planes + AIS_ListOfInteractive aList; + myAISContext->DisplayedObjects (aList); + for ( AIS_ListIteratorOfListOfInteractive anIter (aList); anIter.More(); anIter.Next() ) { + Handle(AIS_InteractiveObject) anObj = anIter.Value(); + Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (anObj); + if (!aShape.IsNull() && aShape->IsClippable()) { + aShape->SetClipPlanes(myInternalClipPlanes); + } + } +} + +/*! + Returns the clipping planes applied to the displayed objects. +*/ +ClipPlanesList OCCViewer_Viewer::getClipPlanes() const { + return myClipPlanes; +} +/*! + Applies clipping planes to given object objects +*/ +void OCCViewer_Viewer::applyExistingClipPlanesToObject (const Handle(AIS_InteractiveObject)& theObject) +{ + Handle(ViewerData_AISShape) aShape = Handle(ViewerData_AISShape)::DownCast (theObject); + if (!aShape.IsNull() && aShape->IsClippable()) + { + aShape->SetClipPlanes (myInternalClipPlanes); + } +} + +/*! + Returns the pointer to the clipping dialog box. +*/ +OCCViewer_ClippingDlg* OCCViewer_Viewer::getClippingDlg() const{ + return myClippingDlg; +} + + +/*! + Stores pointer to the clipping dialog box. +*/ +void OCCViewer_Viewer::setClippingDlg(OCCViewer_ClippingDlg* theDlg) { + if(myClippingDlg != theDlg) { + myClippingDlg = theDlg; + } +} diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 9b98467ff..2e111ae83 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -28,6 +28,7 @@ #include #include "OCCViewer.h" +#include "OCCViewer_ClipPlane.h" #include "Qtx.h" #include "SUIT_ViewModel.h" @@ -42,10 +43,14 @@ class QMouseEvent; class SUIT_ViewWindow; class SUIT_Desktop; +class OCCViewer_ClippingDlg; class OCCViewer_ViewWindow; class AIS_ListOfInteractive; +class QtxAction; + + #ifdef WIN32 #pragma warning( disable:4251 ) #endif @@ -148,6 +153,15 @@ public: bool isStaticTrihedronDisplayed() { return myShowStaticTrihedron; } void setStaticTrihedronDisplayed(const bool on); + /* Clip planes management */ + void setClipPlanes (ClipPlanesList theList); + ClipPlanesList getClipPlanes() const; + void applyExistingClipPlanesToObject (const Handle(AIS_InteractiveObject)& theObject); + + OCCViewer_ClippingDlg* getClippingDlg() const; + void setClippingDlg(OCCViewer_ClippingDlg* theDlg); + + /* Selection management */ bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true ); bool unHighlightAll( bool=true, bool=true ); @@ -186,7 +200,7 @@ protected: Handle(AIS_Trihedron) myTrihedron; - Handle(AIS_InteractiveContext) myAISContext; + Handle(AIS_InteractiveContext) myAISContext; int myInteractionStyle; int myZoomingStyle; @@ -206,6 +220,11 @@ protected: double myTrihedronSize; QVector myBackgrounds; + + OCCViewer_ClippingDlg* myClippingDlg; + + ClipPlanesList myClipPlanes; + Graphic3d_SetOfHClipPlane myInternalClipPlanes; }; #ifdef WIN32 diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 2c52f50c3..ae69b7c9b 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -29,10 +29,11 @@ #include "OCCViewer_ViewManager.h" #include "OCCViewer_ViewSketcher.h" #include "OCCViewer_CreateRestoreViewDlg.h" -#include "OCCViewer_ClippingDlg.h" +#include "OCCViewer_ClipPlane.h" #include "OCCViewer_SetRotationPointDlg.h" #include "OCCViewer_AxialScaleDlg.h" #include "OCCViewer_CubeAxesDlg.h" +#include "OCCViewer_ClippingDlg.h" #include @@ -230,7 +231,6 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop* theDesktop, myEnableDrawMode = false; myDrawRect=false; updateEnabledDrawMode(); - myClippingDlg = 0; myScalingDlg = 0; mySetRotationPointDlg = 0; myRectBand = 0; @@ -361,13 +361,13 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e ) case QEvent::Wheel: { QWheelEvent* aEvent = (QWheelEvent*) e; - myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() ); - double delta = (double)( aEvent->delta() ) / ( 15 * 8 ); - int x = aEvent->x(); - int y = aEvent->y(); - int x1 = (int)( aEvent->x() + width()*delta/100 ); - int y1 = (int)( aEvent->y() + height()*delta/100 ); - myViewPort->zoom( x, y, x1, y1 ); + myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() ); + double delta = (double)( aEvent->delta() ) / ( 15 * 8 ); + int x = aEvent->x(); + int y = aEvent->y(); + int x1 = (int)( aEvent->x() + width()*delta/100 ); + int y1 = (int)( aEvent->y() + height()*delta/100 ); + myViewPort->zoom( x, y, x1, y1 ); } return true; @@ -867,8 +867,8 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent ) int anInteractionStyle = interactionStyle(); if ( ( anInteractionStyle == SUIT_ViewModel::STANDARD && aButton == Qt::LeftButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) || - ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && - aButton == Qt::LeftButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) { + ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && + aButton == Qt::LeftButton && ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) { myDrawRect = myEnableDrawMode; if ( myDrawRect ) { drawRect(); @@ -1211,13 +1211,12 @@ void OCCViewer_ViewWindow::createActions() connect(aAction, SIGNAL(triggered()), this, SLOT(onCloneView())); toolMgr()->registerAction( aAction, CloneId ); - myClippingAction = new QtxAction(tr("MNU_CLIPPING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" ) ), - tr( "MNU_CLIPPING" ), 0, this); - myClippingAction->setStatusTip(tr("DSC_CLIPPING")); - myClippingAction->setCheckable( true ); - connect(myClippingAction, SIGNAL(toggled( bool )), this, SLOT(onClipping( bool ))); - // RNV: Temporary commented, this functionality will be moved into Geometry module - //toolMgr()->registerAction( myClippingAction, ClippingId ); + aAction = new QtxAction (tr ("MNU_CLIPPING"), aResMgr->loadPixmap ("OCCViewer", tr ("ICON_OCCVIEWER_CLIPPING")), + tr ("MNU_CLIPPING"), 0, this); + aAction->setStatusTip (tr ("DSC_CLIPPING")); + aAction->setCheckable (true); + connect (aAction, SIGNAL (toggled (bool)), this, SLOT (onClipping (bool))); + toolMgr()->registerAction (aAction, ClippingId); aAction = new QtxAction(tr("MNU_SHOOT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_SHOOT_VIEW" ) ), tr( "MNU_SHOOT_VIEW" ), 0, this); @@ -1566,43 +1565,6 @@ void OCCViewer_ViewWindow::onCloneView() emit viewCloned( vw ); } -/*! - \brief called if clipping operation is activated. - - Enables/disables clipping plane displaying. - - \parma on action state -*/ -void OCCViewer_ViewWindow::onClipping( bool on ) -{ - /* - SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); - if ( on ) - myActionsMap[ ClippingId ]->setIcon(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING_PRESSED" ))); - else - myActionsMap[ ClippingId ]->setIcon(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" ))); - */ - OCCViewer_ViewWindow* aParent = dynamic_cast(parent()->parent()); - if (!aParent) - aParent = this; - if ( on ) - { - if ( !myClippingDlg ) - { - myClippingDlg = new OCCViewer_ClippingDlg( aParent ); - myClippingDlg->SetAction( myClippingAction ); - } - - if ( !myClippingDlg->isVisible() ) - myClippingDlg->show(); - } - else - { - if ( myClippingDlg->isVisible() ) - myClippingDlg->hide(); - } -} - /*! Creates one more window with same content */ @@ -1683,10 +1645,6 @@ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool base aView3d->SetEye( anItem.eyeX, anItem.eyeY, anItem.eyeZ ); aView3d->SetProj( anItem.projX, anItem.projY, anItem.projZ ); aView3d->SetAxialScale( anItem.scaleX, anItem.scaleY, anItem.scaleZ ); - if ( myClippingDlg ) { - myClippingDlg->onApply(); - myClippingDlg->isRestore = false; - } if ( !baseParamsOnly ) { @@ -1704,14 +1662,14 @@ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool base anAxisData[1].Name = anItem.gtNameZ; anAxisData[2].Name = anItem.gtNameZ; anAxisData[0].NameColor = QColor( anItem.gtNameColorRX, - anItem.gtNameColorGX, - anItem.gtNameColorBX ); + anItem.gtNameColorGX, + anItem.gtNameColorBX ); anAxisData[1].NameColor = QColor( anItem.gtNameColorRY, - anItem.gtNameColorGY, - anItem.gtNameColorBY ); + anItem.gtNameColorGY, + anItem.gtNameColorBY ); anAxisData[2].NameColor = QColor( anItem.gtNameColorRZ, - anItem.gtNameColorGZ, - anItem.gtNameColorBZ ); + anItem.gtNameColorGZ, + anItem.gtNameColorBZ ); anAxisData[0].DrawValues = anItem.gtDrawValuesX; anAxisData[1].DrawValues = anItem.gtDrawValuesY; anAxisData[2].DrawValues = anItem.gtDrawValuesZ; @@ -1722,14 +1680,14 @@ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem, bool base anAxisData[1].Offset = anItem.gtOffsetY; anAxisData[2].Offset = anItem.gtOffsetZ; anAxisData[0].Color = QColor( anItem.gtColorRX, - anItem.gtColorGX, - anItem.gtColorBX ); + anItem.gtColorGX, + anItem.gtColorBX ); anAxisData[1].Color = QColor( anItem.gtColorRY, - anItem.gtColorGY, - anItem.gtColorBY ); + anItem.gtColorGY, + anItem.gtColorBY ); anAxisData[2].Color = QColor( anItem.gtColorRZ, - anItem.gtColorGZ, - anItem.gtColorBZ ); + anItem.gtColorGZ, + anItem.gtColorBZ ); anAxisData[0].DrawTickmarks = anItem.gtDrawTickmarksX; anAxisData[1].DrawTickmarks = anItem.gtDrawTickmarksY; anAxisData[2].DrawTickmarks = anItem.gtDrawTickmarksZ; @@ -2177,34 +2135,28 @@ QString OCCViewer_ViewWindow::getVisualParameters() data << QString( "isVisible=%1" ).arg( params.isVisible ); data << QString( "size=%1" ) .arg( params.size, 0, 'f', 2 ); - if ( myClippingDlg ) { - if ( !myClippingDlg->myClippingPlanes.empty() ) { - for ( int i=0; i < myClippingDlg->myClippingPlanes.size(); i++ ) { - QString ClippingPlane = QString( "ClippingPlane%1=").arg( i+1 ); - Pnt_ClipPlane aPlane = myClippingDlg->myClippingPlanes[i]; - ClippingPlane += QString( "Mode~%1;").arg( (int)aPlane->PlaneMode ); - ClippingPlane += QString( "IsActive~%1;").arg( aPlane->IsActive ); - if ( aPlane->PlaneMode == Absolute ) { - ClippingPlane += QString( "AbsoluteOrientation~%1;" ).arg( aPlane->Orientation ); - ClippingPlane += QString( "IsInvert~%1;" ).arg( aPlane->IsInvert ); - ClippingPlane += QString( "X~%1;" ).arg( aPlane->X ); - ClippingPlane += QString( "Y~%1;" ).arg( aPlane->Y ); - ClippingPlane += QString( "Z~%1;" ).arg( aPlane->Z ); - ClippingPlane += QString( "Dx~%1;" ).arg( aPlane->Dx ); - ClippingPlane += QString( "Dy~%1;" ).arg( aPlane->Dy );; - ClippingPlane += QString( "Dz~%1" ).arg( aPlane->Dz ); - } - else if ( aPlane->PlaneMode == Relative ) { - ClippingPlane += QString( "RelativeOrientation~%1;" ).arg( aPlane->RelativeMode.Orientation ); - ClippingPlane += QString( "Distance~%1;" ).arg( aPlane->RelativeMode.Distance ); - ClippingPlane += QString( "Rotation1~%1;" ).arg( aPlane->RelativeMode.Rotation1 ); - ClippingPlane += QString( "Rotation2~%1" ).arg( aPlane->RelativeMode.Rotation2 ); - } - data << ClippingPlane; - } - } + ClipPlanesList aPlanes = myModel->getClipPlanes(); + for ( int i=0; i < aPlanes.size(); i++ ) { + OCCViewer_ClipPlane& aPlane = aPlanes[i]; + QString ClippingPlane = QString( "ClippingPlane%1=").arg( i+1 ); + ClippingPlane += QString( "Mode~%1;").arg( (int)aPlane.PlaneMode ); + ClippingPlane += QString( "IsActive~%1;").arg( aPlane.IsOn ); + ClippingPlane += QString( "AbsoluteOrientation~%1;" ).arg( aPlane.Orientation ); + ClippingPlane += QString( "IsInvert~%1;" ).arg( aPlane.IsInvert ); + ClippingPlane += QString( "X~%1;" ).arg( aPlane.X ); + ClippingPlane += QString( "Y~%1;" ).arg( aPlane.Y ); + ClippingPlane += QString( "Z~%1;" ).arg( aPlane.Z ); + ClippingPlane += QString( "Dx~%1;" ).arg( aPlane.Dx ); + ClippingPlane += QString( "Dy~%1;" ).arg( aPlane.Dy );; + ClippingPlane += QString( "Dz~%1;" ).arg( aPlane.Dz ); + ClippingPlane += QString( "RelativeOrientation~%1;" ).arg( aPlane.RelativeMode.Orientation ); + ClippingPlane += QString( "Distance~%1;" ).arg( aPlane.RelativeMode.Distance ); + ClippingPlane += QString( "Rotation1~%1;" ).arg( aPlane.RelativeMode.Rotation1 ); + ClippingPlane += QString( "Rotation2~%1" ).arg( aPlane.RelativeMode.Rotation2 ); + data << ClippingPlane; } + #if OCC_VERSION_LARGE > 0x06030009 // available only with OCC-6.3-sp10 or newer version // graduated trihedron data << QString( "gtIsVisible=%1" ) .arg( params.gtIsVisible ); @@ -2261,7 +2213,7 @@ QString OCCViewer_ViewWindow::getVisualParameters() void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) { viewAspect params; - + ClipPlanesList aClipPlanes; QStringList data = parameters.split( '*' ); Qtx::BackgroundData bgData; if ( parameters.contains( '=' ) ) // new format - "scale=1.000e+00*centerX=0.000e+00..." @@ -2288,39 +2240,27 @@ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) else if ( paramName == "isVisible" ) params.isVisible = paramValue.toInt(); else if ( paramName == "size" ) params.size = paramValue.toDouble(); else if ( paramName.contains( "ClippingPlane" ) ) { - OCCViewer_ViewWindow* aParent = dynamic_cast(parent()->parent()); - if (!aParent) - aParent = this; - if ( !myClippingDlg ) - { - myClippingDlg = new OCCViewer_ClippingDlg( aParent ); - myClippingDlg->SetAction( myClippingAction ); - myClippingDlg->hide(); + QStringList ClipPlaneData = paramValue.split( ';' ); + OCCViewer_ClipPlane aPlane; + foreach( QString ClipPlaneParam, ClipPlaneData ) { + QString ClipPlane_paramName = ClipPlaneParam.section( '~', 0, 0 ).trimmed(); + QString ClipPlane_paramValue = ClipPlaneParam.section( '~', 1, 1 ).trimmed(); + if ( ClipPlane_paramName == "Mode" ) aPlane.PlaneMode = ( ClipPlaneMode )ClipPlane_paramValue.toInt(); + else if ( ClipPlane_paramName == "IsActive" ) aPlane.IsOn = ClipPlane_paramValue.toInt(); + else if ( ClipPlane_paramName == "AbsoluteOrientation" ) aPlane.Orientation = ClipPlane_paramValue.toInt(); + else if ( ClipPlane_paramName == "IsInvert" ) aPlane.IsInvert = ClipPlane_paramValue.toInt(); + else if ( ClipPlane_paramName == "X" ) aPlane.X = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Y" ) aPlane.Y = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Z" ) aPlane.Z = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Dx" ) aPlane.Dx = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Dy" ) aPlane.Dy = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Dz" ) aPlane.Dz = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "RelativeOrientation" ) aPlane.RelativeMode.Orientation = ClipPlane_paramValue.toInt(); + else if ( ClipPlane_paramName == "Distance" ) aPlane.RelativeMode.Distance = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Rotation1" ) aPlane.RelativeMode.Rotation1 = ClipPlane_paramValue.toDouble(); + else if ( ClipPlane_paramName == "Rotation2" ) aPlane.RelativeMode.Rotation2 = ClipPlane_paramValue.toDouble(); } - QStringList ClipPlaneData = paramValue.split( ';' ); - ClipPlane* aPlane = new ClipPlane(); - foreach( QString ClipPlaneParam, ClipPlaneData ) { - QString ClipPlane_paramName = ClipPlaneParam.section( '~', 0, 0 ).trimmed(); - QString ClipPlane_paramValue = ClipPlaneParam.section( '~', 1, 1 ).trimmed(); - if ( ClipPlane_paramName == "Mode" ) aPlane->PlaneMode = ( Mode )ClipPlane_paramValue.toInt(); - else if ( ClipPlane_paramName == "IsActive" ) aPlane->IsActive = ClipPlane_paramValue.toInt(); - else if ( ClipPlane_paramName == "AbsoluteOrientation" ) aPlane->Orientation = ClipPlane_paramValue.toInt(); - else if ( ClipPlane_paramName == "IsInvert" ) aPlane->IsInvert = ClipPlane_paramValue.toInt(); - else if ( ClipPlane_paramName == "X" ) aPlane->X = ClipPlane_paramValue.toDouble(); - else if ( ClipPlane_paramName == "Y" ) aPlane->Y = ClipPlane_paramValue.toDouble(); - else if ( ClipPlane_paramName == "Z" ) aPlane->Z = ClipPlane_paramValue.toDouble(); - else if ( ClipPlane_paramName == "Dx" ) aPlane->Dx = ClipPlane_paramValue.toDouble(); - else if ( ClipPlane_paramName == "Dy" ) aPlane->Dy = ClipPlane_paramValue.toDouble(); - else if ( ClipPlane_paramName == "Dz" ) aPlane->Dz = ClipPlane_paramValue.toDouble(); - else if ( ClipPlane_paramName == "RelativeOrientation" ) aPlane->RelativeMode.Orientation = ClipPlane_paramValue.toInt(); - else if ( ClipPlane_paramName == "Distance" ) aPlane->RelativeMode.Distance = ClipPlane_paramValue.toDouble(); - else if ( ClipPlane_paramName == "Rotation1" ) aPlane->RelativeMode.Rotation1 = ClipPlane_paramValue.toDouble(); - else if ( ClipPlane_paramName == "Rotation2" ) aPlane->RelativeMode.Rotation2 = ClipPlane_paramValue.toDouble(); - } - myClippingDlg->myClippingPlanes.push_back( aPlane ); - myClippingDlg->isRestore = true; - myClippingDlg->synchronize(); - myClippingDlg->SetCurrentPlaneParam(); + aClipPlanes.push_back(aPlane); } // graduated trihedron else if ( paramName == "gtIsVisible" ) params.gtIsVisible = paramValue.toInt(); @@ -2364,8 +2304,8 @@ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) else if ( paramName == "gtTickmarkLengthY" ) params.gtTickmarkLengthY = paramValue.toInt(); else if ( paramName == "gtTickmarkLengthZ" ) params.gtTickmarkLengthZ = paramValue.toInt(); else if ( paramName == "background" ) { - QString bg = paramValue.replace( "$", "=" ); - bgData = Qtx::stringToBackground( bg ); + QString bg = paramValue.replace( "$", "=" ); + bgData = Qtx::stringToBackground( bg ); } } } @@ -2391,8 +2331,9 @@ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) params.isVisible = data.count() > idx ? data[idx++].toInt() : 1; params.size = data.count() > idx ? data[idx++].toDouble() : 100.0; } - performRestoring( params ); + performRestoring( params ); setBackground( bgData ); + myModel->setClipPlanes(aClipPlanes); } /*! @@ -2927,3 +2868,49 @@ void OCCViewer_ViewWindow::enableSelection( bool theIsToEnable ) { onSwitchSelection( theIsToEnable ); } + + +/*! + \brief called if clipping operation is activated / deactivated. + + Enables/disables clipping plane displaying. + + \parma on action state +*/ +void OCCViewer_ViewWindow::onClipping (bool theIsOn) +{ + if(!myModel) return; + OCCViewer_ClippingDlg* aClippingDlg = myModel->getClippingDlg(); + + if (theIsOn) { + if (!aClippingDlg) { + aClippingDlg = new OCCViewer_ClippingDlg (this, myModel); + myModel->setClippingDlg(aClippingDlg); + } + if (!aClippingDlg->isVisible()) + aClippingDlg->show(); + } else { + if ( aClippingDlg ) { + aClippingDlg->close(); + myModel->setClippingDlg(0); + } + } + + SUIT_ViewManager* mgr = getViewManager(); + if( mgr ) { + QVector aViews = mgr->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) { + if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) { + QtxActionToolMgr* mgr = aViewWindow->toolMgr(); + if(!mgr) continue; + QAction* a = toolMgr()->action( ClippingId ); + if(!a) continue; + if(theIsOn != a->isChecked()){ + disconnect (a, SIGNAL (toggled (bool)), aViewWindow, SLOT (onClipping (bool))); + a->setChecked(theIsOn); + connect (a, SIGNAL (toggled (bool)), aViewWindow, SLOT (onClipping (bool))); + } + } + } + } +} diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index afd98e550..be7859da6 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -33,7 +33,6 @@ class QtxRectRubberBand; class SUIT_Desktop; class OCCViewer_ViewPort3d; class OCCViewer_ViewSketcher; -class OCCViewer_ClippingDlg; class OCCViewer_AxialScaleDlg; class OCCViewer_SetRotationPointDlg; class OCCViewer_Viewer; @@ -210,6 +209,7 @@ public slots: virtual void onFrontView(); virtual void onViewFitAll(); virtual void onBackView(); + virtual void onClipping(bool on); virtual void onTopView(); virtual void onBottomView(); virtual void onLeftView(); @@ -225,7 +225,6 @@ public slots: virtual void activateGlobalPanning(); virtual void onSetRotationPoint( bool on ); virtual void onCloneView(); - virtual void onClipping( bool on ); virtual void onAxialScale(); virtual void onGraduatedAxes(); virtual void onAmbientToogle(); @@ -335,9 +334,6 @@ protected: double myCurScale; private: - OCCViewer_ClippingDlg* myClippingDlg; - QtxAction* myClippingAction; - OCCViewer_AxialScaleDlg* myScalingDlg; OCCViewer_SetRotationPointDlg* mySetRotationPointDlg; @@ -354,7 +350,7 @@ private: Mode2dType my2dMode; - Handle(V3d_Plane) myReserveClippingPlane; + Handle(V3d_Plane) myReserveClipPlane; viewAspectList myViewAspects; }; diff --git a/src/Prs/SALOME_Prs.h b/src/Prs/SALOME_Prs.h index 0cc6e04e2..f4836eec3 100755 --- a/src/Prs/SALOME_Prs.h +++ b/src/Prs/SALOME_Prs.h @@ -47,6 +47,9 @@ class Handle_SALOME_InteractiveObject; class PRS_EXPORT SALOME_Prs { public: + //! Constructor + SALOME_Prs() : myIsClippable (true) {}; + //! Destructor virtual ~SALOME_Prs() {} @@ -76,6 +79,22 @@ public: //! Key method for double dispatch of activation of sub-shapes selection virtual void LocalSelectionIn( SALOME_View*, const int ) const = 0; + + // checks if shape is clippable + inline bool IsClippable() const + { + return myIsClippable; + } + + // makes shape clippable/not clippable + inline void SetClippable (bool isClippable) + { + myIsClippable = isClippable; + } + +protected: + + bool myIsClippable; }; /*! diff --git a/src/SOCC/CMakeLists.txt b/src/SOCC/CMakeLists.txt index 8bc89cefe..692b19a87 100755 --- a/src/SOCC/CMakeLists.txt +++ b/src/SOCC/CMakeLists.txt @@ -30,6 +30,7 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/OBJECT ${PROJECT_SOURCE_DIR}/src/Prs ${PROJECT_SOURCE_DIR}/src/OCCViewer + ${PROJECT_SOURCE_DIR}/src/ViewerData ) # additional preprocessor / compiler flags diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index 455a51d10..6df18ab59 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -395,17 +395,21 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) } ic->Display( anAIS, false ); - -#if OCC_VERSION_LARGE > 0x06050200 - Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast(anAIS); - if ( !aSh.IsNull() ) { - bool top = (aSh->isTopLevel() && aSh->switchTopLevel()); + Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast (anAIS); + if (!aSh.IsNull()) + { + aSh->SetClippable (prs->IsClippable()); + applyExistingClipPlanesToObject (anAIS); +#if OCC_VERSION_LARGE > 0x06050200 + bool top = (aSh->isTopLevel() && aSh->switchTopLevel()); ic->SetZLayer( aSh, top ? getTopLayerId() : 0 ); - if(!aSh->toActivate()) { - ic->Deactivate( aSh ); - } - } + if(!aSh->toActivate()) + { + ic->Deactivate( aSh ); + } #endif + } + //Register anAIS (if it has an entry) in entry2aisobjects map Handle(SALOME_InteractiveObject) anObj = Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); if ( !anObj.IsNull() && anObj->hasEntry()) diff --git a/src/ViewerData/CMakeLists.txt b/src/ViewerData/CMakeLists.txt new file mode 100644 index 000000000..aaa43f895 --- /dev/null +++ b/src/ViewerData/CMakeLists.txt @@ -0,0 +1,54 @@ +# Copyright (C) 2012-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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 +# + +# --- options --- + +# additional include directories +INCLUDE_DIRECTORIES( + ${CAS_INCLUDE_DIRS} +) + +# additional preprocessor / compiler flags +ADD_DEFINITIONS(${CAS_DEFINITIONS}) + +# libraries to link to +SET(_link_LIBRARIES ${CAS_LDPATH} ${CAS_KERNEL} ${CAS_TKV3d}) + +# --- headers --- + +# header files / to install +SET(ViewerData_HEADERS + ViewerData_AISShape.hxx +) + +# --- sources --- + +# sources / to compile + +SET(ViewerData_SOURCES + ViewerData_AISShape.cxx +) + +# --- rules --- + +ADD_LIBRARY(ViewerData ${ViewerData_SOURCES}) +TARGET_LINK_LIBRARIES(ViewerData ${_link_LIBRARIES}) +INSTALL(TARGETS ViewerData EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +INSTALL(FILES ${ViewerData_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/ViewerData/ViewerData_AISShape.cxx b/src/ViewerData/ViewerData_AISShape.cxx new file mode 100644 index 000000000..fc175dc64 --- /dev/null +++ b/src/ViewerData/ViewerData_AISShape.cxx @@ -0,0 +1,36 @@ +// Copyright (C) 2007-2013 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 "ViewerData_AISShape.hxx" + +IMPLEMENT_STANDARD_HANDLE (ViewerData_AISShape, AIS_TexturedShape) +IMPLEMENT_STANDARD_RTTIEXT(ViewerData_AISShape, AIS_TexturedShape) + +/*! + Constructor + \param shape - TopoDS shape +*/ +ViewerData_AISShape::ViewerData_AISShape (const TopoDS_Shape& theShape) +: AIS_TexturedShape (theShape), + myIsClippable (true) +{ +} diff --git a/src/ViewerData/ViewerData_AISShape.hxx b/src/ViewerData/ViewerData_AISShape.hxx new file mode 100644 index 000000000..1314dda92 --- /dev/null +++ b/src/ViewerData/ViewerData_AISShape.hxx @@ -0,0 +1,59 @@ +// Copyright (C) 2007-2013 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 +// + +#ifndef _ViewerData_AISShape_HeaderFile +#define _ViewerData_AISShape_HeaderFile + +#ifndef _AIS_TexturedShape_HeaderFile +#include +#endif + +#include +#include + +class ViewerData_AISShape : public AIS_TexturedShape +{ +public: + Standard_EXPORT ViewerData_AISShape (const TopoDS_Shape& theShape); + + // checks if shape is clippable + inline bool IsClippable() const + { + return myIsClippable; + } + + // makes shape clippable/not clippable + inline void SetClippable (bool isClippable) + { + myIsClippable = isClippable; + } + +protected: + bool myIsClippable; + +public: + DEFINE_STANDARD_RTTI(ViewerData_AISShape) +}; + +DEFINE_STANDARD_HANDLE(ViewerData_AISShape, AIS_TexturedShape) + +#endif