# 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
)
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)
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)
##
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
)
##
# 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 ---
// #ifndef _Handle_AIS_Shape_HeaderFile
// #include <Handle_AIS_Shape.hxx>
// #endif
-#ifndef _AIS_TexturedShape_HeaderFile
-#include <AIS_TexturedShape.hxx>
+#ifndef _ViewerData_AISShape_HeaderFile
+#include <ViewerData_AISShape.hxx>
#endif
class Standard_Transient;
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);
\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)
{
// {
// 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)
{
}
\param shape - TopoDS shape
*/
SALOME_AISShape::SALOME_AISShape(const TopoDS_Shape& shape)
-: AIS_TexturedShape(shape)
+: ViewerData_AISShape(shape)
{
}
-
// #ifndef _AIS_Shape_HeaderFile
// #include <AIS_Shape.hxx>
// #endif
-#ifndef _AIS_TexturedShape_HeaderFile
-#include <AIS_TexturedShape.hxx>
+//#ifndef _AIS_TexturedShape_HeaderFile
+//#include <AIS_TexturedShape.hxx>
+//#endif
+#ifndef _ViewerData_AISShape_HeaderFile
+#include <ViewerData_AISShape.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
class TColStd_IndexedMapOfInteger;
-class SALOME_AISShape : public AIS_TexturedShape {
+class SALOME_AISShape : public ViewerData_AISShape {
public:
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,
${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
)
# header files / no moc processing
SET(_other_HEADERS
OCCViewer.h
+ OCCViewer_ClipPlane.h
OCCViewer_Trihedron.h
OCCViewer_VService.h
)
OCCViewer_AISSelector.cxx
OCCViewer_AxialScaleDlg.cxx
OCCViewer_ClippingDlg.cxx
+ OCCViewer_ClipPlane.cxx
OCCViewer_CreateRestoreViewDlg.cxx
OCCViewer_CubeAxesDlg.cxx
OCCViewer_FontWidget.cxx
// 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)
#if defined WIN32
#pragma warning ( disable: 4251 )
#endif
+
+#endif //OCCVIEWER_H
--- /dev/null
+// 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 <gp_Pln.hxx>
+
+/*!
+ 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;
+}
--- /dev/null
+// 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 <Graphic3d_ClipPlane.hxx>
+#include <vector>
+
+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<OCCViewer_ClipPlane> ClipPlanesList;
+
+#endif
#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"
#include <QSlider>
#include <QMenu>
-/*!
- 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
*/
*/
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;
/*!
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];
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 *********************
*********************************************************************************/
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 );
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 );
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();
}
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();
}
/*!
void OCCViewer_ClippingDlg::closeEvent( QCloseEvent* e )
{
erasePreview();
- myAction->setChecked( false );
QDialog::closeEvent( e );
+ OCCViewer_ViewWindow* v = qobject_cast<OCCViewer_ViewWindow*>(parent());
+ if(v)
+ v->onClipping(false);
}
/*!
{
erasePreview();
QDialog::hideEvent( e );
+ OCCViewer_ViewWindow* v = qobject_cast<OCCViewer_ViewWindow*>(parent());
+ if(v)
+ v->onClipping(false);
+
}
/*!
CBAbsoluteOrientation->setCurrentIndex(0);
- TLValueDistance->setText( "0" );
+ TLValueDistance->setText( "0.5" );
TLValueRotation1->setText( "0\xB0" );
TLValueRotation2->setText( "0\xB0" );
CBRelativeOrientation->setCurrentIndex( 0 );
void OCCViewer_ClippingDlg::synchronize()
{
ComboBoxPlanes->clear();
- int aNbPlanesAbsolute = myClippingPlanes.size();
+ int aNbPlanesAbsolute = myLocalPlanes.size();
QString aName;
for(int i = 1; i<=aNbPlanesAbsolute; i++ ) {
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 );
invertButton->setEnabled( anIsControlsEnable );
resetButton->setEnabled( anIsControlsEnable );
}
- else if( CurrentMode == Relative ) {
+ else if( myCurrentClipPlaneMode == Relative ) {
CBRelativeOrientation->setEnabled( anIsControlsEnable );
SliderDistance->setEnabled( anIsControlsEnable );
SliderRotation1->setEnabled( anIsControlsEnable );
*/
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();
}
/*!
*/
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 ) ) {
myPreviewPlane.Nullify();
}
}
- anOCCViewer->update();
+ myPreviewPlaneVector.clear();
+ myModel->update();
}
/*!
/*!
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();
}
}
*/
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();
}
*/
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();
}
/*!
*/
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();
}
/*!
void OCCViewer_ClippingDlg::ClickOnOk()
{
onApply();
- erasePreview();
- myAction->setChecked( false );
+ ClickOnClose();
}
/*!
void OCCViewer_ClippingDlg::ClickOnApply()
{
onApply();
- myView3d->Update();
- myView3d->Redraw();
+ myModel->update();
}
/*!
void OCCViewer_ClippingDlg::ClickOnClose()
{
erasePreview();
- myAction->setChecked( false );
+ OCCViewer_ViewWindow* v = qobject_cast<OCCViewer_ViewWindow*>(parent());
+ if(v)
+ v->onClipping(false);
}
/*!
*/
void OCCViewer_ClippingDlg::onModeAbsolute()
{
+ myIsPlaneCreation = true;
ModeStackedLayout->setCurrentIndex(0);
- CurrentMode = Absolute;
+ myCurrentClipPlaneMode = Absolute;
ClickOnNew();
- onValueChanged();
+ myIsPlaneCreation = false;
+ updateClipping();
}
/*!
*/
void OCCViewer_ClippingDlg::onModeRelative()
{
+ myIsPlaneCreation = true;
ModeStackedLayout->setCurrentIndex(1);
- CurrentMode = Relative;
+ myCurrentClipPlaneMode = Relative;
ClickOnNew();
- onValueChanged();
+ myIsPlaneCreation = false;
+ SetCurrentPlaneParam();
+ updateClipping();
}
/*!
SetCurrentPlaneParam();
if ( myIsSelectPlane )
return;
- updateView();
+ updateClipping();
}
/*!
*/
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;
}
*/
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();
}
/*!
SpinBox_Z->setValue(0);
myBusy = false;
- updateView();
+ updateClipping();
}
/*!
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();
}
/*!
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();
}
/*!
*/
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" ) );
if( (QComboBox*)sender() == CBRelativeOrientation )
SetCurrentPlaneParam();
- updateView();
+ updateClipping();
}
/*!
*/
void OCCViewer_ClippingDlg::onAutoApply( bool toggled )
{
- if ( toggled ) onApply();
- myView3d->Update();
- myView3d->Redraw();
+ if ( toggled ) {
+ onApply();
+ myModel->update();
+ }
}
/*!
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;i<myClippingPlanes.size();i++ ) {
- Pnt_ClipPlane aPlane = myClippingPlanes[i];
- ClipPlane* aClipPlane = aPlane;
- if ( aClipPlane->IsActive == 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
*/
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();
+}
#define OCCVIEWER_CLIPPINGDLG_H
#include "OCCViewer.h"
+#include "OCCViewer_ClipPlane.h"
#include <QDialog>
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<Pnt_ClipPlane> 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 :
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;
QtxDoubleSpinBox* SpinBox_Y;
QtxDoubleSpinBox* SpinBox_Z;
QPushButton* resetButton;
-
+
QGroupBox* GroupAbsoluteDirection;
QLabel* TextLabelDx;
QLabel* TextLabelDy;
QtxDoubleSpinBox* SpinBox_Dz;
QPushButton* invertButton;
QComboBox* CBAbsoluteOrientation;
-
+
QGroupBox* GroupRelative;
QLabel* TextLabelOrientation;
QLabel* TextLabelDistance;
QPushButton* buttonOk;
QPushButton* buttonApply;
QPushButton* buttonClose;
-
- OCCViewer_ViewWindow* myView;
+
+ OCCViewer_Viewer* myModel;
Handle(V3d_View) myView3d;
+ Standard_Integer myCurrentClipPlaneMode;
std::vector<Handle(AIS_Plane)> myPreviewPlaneVector;
bool myIsSelectPlane;
bool myBusy;
+ bool myIsPlaneCreation;
- Mode CurrentMode;
-
- QtxAction* myAction;
-
+ ClipPlanesList myLocalPlanes;
+
public slots:
void onApply();
-
+
private slots:
void ClickOnNew();
void onPreview( bool on );
void onAutoApply(bool);
- void onViewShow();
- void onViewHide();
-
void SliderDistanceHasMoved(int);
void SliderRotation1HasMoved(int);
void SliderRotation2HasMoved(int);
#include "OCCViewer_ViewFrame.h"
#include "OCCViewer_VService.h"
#include "OCCViewer_ViewPort3d.h"
+#include "OCCViewer_ClippingDlg.h"
#include "SUIT_ViewWindow.h"
#include "SUIT_ViewManager.h"
#include "SUIT_Session.h"
#include "SUIT_ResourceMgr.h"
+#include "ViewerData_AISShape.hxx"
+
#include "QtxActionToolMgr.h"
#include "QtxBackgroundTool.h"
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() );
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;
+ }
+}
#include <QVector>
#include "OCCViewer.h"
+#include "OCCViewer_ClipPlane.h"
#include "Qtx.h"
#include "SUIT_ViewModel.h"
class SUIT_ViewWindow;
class SUIT_Desktop;
+class OCCViewer_ClippingDlg;
class OCCViewer_ViewWindow;
class AIS_ListOfInteractive;
+class QtxAction;
+
+
#ifdef WIN32
#pragma warning( disable:4251 )
#endif
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 );
Handle(AIS_Trihedron) myTrihedron;
- Handle(AIS_InteractiveContext) myAISContext;
+ Handle(AIS_InteractiveContext) myAISContext;
int myInteractionStyle;
int myZoomingStyle;
double myTrihedronSize;
QVector<Qtx::BackgroundData> myBackgrounds;
+
+ OCCViewer_ClippingDlg* myClippingDlg;
+
+ ClipPlanesList myClipPlanes;
+ Graphic3d_SetOfHClipPlane myInternalClipPlanes;
};
#ifdef WIN32
#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 <Basics_OCCTVersion.hxx>
myEnableDrawMode = false;
myDrawRect=false;
updateEnabledDrawMode();
- myClippingDlg = 0;
myScalingDlg = 0;
mySetRotationPointDlg = 0;
myRectBand = 0;
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;
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();
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);
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<OCCViewer_ViewWindow*>(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
*/
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 ) {
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;
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;
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 );
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..."
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<OCCViewer_ViewWindow*>(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();
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 );
}
}
}
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);
}
/*!
{
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<SUIT_ViewWindow*> 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)));
+ }
+ }
+ }
+ }
+}
class SUIT_Desktop;
class OCCViewer_ViewPort3d;
class OCCViewer_ViewSketcher;
-class OCCViewer_ClippingDlg;
class OCCViewer_AxialScaleDlg;
class OCCViewer_SetRotationPointDlg;
class OCCViewer_Viewer;
virtual void onFrontView();
virtual void onViewFitAll();
virtual void onBackView();
+ virtual void onClipping(bool on);
virtual void onTopView();
virtual void onBottomView();
virtual void onLeftView();
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();
double myCurScale;
private:
- OCCViewer_ClippingDlg* myClippingDlg;
- QtxAction* myClippingAction;
-
OCCViewer_AxialScaleDlg* myScalingDlg;
OCCViewer_SetRotationPointDlg* mySetRotationPointDlg;
Mode2dType my2dMode;
- Handle(V3d_Plane) myReserveClippingPlane;
+ Handle(V3d_Plane) myReserveClipPlane;
viewAspectList myViewAspects;
};
class PRS_EXPORT SALOME_Prs
{
public:
+ //! Constructor
+ SALOME_Prs() : myIsClippable (true) {};
+
//! Destructor
virtual ~SALOME_Prs() {}
//! 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;
};
/*!
${PROJECT_SOURCE_DIR}/src/OBJECT
${PROJECT_SOURCE_DIR}/src/Prs
${PROJECT_SOURCE_DIR}/src/OCCViewer
+ ${PROJECT_SOURCE_DIR}/src/ViewerData
)
# additional preprocessor / compiler flags
}
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())
--- /dev/null
+# 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})
--- /dev/null
+// 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)
+{
+}
--- /dev/null
+// 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 <AIS_TexturedShape.hxx>
+#endif
+
+#include <Standard.hxx>
+#include <Standard_DefineHandle.hxx>
+
+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