'TG-D5-38-2003_D2005-20-12'.
Sprout from master 2005-12-19 14:01:51 UTC asv <asv@opencascade.com> 'missing include <qimage.h> is added.'
Cherrypick from master 2005-10-03 06:19:30 UTC apo <apo@opencascade.com> 'To provide correct memory management':
src/SVTK/SVTK_ViewManager.cxx
src/VTKViewer/VTKViewer.h
src/VTKViewer/VTKViewer_Actor.cxx
src/VTKViewer/VTKViewer_Actor.h
src/VTKViewer/VTKViewer_CellRectPicker.cxx
src/VTKViewer/VTKViewer_ExtractUnstructuredGrid.h
src/VTKViewer/VTKViewer_PassThroughFilter.h
src/VTKViewer/VTKViewer_RenderWindow.cxx
src/VTKViewer/VTKViewer_RenderWindow.h
src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx
src/VTKViewer/VTKViewer_RenderWindowInteractor.h
src/VTKViewer/VTKViewer_ShrinkFilter.h
src/VTKViewer/VTKViewer_Transform.h
src/VTKViewer/VTKViewer_TransformFilter.h
src/VTKViewer/VTKViewer_Trihedron.cxx
src/VTKViewer/VTKViewer_Trihedron.h
src/VTKViewer/VTKViewer_Utilities.cxx
src/VTKViewer/VTKViewer_Utilities.h
src/VTKViewer/VTKViewer_VectorText.cxx
src/VTKViewer/VTKViewer_VectorText.h
src/VTKViewer/VTKViewer_ViewManager.cxx
src/VTKViewer/VTKViewer_ViewManager.h
src/VTKViewer/VTKViewer_ViewModel.cxx
src/VTKViewer/VTKViewer_ViewModel.h
src/VTKViewer/VTKViewer_ViewWindow.h
Cherrypick from master 2005-10-28 09:58:41 UTC jfa <jfa@opencascade.com> 'Fix for bug 10411: Attempt to create polyhedral volume calls error message':
src/VTKViewer/VTKViewer_ConvexTool.cxx
Cherrypick from BR-D5-38-2003 2005-12-16 15:29:05 UTC apo <apo@opencascade.com> 'Adjust to HEAD modifications':
doc/salome/tui/SUIT/doxyfile
src/LightApp/LightApp_Module.cxx
src/LightApp/LightApp_OBSelector.cxx
src/LightApp/LightApp_OBSelector.h
src/LightApp/LightApp_VTKSelector.cxx
src/LightApp/LightApp_VTKSelector.h
src/OBJECT/Makefile.in
src/ObjBrowser/OB_Browser.cxx
src/ObjBrowser/OB_Browser.h
src/SALOME_PY/SalomePy.cxx
src/SVTK/Makefile.in
src/SVTK/SALOME_Actor.cxx
src/SVTK/SALOME_Actor.h
src/SVTK/SVTK.cxx
src/SVTK/SVTK_Actor.cxx
src/SVTK/SVTK_Actor.h
src/SVTK/SVTK_CubeAxesDlg.cxx
src/SVTK/SVTK_CubeAxesDlg.h
src/SVTK/SVTK_Event.h
src/SVTK/SVTK_FontWidget.cxx
src/SVTK/SVTK_FontWidget.h
src/SVTK/SVTK_Functor.h
src/SVTK/SVTK_GenericRenderWindowInteractor.cxx
src/SVTK/SVTK_GenericRenderWindowInteractor.h
src/SVTK/SVTK_InteractorStyle.cxx
src/SVTK/SVTK_InteractorStyle.h
src/SVTK/SVTK_MainWindow.cxx
src/SVTK/SVTK_MainWindow.h
src/SVTK/SVTK_NonIsometricDlg.cxx
src/SVTK/SVTK_NonIsometricDlg.h
src/SVTK/SVTK_RenderWindowInteractor.cxx
src/SVTK/SVTK_RenderWindowInteractor.h
src/SVTK/SVTK_Renderer.cxx
src/SVTK/SVTK_Renderer.h
src/SVTK/SVTK_Selection.h
src/SVTK/SVTK_SelectionEvent.h
src/SVTK/SVTK_Selector.cxx
src/SVTK/SVTK_Selector.h
src/SVTK/SVTK_SelectorDef.h
src/SVTK/SVTK_SpaceMouse.cxx
src/SVTK/SVTK_SpaceMouse.h
src/SVTK/SVTK_View.cxx
src/SVTK/SVTK_View.h
src/SVTK/SVTK_ViewManager.h
src/SVTK/SVTK_ViewModel.cxx
src/SVTK/SVTK_ViewModel.h
src/SVTK/SVTK_ViewModelBase.h
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h
src/SalomeApp/SalomeApp_DataModel.cxx
src/SalomeApp/resources/SalomeApp.xml
src/VTKViewer/Makefile.in
src/VTKViewer/VTKViewer_AppendFilter.cxx
src/VTKViewer/VTKViewer_AppendFilter.h
src/VTKViewer/VTKViewer_GeometryFilter.cxx
src/VTKViewer/VTKViewer_GeometryFilter.h
src/VTKViewer/VTKViewer_ViewWindow.cxx
src/VTKViewer/resources/VTKViewerM_images.po
src/VTKViewer/resources/VTKViewerM_msg_en.po
src/VTKViewer/resources/view_graduated_axes.png
src/VTKViewer/resources/view_scaling.png
Delete:
src/OBJECT/SALOME_Actor.cxx
src/OBJECT/SALOME_Actor.h
src/SVTK/SVTK_RenderWindow.cxx
src/SVTK/SVTK_RenderWindow.h
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
-REPEAT_BRIEF = NO
+REPEAT_BRIEF = YES
ABBREVIATE_BRIEF =
-ALWAYS_DETAILED_SEC = YES
-INLINE_INHERITED_MEMB = YES
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
-INHERIT_DOCS = YES
+INHERIT_DOCS = NO
DISTRIBUTE_GROUP_DOC = NO
TAB_SIZE = 5
ALIASES =
EXTRACT_STATIC = YES
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
-HIDE_UNDOC_MEMBERS = NO
-HIDE_UNDOC_CLASSES = NO
+HIDE_UNDOC_MEMBERS = YES
+HIDE_UNDOC_CLASSES = YES
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = YES
#include "LightApp_Application.h"
#include "LightApp_DataModel.h"
+#include "LightApp_DataObject.h"
#include "LightApp_Study.h"
#include "LightApp_Preferences.h"
#include "LightApp_Selection.h"
/*!Update object browser.
* For updating model or whole object browser use update() method can be used.
*/
-void LightApp_Module::updateObjBrowser( bool updateDataModel, SUIT_DataObject* root )
-{
- if( updateDataModel )
- if( CAM_DataModel* aDataModel = dataModel() )
- if( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) )
- aModel->update( 0, dynamic_cast<LightApp_Study*>( getApp()->activeStudy() ) );
- getApp()->objectBrowser()->updateTree( root );
+void LightApp_Module::updateObjBrowser( bool theIsUpdateDataModel,
+ SUIT_DataObject* theDataObject )
+{
+ SUIT_DataObject* aDataObject = theDataObject;
+ if( theIsUpdateDataModel ){
+ if( CAM_DataModel* aDataModel = dataModel() ){
+ if ( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) ) {
+ SUIT_DataObject* aParent = NULL;
+ if(theDataObject && theDataObject != aDataModel->root())
+ aParent = theDataObject->parent();
+
+ LightApp_DataObject* anObject = dynamic_cast<LightApp_DataObject*>(theDataObject);
+ LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(getApp()->activeStudy());
+ aModel->update( anObject, aStudy );
+
+ if(aParent && aParent->childPos(anObject) < 0)
+ aDataObject = dynamic_cast<LightApp_DataObject*>(aParent);
+ }
+ }
+ }
+ getApp()->objectBrowser()->updateTree( aDataObject );
}
/*!NOT IMPLEMENTED*/
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include "LightApp_OBSelector.h"
#include "LightApp_DataOwner.h"
if ( myBrowser ) {
connect( myBrowser, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
}
+
+ setModified();
}
/*!
if ( !myBrowser )
return;
- QMap<QString, LightApp_DataObject*> themap;
- fillEntries( themap );
+ if( myEntries.count() == 0 ||
+ myModifiedTime < myBrowser->getModifiedTime() )
+ fillEntries( myEntries );
DataObjectList objList;
for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it )
{
const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
- if ( owner && themap.contains( owner->entry() ) )
- objList.append( themap[owner->entry()] );
+ if ( owner && myEntries.contains( owner->entry() ) )
+ objList.append( myEntries[owner->entry()] );
}
myBrowser->setSelected( objList );
if ( obj )
entires.insert( obj->entry(), obj );
}
+
+ setModified();
+}
+
+/*!Update modified time.*/
+void LightApp_OBSelector::setModified()
+{
+ myModifiedTime = clock();
}
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef LIGHTAPP_OBSELECTOR_H
#define LIGHTAPP_OBSELECTOR_H
/*!Return "ObjectBrowser"*/
virtual QString type() const { return "ObjectBrowser"; }
+ void setModified();
+ unsigned long getModifiedTime() { return myModifiedTime; }
+
private slots:
void onSelectionChanged();
private:
OB_Browser* myBrowser;
+
+ QMap<QString, LightApp_DataObject*> myEntries;
+
+ unsigned long myModifiedTime;
};
#endif
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include "LightApp_VTKSelector.h"
#include "LightApp_DataOwner.h"
-#include "SVTK_ViewModel.h"
+#include "SVTK_ViewModelBase.h"
#include "SVTK_Selector.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_Functor.h"
*/
LightApp_SVTKDataOwner
::LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO,
- const TColStd_IndexedMapOfInteger& theIds,
- Selection_Mode theMode,
- SALOME_Actor* theActor):
+ const TColStd_IndexedMapOfInteger& theIds,
+ Selection_Mode theMode,
+ SALOME_Actor* theActor):
LightApp_DataOwner( theIO ),
mySelectionMode(theMode),
myActor(theActor)
Constructor.
*/
LightApp_VTKSelector
-::LightApp_VTKSelector( SVTK_Viewer* viewer,
- SUIT_SelectionMgr* mgr ):
+::LightApp_VTKSelector( SVTK_ViewModelBase* viewer,
+ SUIT_SelectionMgr* mgr ):
SUIT_Selector( mgr, viewer ),
myViewer( viewer )
{
/*!
Gets viewer.
*/
-SVTK_Viewer*
+SVTK_ViewModelBase*
LightApp_VTKSelector
::viewer() const
{
}
/*!
- Gets type of vtk viewer.
+ Gets type of salome vtk viewer.
*/
QString
LightApp_VTKSelector
::type() const
{
- return SVTK_Viewer::Type();
+ return myViewer->getType();
}
/*!
TColStd_IndexedMapOfInteger anIds;
aSelector->GetIndex(anIO,anIds);
SALOME_Actor* anActor = aSelector->GetActor(anIO);
- if( !anActor )
- anActor = VTK::Find<SALOME_Actor>(aView->getRenderer()->GetActors(),VTK::TIsSameIObject<SALOME_Actor>(anIO));
-
+ if( !anActor ){
+ using namespace SVTK;
+ anActor = Find<SALOME_Actor>(aView->getRenderer()->GetActors(),TIsSameIObject<SALOME_Actor>(anIO));
+ }
aList.append(new LightApp_SVTKDataOwner(anIO,anIds,aMode,anActor));
}
}
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef LIGHTAPP_VTKSELECTOR_H
#define LIGHTAPP_VTKSELECTOR_H
#include "SALOME_InteractiveObject.hxx"
class SALOME_Actor;
-class SVTK_Viewer;
+class SVTK_ViewModelBase;
/*!
Provide salome vtk data owner list.
Q_OBJECT;
public:
- LightApp_VTKSelector( SVTK_Viewer*, SUIT_SelectionMgr* );
+ LightApp_VTKSelector( SVTK_ViewModelBase*, SUIT_SelectionMgr* );
virtual ~LightApp_VTKSelector();
- SVTK_Viewer* viewer() const;
+ SVTK_ViewModelBase* viewer() const;
virtual QString type() const;
virtual void setSelection( const SUIT_DataOwnerPtrList& );
private:
- SVTK_Viewer* myViewer;
+ SVTK_ViewModelBase* myViewer;
};
#endif
EXPORT_HEADERS = SALOME_InteractiveObject.hxx \
Handle_SALOME_InteractiveObject.hxx \
- SALOME_Actor.h \
SALOME_GLOwner.h \
SALOME_AISShape.hxx \
Handle_SALOME_AISShape.hxx \
LIB = libSalomeObject.la
LIB_SRC = SALOME_InteractiveObject.cxx \
- SALOME_Actor.cxx \
SALOME_GLOwner.cxx \
SALOME_AISShape.cxx\
SALOME_AISObject.cxx\
BIN =
BIN_SRC =
-CPPFLAGS+=$(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(QT_INCLUDES) $(OGL_INCLUDES)
+CPPFLAGS+=$(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(QT_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
LDFLAGS+= $(PYTHON_LIBS) $(VTK_LIBS) $(QT_LIBS) $(OGL_LIBS) $(CAS_LDPATH) -lTKV3d -lVTKViewer -lsuit
+++ /dev/null
-// SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
-//
-// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : SALOME_Actor.cxx
-// Author : Nicolas REJNERI
-// Module : SALOME
-// $Header$
-
-/*!
- \class SALOME_Actor SALOME_Actor.h
- \brief Abstract class of SALOME Objects in VTK.
-*/
-
-
-#include "SALOME_Actor.h"
-
-#include "VTKViewer_Transform.h"
-#include "VTKViewer_TransformFilter.h"
-#include "VTKViewer_PassThroughFilter.h"
-#include "VTKViewer_GeometryFilter.h"
-
-// SALOME Includes
-//#include "utilities.h"
-
-// VTK Includes
-#include <vtkCell.h>
-#include <vtkRenderer.h>
-#include <vtkPolyData.h>
-#include <vtkObjectFactory.h>
-#include <vtkDataSetMapper.h>
-#include <vtkPolyDataMapper.h>
-#include <vtkProperty.h>
-
-//using namespace std;
-
-
-#if defined __GNUC__
- #if __GNUC__ == 2
- #define __GNUC_2__
- #endif
-#endif
-
-int SALOME_POINT_SIZE = 3;
-
-
-vtkStandardNewMacro(SALOME_Actor);
-
-
-SALOME_Actor::SALOME_Actor(){
- myIsHighlighted = myIsPreselected = false;
-
- myRepresentation = 1;
- myDisplayMode = myRepresentation - 1;
-
- myProperty = vtkProperty::New();
- PreviewProperty = NULL;
-
- myIsInfinite = false;
-
- myIsResolveCoincidentTopology = true;
-
- vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
- myPolygonOffsetUnits);
- myStoreMapping = false;
- myGeomFilter = VTKViewer_GeometryFilter::New();
-
- myTransformFilter = VTKViewer_TransformFilter::New();
-
- for(int i = 0; i < 6; i++)
- myPassFilter.push_back(VTKViewer_PassThroughFilter::New());
-}
-
-
-SALOME_Actor::~SALOME_Actor(){
- SetPreviewProperty(NULL);
-
- myGeomFilter->UnRegisterAllOutputs();
- myGeomFilter->Delete();
-
- myTransformFilter->UnRegisterAllOutputs();
- myTransformFilter->Delete();
-
- for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){
- if(myPassFilter[i]){
- myPassFilter[i]->UnRegisterAllOutputs();
- myPassFilter[i]->Delete();
- }
- }
-
- myProperty->Delete();
-}
-
-
-void SALOME_Actor::AddToRender(vtkRenderer* theRenderer){
- theRenderer->AddActor(this);
-}
-
-void SALOME_Actor::RemoveFromRender(vtkRenderer* theRenderer){
- theRenderer->RemoveActor(this);
-}
-
-
-void SALOME_Actor::SetTransform(VTKViewer_Transform* theTransform){
- myTransformFilter->SetTransform(theTransform);
-}
-
-
-void SALOME_Actor::SetMapper(vtkMapper* theMapper){
- InitPipeLine(theMapper);
-}
-
-void SALOME_Actor::InitPipeLine(vtkMapper* theMapper){
- if(theMapper){
- int anId = 0;
- myPassFilter[ anId ]->SetInput( theMapper->GetInput() );
- myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
-
- anId++; // 1
- myGeomFilter->SetStoreMapping( myStoreMapping );
- myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
-
- anId++; // 2
- myPassFilter[ anId ]->SetInput( myGeomFilter->GetOutput() );
- myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
-
- anId++; // 3
- myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
-
- anId++; // 4
- myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
- myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
-
- anId++; // 5
- if(vtkDataSetMapper* aMapper = dynamic_cast<vtkDataSetMapper*>(theMapper)){
- aMapper->SetInput(myPassFilter[anId]->GetOutput());
- }else if(vtkPolyDataMapper* aMapper = dynamic_cast<vtkPolyDataMapper*>(theMapper)){
- aMapper->SetInput(myPassFilter[anId]->GetPolyDataOutput());
- }
- }
- vtkLODActor::SetMapper(theMapper);
-}
-
-
-void SALOME_Actor::Render(vtkRenderer *ren, vtkMapper* m){
- if(myIsResolveCoincidentTopology){
- int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
- float aFactor, aUnit;
- vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
-
- vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
- vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
- myPolygonOffsetUnits);
- vtkLODActor::Render(ren,m);
-
- vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
- vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
- }else{
- vtkLODActor::Render(ren,m);
- }
-}
-
-
-void SALOME_Actor::SetResolveCoincidentTopology(bool theIsResolve) {
- myIsResolveCoincidentTopology = theIsResolve;
-}
-
-void SALOME_Actor::SetPolygonOffsetParameters(float factor, float units){
- myPolygonOffsetFactor = factor;
- myPolygonOffsetUnits = units;
-}
-
-void SALOME_Actor::GetPolygonOffsetParameters(float& factor, float& units){
- factor = myPolygonOffsetFactor;
- units = myPolygonOffsetUnits;
-}
-
-
-vtkDataSet* SALOME_Actor::GetInput(){
- return myPassFilter.front()->GetOutput();
-}
-
-
-unsigned long int SALOME_Actor::GetMTime(){
- unsigned long mTime = this->Superclass::GetMTime();
- unsigned long time = myTransformFilter->GetMTime();
- mTime = ( time > mTime ? time : mTime );
- if(vtkDataSet *aDataSet = myPassFilter[0]->GetInput()){
- time = aDataSet->GetMTime();
- mTime = ( time > mTime ? time : mTime );
- }
- return mTime;
-}
-
-
-void SALOME_Actor::SetRepresentation(int theMode) {
- switch(myRepresentation){
- case VTK_POINTS :
- case VTK_SURFACE :
- myProperty->DeepCopy(GetProperty());
- }
- switch(theMode){
- case VTK_POINTS :
- case VTK_SURFACE :
- GetProperty()->DeepCopy(myProperty);
- break;
- default:
- GetProperty()->SetAmbient(1.0);
- GetProperty()->SetDiffuse(0.0);
- GetProperty()->SetSpecular(0.0);
- }
- switch(theMode){
- case 3 :
- myGeomFilter->SetInside(true);
- GetProperty()->SetRepresentation(1);
- break;
- case VTK_POINTS :
- GetProperty()->SetPointSize(SALOME_POINT_SIZE);
- default :
- GetProperty()->SetRepresentation(theMode);
- myGeomFilter->SetInside(false);
- }
- myRepresentation = theMode;
-}
-
-int SALOME_Actor::GetRepresentation(){
- return myRepresentation;
-}
-
-
-vtkCell* SALOME_Actor::GetElemCell(int theObjID){
- return GetInput()->GetCell(theObjID);
-}
-
-
-float* SALOME_Actor::GetNodeCoord(int theObjID){
- return GetInput()->GetPoint(theObjID);
-}
-
-
-//=================================================================================
-// function : GetObjDimension
-// purpose : Return object dimension.
-// Virtual method shoulb be redifined by derived classes
-//=================================================================================
-int SALOME_Actor::GetObjDimension( const int theObjId )
-{
- if ( vtkCell* aCell = GetElemCell(theObjId) )
- return aCell->GetCellDimension();
- return 0;
-}
-
-
-bool SALOME_Actor::IsInfinitive(){
- return myIsInfinite;
-}
-
-
-void SALOME_Actor::SetOpacity(float theOpacity){
- myOpacity = theOpacity;
- GetProperty()->SetOpacity(theOpacity);
-}
-
-float SALOME_Actor::GetOpacity(){
- return myOpacity;
-}
-
-
-void SALOME_Actor::SetColor(float r,float g,float b){
- GetProperty()->SetColor(r,g,b);
-}
-
-void SALOME_Actor::GetColor(float& r,float& g,float& b){
- float aColor[3];
- GetProperty()->GetColor(aColor);
- r = aColor[0];
- g = aColor[1];
- b = aColor[2];
-}
-
-
-int SALOME_Actor::getDisplayMode(){
- return myDisplayMode;
-}
-
-void SALOME_Actor::setDisplayMode(int theMode){
- SetRepresentation(theMode+1);
- myDisplayMode = GetRepresentation() - 1;
-}
+++ /dev/null
-// SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
-//
-// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : SALOME_Actor.h
-// Author : Nicolas REJNERI
-// Module : SALOME
-// $Header$
-
-#ifndef SALOME_ACTOR_H
-#define SALOME_ACTOR_H
-
-#include "SALOME_InteractiveObject.hxx" // INCLUDES "using namespace std"
-#ifndef _Handle_SALOME_InteractiveObject_HeaderFile
-#include "Handle_SALOME_InteractiveObject.hxx"
-#endif
-
-#include <vtkLODActor.h> // INCLUDES "stdio.h"
-#include <vtkProperty.h>
-
-// to overcome the conflict between std::ostream and io::ostream
-// the following variable must be defined:
-// VTK_USE_ANSI_STDLIB
-
-#include <vector>
-
-class vtkCell;
-class vtkDataSet;
-class vtkPolyData;
-class vtkCamera;
-class vtkProperty;
-
-class VTKViewer_Transform;
-class VTKViewer_GeometryFilter;
-class VTKViewer_TransformFilter;
-class VTKViewer_PassThroughFilter;
-
-extern int SALOME_POINT_SIZE;
-
-#ifdef WNT
-#define SALOME_OBJECT_EXPORT __declspec (dllexport)
-#else
-#define SALOME_OBJECT_EXPORT
-#endif
-
-#include <VTKViewer_Actor.h>
-
-class SALOME_OBJECT_EXPORT SALOME_Actor : public VTKViewer_Actor {
- public:
- static SALOME_Actor* New();
-
- vtkTypeMacro(SALOME_Actor,vtkLODActor);
-
- virtual Standard_Boolean hasIO() { return !myIO.IsNull(); }
- virtual const Handle(SALOME_InteractiveObject)& getIO() { return myIO; }
- virtual void setIO(const Handle(SALOME_InteractiveObject)& io) { myIO = io; }
-
- virtual const char* getName() { return myName.c_str(); }
- virtual void setName(const char* theName){
- if(hasIO()) myIO->setName(theName);
- myName = theName;
- }
-
- // To generate highlight automaticaly
- virtual bool hasHighlight() { return false; }
- virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; }
- virtual bool isHighlighted() { return myIsHighlighted; }
-
- virtual void SetOpacity(float theOpacity);
- virtual float GetOpacity();
-
- virtual void SetColor(float r,float g,float b);
- virtual void GetColor(float& r,float& g,float& b);
- void SetColor(const float theRGB[3]){
- SetColor(theRGB[0],theRGB[1],theRGB[2]);
- }
-
- vtkSetObjectMacro(PreviewProperty,vtkProperty);
-
- virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;}
-
-
- // Used to obtain all dependent actors
- virtual void GetChildActors(vtkActorCollection*) {};
-
- virtual void AddToRender(vtkRenderer* theRenderer);
- virtual void RemoveFromRender(vtkRenderer* theRenderer);
-
-
- // For selection mapping purpose
- virtual int GetNodeObjId(int theVtkID) { return theVtkID;}
- virtual float* GetNodeCoord(int theObjID);
-
- virtual int GetElemObjId(int theVtkID) { return theVtkID;}
- virtual vtkCell* GetElemCell(int theObjID);
-
- virtual int GetObjDimension( const int theObjId );
-
- virtual void SetMapper(vtkMapper* theMapper);
- virtual vtkDataSet* GetInput();
-
-
- virtual void SetTransform(VTKViewer_Transform* theTransform);
- virtual unsigned long int GetMTime();
-
- virtual void SetRepresentation(int theMode);
- virtual int GetRepresentation();
-
- virtual int getDisplayMode();
- virtual void setDisplayMode(int theMode);
-
- // Infinitive means actor without size (point for example),
- // which is not taken into account in calculation of boundaries of the scene
- void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; }
- virtual bool IsInfinitive();
-
- void SetResolveCoincidentTopology(bool theIsResolve);
- void SetPolygonOffsetParameters(float factor, float units);
- void GetPolygonOffsetParameters(float& factor, float& units);
-
- virtual void Render(vtkRenderer *, vtkMapper *);
-
- virtual float GetShrinkFactor() { return 1.0;}
-
- virtual bool IsShrunkable() { return false;}
- virtual bool IsShrunk() { return false;}
-
- virtual void SetShrink() {}
- virtual void UnShrink() {}
-
- virtual bool IsSetCamera() const { return false; }
- virtual bool IsResizable() const { return false; }
- virtual void SetSize( const float ) {}
- virtual void SetCamera( vtkCamera* ) {}
-
- protected:
- bool myIsResolveCoincidentTopology;
- float myPolygonOffsetFactor;
- float myPolygonOffsetUnits;
-
- Handle(SALOME_InteractiveObject) myIO;
- std::string myName;
-
- vtkProperty *PreviewProperty;
- bool myIsPreselected;
-
- float myOpacity;
- bool myIsHighlighted;
- int myDisplayMode;
- bool myIsInfinite;
-
- bool myStoreMapping;
- VTKViewer_GeometryFilter *myGeomFilter;
- VTKViewer_TransformFilter *myTransformFilter;
- std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
-
- int myRepresentation;
- vtkProperty *myProperty;
-
- void InitPipeLine(vtkMapper* theMapper);
-
- SALOME_Actor();
- ~SALOME_Actor();
-};
-
-
-#endif // SALOME_ACTOR_H
-
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include "OB_Browser.h"
#include "OB_Filter.h"
this, SLOT( onDoubleClicked( QListViewItem* ) ) );
setRootObject( root );
+
+ setModified();
}
OB_Browser::~OB_Browser()
autoOpenBranches();
+ setModified();
+
if ( selNum != numberOfSelected() )
emit selectionChanged();
}
autoOpenBranches();
+ setModified();
+
if ( selNum != numberOfSelected() )
emit selectionChanged();
}
autoOpenBranches();
+ setModified();
+
if ( selNum != numberOfSelected() )
emit selectionChanged();
}
if ( item )
emit doubleClicked( dataObject( item ) );
}
+
+void OB_Browser::setModified()
+{
+ myModifiedTime = clock();
+}
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef OB_BROWSER_H
#define OB_BROWSER_H
virtual void contextMenuPopup( QPopupMenu* );
+ void setModified();
+ unsigned long getModifiedTime() { return myModifiedTime; }
+
signals:
void selectionChanged();
void doubleClicked( SUIT_DataObject* );
int myAutoOpenLevel;
friend class OB_Browser::ToolTip;
+
+ unsigned long myModifiedTime;
};
#endif
#include "SVTK_ViewManager.h"
#include "SVTK_ViewWindow.h"
-#include "SVTK_RenderWindow.h"
-#include "SVTK_RenderWindowInteractor.h"
using namespace std;
virtual void Execute() {
if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow() ) {
PyObject* aPyClass = GetPyClass("vtkRenderWindow");
- vtkRenderWindow* aVTKObject = aVTKViewWindow->getRenderWindow()->getRenderWindow();
+ vtkRenderWindow* aVTKObject = aVTKViewWindow->getRenderWindow();
myResult = PyVTKObject_New(aPyClass,aVTKObject);
}
}
virtual void Execute() {
if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow() ) {
PyObject* aPyClass = GetPyClass("vtkRenderWindowInteractor");
- vtkRenderWindowInteractor* aVTKObject = aVTKViewWindow->getRWInteractor();
+ vtkRenderWindowInteractor* aVTKObject = aVTKViewWindow->getInteractor();
myResult = PyVTKObject_New(aPyClass,aVTKObject);
}
}
# File : Makefile.in
# Author : Alexander Solovyov(OCN)
# Module : SVTK
-# $Header: /dn06/SALOME_CVS/GUI_SRC/src/SVTK/Makefile.in,v 1.1
+# $Header:
top_srcdir=@top_srcdir@
top_builddir=../..
srcdir=@srcdir@
-VPATH=.:@srcdir@:@srcdir@/resources
+VPATH=.:@srcdir@
@COMMENCE@
# header files
-EXPORT_HEADERS= SVTK.h \
- SVTK_Prs.h \
- SVTK_Actor.h \
- SVTK_CubeAxesActor2D.h \
- SVTK_Functor.h \
- SVTK_ViewManager.h \
- SVTK_ViewModel.h \
- SVTK_ViewWindow.h \
- SVTK_RenderWindow.h \
- SVTK_InteractorStyle.h \
- SVTK_RenderWindowInteractor.h \
- SVTK_Selector.h \
- SVTK_Selection.h
-
-PO_FILES = SVTK_msg_en.po
+EXPORT_HEADERS= \
+ SVTK.h \
+ SVTK_Prs.h \
+ SVTK_Actor.h \
+ SALOME_Actor.h \
+ SVTK_FontWidget.h \
+ SVTK_CubeAxesActor2D.h \
+ SVTK_Functor.h \
+ SVTK_MainWindow.h \
+ SVTK_View.h \
+ SVTK_ViewManager.h \
+ SVTK_ViewModel.h \
+ SVTK_ViewWindow.h \
+ SVTK_Renderer.h \
+ SVTK_InteractorStyle.h \
+ SVTK_RenderWindowInteractor.h \
+ SVTK_GenericRenderWindowInteractor.h \
+ SVTK_Selector.h \
+ SVTK_Selection.h \
+ SVTK_SelectionEvent.h \
+ SVTK_SpaceMouse.h \
+ SVTK_Event.h \
+ SVTK_ViewModelBase.h
# Libraries targets
LIB = libSVTK.la
-LIB_SRC= SVTK_Prs.cxx \
- SVTK_Actor.cxx \
- SVTK_CubeAxesActor2D.cxx \
- SVTK_Trihedron.cxx \
- SVTK_ViewManager.cxx \
- SVTK_ViewModel.cxx \
- SVTK_ViewWindow.cxx \
- SVTK_RenderWindow.cxx \
- SVTK_InteractorStyle.cxx \
- SVTK_RenderWindowInteractor.cxx \
- SVTK_Selector.cxx
-
-LIB_MOC = SVTK_RenderWindowInteractor.h \
- SVTK_InteractorStyle.h \
- SVTK_RenderWindow.h \
- SVTK_ViewWindow.h \
- SVTK_ViewModel.h \
- SVTK_ViewManager.h
-
-CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS)
-
-LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS)
-LIBS+= -lsuit -lCAM -lSalomeObject -lSalomePrs -lVTKViewer
+LIB_SRC= \
+ SVTK_Prs.cxx \
+ SVTK_Actor.cxx \
+ SALOME_Actor.cxx \
+ SVTK_CubeAxesActor2D.cxx \
+ SVTK_NonIsometricDlg.cxx \
+ SVTK_CubeAxesDlg.cxx \
+ SVTK_FontWidget.cxx \
+ SVTK_Trihedron.cxx \
+ SVTK_MainWindow.cxx \
+ SVTK_View.cxx \
+ SVTK_ViewManager.cxx \
+ SVTK_ViewModel.cxx \
+ SVTK_Renderer.cxx \
+ SVTK_ViewWindow.cxx \
+ SVTK_InteractorStyle.cxx \
+ SVTK_RenderWindowInteractor.cxx \
+ SVTK_GenericRenderWindowInteractor.cxx \
+ SVTK_SpaceMouse.cxx \
+ SVTK_Selector.cxx
+
+LIB_MOC = \
+ SVTK_GenericRenderWindowInteractor.h \
+ SVTK_RenderWindowInteractor.h \
+ SVTK_NonIsometricDlg.h \
+ SVTK_CubeAxesDlg.h \
+ SVTK_FontWidget.h \
+ SVTK_ViewModelBase.h \
+ SVTK_ViewManager.h \
+ SVTK_ViewWindow.h \
+ SVTK_MainWindow.h \
+ SVTK_ViewModel.h \
+ SVTK_View.h
+
+BIN = SVTK
+
+CPPFLAGS+= \
+ $(QT_INCLUDES) \
+ $(OCC_INCLUDES) \
+ $(VTK_INCLUDES) \
+ $(BOOST_CPPFLAGS) \
+ -I$(KERNEL_ROOT_DIR)/include/salome
+
+LDFLAGS+= \
+ $(QT_MT_LIBS) \
+ $(OCC_LIBS) \
+ $(VTK_LIBS) \
+ -L$(KERNEL_ROOT_DIR)/lib/salome
+
+LIBS+= -lsuit -lCAM -lSalomeObject -lSalomePrs -lVTKViewer -lOpUtil -lToolsGUI -lSalomeDS
+
+LDFLAGSFORBIN=$(LDFLAGS) $(LIBS) \
+ -lqtx -lstd -lSALOMELocalTrace -lSalomeNS -lTOOLSDS -lSalomeHDFPersist -lSalomeDSImpl \
+ -lSalomeGenericObj -lSalomeLifeCycleCORBA -lSALOMEBasics -lSalomeContainer \
+ -lSalomeResourcesManager -lRegistry -lSalomeNotification
@CONCLUDE@
--- /dev/null
+// SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SALOME_Actor.cxx
+// Author : Nicolas REJNERI
+// Module : SALOME
+// $Header$
+
+/*!
+ \class SALOME_Actor SALOME_Actor.h
+ \brief Abstract class of SALOME Objects in VTK.
+*/
+
+
+#include "SALOME_Actor.h"
+
+#include "VTKViewer_Transform.h"
+#include "VTKViewer_TransformFilter.h"
+#include "VTKViewer_PassThroughFilter.h"
+#include "VTKViewer_GeometryFilter.h"
+#include "VTKViewer_CellRectPicker.h"
+
+#include "SVTK_Actor.h"
+
+// VTK Includes
+#include <vtkCell.h>
+#include <vtkLine.h>
+#include <vtkPicker.h>
+#include <vtkPointPicker.h>
+#include <vtkCellPicker.h>
+#include <vtkRenderer.h>
+#include <vtkPolyData.h>
+#include <vtkObjectFactory.h>
+#include <vtkDataSetMapper.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkProperty.h>
+#include <vtkOutlineSource.h>
+
+#include <vtkInteractorStyle.h>
+#include <vtkRenderWindowInteractor.h>
+
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+
+#include "utilities.h"
+
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 1;
+#else
+static int MYDEBUG = 0;
+#endif
+
+#if defined __GNUC__
+ #if __GNUC__ == 2
+ #define __GNUC_2__
+ #endif
+#endif
+
+int SALOME_POINT_SIZE = 5;
+int SALOME_LINE_WIDTH = 3;
+
+//----------------------------------------------------------------------------
+namespace
+{
+ int
+ GetEdgeId(SALOME_Actor* theActor,
+ vtkPicker* thePicker,
+ int theObjId)
+ {
+ int anEdgeId = 0;
+ if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
+ float aPickPosition[3];
+ thePicker->GetPickPosition(aPickPosition);
+ float aMinDist = 1000000.0, aDist = 0;
+ for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
+ if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
+ int subId; float pcoords[3], closestPoint[3], weights[3];
+ aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
+ if (aDist < aMinDist) {
+ aMinDist = aDist;
+ anEdgeId = -1 - i;
+ }
+ }
+ }
+ }
+ return anEdgeId;
+ }
+
+ inline
+ bool
+ CheckDimensionId(Selection_Mode theMode,
+ SALOME_Actor *theActor,
+ vtkIdType theObjId)
+ {
+ switch(theMode){
+ case CellSelection:
+ return true;
+ case EdgeSelection:
+ return ( theActor->GetObjDimension( theObjId ) == 1 );
+ case FaceSelection:
+ return ( theActor->GetObjDimension( theObjId ) == 2 );
+ case VolumeSelection:
+ return ( theActor->GetObjDimension( theObjId ) == 3 );
+ };
+ return false;
+ }
+
+}
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(SALOME_Actor);
+
+
+//----------------------------------------------------------------------------
+SALOME_Actor
+::SALOME_Actor():
+ myRenderer(NULL),
+ myInteractor(NULL),
+ mySelectionMode(ActorSelection),
+ myIsHighlighted(false),
+ myIsPreselected(false),
+ myRepresentation(VTK_SURFACE),
+ myDisplayMode(1),
+ myProperty(vtkProperty::New()),
+ PreviewProperty(NULL),
+ myIsInfinite(false),
+ myIsResolveCoincidentTopology(true),
+ myStoreMapping(false),
+ myGeomFilter(VTKViewer_GeometryFilter::New()),
+ myTransformFilter(VTKViewer_TransformFilter::New()),
+ myPreHighlightActor(SVTK_Actor::New()),
+ myHighlightActor(SVTK_Actor::New()),
+ myOutline(vtkOutlineSource::New()),
+ myOutlineActor(VTKViewer_Actor::New())
+{
+ if(MYDEBUG) MESSAGE("SALOME_Actor::SALOME_Actor - this = "<<this);
+
+ vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
+ myPolygonOffsetUnits);
+
+ for(int i = 0; i < 6; i++)
+ myPassFilter.push_back(VTKViewer_PassThroughFilter::New());
+
+ myPreHighlightActor->Delete();
+ myPreHighlightActor->Initialize();
+ myPreHighlightActor->PickableOff();
+ myPreHighlightActor->SetVisibility( false );
+
+ myHighlightActor->Delete();
+ myHighlightActor->Initialize();
+ myHighlightActor->PickableOff();
+ myHighlightActor->SetVisibility( false );
+
+ myOutline->Delete();
+
+ vtkPolyDataMapper* anOutlineMapper = vtkPolyDataMapper::New();
+ anOutlineMapper->SetInput(myOutline->GetOutput());
+
+ myOutlineActor->Delete();
+ myOutlineActor->SetMapper( anOutlineMapper );
+ anOutlineMapper->Delete();
+
+ myOutlineActor->PickableOff();
+ myOutlineActor->DragableOff();
+ myOutlineActor->GetProperty()->SetColor(1.0,0.0,0.0);
+ myOutlineActor->GetProperty()->SetAmbient(1.0);
+ myOutlineActor->GetProperty()->SetDiffuse(0.0);
+ myOutlineActor->SetVisibility( false );
+}
+
+
+//----------------------------------------------------------------------------
+SALOME_Actor
+::~SALOME_Actor()
+{
+ if(MYDEBUG) MESSAGE("SALOME_Actor::~SALOME_Actor - this = "<<this);
+
+ SetPreviewProperty(NULL);
+
+ myGeomFilter->UnRegisterAllOutputs();
+ myGeomFilter->Delete();
+
+ myTransformFilter->UnRegisterAllOutputs();
+ myTransformFilter->Delete();
+
+ for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){
+ if(myPassFilter[i]){
+ myPassFilter[i]->UnRegisterAllOutputs();
+ myPassFilter[i]->Delete();
+ }
+ }
+
+ myProperty->Delete();
+}
+
+
+//----------------------------------------------------------------------------
+Standard_Boolean
+SALOME_Actor
+::hasIO()
+{
+ return !myIO.IsNull();
+}
+
+const Handle(SALOME_InteractiveObject)&
+SALOME_Actor
+::getIO()
+{
+ return myIO;
+}
+
+void
+SALOME_Actor
+::setIO(const Handle(SALOME_InteractiveObject)& theIO)
+{
+ myIO = theIO;
+}
+
+const char*
+SALOME_Actor
+::getName()
+{
+ return myName.c_str();
+}
+
+void
+SALOME_Actor
+::setName(const char* theName)
+{
+ if(hasIO())
+ myIO->setName(theName);
+ myName = theName;
+}
+
+
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::AddToRender(vtkRenderer* theRenderer)
+{
+ myRenderer = theRenderer;
+
+ theRenderer->AddActor(this);
+
+ theRenderer->AddActor( myPreHighlightActor.GetPointer() );
+ theRenderer->AddActor( myHighlightActor.GetPointer() );
+ theRenderer->AddActor( myOutlineActor.GetPointer() );
+}
+
+void
+SALOME_Actor
+::RemoveFromRender(vtkRenderer* theRenderer)
+{
+ theRenderer->RemoveActor(this);
+
+ theRenderer->RemoveActor( myPreHighlightActor.GetPointer() );
+ theRenderer->RemoveActor( myHighlightActor.GetPointer() );
+ theRenderer->RemoveActor( myOutlineActor.GetPointer() );
+}
+
+vtkRenderer*
+SALOME_Actor
+::GetRenderer()
+{
+ return myRenderer;
+}
+
+void
+SALOME_Actor
+::GetChildActors(vtkActorCollection*)
+{}
+
+
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::SetInteractor(vtkRenderWindowInteractor* theInteractor)
+{
+ myInteractor = theInteractor;
+}
+
+void
+SALOME_Actor
+::Update()
+{
+ myInteractor->CreateTimer(VTKI_TIMER_UPDATE);
+}
+
+
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::SetTransform(VTKViewer_Transform* theTransform)
+{
+ Superclass::SetTransform(theTransform);
+
+ myPreHighlightActor->SetTransform(theTransform);
+ myHighlightActor->SetTransform(theTransform);
+ myOutlineActor->SetTransform(theTransform);
+}
+
+
+void
+SALOME_Actor
+::SetPosition(float _arg1, float _arg2, float _arg3)
+{
+ Superclass::SetPosition(_arg1,_arg2,_arg3);
+
+ myPreHighlightActor->SetPosition(_arg1,_arg2,_arg3);
+ myHighlightActor->SetPosition(_arg1,_arg2,_arg3);
+ myOutlineActor->SetPosition(_arg1,_arg2,_arg3);
+}
+
+
+void
+SALOME_Actor
+::SetPosition(float _arg[3])
+{
+ SetPosition(_arg[0],_arg[1],_arg[2]);
+}
+
+
+void
+SALOME_Actor
+::SetMapper(vtkMapper* theMapper)
+{
+ InitPipeLine(theMapper);
+}
+
+void
+SALOME_Actor
+::InitPipeLine(vtkMapper* theMapper)
+{
+ if(theMapper){
+ int anId = 0;
+ myPassFilter[ anId ]->SetInput( theMapper->GetInput() );
+ myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
+
+ anId++; // 1
+ myGeomFilter->SetStoreMapping( myStoreMapping );
+ myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
+
+ anId++; // 2
+ myPassFilter[ anId ]->SetInput( myGeomFilter->GetOutput() );
+ myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
+
+ anId++; // 3
+ myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
+
+ anId++; // 4
+ myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
+ myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
+
+ anId++; // 5
+ if(vtkDataSetMapper* aMapper = dynamic_cast<vtkDataSetMapper*>(theMapper)){
+ aMapper->SetInput(myPassFilter[anId]->GetOutput());
+ }else if(vtkPolyDataMapper* aMapper = dynamic_cast<vtkPolyDataMapper*>(theMapper)){
+ aMapper->SetInput(myPassFilter[anId]->GetPolyDataOutput());
+ }
+ }
+ Superclass::SetMapper(theMapper);
+}
+
+
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::Render(vtkRenderer *ren, vtkMapper* m)
+{
+ if(myIsResolveCoincidentTopology){
+ int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
+ float aFactor, aUnit;
+ vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
+
+ vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
+ vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
+ myPolygonOffsetUnits);
+ Superclass::Render(ren,m);
+
+ vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit);
+ vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
+ }else{
+ Superclass::Render(ren,m);
+ }
+}
+
+
+void
+SALOME_Actor
+::SetResolveCoincidentTopology(bool theIsResolve)
+{
+ myIsResolveCoincidentTopology = theIsResolve;
+}
+
+void
+SALOME_Actor
+::SetPolygonOffsetParameters(float factor, float units)
+{
+ myPolygonOffsetFactor = factor;
+ myPolygonOffsetUnits = units;
+}
+
+void
+SALOME_Actor
+::GetPolygonOffsetParameters(float& factor, float& units)
+{
+ factor = myPolygonOffsetFactor;
+ units = myPolygonOffsetUnits;
+}
+
+
+//----------------------------------------------------------------------------
+float
+SALOME_Actor
+::GetShrinkFactor()
+{
+ return 1.0;
+}
+
+bool
+SALOME_Actor
+::IsShrunkable()
+{
+ return false;
+}
+
+bool
+SALOME_Actor
+::IsShrunk()
+{
+ return false;
+}
+
+void
+SALOME_Actor
+::SetShrink()
+{}
+
+void
+SALOME_Actor
+::UnShrink()
+{}
+
+
+//----------------------------------------------------------------------------
+vtkDataSet*
+SALOME_Actor
+::GetInput()
+{
+ return myPassFilter.front()->GetOutput();
+}
+
+
+unsigned long int
+SALOME_Actor
+::GetMTime()
+{
+ unsigned long mTime = this->Superclass::GetMTime();
+ unsigned long time = myTransformFilter->GetMTime();
+ mTime = ( time > mTime ? time : mTime );
+ if(vtkDataSet *aDataSet = myPassFilter[0]->GetInput()){
+ time = aDataSet->GetMTime();
+ mTime = ( time > mTime ? time : mTime );
+ }
+ return mTime;
+}
+
+
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::SetRepresentation(int theMode)
+{
+ switch(myRepresentation){
+ case VTK_POINTS :
+ case VTK_SURFACE :
+ myProperty->DeepCopy(GetProperty());
+ }
+ switch(theMode){
+ case VTK_POINTS :
+ case VTK_SURFACE :
+ GetProperty()->DeepCopy(myProperty);
+ break;
+ default:
+ GetProperty()->SetAmbient(1.0);
+ GetProperty()->SetDiffuse(0.0);
+ GetProperty()->SetSpecular(0.0);
+ }
+ switch(theMode){
+ case 3 :
+ myGeomFilter->SetInside(true);
+ myGeomFilter->SetWireframeMode(true);
+ GetProperty()->SetRepresentation(1);
+ break;
+ case VTK_POINTS :
+ GetProperty()->SetPointSize(SALOME_POINT_SIZE);
+ GetProperty()->SetRepresentation(theMode);
+ myGeomFilter->SetWireframeMode(false);
+ myGeomFilter->SetInside(false);
+ break;
+ case VTK_WIREFRAME :
+ GetProperty()->SetRepresentation(theMode);
+ myGeomFilter->SetWireframeMode(true);
+ myGeomFilter->SetInside(false);
+ break;
+ case VTK_SURFACE :
+ GetProperty()->SetRepresentation(theMode);
+ myGeomFilter->SetWireframeMode(false);
+ myGeomFilter->SetInside(false);
+ break;
+ }
+ myRepresentation = theMode;
+}
+
+int
+SALOME_Actor
+::GetRepresentation()
+{
+ return myRepresentation;
+}
+
+
+//----------------------------------------------------------------------------
+int
+SALOME_Actor
+::GetNodeObjId(int theVtkID)
+{
+ return theVtkID;
+}
+
+float*
+SALOME_Actor
+::GetNodeCoord(int theObjID)
+{
+ return GetInput()->GetPoint(theObjID);
+}
+
+vtkCell*
+SALOME_Actor
+::GetElemCell(int theObjID)
+{
+ return GetInput()->GetCell(theObjID);
+}
+
+int
+SALOME_Actor
+::GetElemObjId(int theVtkID)
+{
+ return theVtkID;
+}
+
+
+//=================================================================================
+// function : GetObjDimension
+// purpose : Return object dimension.
+// Virtual method shoulb be redifined by derived classes
+//=================================================================================
+int
+SALOME_Actor
+::GetObjDimension( const int theObjId )
+{
+ if ( vtkCell* aCell = GetElemCell(theObjId) )
+ return aCell->GetCellDimension();
+ return 0;
+}
+
+
+void
+SALOME_Actor
+::SetInfinitive(bool theIsInfinite)
+{
+ myIsInfinite = theIsInfinite;
+}
+
+
+bool
+SALOME_Actor
+::IsInfinitive()
+{
+ return myIsInfinite;
+}
+
+
+float*
+SALOME_Actor
+::GetBounds()
+{
+ return Superclass::GetBounds();
+}
+
+
+void
+SALOME_Actor
+::GetBounds(float theBounds[6])
+{
+ Superclass::GetBounds(theBounds);
+}
+
+
+//----------------------------------------------------------------------------
+bool
+SALOME_Actor
+::IsSetCamera() const
+{
+ return false;
+}
+
+bool
+SALOME_Actor
+::IsResizable() const
+{
+ return false;
+}
+
+void
+SALOME_Actor
+::SetSize( const float )
+{}
+
+
+void
+SALOME_Actor
+::SetCamera( vtkCamera* )
+{}
+
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::SetOpacity(float theOpacity)
+{
+ myOpacity = theOpacity;
+ GetProperty()->SetOpacity(theOpacity);
+}
+
+float
+SALOME_Actor
+::GetOpacity()
+{
+ return myOpacity;
+}
+
+
+void
+SALOME_Actor
+::SetColor(float r,float g,float b)
+{
+ GetProperty()->SetColor(r,g,b);
+}
+
+void
+SALOME_Actor
+::SetColor(const float theRGB[3])
+{
+ SetColor(theRGB[0],theRGB[1],theRGB[2]);
+}
+
+void
+SALOME_Actor
+::GetColor(float& r,float& g,float& b)
+{
+ float aColor[3];
+ GetProperty()->GetColor(aColor);
+ r = aColor[0];
+ g = aColor[1];
+ b = aColor[2];
+}
+
+
+//----------------------------------------------------------------------------
+int
+SALOME_Actor
+::getDisplayMode()
+{
+ return myDisplayMode;
+}
+
+void
+SALOME_Actor::setDisplayMode(int theMode)
+{
+ SetRepresentation(theMode+1);
+ myDisplayMode = GetRepresentation() - 1;
+}
+
+
+//----------------------------------------------------------------
+void
+SALOME_Actor
+::SetVisibility( int theVisibility )
+{
+ Superclass::SetVisibility( theVisibility );
+
+ myOutlineActor->SetVisibility( theVisibility && isHighlighted() && !hasHighlight() );
+
+ myPreHighlightActor->SetVisibility( theVisibility && myIsPreselected );
+
+ if(mySelector.GetPointer()){
+ if(mySelector->SelectionMode() != ActorSelection){
+ int aHasIndex = mySelector->HasIndex( getIO() );
+ myHighlightActor->SetVisibility( theVisibility && isHighlighted() && aHasIndex);
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+bool
+SALOME_Actor
+::hasHighlight()
+{
+ return false;
+}
+
+bool
+SALOME_Actor
+::isHighlighted()
+{
+ return myIsHighlighted;
+}
+
+void
+SALOME_Actor
+::SetPreSelected(bool thePreselect)
+{
+ myIsPreselected = thePreselect;
+}
+
+
+//----------------------------------------------------------------
+void
+SALOME_Actor
+::SetSelector(SVTK_Selector* theSelector)
+{
+ mySelector = theSelector;
+}
+
+void
+SALOME_Actor
+::Highlight(bool theIsHighlight)
+{
+ mySelectionMode = mySelector->SelectionMode();
+ myHighlightActor->SetVisibility( false );
+ myOutlineActor->SetVisibility( false );
+
+ if(MYDEBUG) MESSAGE("SALOME_Actor::highlight - this = "<<this<<
+ "; theIsHighlight = "<<theIsHighlight<<
+ "; mySelectionMode = "<<mySelectionMode);
+
+ if(mySelector.GetPointer()){
+ if(mySelectionMode != ActorSelection){
+ TColStd_IndexedMapOfInteger aMapIndex;
+ mySelector->GetIndex( getIO(), aMapIndex );
+ switch( mySelectionMode ){
+ case NodeSelection:
+ myHighlightActor->GetProperty()->SetRepresentationToPoints();
+ myHighlightActor->MapPoints( this, aMapIndex );
+ break;
+ case EdgeOfCellSelection:
+ myHighlightActor->GetProperty()->SetRepresentationToWireframe();
+ myHighlightActor->MapEdge( this, aMapIndex );
+ break;
+ case CellSelection:
+ case EdgeSelection:
+ case FaceSelection:
+ case VolumeSelection:
+ myHighlightActor->GetProperty()->SetRepresentationToSurface();
+ myHighlightActor->MapCells( this, aMapIndex );
+ break;
+ }
+ myHighlightActor->SetVisibility( GetVisibility() && theIsHighlight );
+ }
+ }
+
+ highlight(theIsHighlight);
+}
+
+void
+SALOME_Actor
+::highlight(bool theIsHighlight)
+{
+ myOutline->SetBounds( GetInput()->GetBounds() );
+ myOutlineActor->SetVisibility( GetVisibility() && theIsHighlight );
+ myIsHighlighted = theIsHighlight;
+}
+
+
+//----------------------------------------------------------------
+bool
+SALOME_Actor
+::PreHighlight(vtkInteractorStyle *theInteractorStyle,
+ SVTK_SelectionEvent* theSelectionEvent,
+ bool theIsHighlight)
+{
+ vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
+ //
+ myPreHighlightActor->SetVisibility( false );
+ bool anIsPreselected = myIsPreselected;
+
+ Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
+ bool anIsChanged = (mySelectionMode != aSelectionMode);
+
+ float x = theSelectionEvent->myX;
+ float y = theSelectionEvent->myY;
+ float z = 0.0;
+
+ if( !theIsHighlight ) {
+ SetPreSelected( false );
+ vtkActorCollection* theActors = aRenderer->GetActors();
+ theActors->InitTraversal();
+ while( vtkActor *ac = theActors->GetNextActor() )
+ if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) )
+ if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
+ anActor->SetPreSelected( false );
+
+ }else{
+ switch(aSelectionMode){
+ case NodeSelection:
+ {
+ myPointPicker->Pick( x, y, z, aRenderer );
+
+ int aVtkId = myPointPicker->GetPointId();
+ if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
+ int anObjId = GetNodeObjId( aVtkId );
+ myIsPreselected = (anObjId >= 0);
+ if(myIsPreselected){
+ const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
+ int anExtent = aMapIndex.Extent();
+ anIsChanged |= (anExtent == 0 || anExtent > 0 && anObjId != aMapIndex(1));
+ if(anIsChanged){
+ TColStd_IndexedMapOfInteger aMapIndex;
+ aMapIndex.Add( anObjId );
+
+ myPreHighlightActor->GetProperty()->SetRepresentationToPoints();
+ myPreHighlightActor->SetVisibility( true );
+ myPreHighlightActor->MapPoints( this, aMapIndex );
+ }
+ }
+ }
+ break;
+ }
+ case CellSelection:
+ case EdgeSelection:
+ case FaceSelection:
+ case VolumeSelection:
+ {
+ myCellPicker->Pick( x, y, z, aRenderer );
+
+ int aVtkId = myCellPicker->GetCellId();
+ if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) && hasIO() ) {
+ int anObjId = GetElemObjId (aVtkId );
+ if ( anObjId >= 0 ) {
+ myIsPreselected = CheckDimensionId(aSelectionMode,this,anObjId);
+ if(myIsPreselected){
+ const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
+ int anExtent = aMapIndex.Extent();
+ anIsChanged |= (anExtent == 0 || anExtent > 0 && anObjId != aMapIndex(1));
+ if(anIsChanged){
+ TColStd_IndexedMapOfInteger aMapIndex;
+ aMapIndex.Add( anObjId );
+
+ myPreHighlightActor->GetProperty()->SetRepresentationToSurface();
+ myPreHighlightActor->SetVisibility( true );
+ myPreHighlightActor->MapCells( this, aMapIndex );
+ }
+ }
+ }
+ }
+ break;
+ }
+ case EdgeOfCellSelection:
+ {
+ myCellPicker->Pick( x, y, z, aRenderer );
+
+ int aVtkId = myCellPicker->GetCellId();
+ if ( aVtkId >= 0 && mySelector->IsValid( this, aVtkId )) {
+ int anObjId = GetElemObjId( aVtkId );
+ if ( anObjId >= 0 ) {
+ int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
+ myIsPreselected = anEdgeId < 0;
+ if(myIsPreselected){
+ const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex();
+ int anExtent = aMapIndex.Extent();
+ anIsChanged |= (anExtent != 2);
+ anIsChanged |= (anExtent == 0 && (anObjId != aMapIndex(1) || anEdgeId != aMapIndex(2)));
+ if(anIsChanged){
+ TColStd_IndexedMapOfInteger aMapIndex;
+ aMapIndex.Add( anObjId );
+ aMapIndex.Add( anEdgeId );
+
+ myPreHighlightActor->GetProperty()->SetRepresentationToWireframe();
+ myPreHighlightActor->SetVisibility( true );
+ myPreHighlightActor->MapEdge( this, aMapIndex );
+ }
+ }
+ }
+ }
+ break;
+ }
+ case ActorSelection :
+ {
+ if( !mySelector->IsSelected( myIO ) ) {
+ SetPreSelected( true );
+
+ vtkActorCollection* theActors = aRenderer->GetActors();
+ theActors->InitTraversal();
+ while( vtkActor *anAct = theActors->GetNextActor() ) {
+ if( anAct != this )
+ if( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( anAct ) )
+ if( anActor->hasIO() && myIO->isSame( anActor->getIO() ) )
+ anActor->SetPreSelected( true );
+ }
+ }
+ }
+ default:
+ break;
+ }
+ }
+
+ mySelectionMode = aSelectionMode;
+ anIsChanged |= (anIsPreselected != myIsPreselected);
+
+ return anIsChanged;
+}
+
+
+//----------------------------------------------------------------
+bool
+SALOME_Actor
+::Highlight(vtkInteractorStyle *theInteractorStyle,
+ SVTK_SelectionEvent* theSelectionEvent,
+ bool theIsHighlight)
+{
+ myOutlineActor->SetVisibility( false );
+ myHighlightActor->SetVisibility( false );
+
+ vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
+ //
+ Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
+ bool isShift = theSelectionEvent->myIsShift;
+
+ float x = theSelectionEvent->myX;
+ float y = theSelectionEvent->myY;
+ float z = 0.0;
+
+ if( !theSelectionEvent->myIsRectangle ) {
+ switch(aSelectionMode){
+ case NodeSelection: {
+ myPointPicker->Pick( x, y, z, aRenderer );
+
+ int aVtkId = myPointPicker->GetPointId();
+ if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
+ int anObjId = GetNodeObjId( aVtkId );
+ if( anObjId >= 0 ) {
+ if( mySelector->IsSelected( myIO ) )
+ mySelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+ else {
+ if( !isShift ) {
+ mySelector->ClearIObjects();
+ }
+ mySelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+ mySelector->AddIObject( this );
+ }
+ }
+ }
+ break;
+ }
+ case CellSelection:
+ case EdgeSelection:
+ case FaceSelection:
+ case VolumeSelection:
+ {
+ myCellPicker->Pick( x, y, z, aRenderer );
+
+ int aVtkId = myCellPicker->GetCellId();
+ if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
+ int anObjId = GetElemObjId( aVtkId );
+ if( anObjId >= 0 ) {
+ if ( CheckDimensionId(aSelectionMode,this,anObjId) ) {
+ if( mySelector->IsSelected( myIO ) )
+ mySelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+ else {
+ if( !isShift ) {
+ mySelector->ClearIObjects();
+ }
+ mySelector->AddOrRemoveIndex( myIO, anObjId, isShift );
+ mySelector->AddIObject( this );
+ }
+ }
+ }
+ }
+ break;
+ }
+ case EdgeOfCellSelection:
+ {
+ myCellPicker->Pick( x, y, z, aRenderer );
+
+ int aVtkId = myCellPicker->GetCellId();
+ if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId ) ) {
+ int anObjId = GetElemObjId( aVtkId );
+ if( anObjId >= 0 ) {
+ if( !isShift ) {
+ mySelector->ClearIObjects();
+ }
+ int anEdgeId = GetEdgeId(this,myCellPicker.GetPointer(),anObjId);
+ if( anEdgeId >= 0 ) {
+ mySelector->AddOrRemoveIndex( myIO, anObjId, false );
+ mySelector->AddOrRemoveIndex( myIO, -anEdgeId-1, true );
+ mySelector->AddIObject( this );
+ }
+ }
+ }
+ break;
+ }
+ case ActorSelection :
+ {
+ if( mySelector->IsSelected( myIO ) && isShift )
+ mySelector->RemoveIObject( this );
+ else {
+ if( !isShift ) {
+ mySelector->ClearIObjects();
+ }
+ mySelector->AddIObject( this );
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }else{
+ float xLast = theSelectionEvent->myLastX;
+ float yLast = theSelectionEvent->myLastY;
+ float zLast = 0.0;
+
+ float x1 = x < xLast ? x : xLast;
+ float y1 = y < yLast ? y : yLast;
+ float z1 = z < zLast ? z : zLast;
+ float x2 = x > xLast ? x : xLast;
+ float y2 = y > yLast ? y : yLast;
+ float z2 = z > zLast ? z : zLast;
+
+ switch(aSelectionMode){
+ case NodeSelection: {
+ if( vtkDataSet* aDataSet = GetInput() ) {
+ TColStd_MapOfInteger anIndices;
+ for( int i = 0; i < aDataSet->GetNumberOfPoints(); i++) {
+ float aPoint[3];
+ aDataSet->GetPoint( i, aPoint );
+
+ float aPnt[3];
+ aRenderer->SetWorldPoint( aPoint[0], aPoint[1], aPoint[2], 1.0 );
+ aRenderer->WorldToDisplay();
+ aRenderer->GetDisplayPoint( aPnt );
+
+ if( aPnt[0] > x1 && aPnt[0] < x2 && aPnt[1] > y1 && aPnt[1] < y2 ) {
+ float aDisp[3];
+ aRenderer->SetWorldPoint( aPoint[0], aPoint[1], aPoint[2], 1.0 );
+ aRenderer->WorldToDisplay();
+ aRenderer->GetDisplayPoint( aDisp );
+
+ if( myPointPicker->Pick( aDisp[0], aDisp[1], 0.0, aRenderer ) ) {
+ if( vtkActorCollection* anActorCollection = myPointPicker->GetActors() ) {
+ if( anActorCollection->IsItemPresent( this ) ) {
+ float aPickedPoint[3];
+ myPointPicker->GetMapperPosition( aPickedPoint );
+ vtkIdType aVtkId = aDataSet->FindPoint( aPickedPoint );
+ if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) ) {
+ int anObjId = GetNodeObjId( aVtkId );
+ anIndices.Add( anObjId );
+ }
+ }
+ }
+ }
+ }
+ }
+ if( !anIndices.IsEmpty() ) {
+ mySelector->AddOrRemoveIndex( myIO, anIndices, true );
+ mySelector->AddIObject( this );
+ anIndices.Clear();
+ }
+ else
+ mySelector->RemoveIObject( this );
+ }
+ break;
+ }
+ case ActorSelection :
+ {
+ float aPnt[3];
+ float* aBounds = GetBounds();
+
+ bool picked = true;
+ for( int i = 0; i <= 1; i++ ) {
+ for( int j = 2; j <= 3; j++ ) {
+ for( int k = 4; k <= 5; k++ ) {
+ aRenderer->SetWorldPoint( aBounds[ i ], aBounds[ j ], aBounds[ k ], 1.0 );
+ aRenderer->WorldToDisplay();
+ aRenderer->GetDisplayPoint( aPnt );
+
+ if( aPnt[0] < x1 || aPnt[0] > x2 || aPnt[1] < y1 || aPnt[1] > y2 ) {
+ picked = false;
+ break;
+ }
+ }
+ }
+ }
+
+ if( picked )
+ mySelector->AddIObject(this);
+
+ break;
+ }
+ case CellSelection:
+ case EdgeSelection:
+ case FaceSelection:
+ case VolumeSelection:
+ {
+ myCellRectPicker->SetTolerance( 0.001 );
+ myCellRectPicker->Pick( x1, y1, z1, x2, y2, z2, aRenderer );
+
+ VTKViewer_CellDataSet aCellList = myCellRectPicker->GetCellData( this );
+ TColStd_MapOfInteger anIndexes;
+ if( !aCellList.empty() ) {
+ VTKViewer_CellDataSet::iterator anIter = aCellList.begin();
+ for(; anIter != aCellList.end(); ++anIter ) {
+ int aCellId = anIter->cellId;
+ if ( !mySelector->IsValid( this, aCellId ) )
+ continue;
+
+ int anObjId = GetElemObjId( aCellId );
+ if( anObjId != -1 )
+ if ( CheckDimensionId(aSelectionMode,this,anObjId) ) {
+ anIndexes.Add(anObjId);
+ }
+ }
+ }
+ mySelector->AddOrRemoveIndex( myIO, anIndexes, true );
+ mySelector->AddIObject( this );
+ }
+ default:
+ break;
+ }
+ }
+
+ mySelectionMode = aSelectionMode;
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::SetPointPicker(vtkPointPicker* thePointPicker)
+{
+ myPointPicker = thePointPicker;
+}
+
+void
+SALOME_Actor
+::SetCellPicker(vtkCellPicker* theCellPicker)
+{
+ myCellPicker = theCellPicker;
+}
+
+void
+SALOME_Actor
+::SetCellRectPicker(VTKViewer_CellRectPicker* theCellRectPicker)
+{
+ myCellRectPicker = theCellRectPicker;
+}
+
+//----------------------------------------------------------------------------
+void
+SALOME_Actor
+::SetPreHighlightProperty(vtkProperty* theProperty)
+{
+ myPreHighlightActor->SetProperty(theProperty);
+}
+
+void
+SALOME_Actor
+::SetHighlightProperty(vtkProperty* theProperty)
+{
+ myHighlightActor->SetProperty(theProperty);
+}
--- /dev/null
+// SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SALOME_Actor.h
+// Author : Nicolas REJNERI
+// Module : SALOME
+// $Header$
+
+#ifndef SALOME_ACTOR_H
+#define SALOME_ACTOR_H
+
+#include "SVTK_SelectionEvent.h"
+#include "SVTK_Selector.h"
+#include "SVTK.h"
+
+#include "SALOME_InteractiveObject.hxx"
+
+// undefining min and max because CASCADE's defines them and
+// it clashes with std::min(), std::max()
+#undef min
+#undef max
+
+#include "VTKViewer_Actor.h"
+
+#include <string>
+#include <vector>
+
+#include <vtkSmartPointer.h>
+
+class vtkCell;
+class vtkPicker;
+class vtkPointPicker;
+class vtkCellPicker;
+class vtkDataSet;
+class vtkPolyData;
+class vtkCamera;
+class vtkProperty;
+class vtkOutlineSource;
+class vtkRenderer;
+class vtkInteractorStyle;
+class vtkRenderWindowInteractor;
+
+class VTKViewer_Transform;
+class VTKViewer_GeometryFilter;
+class VTKViewer_TransformFilter;
+class VTKViewer_PassThroughFilter;
+class VTKViewer_CellRectPicker;
+
+class SVTK_Actor;
+class SVTK_InteractorStyle;
+
+extern int SALOME_POINT_SIZE;
+extern int SALOME_LINE_WIDTH;
+
+class SALOME_Actor;
+
+//! The class is a basic one for all SALOME VTK presentation.
+/*!
+ It provide highlight and prehighlight capabilites,
+ common way to publish and remove VTK presentation,
+ mapping of VTK and object IDs and so on.
+ */
+class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor
+{
+ public:
+ static SALOME_Actor* New();
+
+ vtkTypeMacro(SALOME_Actor,VTKViewer_Actor);
+
+ //----------------------------------------------------------------------------
+ //! To check, if the #SALOME_Actor has a reference to #SALOME_InteractiveObject
+ virtual
+ Standard_Boolean
+ hasIO();
+
+ //! Get correspoinding reference to #SALOME_InteractiveObject
+ virtual
+ const Handle(SALOME_InteractiveObject)&
+ getIO();
+
+ //! Set reference to #SALOME_InteractiveObject
+ virtual
+ void
+ setIO(const Handle(SALOME_InteractiveObject)& theIO);
+
+ //! Get its name
+ virtual
+ const char*
+ getName();
+
+ //! Name the #SALOME_Actor
+ virtual
+ void
+ setName(const char* theName);
+
+ //----------------------------------------------------------------------------
+ //! Change opacity
+ virtual
+ void
+ SetOpacity(float theOpacity);
+
+ //! Get current opacity
+ virtual
+ float
+ GetOpacity();
+
+ //! Change color
+ virtual
+ void
+ SetColor(float r,float g,float b);
+
+ //! Get current color
+ virtual
+ void
+ GetColor(float& r,float& g,float& b);
+
+ //! Change color
+ virtual
+ void
+ SetColor(const float theRGB[3]);
+
+ //----------------------------------------------------------------------------
+ // For selection mapping purpose
+ //! Maps VTK index of a node to corresponding object index
+ virtual
+ int
+ GetNodeObjId(int theVtkID);
+
+ //! Get coordinates of a node for given object index
+ virtual
+ float*
+ GetNodeCoord(int theObjID);
+
+ //! Maps VTK index of a cell to corresponding object index
+ virtual
+ int
+ GetElemObjId(int theVtkID);
+
+ //! Get corresponding #vtkCell for given object index
+ virtual
+ vtkCell*
+ GetElemCell(int theObjID);
+
+ //----------------------------------------------------------------------------
+ //! Get dimension of corresponding mesh element
+ virtual
+ int
+ GetObjDimension( const int theObjId );
+
+ //! To insert some additional filters and then sets the given #vtkMapper
+ virtual
+ void
+ SetMapper(vtkMapper* theMapper);
+
+ //! Allows to get initial #vtkDataSet
+ virtual
+ vtkDataSet*
+ GetInput();
+
+ //! Apply view transformation
+ virtual
+ void
+ SetTransform(VTKViewer_Transform* theTransform);
+
+ //! Apply additional position
+ virtual
+ void
+ SetPosition(float _arg1, float _arg2, float _arg3);
+
+ //! Apply additional position
+ virtual
+ void
+ SetPosition(float _arg[3]);
+
+ //! To calculatate last modified time
+ virtual
+ unsigned long int
+ GetMTime();
+
+ //----------------------------------------------------------------------------
+ //! Set representation (VTK_SURFACE, VTK_POINTS, VTK_WIREFRAME and so on)
+ virtual
+ void
+ SetRepresentation(int theMode);
+
+ //! Get current representation mode
+ virtual
+ int
+ GetRepresentation();
+
+ //! Get current display mode (obsolete)
+ virtual
+ int
+ getDisplayMode();
+
+ //! Set display mode (obsolete)
+ virtual
+ void
+ setDisplayMode(int theMode);
+
+ //----------------------------------------------------------------------------
+ //! Set infinive flag
+ /*!
+ Infinitive means actor without size (point for example),
+ which is not taken into account in calculation of boundaries of the scene
+ */
+ void
+ SetInfinitive(bool theIsInfinite);
+
+ //! Get infinive flag
+ virtual
+ bool
+ IsInfinitive();
+
+ //! To calcualte current bounding box
+ virtual
+ float*
+ GetBounds();
+
+ //! To calcualte current bounding box
+ void
+ GetBounds(float bounds[6]);
+
+ //----------------------------------------------------------------------------
+ virtual
+ bool
+ IsSetCamera() const;
+
+ virtual
+ bool
+ IsResizable() const;
+
+ virtual
+ void
+ SetSize( const float );
+
+ virtual
+ void
+ SetCamera( vtkCamera* );
+
+ //----------------------------------------------------------------------------
+ //! Set ResolveCoincidentTopology flag
+ void
+ SetResolveCoincidentTopology(bool theIsResolve);
+
+ //! Set ResolveCoincidentTopology parameters
+ void
+ SetPolygonOffsetParameters(float factor, float units);
+
+ //! Get current ResolveCoincidentTopology parameters
+ void
+ GetPolygonOffsetParameters(float& factor, float& units);
+
+ virtual
+ void
+ Render(vtkRenderer *, vtkMapper *);
+
+ //----------------------------------------------------------------------------
+ //! Get current shrink factor
+ virtual
+ float
+ GetShrinkFactor();
+
+ //! Is the actor is shrunkable
+ virtual
+ bool
+ IsShrunkable();
+
+ //! Is the actor is shrunk
+ virtual
+ bool
+ IsShrunk();
+
+ //! Insert shrink filter into pipeline
+ virtual
+ void
+ SetShrink();
+
+ //! Remove shrink filter from pipeline
+ virtual
+ void
+ UnShrink();
+
+ //----------------------------------------------------------------------------
+ //! Visibility management
+ virtual
+ void
+ SetVisibility( int );
+
+ //----------------------------------------------------------------------------
+ //! To publish the actor an all its internal devices
+ virtual
+ void
+ AddToRender(vtkRenderer* theRendere);
+
+ //! To remove the actor an all its internal devices
+ virtual
+ void
+ RemoveFromRender(vtkRenderer* theRendere);
+
+ //! Get reference on renderer where it is published
+ vtkRenderer*
+ GetRenderer();
+
+ //! Used to obtain all dependent actors
+ virtual
+ void
+ GetChildActors(vtkActorCollection*);
+
+ //----------------------------------------------------------------------------
+ //! To set interactor in order to use #vtkInteractorObserver devices
+ virtual
+ void
+ SetInteractor(vtkRenderWindowInteractor* theInteractor);
+
+ //! Put a request to redraw the view
+ virtual
+ void
+ Update();
+
+ //----------------------------------------------------------------------------
+ //! Ask, if the descendant of the SALOME_Actor will implement its own highlight or not
+ virtual
+ bool
+ hasHighlight();
+
+ //! Ask, if the SALOME_Actor is already highlighted
+ virtual
+ bool
+ isHighlighted();
+
+ //! Set preselection mode
+ virtual
+ void
+ SetPreSelected(bool thePreselect = false);
+
+ //----------------------------------------------------------------------------
+ //! Set selector in order to the actor at any time can restore current selection
+ virtual
+ void
+ SetSelector(SVTK_Selector* theSelector);
+
+ //! Just to update visibility of the highlight devices
+ virtual
+ void
+ highlight(bool theHighlight);
+
+ //! To map current selection to VTK representation
+ virtual
+ void
+ Highlight(bool theHighlight);
+
+ //----------------------------------------------------------------------------
+ //! To process prehighlight (called from #SVTK_InteractorStyle)
+ virtual
+ bool
+ PreHighlight(vtkInteractorStyle* theInteractorStyle,
+ SVTK_SelectionEvent* theSelectionEvent,
+ bool theIsHighlight);
+
+ //! To process highlight (called from #SVTK_InteractorStyle)
+ virtual
+ bool
+ Highlight(vtkInteractorStyle* theInteractorStyle,
+ SVTK_SelectionEvent* theSelectionEvent,
+ bool theIsHighlight);
+
+ //----------------------------------------------------------------------------
+ //! To set up a picker for nodal selection (initialized by #SVTK_Renderer::AddActor)
+ void
+ SetPointPicker(vtkPointPicker* thePointPicker);
+
+ //! To set up a picker for cell selection (initialized by #SVTK_Renderer::AddActor)
+ void
+ SetCellPicker(vtkCellPicker* theCellPicker);
+
+ //! To set up a picker for cell rectangle selection (initialized by #SVTK_Renderer::AddActor)
+ void
+ SetCellRectPicker(VTKViewer_CellRectPicker* theCellRectPicker);
+
+ //----------------------------------------------------------------------------
+ //! To set up a prehighlight property (initialized by #SVTK_Renderer::AddActor)
+ void
+ SetPreHighlightProperty(vtkProperty* theProperty);
+
+ //! To set up a highlight property (initialized by #SVTK_Renderer::AddActor)
+ void
+ SetHighlightProperty(vtkProperty* theProperty);
+
+ vtkSetObjectMacro(PreviewProperty,vtkProperty);
+
+ protected:
+ //----------------------------------------------------------------------------
+ vtkRenderWindowInteractor* myInteractor;
+ vtkRenderer* myRenderer;
+
+ bool myIsResolveCoincidentTopology;
+ float myPolygonOffsetFactor;
+ float myPolygonOffsetUnits;
+
+ Handle(SALOME_InteractiveObject) myIO;
+ std::string myName;
+
+ float myOpacity;
+ int myDisplayMode;
+ bool myIsInfinite;
+
+ bool myStoreMapping;
+ VTKViewer_GeometryFilter *myGeomFilter;
+ VTKViewer_TransformFilter *myTransformFilter;
+ std::vector<VTKViewer_PassThroughFilter*> myPassFilter;
+
+ int myRepresentation;
+ vtkProperty *myProperty;
+
+ void
+ InitPipeLine(vtkMapper* theMapper);
+
+ SALOME_Actor();
+ ~SALOME_Actor();
+
+ protected:
+ vtkProperty *PreviewProperty;
+ bool myIsPreselected;
+ bool myIsHighlighted;
+ Selection_Mode mySelectionMode;
+ vtkSmartPointer<SVTK_Selector> mySelector;
+
+ //----------------------------------------------------------------------------
+ // Highlight/ Prehighlight devices
+ vtkSmartPointer<vtkPointPicker> myPointPicker;
+ vtkSmartPointer<vtkCellPicker> myCellPicker;
+ vtkSmartPointer<VTKViewer_CellRectPicker> myCellRectPicker;
+
+ vtkSmartPointer<SVTK_Actor> myPreHighlightActor;
+ vtkSmartPointer<SVTK_Actor> myHighlightActor;
+
+ vtkSmartPointer<VTKViewer_Actor> myOutlineActor;
+ vtkSmartPointer<vtkOutlineSource> myOutline;
+};
+
+#endif // SALOME_ACTOR_H
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module :
+// $Header$
+
+#include "SVTK.h"
+#include "SVTK_Prs.h"
+#include "SVTK_Actor.h"
+#include "SALOME_Actor.h"
+#include "SVTK_CubeAxesActor2D.h"
+#include "SVTK_Functor.h"
+#include "SVTK_View.h"
+#include "SVTK_MainWindow.h"
+#include "SVTK_MainWindow.h"
+#include "SVTK_NonIsometricDlg.h"
+#include "SVTK_CubeAxesDlg.h"
+#include "SVTK_FontWidget.h"
+#include "SVTK_ViewModel.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_Renderer.h"
+#include "SVTK_InteractorStyle.h"
+#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_GenericRenderWindowInteractor.h"
+#include "SVTK_Selector.h"
+#include "SVTK_Selection.h"
+#include "SVTK_SelectionEvent.h"
+#include "SVTK_SpaceMouse.h"
+#include "SVTK_Event.h"
+#include "SVTK_ViewModelBase.h"
+
+int
+main(int argc, char** argv)
+{
+ return 0;
+}
#include <vtkPolyData.h>
#include <vtkShrinkFilter.h>
+#include "utilities.h"
+
using namespace std;
#ifdef _DEBUG_
#endif
-static void CopyPoints(vtkUnstructuredGrid* theGrid, vtkDataSet *theSourceDataSet){
+static
+void
+CopyPoints(vtkUnstructuredGrid* theGrid, vtkDataSet *theSourceDataSet)
+{
vtkPoints *aPoints = vtkPoints::New();
vtkIdType iEnd = theSourceDataSet->GetNumberOfPoints();
aPoints->SetNumberOfPoints(iEnd);
vtkStandardNewMacro(SVTK_Actor);
-SVTK_Actor::SVTK_Actor()
+SVTK_Actor
+::SVTK_Actor():
+ myUnstructuredGrid(vtkUnstructuredGrid::New())
{
+ if(MYDEBUG) INFOS("SVTK_Actor - "<<this);
+
myRenderer = NULL;
myIsInfinite = true;
Visibility = Pickable = false;
- myUnstructuredGrid = vtkUnstructuredGrid::New();
+ myUnstructuredGrid->Delete();
myUnstructuredGrid->Allocate();
myIsShrunk = false;
myMapper = vtkDataSetMapper::New();
- myMapper->SetInput(myUnstructuredGrid);
+ SetResolveCoincidentTopology(false);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_Actor
+::Initialize()
+{
+ myMapper->SetInput(GetSource());
Superclass::InitPipeLine(myMapper);
+}
- SetResolveCoincidentTopology(false);
+
+//----------------------------------------------------------------------------
+void
+SVTK_Actor
+::SetSource(vtkUnstructuredGrid* theUnstructuredGrid)
+{
+ if(GetSource() == theUnstructuredGrid)
+ return;
+
+ myUnstructuredGrid = theUnstructuredGrid;
+
+ myMapper->SetInput(theUnstructuredGrid);
+
+ Superclass::InitPipeLine(myMapper);
+
+ Modified();
}
-void SVTK_Actor::SetShrinkFactor(float theValue){
+vtkUnstructuredGrid*
+SVTK_Actor
+::GetSource()
+{
+ return myUnstructuredGrid.GetPointer();
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Actor
+::SetShrinkFactor(float theValue)
+{
myShrinkFilter->SetShrinkFactor(theValue);
Modified();
}
-void SVTK_Actor::SetShrink()
+void
+SVTK_Actor
+::SetShrink()
{
if ( !myIsShrinkable ) return;
if ( vtkDataSet* aDataSet = myPassFilter[0]->GetOutput() )
}
}
-void SVTK_Actor::UnShrink()
+void
+SVTK_Actor
+::UnShrink()
{
if ( !myIsShrunk ) return;
if ( vtkDataSet* aDataSet = myPassFilter[0]->GetOutput() )
//----------------------------------------------------------------------------
-SVTK_Actor::~SVTK_Actor()
+SVTK_Actor
+::~SVTK_Actor()
{
- //if(MYDEBUG) INFOS("VTKViewer_Actor::~VTKViewer_Actor()");
+ if(MYDEBUG) INFOS("~SVTK_Actor()");
- myMapper->RemoveAllInputs();
myMapper->Delete();
- myShrinkFilter->UnRegisterAllOutputs();
myShrinkFilter->Delete();
+}
- myUnstructuredGrid->Delete();
+
+//----------------------------------------------------------------------------
+const TColStd_IndexedMapOfInteger&
+SVTK_Actor
+::GetMapIndex() const
+{
+ return myMapIndex;
}
//----------------------------------------------------------------------------
-void SVTK_Actor::MapCells(SALOME_Actor* theMapActor,
- const TColStd_IndexedMapOfInteger& theMapIndex)
+void
+SVTK_Actor
+::MapCells(SALOME_Actor* theMapActor,
+ const TColStd_IndexedMapOfInteger& theMapIndex)
{
myUnstructuredGrid->Reset();
vtkDataSet *aSourceDataSet = theMapActor->GetInput();
- CopyPoints(myUnstructuredGrid,aSourceDataSet);
+ CopyPoints(GetSource(),aSourceDataSet);
int aNbOfParts = theMapIndex.Extent();
for(int ind = 1; ind <= aNbOfParts; ind++){
int aPartId = theMapIndex( ind );
- vtkCell* aCell = theMapActor->GetElemCell(aPartId);
- myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
- //for (int i = 0, iEnd = aCell->GetNumberOfEdges(); i < iEnd; i++){
- // vtkCell* anEdgeCell = aCell->GetEdge(i);
- // myUnstructuredGrid->InsertNextCell(VTK_LINE,anEdgeCell->GetPointIds());
- //}
+ if(vtkCell* aCell = theMapActor->GetElemCell(aPartId))
+ myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
}
UnShrink();
SetShrinkFactor(theMapActor->GetShrinkFactor());
SetShrink();
}
+
+ myMapIndex = theMapIndex;
}
//----------------------------------------------------------------------------
-void SVTK_Actor::MapPoints(SALOME_Actor* theMapActor,
- const TColStd_IndexedMapOfInteger& theMapIndex)
+void
+SVTK_Actor
+::MapPoints(SALOME_Actor* theMapActor,
+ const TColStd_IndexedMapOfInteger& theMapIndex)
{
myUnstructuredGrid->Reset();
if(int aNbOfParts = theMapIndex.Extent()){
aPoints->SetNumberOfPoints(aNbOfParts);
for(int i = 0; i < aNbOfParts; i++){
int aPartId = theMapIndex( i+1 );
- float* aCoord = theMapActor->GetNodeCoord(aPartId);
- aPoints->SetPoint(i,aCoord);
- myUnstructuredGrid->InsertNextCell(VTK_VERTEX,1,&i);
+ if(float* aCoord = theMapActor->GetNodeCoord(aPartId)){
+ aPoints->SetPoint(i,aCoord);
+ myUnstructuredGrid->InsertNextCell(VTK_VERTEX,1,&i);
+ }
}
myUnstructuredGrid->SetPoints(aPoints);
aPoints->Delete();
}
UnShrink();
+
+ myMapIndex = theMapIndex;
}
//----------------------------------------------------------------------------
-void SVTK_Actor::MapEdge(SALOME_Actor* theMapActor,
- const TColStd_IndexedMapOfInteger& theMapIndex)
+void
+SVTK_Actor
+::MapEdge(SALOME_Actor* theMapActor,
+ const TColStd_IndexedMapOfInteger& theMapIndex)
{
myUnstructuredGrid->Reset();
vtkDataSet *aSourceDataSet = theMapActor->GetInput();
- CopyPoints(myUnstructuredGrid,aSourceDataSet);
+ CopyPoints(GetSource(),aSourceDataSet);
int iEnd = theMapIndex.Extent();
int aCellId = -1, aCellCounter = 0;
}
if(aCellCounter == 1){
- vtkCell* aCell = theMapActor->GetElemCell(aCellId);
- if(aCell->GetCellType() <= VTK_LINE){
- myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
- }else{
- int aNbOfParts = aCell->GetNumberOfEdges();
- for(int i = 1; i <= iEnd; i++){
- int aPartId = theMapIndex(i);
- if( aPartId < 0){
- aPartId = -aPartId-1;
- if(0 > aPartId || aPartId >= aNbOfParts) break;
- vtkCell* anEdgeCell = aCell->GetEdge(aPartId);
- myUnstructuredGrid->InsertNextCell(VTK_LINE,anEdgeCell->GetPointIds());
+ if(vtkCell* aCell = theMapActor->GetElemCell(aCellId)){
+ if(aCell->GetCellType() <= VTK_LINE){
+ myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
+ }else{
+ int aNbOfParts = aCell->GetNumberOfEdges();
+ for(int i = 1; i <= iEnd; i++){
+ int aPartId = theMapIndex(i);
+ if( aPartId < 0){
+ aPartId = -aPartId-1;
+ if(0 > aPartId || aPartId >= aNbOfParts) break;
+ if(vtkCell* anEdgeCell = aCell->GetEdge(aPartId))
+ myUnstructuredGrid->InsertNextCell(VTK_LINE,anEdgeCell->GetPointIds());
+ }
}
}
}
SetShrinkFactor(theMapActor->GetShrinkFactor());
SetShrink();
}
+
+ myMapIndex = theMapIndex;
}
//----------------------------------------------------------------------------
#include "SVTK.h"
#include "SALOME_Actor.h"
-class SVTK_EXPORT SVTK_Actor : public SALOME_Actor
+//! This class used for internal SVTK package purpose (highlight and prehighlight)
+class SVTK_EXPORT SVTK_Actor : public VTKViewer_Actor
{
public:
virtual ~SVTK_Actor();
static SVTK_Actor* New();
- vtkTypeMacro(SVTK_Actor,SALOME_Actor);
+ vtkTypeMacro(SVTK_Actor,VTKViewer_Actor);
- void SetShrinkFactor(float value);
- virtual void SetShrink();
- virtual void UnShrink();
+ //! Initialiaze the instance completely
+ void
+ Initialize();
- void MapCells(SALOME_Actor* theMapActor,
- const TColStd_IndexedMapOfInteger& theMapIndex);
+ //! Allows to set an external source
+ void
+ SetSource(vtkUnstructuredGrid* theUnstructuredGrid);
- void MapPoints(SALOME_Actor* theMapActor,
- const TColStd_IndexedMapOfInteger& theMapIndex);
+ //! Get its internal data set
+ vtkUnstructuredGrid*
+ GetSource();
- void MapEdge(SALOME_Actor* theMapActor,
- const TColStd_IndexedMapOfInteger& theMapIndex);
+ //! To manage shrink functionality
+ void
+ SetShrinkFactor(float value);
+
+ //! To manage shrink functionality
+ virtual
+ void
+ SetShrink();
+
+ //! To manage shrink functionality
+ virtual
+ void
+ UnShrink();
+
+ //! Allow to recostruct selected cells from source SALOME_Actor and map of subindexes
+ void
+ MapCells(SALOME_Actor* theMapActor,
+ const TColStd_IndexedMapOfInteger& theMapIndex);
+
+ //! Allow to recostruct selected points from source SALOME_Actor and map of subindexes
+ void
+ MapPoints(SALOME_Actor* theMapActor,
+ const TColStd_IndexedMapOfInteger& theMapIndex);
+
+ //! Allow to recostruct selected edges from source SALOME_Actor and map of subindexes
+ void
+ MapEdge(SALOME_Actor* theMapActor,
+ const TColStd_IndexedMapOfInteger& theMapIndex);
+
+ const TColStd_IndexedMapOfInteger&
+ GetMapIndex() const;
protected:
- vtkUnstructuredGrid* myUnstructuredGrid;
- vtkDataSetMapper* myMapper;
+ TColStd_IndexedMapOfInteger myMapIndex;
+ vtkSmartPointer<vtkUnstructuredGrid> myUnstructuredGrid;
+ vtkDataSetMapper* myMapper;
vtkRenderer* myRenderer;
vtkShrinkFilter* myShrinkFilter;
--- /dev/null
+// VISU VISUGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SVTK_CubeAxesDlg.cxx
+// Author : Sergey LITONIN
+// Module : VISU
+
+#include "SVTK_CubeAxesDlg.h"
+
+#include "SVTK_MainWindow.h"
+#include "SVTK_FontWidget.h"
+
+#include "SVTK_CubeAxesActor2D.h"
+
+#include "QtxAction.h"
+
+#include <qlayout.h>
+#include <qframe.h>
+#include <qpushbutton.h>
+#include <qtabwidget.h>
+#include <qcheckbox.h>
+#include <qgroupbox.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qobjectlist.h>
+#include <qvalidator.h>
+
+#include <vtkAxisActor2D.h>
+#include <vtkTextProperty.h>
+
+/*!
+ * Class : AxisWg
+ * Description : Tab of dialog
+ */
+
+//=======================================================================
+// name : SVTK_AxisWidget::AxisWg
+// Purpose : Constructor
+//=======================================================================
+SVTK_AxisWidget::SVTK_AxisWidget (QWidget* theParent)
+: QFrame(theParent)
+{
+ QValueList< QLabel* > aLabels;
+
+ // "Name" grp
+
+ myNameGrp = new QGroupBox(3, Qt::Vertical, tr("AXIS_NAME"), this);
+ myIsNameVisible = new QCheckBox(tr("IS_VISIBLE"), myNameGrp);
+
+ QHBox* aHBox = new QHBox(myNameGrp);
+ aHBox->setSpacing(5);
+ QLabel* aLabel = new QLabel(tr("NAME"), aHBox);
+ myAxisName = new QLineEdit(aHBox);
+ aLabels.append(aLabel);
+
+ aHBox = new QHBox(myNameGrp);
+ aHBox->setSpacing(5);
+ aLabel = new QLabel(tr("FONT"), aHBox);
+ myNameFont = new SVTK_FontWidget(aHBox);
+ aLabels.append(aLabel);
+
+
+ // "Labels" grp
+
+ myLabelsGrp = new QGroupBox(4, Qt::Vertical, tr("LABELS"), this);
+ myIsLabelsVisible = new QCheckBox(tr("IS_VISIBLE"), myLabelsGrp);
+
+ aHBox = new QHBox(myLabelsGrp);
+ aHBox->setSpacing(5);
+ aLabel = new QLabel(tr("NUMBER"), aHBox);
+ myLabelNumber = new QLineEdit(aHBox);
+ myLabelNumber->setValidator(new QIntValidator(0, 25, this));
+ myLabelNumber->installEventFilter(this);
+ aLabels.append(aLabel);
+
+ aHBox = new QHBox(myLabelsGrp);
+ aHBox->setSpacing(5);
+ aLabel = new QLabel(tr("OFFSET"), aHBox);
+ myLabelOffset = new QLineEdit(aHBox);
+ aLabels.append(aLabel);
+
+ aHBox = new QHBox(myLabelsGrp);
+ aHBox->setSpacing(5);
+ aLabel = new QLabel(tr("FONT"), aHBox);
+ myLabelsFont = new SVTK_FontWidget(aHBox);
+ aLabels.append(aLabel);
+
+ // "Tick marks" grp
+
+ myTicksGrp = new QGroupBox(2, Qt::Vertical, tr("TICK_MARKS"), this);
+ myIsTicksVisible = new QCheckBox(tr("IS_VISIBLE"), myTicksGrp);
+
+ aHBox = new QHBox(myTicksGrp);
+ aHBox->setSpacing(5);
+ aLabel = new QLabel(tr("LENGTH"), aHBox);
+ myTickLength = new QLineEdit(aHBox);
+ aLabels.append(aLabel);
+
+ // Layout
+
+ QVBoxLayout* aLay = new QVBoxLayout(this, 0, 5);
+ aLay->addWidget(myNameGrp);
+ aLay->addWidget(myLabelsGrp);
+ aLay->addWidget(myTicksGrp);
+
+ // init
+ myIsNameVisible->setChecked(true);
+ myIsLabelsVisible->setChecked(true);
+ myIsTicksVisible->setChecked(true);
+ updateControlState();
+
+ // Adjust label widths
+ QValueList< QLabel* >::iterator anIter;
+ int aMaxWidth = 0;
+ for (anIter = aLabels.begin(); anIter != aLabels.end(); anIter++)
+ aMaxWidth = QMAX(aMaxWidth, (*anIter)->sizeHint().width());
+ for (anIter = aLabels.begin(); anIter != aLabels.end(); anIter++)
+ (*anIter)->setFixedWidth(aMaxWidth);
+
+ // connect signals and slots
+ connect(myIsNameVisible, SIGNAL(stateChanged(int)), SLOT(onNameChecked()));
+ connect(myIsLabelsVisible, SIGNAL(stateChanged(int)), SLOT(onLabelsChecked()));
+ connect(myIsTicksVisible, SIGNAL(stateChanged(int)), SLOT(onTicksChecked()));
+}
+
+SVTK_AxisWidget::~SVTK_AxisWidget()
+{
+}
+
+void SVTK_AxisWidget::updateControlState()
+{
+ onNameChecked();
+ onLabelsChecked();
+ onTicksChecked();
+}
+
+bool SVTK_AxisWidget::eventFilter(QObject* o, QEvent* e)
+{
+ if (e->type() == QEvent::FocusOut) {
+ bool isOK = false;
+ int k = myLabelNumber->text().toInt(&isOK);
+ if (isOK && k > 25) myLabelNumber->setText("25");
+ }
+ return false;
+}
+
+//=======================================================================
+// name : SVTK_AxisWidget::onNameChecked
+// Purpose :
+//=======================================================================
+void SVTK_AxisWidget::setEnabled(QGroupBox* theGrp, const bool theState)
+{
+ QObjectList aChildren(*theGrp->children());
+ QObject* anObj;
+ for(anObj = aChildren.first(); anObj !=0; anObj = aChildren.next())
+ if (anObj !=0 && anObj->inherits("QHBox"))
+ ((QHBox*)anObj)->setEnabled(theState);
+}
+
+//=======================================================================
+// Labels : SVTK_AxisWidget::onLabelsChecked
+// Purpose :
+//=======================================================================
+void SVTK_AxisWidget::onLabelsChecked()
+{
+ setEnabled(myLabelsGrp, myIsLabelsVisible->isChecked());
+}
+
+//=======================================================================
+// Labels : SVTK_AxisWidget::onTicksChecked
+// Purpose :
+//=======================================================================
+void SVTK_AxisWidget::onTicksChecked()
+{
+ setEnabled(myTicksGrp, myIsTicksVisible->isChecked());
+}
+
+//=======================================================================
+// name : SVTK_AxisWidget::onNameChecked
+// Purpose :
+//=======================================================================
+void SVTK_AxisWidget::onNameChecked()
+{
+ setEnabled(myNameGrp, myIsNameVisible->isChecked());
+}
+
+//=======================================================================
+// name : SVTK_AxisWidget::UseName
+// Purpose :
+//=======================================================================
+void SVTK_AxisWidget::UseName(const bool toUse)
+{
+ myIsNameVisible->setChecked(toUse);
+}
+
+//=======================================================================
+// name : SVTK_AxisWidget::SetName
+// Purpose :
+//================================================== =====================
+void SVTK_AxisWidget::SetName(const QString& theName)
+{
+ myAxisName->setText(theName);
+}
+
+//=======================================================================
+// name : SVTK_AxisWidget::SetNameFont
+// Purpose :
+//=======================================================================
+void SVTK_AxisWidget::SetNameFont(const QColor& theColor,
+ const int theFont,
+ const bool theIsBold,
+ const bool theIsItalic,
+ const bool theIsShadow)
+{
+ myNameFont->SetData(theColor, theFont, theIsBold, theIsItalic, theIsShadow);
+}
+
+//=======================================================================
+// name : SVTK_AxisWidget::SetNameFont
+// Purpose :
+//=======================================================================
+bool SVTK_AxisWidget::ReadData(vtkAxisActor2D* theActor)
+{
+ if (theActor == 0)
+ return false;
+
+ // Name
+
+ bool useName = theActor->GetTitleVisibility();
+ QString aTitle(theActor->GetTitle());
+
+ QColor aTitleColor(255, 255, 255);
+ int aTitleFontFamily = VTK_ARIAL;
+ bool isTitleBold = false;
+ bool isTitleItalic = false;
+ bool isTitleShadow = false;
+
+ vtkTextProperty* aTitleProp = theActor->GetTitleTextProperty();
+ if (aTitleProp !=0)
+ {
+ float c[ 3 ];
+ aTitleProp->GetColor(c);
+ aTitleColor.setRgb((int)(c[ 0 ] * 255), (int)(c[ 1 ] * 255), (int)(c[ 2 ] * 255));
+ aTitleFontFamily = aTitleProp->GetFontFamily();
+ isTitleBold = aTitleProp->GetBold() ? true : false;
+ isTitleItalic = aTitleProp->GetItalic() ? true : false;
+ isTitleShadow = aTitleProp->GetShadow() ? true : false;
+ }
+
+ myIsNameVisible->setChecked(useName);
+ myAxisName->setText(aTitle);
+ myNameFont->SetData(aTitleColor, aTitleFontFamily, isTitleBold, isTitleItalic, isTitleShadow);
+
+ // Labels
+
+ bool useLabels = theActor->GetLabelVisibility();
+ int nbLabels = theActor->GetNumberOfLabels();
+ int anOffset = theActor->GetTickOffset();
+
+ QColor aLabelsColor(255, 255, 255);
+ int aLabelsFontFamily = VTK_ARIAL;
+ bool isLabelsBold = false;
+ bool isLabelsItalic = false;
+ bool isLabelsShadow = false;
+
+ vtkTextProperty* aLabelsProp = theActor->GetLabelTextProperty();
+ if (aLabelsProp !=0)
+ {
+ float c[ 3 ];
+ aLabelsProp->GetColor(c);
+ aLabelsColor.setRgb((int)(c[ 0 ] * 255), (int)(c[ 1 ] * 255), (int)(c[ 2 ] * 255));
+ aLabelsFontFamily = aLabelsProp->GetFontFamily();
+ isLabelsBold = aLabelsProp->GetBold() ? true : false;
+ isLabelsItalic = aLabelsProp->GetItalic() ? true : false;
+ isLabelsShadow = aLabelsProp->GetShadow() ? true : false;
+ }
+
+ myIsLabelsVisible->setChecked(useLabels);
+ myLabelNumber->setText(QString("%1").arg(nbLabels));
+ myLabelOffset->setText(QString("%1").arg(anOffset));
+ myLabelsFont->SetData(aLabelsColor, aLabelsFontFamily, isLabelsBold, isLabelsItalic, isLabelsShadow);
+
+ // Tick marks
+ bool useTickMarks = theActor->GetTickVisibility();
+ int aTickLength = theActor->GetTickLength();
+
+ myIsTicksVisible->setChecked(useTickMarks);
+ myTickLength->setText(QString("%1").arg(aTickLength));
+
+ return true;
+}
+
+//=======================================================================
+// name : SVTK_CubeAxesDlg::Apply
+// Purpose :
+//=======================================================================
+bool SVTK_AxisWidget::Apply(vtkAxisActor2D* theActor)
+{
+ if (theActor == 0)
+ return false;
+
+ // Name
+
+ theActor->SetTitleVisibility(myIsNameVisible->isChecked() ? 1 : 0);
+ theActor->SetTitle(myAxisName->text().latin1());
+
+ QColor aTitleColor(255, 255, 255);
+ int aTitleFontFamily = VTK_ARIAL;
+ bool isTitleBold = false;
+ bool isTitleItalic = false;
+ bool isTitleShadow = false;
+
+ myNameFont->GetData(aTitleColor, aTitleFontFamily, isTitleBold, isTitleItalic, isTitleShadow);
+ vtkTextProperty* aTitleProp = theActor->GetTitleTextProperty();
+ if (aTitleProp)
+ {
+ aTitleProp->SetColor(aTitleColor.red() / 255.,
+ aTitleColor.green() / 255.,
+ aTitleColor.blue() / 255.);
+ aTitleProp->SetFontFamily(aTitleFontFamily);
+
+ aTitleProp->SetBold(isTitleBold ? 1 : 0);
+ aTitleProp->SetItalic(isTitleItalic ? 1 : 0);
+ aTitleProp->SetShadow(isTitleShadow ? 1 : 0);
+
+ theActor->SetTitleTextProperty(aTitleProp);
+ }
+
+ // Labels
+
+ theActor->SetLabelVisibility(myIsLabelsVisible->isChecked() ? 1 : 0);
+
+ bool isOk = false;
+ int nbLabels = myLabelNumber->text().toInt(&isOk);
+ if (isOk)
+ theActor->SetNumberOfLabels(nbLabels);
+
+ int anOffset = myLabelOffset->text().toInt(&isOk);
+ if (isOk)
+ theActor->SetTickOffset(anOffset);
+
+ QColor aLabelsColor(255, 255, 255);
+ int aLabelsFontFamily = VTK_ARIAL;
+ bool isLabelsBold = false;
+ bool isLabelsItalic = false;
+ bool isLabelsShadow = false;
+
+ myLabelsFont->GetData(aLabelsColor, aLabelsFontFamily, isLabelsBold, isLabelsItalic, isLabelsShadow);
+ vtkTextProperty* aLabelsProp = theActor->GetLabelTextProperty();
+ if (aLabelsProp)
+ {
+ aLabelsProp->SetColor(aLabelsColor.red() / 255.,
+ aLabelsColor.green() / 255.,
+ aLabelsColor.blue() / 255.);
+ aLabelsProp->SetFontFamily(aLabelsFontFamily);
+
+ aLabelsProp->SetBold(isLabelsBold ? 1 : 0);
+ aLabelsProp->SetItalic(isLabelsItalic ? 1 : 0);
+ aLabelsProp->SetShadow(isLabelsShadow ? 1 : 0);
+
+ aLabelsProp->Modified();
+ theActor->SetLabelTextProperty(aLabelsProp);
+ }
+
+
+ // Tick marks
+ theActor->SetTickVisibility(myIsTicksVisible->isChecked());
+ int aTickLength = myTickLength->text().toInt(&isOk);
+ if (isOk)
+ theActor->SetTickLength(aTickLength);
+
+ return true;
+}
+
+/*
+ Class : SVTK_CubeAxesDlg
+ Description : Dialog for specifynig cube axes properties
+*/
+
+//=======================================================================
+// name : SVTK_CubeAxesDlg::SVTK_CubeAxesDlg
+// Purpose : Constructor
+//=======================================================================
+SVTK_CubeAxesDlg::SVTK_CubeAxesDlg(SVTK_MainWindow* theParent,
+ const char* theName,
+ QtxAction* theAction):
+ QDialog(theParent,
+ theName,
+ false,
+ WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
+ myMainWindow(theParent),
+ myAction(theAction)
+{
+ setCaption(tr("CAPTION"));
+
+ QVBoxLayout* aLay = new QVBoxLayout(this, 5, 5);
+ aLay->addWidget(createMainFrame(this));
+ aLay->addWidget(createButtonFrame(this));
+}
+
+//=======================================================================
+// name : SVTK_CubeAxesDlg::createMainFrame
+// Purpose : Create frame containing dialog's input fields
+//=======================================================================
+QWidget* SVTK_CubeAxesDlg::createMainFrame(QWidget* theParent)
+{
+ QFrame* aFrame = new QFrame(theParent);
+
+ myTabWg = new QTabWidget(aFrame);
+
+ myAxes[ 0 ] = new SVTK_AxisWidget(myTabWg);
+ myAxes[ 1 ] = new SVTK_AxisWidget(myTabWg);
+ myAxes[ 2 ] = new SVTK_AxisWidget(myTabWg);
+
+ myTabWg->addTab(myAxes[ 0 ], tr("X_AXIS"));
+ myTabWg->addTab(myAxes[ 1 ], tr("Y_AXIS"));
+ myTabWg->addTab(myAxes[ 2 ], tr("Z_AXIS"));
+
+ myTabWg->setMargin(5);
+
+ myIsVisible = new QCheckBox(tr("IS_VISIBLE"), aFrame);
+
+ QVBoxLayout* aLay = new QVBoxLayout(aFrame, 0, 5);
+ aLay->addWidget(myTabWg);
+ aLay->addWidget(myIsVisible);
+
+ return aFrame;
+}
+
+//=======================================================================
+// name : SVTK_CubeAxesDlg::createButtonFrame
+// Purpose : Create frame containing buttons
+//=======================================================================
+QWidget* SVTK_CubeAxesDlg::createButtonFrame(QWidget* theParent)
+{
+ QFrame* aFrame = new QFrame(theParent);
+ aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
+
+ myOkBtn = new QPushButton(tr("BUT_OK"), aFrame);
+ myApplyBtn = new QPushButton(tr("BUT_APPLY"), aFrame);
+ myCloseBtn = new QPushButton(tr("BUT_CLOSE"), aFrame);
+
+ QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
+
+ QHBoxLayout* aLay = new QHBoxLayout(aFrame, 5, 5);
+
+ aLay->addWidget(myOkBtn);
+ aLay->addWidget(myApplyBtn);
+ aLay->addItem(aSpacer);
+ aLay->addWidget(myCloseBtn);
+
+ connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
+ connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
+ connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
+
+ return aFrame;
+}
+
+//=======================================================================
+// name : SVTK_CubeAxesDlg::~SVTK_CubeAxesDlg
+// Purpose : Destructor
+//=======================================================================
+SVTK_CubeAxesDlg::~SVTK_CubeAxesDlg()
+{
+}
+
+//=======================================================================
+// name : SVTK_CubeAxesDlg::Update
+// Purpose : Update dialog fields, connect signals and slots, show dialog
+//=======================================================================
+void SVTK_CubeAxesDlg::Update()
+{
+ myActor = myMainWindow->GetCubeAxes();
+
+ myAxes[ 0 ]->ReadData(myActor->GetXAxisActor2D());
+ myAxes[ 1 ]->ReadData(myActor->GetYAxisActor2D());
+ myAxes[ 2 ]->ReadData(myActor->GetZAxisActor2D());
+
+ myIsVisible->setChecked(myActor->GetVisibility() ? true : false);
+}
+
+//=======================================================================
+// name : SVTK_CubeAxesDlg::isValid
+// Purpose : Verify validity of entry data
+//=======================================================================
+bool SVTK_CubeAxesDlg::isValid() const
+{
+ return true;
+}
+
+//=======================================================================
+// name : SVTK_CubeAxesDlg::onApply
+// Purpose : Verify validity of entry data
+//=======================================================================
+bool SVTK_CubeAxesDlg::onApply()
+{
+ bool isOk = true;
+
+ try
+ {
+ isOk = isOk && myAxes[ 0 ]->Apply(myActor->GetXAxisActor2D());
+ isOk = isOk && myAxes[ 1 ]->Apply(myActor->GetYAxisActor2D());
+ isOk = isOk && myAxes[ 2 ]->Apply(myActor->GetZAxisActor2D());
+
+
+ //myActor->SetXLabel(myAxes[ 0 ]->myAxisName->text());
+ //myActor->SetYLabel(myAxes[ 1 ]->myAxisName->text());
+ //myActor->SetZLabel(myAxes[ 2 ]->myAxisName->text());
+
+ //myActor->SetNumberOfLabels(myActor->GetXAxisActor2D()->GetNumberOfLabels());
+ if (myIsVisible->isChecked())
+ myActor->VisibilityOn();
+ else
+ myActor->VisibilityOff();
+
+ if (isOk)
+ myMainWindow->Repaint();
+ }
+ catch(...)
+ {
+ isOk = false;
+ }
+
+ return isOk;
+}
+
+//=======================================================================
+// name : SVTK_CubeAxesDlg::onOk
+// Purpose : SLOT called when "Ok" button pressed.
+//=======================================================================
+void SVTK_CubeAxesDlg::onOk()
+{
+ if (onApply())
+ onClose();
+}
+
+//=======================================================================
+// name : SVTK_CubeAxesDlg::onClose
+// Purpose : SLOT called when "Close" button pressed. Close dialog
+//=======================================================================
+void SVTK_CubeAxesDlg::onClose()
+{
+ reject();
+
+ myAction->setOn( false );
+}
+
+void SVTK_CubeAxesDlg::done( int r )
+{
+ myAction->setOn( false );
+ QDialog::done( r );
+}
--- /dev/null
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SVTK_CubeAxesDlg.h
+// Author : Sergey LITONIN
+// Module : VISU
+
+
+#ifndef SVTK_CubeAxesDlg_H
+#define SVTK_CubeAxesDlg_H
+
+#include <qdialog.h>
+#include <qframe.h>
+
+class QWidget;
+class QFrame;
+class QPushButton;
+class QTabWidget;
+class QCheckBox;
+class QLineEdit;
+class QGroupBox;
+
+class QtxAction;
+
+class vtkAxisActor2D;
+class SVTK_CubeAxesActor2D;
+
+class SVTK_FontWidget;
+class SVTK_AxisWidget;
+class SVTK_MainWindow;
+
+/*!
+ * Class : SVTK_CubeAxesDlg
+ * Description : Dialog for specifynig cube axes properties
+ */
+class SVTK_CubeAxesDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ SVTK_CubeAxesDlg(SVTK_MainWindow* theParent,
+ const char* theName,
+ QtxAction* theAction);
+ virtual ~SVTK_CubeAxesDlg();
+
+ void Update();
+
+private slots:
+ void onOk();
+ bool onApply();
+ void onClose();
+
+ virtual void done( int );
+
+private:
+ QWidget* createButtonFrame( QWidget* );
+ QWidget* createMainFrame ( QWidget* );
+ bool isValid() const;
+
+private:
+ SVTK_MainWindow *myMainWindow;
+ SVTK_CubeAxesActor2D* myActor;
+ QtxAction* myAction;
+
+ QTabWidget* myTabWg;
+ QCheckBox* myIsVisible;
+
+ QPushButton* myOkBtn;
+ QPushButton* myApplyBtn;
+ QPushButton* myCloseBtn;
+ SVTK_AxisWidget* myAxes[ 3 ];
+};
+
+/*!
+ * Class : SVTK_AxisWidget
+ * Description : Tab of dialog
+ */
+class SVTK_AxisWidget : public QFrame
+{
+ Q_OBJECT
+
+public:
+ SVTK_AxisWidget( QWidget* );
+ ~SVTK_AxisWidget();
+
+ void UseName( const bool );
+ void SetName( const QString& );
+ void SetNameFont( const QColor&, const int, const bool, const bool, const bool );
+ bool ReadData( vtkAxisActor2D* );
+ bool Apply( vtkAxisActor2D* );
+
+protected:
+ bool eventFilter(QObject*, QEvent*);
+
+private slots:
+ void onNameChecked();
+ void onLabelsChecked();
+ void onTicksChecked();
+
+private:
+ void updateControlState();
+ void setEnabled( QGroupBox*, const bool );
+
+private:
+ // name
+ QGroupBox* myNameGrp;
+ QCheckBox* myIsNameVisible;
+ QLineEdit* myAxisName;
+ SVTK_FontWidget* myNameFont;
+
+ // labels
+ QGroupBox* myLabelsGrp;
+ QCheckBox* myIsLabelsVisible;
+ QLineEdit* myLabelNumber;
+ QLineEdit* myLabelOffset;
+ SVTK_FontWidget* myLabelsFont;
+
+ // tick marks
+ QGroupBox* myTicksGrp;
+ QCheckBox* myIsTicksVisible;
+ QLineEdit* myTickLength;
+
+ friend class SVTK_CubeAxesDlg;
+};
+
+#endif
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author : Alexander SLADKOV
+// Module : SALOME
+// $Header$
+
+#ifndef SVTK_Event_h
+#define SVTK_Event_h
+
+#include <vtkCommand.h>
+
+namespace SVTK
+{
+ enum Event
+ {
+ SpaceMouseMoveEvent = vtkCommand::UserEvent + 1000,
+ SpaceMouseButtonEvent,
+ PanLeftEvent,
+ PanRightEvent,
+ PanUpEvent,
+ PanDownEvent,
+ ZoomInEvent,
+ ZoomOutEvent,
+ RotateLeftEvent,
+ RotateRightEvent,
+ RotateUpEvent,
+ RotateDownEvent,
+ PlusSpeedIncrementEvent,
+ MinusSpeedIncrementEvent,
+ SetSpeedIncrementEvent,
+
+ SetSMDecreaseSpeedEvent,
+ SetSMIncreaseSpeedEvent,
+ SetSMDominantCombinedSwitchEvent,
+
+ StartZoom,
+ StartPan,
+ StartRotate,
+ StartGlobalPan,
+ StartFitArea,
+
+ LastEvent
+ };
+}
+
+#endif
--- /dev/null
+// VISU VISUGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author : Sergey LITONIN
+// Module :
+
+#include "SVTK_FontWidget.h"
+
+#include <qtoolbutton.h>
+#include <qcombobox.h>
+#include <qcolordialog.h>
+#include <qcheckbox.h>
+
+#include <vtkTextProperty.h>
+
+/*!
+ * Class : SVTK_FontWidget
+ * Description : Dialog for specifynig font
+ */
+
+//=======================================================================
+// name : SVTK_FontWidget
+// Purpose : Constructor
+//=======================================================================
+SVTK_FontWidget::SVTK_FontWidget( QWidget* theParent )
+: QHBox( theParent )
+{
+ setSpacing( 5 );
+ myColorBtn = new QToolButton( this );
+ myColorBtn->setMinimumWidth( 20 );
+
+ myFamily = new QComboBox( this );
+ myFamily->insertItem( tr( "ARIAL" ) );
+ myFamily->insertItem( tr( "COURIER" ) );
+ myFamily->insertItem( tr( "TIMES" ) );
+
+ myBold = new QCheckBox( tr( "BOLD" ), this );
+ myItalic = new QCheckBox( tr( "ITALIC" ), this );
+ myShadow = new QCheckBox( tr( "SHADOW" ), this );
+
+ connect( myColorBtn, SIGNAL( clicked() ), SLOT( onColor() ) );
+}
+
+//=======================================================================
+// name : ~SVTK_FontWidget
+// Purpose : Destructor
+//=======================================================================
+SVTK_FontWidget::~SVTK_FontWidget()
+{
+}
+
+//=======================================================================
+// name : SetColor
+// Purpose :
+//=======================================================================
+void SVTK_FontWidget::SetColor( const QColor& theColor )
+{
+ myColorBtn->setPaletteBackgroundColor( theColor );
+}
+
+//=======================================================================
+// name : GetColor
+// Purpose :
+//=======================================================================
+QColor SVTK_FontWidget::GetColor() const
+{
+ return myColorBtn->paletteBackgroundColor();
+}
+
+//=======================================================================
+// name : onColor
+// Purpose :
+//=======================================================================
+void SVTK_FontWidget::onColor()
+{
+ QColor aColor = QColorDialog::getColor( GetColor(), this );
+ if ( aColor.isValid() )
+ SetColor( aColor );
+}
+
+//=======================================================================
+// name : SetData
+// Purpose :
+//=======================================================================
+void SVTK_FontWidget::SetData( const QColor& theColor,
+ const int theFamily,
+ const bool theBold,
+ const bool theItalic,
+ const bool theShadow )
+{
+ SetColor( theColor );
+
+ if ( theFamily == VTK_ARIAL )
+ myFamily->setCurrentItem( 0 );
+ else if ( theFamily == VTK_COURIER )
+ myFamily->setCurrentItem( 1 );
+ else
+ myFamily->setCurrentItem( 2 );
+
+ myBold->setChecked( theBold );
+ myItalic->setChecked( theItalic );
+ myShadow->setChecked( theShadow );
+}
+
+//=======================================================================
+// name : GetData
+// Purpose :
+//=======================================================================
+void SVTK_FontWidget::GetData( QColor& theColor,
+ int& theFamily,
+ bool& theBold,
+ bool& theItalic,
+ bool& theShadow ) const
+{
+ theColor = GetColor();
+
+ int anItem =myFamily->currentItem();
+ if ( anItem == 0 )
+ theFamily = VTK_ARIAL;
+ else if ( anItem == 1 )
+ theFamily = VTK_COURIER;
+ else
+ theFamily = VTK_TIMES;
+
+ theBold = myBold->isChecked();
+ theItalic = myItalic->isChecked();
+ theShadow = myShadow->isChecked();
+}
--- /dev/null
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author : Sergey LITONIN
+// Module :
+
+
+#ifndef SVTK_FontWidget_H
+#define SVTK_FontWidget_H
+
+#include <qhbox.h>
+
+class QToolButton;
+class QComboBox;
+class QCheckBox;
+class QColor;
+
+
+/*!
+ * Class : SVTK_FontWidget
+ * Description : Dialog for specifynig font
+ */
+class SVTK_FontWidget : public QHBox
+{
+ Q_OBJECT
+
+public:
+ SVTK_FontWidget( QWidget* );
+ virtual ~SVTK_FontWidget();
+
+ void SetColor( const QColor& );
+ QColor GetColor() const;
+
+ void SetData( const QColor&, const int, const bool, const bool, const bool );
+
+ void GetData( QColor&, int&, bool&, bool&, bool& ) const;
+
+private slots:
+ void onColor();
+
+private:
+ QToolButton* myColorBtn;
+ QComboBox* myFamily;
+ QCheckBox* myBold;
+ QCheckBox* myItalic;
+ QCheckBox* myShadow;
+};
+
+#endif
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef SVTK_Functor_H
#define SVTK_Functor_H
#include "SALOME_InteractiveObject.hxx"
-namespace VTK
+/*!
+ \file SVTK_Functor.h
+ This file contains numbers of functors that allows user to perform corresponding operations with existing presentations.
+ Combination with algorithms it gives powerful, flexible and simple to extend way to introduce new type of operation.
+*/
+
+namespace SVTK
{
+ using namespace VTK;
+
+ //! This functor check, if the actor have pointed entry
template<class TActor>
struct TIsSameEntry
{
std::string myEntry;
- TIsSameEntry(const char* theEntry): myEntry(theEntry) {}
+ //! To construct the functor
+ TIsSameEntry(const char* theEntry):
+ myEntry(theEntry)
+ {}
+ //! To calculate the functor
bool operator()(TActor* theActor)
{
if ( theActor->hasIO() )
//----------------------------------------------------------------
+ //! This functor check, if the actor point to the same #SALOME_InteractiveObject
template<class TActor>
struct TIsSameIObject
{
Handle(SALOME_InteractiveObject) myIObject;
+ //! To construct the functor
TIsSameIObject(const Handle(SALOME_InteractiveObject)& theIObject):
myIObject(theIObject)
{}
+ //! To calculate the functor
bool operator()(TActor* theActor)
{
if(theActor->hasIO())
//----------------------------------------------------------------
+ /*!
+ This highlight every input actor
+ */
template<class TActor>
struct THighlight
{
bool myIsHighlight;
- THighlight(bool theIsHighlight): myIsHighlight( theIsHighlight ) {}
+ //! To construct the functor
+ THighlight(bool theIsHighlight):
+ myIsHighlight( theIsHighlight )
+ {}
+ //! To calculate the functor
void operator()(TActor* theActor)
{
if(theActor->GetVisibility() && theActor->GetMapper())
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+
+#include "SVTK_GenericRenderWindowInteractor.h"
+#include "SVTK_Selector.h"
+
+#include "utilities.h"
+
+#include <vtkObjectFactory.h>
+#include <vtkCommand.h>
+
+#include <qtimer.h>
+
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(QVTK_GenericRenderWindowInteractor);
+
+QVTK_GenericRenderWindowInteractor
+::QVTK_GenericRenderWindowInteractor()
+{
+ if(MYDEBUG) INFOS("QVTK_GenericRenderWindowInteractor() - "<<this);
+ myTimer = new QTimer( ) ;
+ connect(myTimer, SIGNAL(timeout()), this, SLOT(OnTimeOut())) ;
+}
+
+QVTK_GenericRenderWindowInteractor
+::~QVTK_GenericRenderWindowInteractor()
+{
+ if(MYDEBUG) INFOS("~QVTK_GenericRenderWindowInteractor() - "<<this);
+ delete myTimer;
+}
+
+
+//----------------------------------------------------------------------------
+void
+QVTK_GenericRenderWindowInteractor
+::OnTimeOut()
+{
+ if( GetEnabled() ) {
+ this->InvokeEvent(vtkCommand::TimerEvent,NULL);
+ }
+}
+
+int
+QVTK_GenericRenderWindowInteractor
+::CreateTimer(int vtkNotUsed(timertype))
+{
+ //
+ // Start a one-shot timer for <DELAY> ms.
+ //
+ static int DELAY = 1;
+ myTimer->start(DELAY,TRUE);
+ return 1;
+}
+
+int
+QVTK_GenericRenderWindowInteractor
+::DestroyTimer(void)
+{
+ //
+ // :TRICKY: Tue May 2 00:17:32 2000 Pagey
+ //
+ // QTimer will automatically expire after 10ms. So
+ // we do not need to do anything here. In fact, we
+ // should not even Stop() the QTimer here because doing
+ // this will skip some of the processing that the TimerFunc()
+ // does and will result in undesirable effects. For
+ // example, this will result in vtkLODActor to leave
+ // the models in low-res mode after the mouse stops
+ // moving.
+ //
+ return 1;
+}
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(SVTK_GenericRenderWindowInteractor);
+
+SVTK_GenericRenderWindowInteractor
+::SVTK_GenericRenderWindowInteractor():
+ myRenderWidget(NULL)
+{
+ if(MYDEBUG) INFOS("SVTK_GenericRenderWindowInteractor() - "<<this);
+}
+
+SVTK_GenericRenderWindowInteractor
+::~SVTK_GenericRenderWindowInteractor()
+{
+ if(MYDEBUG) INFOS("~SVTK_GenericRenderWindowInteractor() - "<<this);
+}
+
+SVTK_Selector*
+SVTK_GenericRenderWindowInteractor
+::GetSelector()
+{
+ return mySelector.GetPointer();
+}
+
+void
+SVTK_GenericRenderWindowInteractor
+::SetSelector(SVTK_Selector* theSelector)
+{
+ mySelector = theSelector;
+}
+
+QWidget*
+SVTK_GenericRenderWindowInteractor
+::GetRenderWidget()
+{
+ return myRenderWidget;
+}
+
+void
+SVTK_GenericRenderWindowInteractor
+::SetRenderWidget(QWidget* theRenderWidget)
+{
+ myRenderWidget = theRenderWidget;
+}
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+
+#ifndef SVTK_GenericRenderWindowInteractor_h
+#define SVTK_GenericRenderWindowInteractor_h
+
+#include "SVTK.h"
+
+#include <qobject.h>
+#include <vtkGenericRenderWindowInteractor.h>
+#include <vtkSmartPointer.h>
+
+class QTimer;
+class QWidget;
+
+class SVTK_Selector;
+class SVTK_Renderer;
+
+
+//============================================================================
+//! Introduction of the class is intended to implement Qt based #CreateTimer and #DestroyTimer functionality.
+/*!
+ The class intendes to implement platform indepenedant subclass of vtkRenderWindowInteractor.
+ This is done by usage of Qt library.
+ \note
+ The Signal/Slot mechanism used by Qt requires that QObject
+ appear as the first class when using multiple inheritance.
+ Hence the order of the two classes QObject and vtkRenderWindowInteractor
+ matters here. So, be careful, not to change the sequence of the inheritance by accident.
+*/
+class SVTK_EXPORT QVTK_GenericRenderWindowInteractor:
+ public QObject,
+ public vtkGenericRenderWindowInteractor
+{
+ Q_OBJECT;
+
+ public:
+ static QVTK_GenericRenderWindowInteractor* New();
+ vtkTypeMacro(QVTK_GenericRenderWindowInteractor,vtkGenericRenderWindowInteractor);
+
+ //! Starts the QTimer instance on defined microseconds
+ virtual
+ int
+ CreateTimer( int ) ;
+
+ //! Stops the QTimer instance
+ virtual
+ int
+ DestroyTimer() ;
+
+ protected slots:
+ //! The slot connects to QTimer::timeout signal to invoke vtkCommand::TimerEvent
+ void
+ OnTimeOut();
+
+ protected:
+ QVTK_GenericRenderWindowInteractor(); //!< Instatiate QTimer
+ ~QVTK_GenericRenderWindowInteractor(); //!< Destroy the instance of QTimer
+
+ QTimer* myTimer; //!< Qt timer device
+};
+
+
+//============================================================================
+//! This class introduce SALOME specific to the base one
+/*!
+ In this class new members is added (#mySelector and #myRenderWidget).
+ They are used for initialization of #SVTK_InteractorStyle by redefinition of
+ #SVTK_InteractorStyle::SetInteractor method
+*/
+class SVTK_EXPORT SVTK_GenericRenderWindowInteractor: public QVTK_GenericRenderWindowInteractor
+{
+ public:
+ static SVTK_GenericRenderWindowInteractor* New();
+ vtkTypeMacro(SVTK_GenericRenderWindowInteractor,QVTK_GenericRenderWindowInteractor);
+
+ //! To get access to SVTK_Selector
+ SVTK_Selector*
+ GetSelector();
+
+ //! To initialize mySelector field
+ void
+ SetSelector(SVTK_Selector* theSelector);
+
+ //! To get access to QWidget, where vtkRenderWindow maps to.
+ QWidget*
+ GetRenderWidget();
+
+ //! To initialize myRenderWidget field.
+ void
+ SetRenderWidget(QWidget* theRenderWidget);
+
+ protected:
+ SVTK_GenericRenderWindowInteractor();
+ ~SVTK_GenericRenderWindowInteractor();
+
+ vtkSmartPointer<SVTK_Selector> mySelector; //!< Keeps a pointer to SVTK_Selector
+ QWidget* myRenderWidget; //!< Keeps a pointer to QWidget, where vtkRenderWindow maps to.
+};
+
+#endif
//
//
//
-// File : SVTK_InteractorStyle.cxx
-// Author : Christophe ATTANASIO
+// File :
+// Author :
// Module : SALOME
// $Header$
#include "SVTK_InteractorStyle.h"
-#include "VTKViewer_CellRectPicker.h"
#include "VTKViewer_Utilities.h"
-#include "VTKViewer_RectPicker.h"
+#include "SVTK_GenericRenderWindowInteractor.h"
-#include "SVTK_RenderWindowInteractor.h"
-#include "SVTK_RenderWindow.h"
-#include "SVTK_ViewWindow.h"
-
-#include "SALOME_Actor.h"
-#include "SVTK_Actor.h"
+#include "SVTK_Selection.h"
+#include "SVTK_Event.h"
#include "SVTK_Selector.h"
+#include "SVTK_Functor.h"
-#include "SALOME_ListIteratorOfListIO.hxx"
-#include "SALOME_ListIO.hxx"
+#include "VTKViewer_Algorithm.h"
+#include "SVTK_Functor.h"
-#include "SUIT_Session.h"
-#include "CAM_Application.h"
+#include "SALOME_Actor.h"
#include <vtkObjectFactory.h>
#include <vtkMath.h>
#include <vtkCamera.h>
#include <vtkRenderer.h>
#include <vtkPicker.h>
-#include <vtkPointPicker.h>
-#include <vtkCellPicker.h>
-#include <vtkLine.h>
-#include <vtkMapper.h>
-#include <vtkDataSet.h>
-#include <vtkSmartPointer.h>
#include <vtkRenderWindow.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkCallbackCommand.h>
+#include <vtkRendererCollection.h>
#include <qapplication.h>
+#include <qpixmap.h>
//VRV: porting on Qt 3.0.5
#if QT_VERSION >= 0x030005
#include <qpainter.h>
//VRV: porting on Qt 3.0.5
#include <algorithm>
+#include "utilities.h"
+
using namespace std;
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
namespace
{
- int
- GetEdgeId(vtkPicker *thePicker, SALOME_Actor *theActor, int theObjId)
+ inline
+ void
+ GetEventPosition(vtkRenderWindowInteractor* theInteractor,
+ int& theX,
+ int& theY)
{
- int anEdgeId = -1;
- if (vtkCell* aPickedCell = theActor->GetElemCell(theObjId)) {
- float aPickPosition[3];
- thePicker->GetPickPosition(aPickPosition);
- float aMinDist = 1000000.0, aDist = 0;
- for (int i = 0, iEnd = aPickedCell->GetNumberOfEdges(); i < iEnd; i++){
- if(vtkLine* aLine = vtkLine::SafeDownCast(aPickedCell->GetEdge(i))){
- int subId; float pcoords[3], closestPoint[3], weights[3];
- aLine->EvaluatePosition(aPickPosition,closestPoint,subId,pcoords,aDist,weights);
- if (aDist < aMinDist) {
- aMinDist = aDist;
- anEdgeId = i;
- }
- }
- }
- }
- return anEdgeId;
+ theInteractor->GetEventPosition(theX,theY);
+ theY = theInteractor->GetSize()[1] - theY - 1;
}
-
-
- bool CheckDimensionId(Selection_Mode theMode, SALOME_Actor *theActor, vtkIdType theObjId){
- switch(theMode){
- case CellSelection:
- return true;
- case EdgeSelection:
- return ( theActor->GetObjDimension( theObjId ) == 1 );
- case FaceSelection:
- return ( theActor->GetObjDimension( theObjId ) == 2 );
- case VolumeSelection:
- return ( theActor->GetObjDimension( theObjId ) == 3 );
- };
- return false;
+ //==================================================================
+ // function : GetFirstSALOMEActor
+ // purpose :
+ //==================================================================
+ struct THaveIO
+ {
+ bool
+ operator()(SALOME_Actor* theActor)
+ {
+ return theActor->hasIO();
+ }
+ };
+
+ inline
+ SALOME_Actor*
+ GetFirstSALOMEActor(vtkPicker *thePicker)
+ {
+ return VTK::Find<SALOME_Actor>(thePicker->GetActors(),THaveIO());
}
-}
-
+}
+
+
//----------------------------------------------------------------------------
vtkStandardNewMacro(SVTK_InteractorStyle);
//----------------------------------------------------------------------------
-
SVTK_InteractorStyle
-::SVTK_InteractorStyle()
+::SVTK_InteractorStyle():
+ mySelectionEvent(new SVTK_SelectionEvent()),
+ myPicker(vtkPicker::New()),
+ myLastHighlitedActor(NULL),
+ myLastPreHighlitedActor(NULL),
+ myControllerIncrement(SVTK_ControllerIncrement::New()),
+ myControllerOnKeyDown(SVTK_ControllerOnKeyDown::New())
{
- myPreViewActor = NULL;
- myInteractor = NULL;
- myViewWindow = NULL;
- myGUIWindow = NULL;
+ myPicker->Delete();
+
+ if(MYDEBUG) INFOS("SVTK_InteractorStyle() - "<<this);
+
this->MotionFactor = 10.0;
this->State = VTK_INTERACTOR_STYLE_CAMERA_NONE;
this->RadianToDegree = 180.0 / vtkMath::Pi();
this->ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE;
+
loadCursors();
- myPreSelectionActor = SVTK_Actor::New();
- myPreSelectionActor->GetProperty()->SetColor(0,1,1);
- myPreSelectionActor->GetProperty()->SetLineWidth(5);
- myPreSelectionActor->GetProperty()->SetPointSize(5);
+ // set custom event handling function (to handle 3d space mouse events)
+ EventCallbackCommand->SetCallback( SVTK_InteractorStyle::ProcessEvents );
- OnSelectionModeChanged();
+ // set default values of properties. user may edit them in preferences.
+ mySMDecreaseSpeedBtn = 1;
+ mySMIncreaseSpeedBtn = 2;
+ mySMDominantCombinedSwitchBtn = 9;
+ //
+ myControllerIncrement->Delete();
+ myControllerOnKeyDown->Delete();
}
//----------------------------------------------------------------------------
SVTK_InteractorStyle
::~SVTK_InteractorStyle()
{
- myViewWindow->RemoveActor(myPreSelectionActor);
+ if(MYDEBUG) INFOS("~SVTK_InteractorStyle() - "<<this);
}
//----------------------------------------------------------------------------
-SVTK_Selector*
+QWidget*
SVTK_InteractorStyle
-::GetSelector()
+::GetRenderWidget()
{
- return myViewWindow->GetSelector();
+ return myInteractor->GetRenderWidget();
}
-//----------------------------------------------------------------------------
-void
+SVTK_Selector*
SVTK_InteractorStyle
-::setPreselectionProp(const double& theRed,
- const double& theGreen,
- const double& theBlue,
- const int& theWidth)
+::GetSelector()
{
- if ( myPreSelectionActor->GetProperty() == 0 )
- return;
- myPreSelectionActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
- myPreSelectionActor->GetProperty()->SetLineWidth(theWidth);
- myPreSelectionActor->GetProperty()->SetPointSize(theWidth);
+ return myInteractor->GetSelector();
}
//----------------------------------------------------------------------------
-void
+SVTK_SelectionEvent*
SVTK_InteractorStyle
-::SetInteractor(vtkRenderWindowInteractor *theInteractor)
+::GetSelectionEvent()
{
- myInteractor = dynamic_cast<SVTK_RenderWindowInteractor*>(theInteractor);
- Superclass::SetInteractor(theInteractor);
-}
+ mySelectionEvent->mySelectionMode = GetSelector()->SelectionMode();
-//----------------------------------------------------------------------------
-int
-SVTK_InteractorStyle
-::GetState()
-{
- return State | ForcedState;
-}
+ mySelectionEvent->myIsCtrl = Interactor->GetControlKey();
+ mySelectionEvent->myIsShift = Interactor->GetShiftKey();
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorStyle
-::setViewWindow(SVTK_ViewWindow* theViewWindow)
-{
- myViewWindow = theViewWindow;
- myViewWindow->AddActor(myPreSelectionActor);
- myPreSelectionActor->Delete();
+ mySelectionEvent->myLastX = mySelectionEvent->myX;
+ mySelectionEvent->myLastY = mySelectionEvent->myY;
+
+ GetEventPosition( this->Interactor, mySelectionEvent->myX, mySelectionEvent->myY );
+
+ return mySelectionEvent.get();
}
//----------------------------------------------------------------------------
-void
+SVTK_SelectionEvent*
SVTK_InteractorStyle
-::setGUIWindow(QWidget* theWindow)
+::GetSelectionEventFlipY()
{
- myGUIWindow = theWindow;
+ mySelectionEvent->mySelectionMode = GetSelector()->SelectionMode();
+
+ mySelectionEvent->myIsCtrl = Interactor->GetControlKey();
+ mySelectionEvent->myIsShift = Interactor->GetShiftKey();
+
+ mySelectionEvent->myLastX = mySelectionEvent->myX;
+ mySelectionEvent->myLastY = mySelectionEvent->myY;
+
+ this->Interactor->GetEventPosition(mySelectionEvent->myX, mySelectionEvent->myY);
+
+ return mySelectionEvent.get();
}
//----------------------------------------------------------------------------
SVTK_InteractorStyle
::RotateXY(int dx, int dy)
{
- double rxf;
- double ryf;
- vtkCamera *cam;
-
- if (this->CurrentRenderer == NULL)
- {
- return;
- }
+ if(GetCurrentRenderer() == NULL)
+ return;
- int *size = this->CurrentRenderer->GetRenderWindow()->GetSize();
- this->DeltaElevation = -20.0 / size[1];
- this->DeltaAzimuth = -20.0 / size[0];
+ int *size = GetCurrentRenderer()->GetRenderWindow()->GetSize();
+ double aDeltaElevation = -20.0 / size[1];
+ double aDeltaAzimuth = -20.0 / size[0];
- rxf = (double)dx * this->DeltaAzimuth * this->MotionFactor;
- ryf = (double)dy * this->DeltaElevation * this->MotionFactor;
+ double rxf = double(dx) * aDeltaAzimuth * this->MotionFactor;
+ double ryf = double(dy) * aDeltaElevation * this->MotionFactor;
- cam = this->CurrentRenderer->GetActiveCamera();
+ vtkCamera *cam = GetCurrentRenderer()->GetActiveCamera();
cam->Azimuth(rxf);
cam->Elevation(ryf);
cam->OrthogonalizeViewUp();
- ::ResetCameraClippingRange(this->CurrentRenderer);
- //this->Interactor->Render();
- myGUIWindow->update();
+
+ GetCurrentRenderer()->ResetCameraClippingRange();
+
+ this->Render();
}
//----------------------------------------------------------------------------
::PanXY(int x, int y, int oldX, int oldY)
{
TranslateView(x, y, oldX, oldY);
- //this->Interactor->Render();
- myGUIWindow->update();
+ this->Render();
}
SVTK_InteractorStyle
::DollyXY(int dx, int dy)
{
- if (this->CurrentRenderer == NULL) return;
+ if (GetCurrentRenderer() == NULL)
+ return;
- double dxf = this->MotionFactor * (double)(dx) / (double)(this->CurrentRenderer->GetCenter()[1]);
- double dyf = this->MotionFactor * (double)(dy) / (double)(this->CurrentRenderer->GetCenter()[1]);
+ double dxf = this->MotionFactor * (double)(dx) / (double)(GetCurrentRenderer()->GetCenter()[1]);
+ double dyf = this->MotionFactor * (double)(dy) / (double)(GetCurrentRenderer()->GetCenter()[1]);
double zoomFactor = pow((double)1.1, dxf + dyf);
- vtkCamera *aCam = this->CurrentRenderer->GetActiveCamera();
+ vtkCamera *aCam = GetCurrentRenderer()->GetActiveCamera();
if (aCam->GetParallelProjection())
aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor);
else{
aCam->Dolly(zoomFactor);
- ::ResetCameraClippingRange(this->CurrentRenderer);
+ GetCurrentRenderer()->ResetCameraClippingRange();
}
- //this->Interactor->Render();
- myGUIWindow->update();
+ this->Render();
}
//----------------------------------------------------------------------------
{
vtkCamera *cam;
- if (this->CurrentRenderer == NULL)
- {
- return;
- }
+ if (GetCurrentRenderer() == NULL)
+ return;
- double newAngle = atan2((double)(y - this->CurrentRenderer->GetCenter()[1]),
- (double)(x - this->CurrentRenderer->GetCenter()[0]));
- double oldAngle = atan2((double)(oldY -this->CurrentRenderer->GetCenter()[1]),
- (double)(oldX - this->CurrentRenderer->GetCenter()[0]));
+ double newAngle = atan2((double)(y - GetCurrentRenderer()->GetCenter()[1]),
+ (double)(x - GetCurrentRenderer()->GetCenter()[0]));
+ double oldAngle = atan2((double)(oldY -GetCurrentRenderer()->GetCenter()[1]),
+ (double)(oldX - GetCurrentRenderer()->GetCenter()[0]));
newAngle *= this->RadianToDegree;
oldAngle *= this->RadianToDegree;
- cam = this->CurrentRenderer->GetActiveCamera();
+ cam = GetCurrentRenderer()->GetActiveCamera();
cam->Roll(newAngle - oldAngle);
cam->OrthogonalizeViewUp();
- //this->Interactor->Render();
- myGUIWindow->update();
+ this->Render();
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnConfigure()
+{
+ this->FindPokedRenderer(0,0);
+ this->GetCurrentRenderer()->InvokeEvent(vtkCommand::ConfigureEvent,NULL);
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnMouseMove()
+{
+ int x, y;
+ GetEventPosition( this->Interactor, x, y );
+ this->OnMouseMove( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnLeftButtonDown()
+{
+ int x, y;
+ GetEventPosition( this->Interactor, x, y );
+ this->OnLeftButtonDown( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnLeftButtonUp()
+{
+ int x, y;
+ GetEventPosition( this->Interactor, x, y );
+ this->OnLeftButtonUp( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnMiddleButtonDown()
+{
+ int x, y;
+ GetEventPosition( this->Interactor, x, y );
+ this->OnMiddleButtonDown( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnMiddleButtonUp()
+{
+ int x, y;
+ GetEventPosition( this->Interactor, x, y );
+ this->OnMiddleButtonUp( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnRightButtonDown()
+{
+ int x, y;
+ GetEventPosition( this->Interactor, x, y );
+ this->OnRightButtonDown( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::OnRightButtonUp()
+{
+ int x, y;
+ GetEventPosition( this->Interactor, x, y );
+ this->OnRightButtonUp( this->Interactor->GetControlKey(),
+ this->Interactor->GetShiftKey(),
+ x, y );
}
::OnLeftButtonDown(int ctrl, int shift,
int x, int y)
{
- if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) {
- this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
- return;
- }
this->FindPokedRenderer(x, y);
- if (this->CurrentRenderer == NULL) {
+ if(GetCurrentRenderer() == NULL)
return;
- }
+
myShiftState = shift;
// finishing current viewer operation
if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
int shift,
int x, int y)
{
- if (this->HasObserver(vtkCommand::MiddleButtonPressEvent))
- {
- this->InvokeEvent(vtkCommand::MiddleButtonPressEvent,NULL);
- return;
- }
this->FindPokedRenderer(x, y);
- if (this->CurrentRenderer == NULL)
- {
- return;
- }
+ if(GetCurrentRenderer() == NULL)
+ return;
+
myShiftState = shift;
// finishing current viewer operation
if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
int shift,
int x, int y)
{
- if (this->HasObserver(vtkCommand::RightButtonPressEvent))
- {
- this->InvokeEvent(vtkCommand::RightButtonPressEvent,NULL);
- return;
- }
this->FindPokedRenderer(x, y);
- if (this->CurrentRenderer == NULL)
- {
- return;
- }
+ if(GetCurrentRenderer() == NULL)
+ return;
+
myShiftState = shift;
// finishing current viewer operation
if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
SVTK_InteractorStyle
::loadCursors()
{
- myDefCursor = QCursor(ArrowCursor);
- myHandCursor = QCursor(PointingHandCursor);
- myPanCursor = QCursor(SizeAllCursor);
+ myDefCursor = QCursor(Qt::ArrowCursor);
+ myHandCursor = QCursor(Qt::PointingHandCursor);
+ myPanCursor = QCursor(Qt::SizeAllCursor);
myZoomCursor = QCursor(QPixmap(imageZoomCursor));
myRotateCursor = QCursor(QPixmap(imageRotateCursor));
mySpinCursor = QCursor(QPixmap(imageRotateCursor)); // temporarly !!!!!!
- myGlobalPanCursor = QCursor(CrossCursor);
+ myGlobalPanCursor = QCursor(Qt::CrossCursor);
myCursorState = false;
}
-//----------------------------------------------------------------------------
-// event filter - controls mouse and keyboard events during viewer operations
-bool
-SVTK_InteractorStyle
-::eventFilter(QObject* object, QEvent* event)
-{
- if (!myGUIWindow) return false;
- if ( (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::KeyPress) && object != myGUIWindow)
- {
- qApp->removeEventFilter(this);
- startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
- }
- return QObject::eventFilter(object, event);
-}
-
-
//----------------------------------------------------------------------------
// starts Zoom operation (e.g. through menu command)
void
}
setCursor(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ZOOM;
- qApp->installEventFilter(this);
}
}
setCursor(VTK_INTERACTOR_STYLE_CAMERA_PAN);
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_PAN;
- qApp->installEventFilter(this);
}
//----------------------------------------------------------------------------
}
setCursor(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ROTATE;
- qApp->installEventFilter(this);
}
}
setCursor(VTK_INTERACTOR_STYLE_CAMERA_SPIN);
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_SPIN;
- qApp->installEventFilter(this);
}
}
setCursor(VTK_INTERACTOR_STYLE_CAMERA_FIT);
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_FIT;
- qApp->installEventFilter(this);
}
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN;
// store current zoom scale
- vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
- myScale = cam->GetParallelScale();
-
- if (myViewWindow) myViewWindow->onFitAll();
-
- if (myGUIWindow) myGUIWindow->update();
-
- qApp->installEventFilter(this);
-}
+ myScale = GetCurrentRenderer()->GetActiveCamera()->GetParallelScale();
+ GetCurrentRenderer()->ResetCamera();
-//----------------------------------------------------------------------------
-// returns TRUE if needs redrawing
-bool
-SVTK_InteractorStyle
-::needsRedrawing()
-{
- return State == VTK_INTERACTOR_STYLE_CAMERA_ZOOM ||
- State == VTK_INTERACTOR_STYLE_CAMERA_PAN ||
- State == VTK_INTERACTOR_STYLE_CAMERA_ROTATE ||
- State == VTK_INTERACTOR_STYLE_CAMERA_SPIN ||
- State == VTK_INTERACTOR_STYLE_CAMERA_NONE;
+ this->Render();
}
const int right,
const int bottom)
{
- if (this->CurrentRenderer == NULL) return;
+ if (GetCurrentRenderer() == NULL)
+ return;
// move camera
int x = (left + right)/2;
int y = (top + bottom)/2;
- int *aSize = this->CurrentRenderer->GetRenderWindow()->GetSize();
+ int *aSize = GetCurrentRenderer()->GetRenderWindow()->GetSize();
int oldX = aSize[0]/2;
int oldY = aSize[1]/2;
TranslateView(oldX, oldY, x, y);
double dyf = (double)(aSize[1]) / (double)(abs(bottom - top));
double zoomFactor = (dxf + dyf)/2 ;
- vtkCamera *aCam = this->CurrentRenderer->GetActiveCamera();
+ vtkCamera *aCam = GetCurrentRenderer()->GetActiveCamera();
if(aCam->GetParallelProjection())
aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor);
else{
aCam->Dolly(zoomFactor);
- ::ResetCameraClippingRange(this->CurrentRenderer);
+ GetCurrentRenderer()->ResetCameraClippingRange();
}
- myGUIWindow->update();
+ this->Render();
}
SVTK_InteractorStyle
::setCursor(const int operation)
{
- if (!myGUIWindow) return;
+ if (!GetRenderWidget()) return;
switch (operation)
{
case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
- myGUIWindow->setCursor(myZoomCursor);
+ GetRenderWidget()->setCursor(myZoomCursor);
myCursorState = true;
break;
case VTK_INTERACTOR_STYLE_CAMERA_PAN:
- myGUIWindow->setCursor(myPanCursor);
+ GetRenderWidget()->setCursor(myPanCursor);
myCursorState = true;
break;
case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
- myGUIWindow->setCursor(myRotateCursor);
+ GetRenderWidget()->setCursor(myRotateCursor);
myCursorState = true;
break;
case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
- myGUIWindow->setCursor(mySpinCursor);
+ GetRenderWidget()->setCursor(mySpinCursor);
myCursorState = true;
break;
case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
- myGUIWindow->setCursor(myGlobalPanCursor);
+ GetRenderWidget()->setCursor(myGlobalPanCursor);
myCursorState = true;
break;
case VTK_INTERACTOR_STYLE_CAMERA_FIT:
case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
- myGUIWindow->setCursor(myHandCursor);
+ GetRenderWidget()->setCursor(myHandCursor);
myCursorState = true;
break;
case VTK_INTERACTOR_STYLE_CAMERA_NONE:
default:
- myGUIWindow->setCursor(myDefCursor);
+ GetRenderWidget()->setCursor(myDefCursor);
myCursorState = false;
break;
}
SVTK_InteractorStyle
::onStartOperation()
{
- if (!myGUIWindow) return;
+ if (!GetRenderWidget()) return;
// VSV: LOD actor activisation
// this->Interactor->GetRenderWindow()->SetDesiredUpdateRate(this->Interactor->GetDesiredUpdateRate());
switch (State) {
case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
case VTK_INTERACTOR_STYLE_CAMERA_FIT:
{
- QPainter p(myGUIWindow);
+ QPainter p(GetRenderWidget());
p.setPen(Qt::lightGray);
p.setRasterOp(Qt::XorROP);
p.drawRect(QRect(myPoint, myOtherPoint));
SVTK_InteractorStyle
::onFinishOperation()
{
- if (!myGUIWindow)
+ if (!GetRenderWidget())
return;
// VSV: LOD actor activisation
// rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate());
- Selection_Mode aSelectionMode = myViewWindow->SelectionMode();
- bool aSelActiveCompOnly = false;
-
- QString aComponentDataType;
- if(SUIT_Session* aSession = SUIT_Session::session())
- if(SUIT_Application* aSUITApp = aSession->activeApplication())
- if(CAM_Application* aCAMApp = dynamic_cast<CAM_Application*>(aSUITApp))
- if(CAM_Module* aModule = aCAMApp->activeModule())
- aComponentDataType = aModule->name();
+ SVTK_SelectionEvent* aSelectionEvent = GetSelectionEventFlipY();
switch (State) {
case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
case VTK_INTERACTOR_STYLE_CAMERA_FIT:
{
- QPainter p(myGUIWindow);
- p.setPen(Qt::lightGray);
- p.setRasterOp(Qt::XorROP);
- QRect rect(myPoint, myOtherPoint);
- p.drawRect(rect);
- rect = rect.normalize();
+ QPainter aPainter(GetRenderWidget());
+ aPainter.setPen(Qt::lightGray);
+ aPainter.setRasterOp(Qt::XorROP);
+ QRect aRect(myPoint, myOtherPoint);
+ aPainter.drawRect(aRect);
+ aRect = aRect.normalize();
+
if (State == VTK_INTERACTOR_STYLE_CAMERA_FIT) {
// making fit rect opeation
int w, h;
- myInteractor->GetSize(w, h);
- int x1, y1, x2, y2;
- x1 = rect.left();
- y1 = h - rect.top() - 1;
- x2 = rect.right();
- y2 = h - rect.bottom() - 1;
+ Interactor->GetSize(w, h);
+ int x1 = aRect.left();
+ int y1 = h - aRect.top() - 1;
+ int x2 = aRect.right();
+ int y2 = h - aRect.bottom() - 1;
fitRect(x1, y1, x2, y2);
}
else {
if (myPoint == myOtherPoint) {
// process point selection
- int w, h, x, y;
- myInteractor->GetSize(w, h);
- x = myPoint.x();
- y = h - myPoint.y() - 1;
-
- this->FindPokedRenderer(x, y);
- myInteractor->StartPickCallback();
-
- vtkPicker* aPicker = vtkPicker::SafeDownCast(myInteractor->GetPicker());
- aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
-
- SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
-
- if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
- int aVtkId = picker->GetCellId();
- if ( aVtkId >= 0 && aSActor && aSActor->hasIO() && IsValid( aSActor, aVtkId ) ) {
- int anObjId = aSActor->GetElemObjId(aVtkId);
- if(anObjId >= 0){
- Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
- if(aSelectionMode != EdgeOfCellSelection) {
- if(CheckDimensionId(aSelectionMode,aSActor,anObjId)){
- if (GetSelector()->IsSelected(anIO)) {
- // This IO is already in the selection
- GetSelector()->AddOrRemoveIndex(anIO,anObjId,myShiftState);
- } else {
- if (!myShiftState) {
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
- GetSelector()->AddOrRemoveIndex(anIO,anObjId,myShiftState);
- GetSelector()->AddIObject(aSActor);
- }
- }
- }else{
- if (!myShiftState) {
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
- int anEdgeId = GetEdgeId(picker,aSActor,anObjId);
- if (anEdgeId >= 0) {
- GetSelector()->AddOrRemoveIndex(anIO,anObjId,false);
- GetSelector()->AddOrRemoveIndex(anIO,-anEdgeId-1,true);
- GetSelector()->AddIObject(aSActor);
- }
- }
- }
- } else {
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
- } else if ( vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker) ) {
- int aVtkId = picker->GetPointId();
- if ( aVtkId >= 0 && IsValid( aSActor, aVtkId, true ) ) {
- if ( aSActor && aSActor->hasIO() ) {
- int anObjId = aSActor->GetNodeObjId(aVtkId);
- if(anObjId >= 0){
- Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
- if(GetSelector()->IsSelected(anIO)) {
- // This IO is already in the selection
- GetSelector()->AddOrRemoveIndex(anIO,anObjId,myShiftState);
- } else {
- if(!myShiftState) {
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
- GetSelector()->AddOrRemoveIndex(anIO,anObjId,myShiftState);
- GetSelector()->AddIObject(aSActor);
- }
- }
- }
- } else {
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
- } else {
- if ( aSActor && aSActor->hasIO() ) {
- this->PropPicked++;
- Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
- if(GetSelector()->IsSelected(anIO)) {
- // This IO is already in the selection
- if(myShiftState) {
- GetSelector()->RemoveIObject(aSActor);
- }
- }
- else {
- if(!myShiftState) {
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
- GetSelector()->AddIObject(aSActor);
- }
- }else{
- // No selection clear all
- this->PropPicked = 0;
- this->HighlightProp( NULL );
- GetSelector()->ClearIObjects();
- }
+ this->FindPokedRenderer(aSelectionEvent->myX, aSelectionEvent->myY);
+ Interactor->StartPickCallback();
+
+ myPicker->Pick(aSelectionEvent->myX,
+ aSelectionEvent->myY,
+ 0.0,
+ GetCurrentRenderer());
+ //
+ SALOME_Actor* anActor = GetFirstSALOMEActor(myPicker.GetPointer());
+ aSelectionEvent->myIsRectangle = false;
+ if(anActor){
+ anActor->Highlight( this, aSelectionEvent, true );
+ }else{
+ if(myLastHighlitedActor.GetPointer() && myLastHighlitedActor.GetPointer() != anActor)
+ myLastHighlitedActor->Highlight( this, aSelectionEvent, false );
+ GetSelector()->ClearIObjects();
}
- myInteractor->EndPickCallback();
- } else {
+ myLastHighlitedActor = anActor;
+ }
+ else {
//processing rectangle selection
- if(aSelActiveCompOnly && aComponentDataType.isEmpty()) return;
- myInteractor->StartPickCallback();
+ Interactor->StartPickCallback();
+ GetSelector()->StartPickCallback();
+ aSelectionEvent->myIsRectangle = true;
- if (!myShiftState) {
- this->PropPicked = 0;
- this->HighlightProp( NULL );
+ if(!myShiftState)
GetSelector()->ClearIObjects();
- }
- // Compute bounds
- // vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
- QRect rect(myPoint, myOtherPoint);
- rect = rect.normalize();
- int w, h;
- myInteractor->GetSize(w, h);
- int x1, y1, x2, y2;
- x1 = rect.left();
- y1 = h - rect.top() - 1;
- x2 = rect.right();
- y2 = h - rect.bottom() - 1;
-
- switch (aSelectionMode) {
- case NodeSelection: {
- if ( vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(myInteractor->GetPicker()) ) {
- vtkActorCollection* aListActors = this->CurrentRenderer->GetActors();
- aListActors->InitTraversal();
- while (vtkActor* aActor = aListActors->GetNextActor()) {
- if (!aActor->GetVisibility())
- continue;
- if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
- if (aSActor->hasIO()) {
- Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
- if (anIO.IsNull())
- continue;
- if (aSelActiveCompOnly && aComponentDataType != anIO->getComponentDataType())
- continue;
- if (vtkDataSet* aDataSet = aSActor->GetInput()) {
- TColStd_MapOfInteger anIndices;
- for(int i = 0; i < aDataSet->GetNumberOfPoints(); i++) {
- float aPoint[3];
- aDataSet->GetPoint(i,aPoint);
- if (IsInRect(aPoint,x1,y1,x2,y2)){
- float aDisp[3];
- ComputeWorldToDisplay(aPoint[0],aPoint[1],aPoint[2],aDisp);
- if(aPointPicker->Pick(aDisp[0],aDisp[1],0.0,CurrentRenderer)){
- if(vtkActorCollection *anActorCollection = aPointPicker->GetActors()){
- if(anActorCollection->IsItemPresent(aSActor)){
- float aPickedPoint[3];
- aPointPicker->GetMapperPosition(aPickedPoint);
- vtkIdType aVtkId = aDataSet->FindPoint(aPickedPoint);
- if ( aVtkId >= 0 && IsValid( aSActor, aVtkId, true ) ){
- int anObjId = aSActor->GetNodeObjId(aVtkId);
- anIndices.Add(anObjId);
- }
- }
- }
- }
- }
- }
- if (!anIndices.IsEmpty()) {
- GetSelector()->AddOrRemoveIndex(anIO,anIndices,true); // ENK false to true
- GetSelector()->AddIObject(aSActor);
- anIndices.Clear();
- }else{
- GetSelector()->RemoveIObject(aSActor);
- }
- }
- }
- }
+ vtkActorCollection* aListActors = GetCurrentRenderer()->GetActors();
+ aListActors->InitTraversal();
+ while(vtkActor* aActor = aListActors->GetNextActor()){
+ if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)){
+ if(aSActor->hasIO()){
+ aSActor->Highlight( this, aSelectionEvent, true );
}
}
- break;
}
- case CellSelection:
- case EdgeOfCellSelection:
- case EdgeSelection:
- case FaceSelection:
- case VolumeSelection:
- {
- vtkSmartPointer<VTKViewer_CellRectPicker> picker = VTKViewer_CellRectPicker::New();
- picker->SetTolerance(0.001);
- picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
-
- vtkActorCollection* aListActors = picker->GetActors();
- aListActors->InitTraversal();
- while(vtkActor* aActor = aListActors->GetNextActor()) {
- if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
- if (aSActor->hasIO()) {
- Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
- if (aSelActiveCompOnly && aComponentDataType != anIO->getComponentDataType())
- continue;
- VTKViewer_CellDataSet cellList = picker->GetCellData(aActor);
- if ( !cellList.empty() ) {
- TColStd_MapOfInteger anIndexes;
- VTKViewer_CellDataSet::iterator it;
- for ( it = cellList.begin(); it != cellList.end(); ++it ) {
- int aCellId = (*it).cellId;
-
- if ( !IsValid( aSActor, aCellId ) )
- continue;
-
- int anObjId = aSActor->GetElemObjId(aCellId);
- if (anObjId != -1){
- if ( CheckDimensionId(aSelectionMode,aSActor,anObjId) ) {
- anIndexes.Add(anObjId);
- }
- }
- }
- GetSelector()->AddOrRemoveIndex(anIO,anIndexes,true);
- GetSelector()->AddIObject(aSActor);
- }
- }
- }
- }
- }
- break;
- case ActorSelection: // objects selection
- {
- vtkSmartPointer<VTKViewer_RectPicker> picker = VTKViewer_RectPicker::New();
- picker->SetTolerance(0.001);
- picker->Pick(x1, y1, 0.0, x2, y2, 0.0, this->CurrentRenderer);
-
- vtkActorCollection* aListActors = picker->GetActors();
- aListActors->InitTraversal();
- while(vtkActor* aActor = aListActors->GetNextActor()) {
- if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor)) {
- if (aSActor->hasIO()) {
- Handle(SALOME_InteractiveObject) anIO = aSActor->getIO();
- GetSelector()->AddIObject(aSActor);
- this->PropPicked++;
- }
- }
- }
- } // end case 4
- } //end switch
- myInteractor->EndPickCallback();
}
- myViewWindow->onSelectionChanged();
+ Interactor->EndPickCallback();
+ GetSelector()->EndPickCallback();
}
}
break;
case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
{
int w, h, x, y;
- myInteractor->GetSize(w, h);
+ Interactor->GetSize(w, h);
x = myPoint.x();
y = h - myPoint.y() - 1;
Place(x, y);
}
break;
}
- if (myGUIWindow) myGUIWindow->update();
+ this->Render();
}
// called during viewer operation when user moves mouse (!put necessary processing here!)
+//----------------------------------------------------------------------------
void
SVTK_InteractorStyle
::onOperation(QPoint mousePos)
{
- if (!myGUIWindow) return;
- int w, h;
- GetInteractor()->GetSize(w, h);
+ if (!GetRenderWidget())
+ return;
+
switch (State) {
case VTK_INTERACTOR_STYLE_CAMERA_PAN:
{
- // processing panning
- //this->FindPokedCamera(mousePos.x(), mousePos.y());
this->PanXY(mousePos.x(), myPoint.y(), myPoint.x(), mousePos.y());
myPoint = mousePos;
break;
}
case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
{
- // processing zooming
- //this->FindPokedCamera(mousePos.x(), mousePos.y());
this->DollyXY(mousePos.x() - myPoint.x(), mousePos.y() - myPoint.y());
myPoint = mousePos;
break;
}
case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
{
- // processing rotation
- //this->FindPokedCamera(mousePos.x(), mousePos.y());
this->RotateXY(mousePos.x() - myPoint.x(), myPoint.y() - mousePos.y());
myPoint = mousePos;
break;
}
case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
{
- // processing spinning
- //this->FindPokedCamera(mousePos.x(), mousePos.y());
this->SpinXY(mousePos.x(), mousePos.y(), myPoint.x(), myPoint.y());
myPoint = mousePos;
break;
}
case VTK_INTERACTOR_STYLE_CAMERA_FIT:
{
- QPainter p(myGUIWindow);
+ QPainter p(GetRenderWidget());
p.setPen(Qt::lightGray);
p.setRasterOp(Qt::XorROP);
p.drawRect(QRect(myPoint, myOtherPoint));
break;
}
}
- this->LastPos[0] = mousePos.x();
- this->LastPos[1] = h - mousePos.y() - 1;
-}
-
-// called when selection mode changed (!put necessary initialization here!)
-void
-SVTK_InteractorStyle
-::OnSelectionModeChanged()
-{
-
- myPreSelectionActor->SetVisibility(false);
- myElemId = myEdgeId = myNodeId = -1;
- mySelectedActor = NULL;
}
// called when user moves mouse inside viewer window and there is no active viewer operation
// (!put necessary processing here!)
+//----------------------------------------------------------------------------
void
SVTK_InteractorStyle
::onCursorMove(QPoint mousePos)
{
// processing highlighting
- Selection_Mode aSelectionMode = myViewWindow->SelectionMode();
+ SVTK_SelectionEvent* aSelectionEvent = GetSelectionEventFlipY();
+ this->FindPokedRenderer(aSelectionEvent->myX,aSelectionEvent->myY);
- int w, h, x, y;
- myInteractor->GetSize(w, h);
- x = mousePos.x(); y = h - mousePos.y() - 1;
+ bool anIsChanged = false;
- this->FindPokedRenderer(x,y);
- myInteractor->StartPickCallback();
- myPreSelectionActor->SetVisibility(false);
+ myPicker->Pick(aSelectionEvent->myX,
+ aSelectionEvent->myY,
+ 0.0,
+ GetCurrentRenderer());
+
+ SALOME_Actor *anActor = GetFirstSALOMEActor(myPicker.GetPointer());
+ if (anActor){
+ anIsChanged |= anActor->PreHighlight( this, aSelectionEvent, true );
+ }
- vtkPicker* aPicker = vtkPicker::SafeDownCast(myInteractor->GetPicker());
- aPicker->Pick(x, y, 0.0, this->CurrentRenderer);
+ if(myLastPreHighlitedActor.GetPointer() && myLastPreHighlitedActor.GetPointer() != anActor)
+ anIsChanged |= myLastPreHighlitedActor->PreHighlight( this, aSelectionEvent, false );
- SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aPicker->GetActor());
+ myLastPreHighlitedActor = anActor;
- if (aSActor && myPreSelectionActor){
- float aPos[3];
- aSActor->GetPosition(aPos);
- myPreSelectionActor->SetPosition(aPos);
- }
-
- if (vtkCellPicker* picker = vtkCellPicker::SafeDownCast(aPicker)) {
- int aVtkId = picker->GetCellId();
- if ( aVtkId >= 0 ) {
- int anObjId = aSActor->GetElemObjId(aVtkId);
- if ( aSActor && aSActor->hasIO() && IsValid( aSActor, aVtkId ) ) {
- bool anIsSameObjId = (mySelectedActor == aSActor && myElemId == anObjId);
- bool aResult = anIsSameObjId;
- if(!anIsSameObjId) {
- if(aSelectionMode != EdgeOfCellSelection) {
- aResult = CheckDimensionId(aSelectionMode,aSActor,anObjId);
- if(aResult){
- mySelectedActor = aSActor;
- myElemId = anObjId;
- myInteractor->setCellData(anObjId,aSActor,myPreSelectionActor);
- }
- }
- }
- if(aSelectionMode == EdgeOfCellSelection){
- int anEdgeId = GetEdgeId(picker,aSActor,anObjId);
- bool anIsSameEdgeId = (myEdgeId != anEdgeId) && anIsSameObjId;
- aResult = anIsSameEdgeId;
- if(!anIsSameEdgeId) {
- aResult = (anEdgeId >= 0);
- if (aResult) {
- mySelectedActor = aSActor;
- myEdgeId = anEdgeId;
- myElemId = anObjId;
- myInteractor->setEdgeData(anObjId,aSActor,-anEdgeId-1,myPreSelectionActor);
- }
- }
- }
- if(aResult) {
- myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
- myPreSelectionActor->SetVisibility(true);
- }
- }
- }
- }
- else if (vtkPointPicker* picker = vtkPointPicker::SafeDownCast(aPicker)) {
- int aVtkId = picker->GetPointId();
- if ( aVtkId >= 0 && IsValid( aSActor, aVtkId, true ) ) {
- if ( aSActor && aSActor->hasIO() ) {
- int anObjId = aSActor->GetNodeObjId(aVtkId);
- bool anIsSameObjId = (mySelectedActor == aSActor && myNodeId == anObjId);
- if(!anIsSameObjId) {
- mySelectedActor = aSActor;
- myNodeId = anObjId;
- myInteractor->setPointData(anObjId,aSActor,myPreSelectionActor);
- }
- myPreSelectionActor->GetProperty()->SetRepresentationToSurface();
- myPreSelectionActor->SetVisibility(true);
- }
- }
- }
- else if ( vtkPicker::SafeDownCast(aPicker) ) {
- if ( aSActor ) {
- if ( myPreViewActor != aSActor ) {
- if ( myPreViewActor != NULL ) {
- myPreViewActor->SetPreSelected( false );
- }
- myPreViewActor = aSActor;
-
- if ( aSActor->hasIO() ) {
- Handle( SALOME_InteractiveObject) IO = aSActor->getIO();
- if ( !GetSelector()->IsSelected(IO) ) {
- // Find All actors with same IO
- vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
- theActors->InitTraversal();
- while( vtkActor *ac = theActors->GetNextActor() ) {
- if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
- if ( anActor->hasIO() ) {
- Handle(SALOME_InteractiveObject) IOS = anActor->getIO();
- if(IO->isSame(IOS)) {
- anActor->SetPreSelected( true );
- }
- }
- }
- }
- }
- }
- }
- } else {
- myPreViewActor = NULL;
- vtkActorCollection* theActors = this->CurrentRenderer->GetActors();
- theActors->InitTraversal();
- while( vtkActor *ac = theActors->GetNextActor() ) {
- if ( SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ) ) {
- anActor->SetPreSelected( false );
- }
- }
- }
- }
- myInteractor->EndPickCallback();
- //myInteractor->Render();
- myGUIWindow->update();
-
- this->LastPos[0] = x;
- this->LastPos[1] = y;
+ if(anIsChanged)
+ this->Render();
}
// called on finsh GlobalPan operation
+//----------------------------------------------------------------------------
void
SVTK_InteractorStyle
::Place(const int theX, const int theY)
{
- if (this->CurrentRenderer == NULL) {
+ if (GetCurrentRenderer() == NULL)
return;
- }
//translate view
- int *aSize = this->CurrentRenderer->GetRenderWindow()->GetSize();
+ int *aSize = GetCurrentRenderer()->GetRenderWindow()->GetSize();
int centerX = aSize[0]/2;
int centerY = aSize[1]/2;
TranslateView(centerX, centerY, theX, theY);
// restore zoom scale
- vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
+ vtkCamera *cam = GetCurrentRenderer()->GetActiveCamera();
cam->SetParallelScale(myScale);
- ::ResetCameraClippingRange(this->CurrentRenderer);
-
- if (myGUIWindow) myGUIWindow->update();
+ GetCurrentRenderer()->ResetCameraClippingRange();
+ this->Render();
}
// Translates view from Point to Point
+//----------------------------------------------------------------------------
void
SVTK_InteractorStyle
::TranslateView(int toX, int toY, int fromX, int fromY)
{
- vtkCamera *cam = this->CurrentRenderer->GetActiveCamera();
+ vtkCamera *cam = GetCurrentRenderer()->GetActiveCamera();
double viewFocus[4], focalDepth, viewPoint[3];
float newPickPoint[4], oldPickPoint[4], motionVector[3];
cam->GetFocalPoint(viewFocus);
motionVector[2] + viewPoint[2]);
}
-
-/// Checks: is the given Actor within display coordinates?
-bool
+//----------------------------------------------------------------------------
+void
SVTK_InteractorStyle
-::IsInRect(vtkActor* theActor,
- const int left, const int top,
- const int right, const int bottom)
-{
- float* aBounds = theActor->GetBounds();
- float aMin[3], aMax[3];
- ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
- ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
- if (aMin[0] > aMax[0]) {
- float aBuf = aMin[0];
- aMin[0] = aMax[0];
- aMax[0] = aBuf;
- }
- if (aMin[1] > aMax[1]) {
- float aBuf = aMin[1];
- aMin[1] = aMax[1];
- aMax[1] = aBuf;
- }
-
- return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
+::IncrementalPan( const int incrX, const int incrY )
+{
+ this->PanXY( incrX, incrY, 0, 0 );
}
-
-/// Checks: is the given Cell within display coordinates?
-bool
+//----------------------------------------------------------------------------
+void
SVTK_InteractorStyle
-::IsInRect(vtkCell* theCell,
- const int left, const int top,
- const int right, const int bottom)
-{
- float* aBounds = theCell->GetBounds();
- float aMin[3], aMax[3];
- ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin);
- ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax);
- if (aMin[0] > aMax[0]) {
- float aBuf = aMin[0];
- aMin[0] = aMax[0];
- aMax[0] = aBuf;
- }
- if (aMin[1] > aMax[1]) {
- float aBuf = aMin[1];
- aMin[1] = aMax[1];
- aMax[1] = aBuf;
- }
-
- return ((aMin[0]>left) && (aMax[0]<right) && (aMin[1]>bottom) && (aMax[1]<top));
+::IncrementalZoom( const int incr )
+{
+ this->DollyXY( incr, incr );
}
-
-bool
+//----------------------------------------------------------------------------
+void
SVTK_InteractorStyle
-::IsInRect(float* thePoint,
- const int left, const int top,
- const int right, const int bottom)
+::IncrementalRotate( const int incrX, const int incrY )
{
- float aPnt[3];
- ComputeWorldToDisplay(thePoint[0], thePoint[1], thePoint[2], aPnt);
-
- return ((aPnt[0]>left) && (aPnt[0]<right) && (aPnt[1]>bottom) && (aPnt[1]<top));
+ this->RotateXY( incrX, -incrY );
}
+//----------------------------------------------------------------------------
void
SVTK_InteractorStyle
-::SetFilter( const Handle(VTKViewer_Filter)& theFilter )
+::SetInteractor( vtkRenderWindowInteractor* theInteractor )
{
- myFilters[ theFilter->GetId() ] = theFilter;
+ // register EventCallbackCommand as observer of standard events (keypress, mousemove, etc)
+ Superclass::SetInteractor( theInteractor );
+
+ myInteractor = dynamic_cast<SVTK_GenericRenderWindowInteractor*>(theInteractor);
+
+ if(theInteractor) {
+ // register EventCallbackCommand as observer of custorm event (3d space mouse event)
+ theInteractor->AddObserver( SVTK::SpaceMouseMoveEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SpaceMouseButtonEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PanLeftEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PanRightEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PanUpEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PanDownEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::ZoomInEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::ZoomOutEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::RotateLeftEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::RotateRightEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::RotateUpEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::RotateDownEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PlusSpeedIncrementEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::MinusSpeedIncrementEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SetSpeedIncrementEvent, EventCallbackCommand, Priority );
+
+ theInteractor->AddObserver( SVTK::SetSMDecreaseSpeedEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SetSMIncreaseSpeedEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SetSMDominantCombinedSwitchEvent, EventCallbackCommand, Priority );
+
+ theInteractor->AddObserver( SVTK::StartZoom, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartPan, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartRotate, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartGlobalPan, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartFitArea, EventCallbackCommand, Priority );
+ }
}
-bool
+
+//----------------------------------------------------------------------------
+void
SVTK_InteractorStyle
-::IsFilterPresent( const int theId )
+::OnTimer()
{
- return myFilters.find( theId ) != myFilters.end();
+ //vtkInteractorStyle::OnTimer();
+ this->Interactor->Render();
}
-void
+//----------------------------------------------------------------------------
+void
SVTK_InteractorStyle
-::RemoveFilter( const int theId )
+::Render()
{
- if ( IsFilterPresent( theId ) )
- myFilters.erase( theId );
+ this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
}
-
-bool
+//----------------------------------------------------------------------------
+void
SVTK_InteractorStyle
-::IsValid( SALOME_Actor* theActor,
- const int theId,
- const bool theIsNode )
+::onSpaceMouseMove( double* data )
{
- std::map<int, Handle(VTKViewer_Filter)>::const_iterator anIter;
- for ( anIter = myFilters.begin(); anIter != myFilters.end(); ++anIter )
- {
- const Handle(VTKViewer_Filter)& aFilter = anIter->second;
- if ( theIsNode == aFilter->IsNodeFilter() &&
- !aFilter->IsValid( theActor, theId ) )
- return false;
- }
- return true;
+ // general things, do SetCurrentRenderer() within FindPokedRenderer()
+ int x, y;
+ GetEventPosition( this->Interactor, x, y ); // current mouse position (from last mouse move event or any other event)
+ FindPokedRenderer( x, y ); // calls SetCurrentRenderer
+
+ IncrementalZoom( (int)data[2] ); // 1. push toward / pull backward = zoom out / zoom in
+ IncrementalPan( (int)data[0], (int)data[1] );// 2. pull up / push down = pan up / down, 3. move left / right = pan left / right
+ IncrementalRotate( 0, (int)data[4] ); // 4. twist the control = rotate around Y axis
+ IncrementalRotate( (int)data[3], 0 ); // 5. tilt the control forward/backward = rotate around X axis (Z axis of local coordinate system of space mouse)
}
-Handle(VTKViewer_Filter)
+//----------------------------------------------------------------------------
+void
SVTK_InteractorStyle
-::GetFilter( const int theId )
+::onSpaceMouseButton( int button )
{
- return IsFilterPresent( theId ) ? myFilters[ theId ] : Handle(VTKViewer_Filter)();
+ if( mySMDecreaseSpeedBtn == button ) {
+ ControllerIncrement()->Decrease();
+ }
+ if( mySMIncreaseSpeedBtn == button ) {
+ ControllerIncrement()->Increase();
+ }
+ if( mySMDominantCombinedSwitchBtn == button )
+ DominantCombinedSwitch();
}
+//----------------------------------------------------------------------------
void
SVTK_InteractorStyle
-::IncrementalPan( const int incrX, const int incrY )
+::DominantCombinedSwitch()
{
- this->PanXY( incrX, incrY, 0, 0 );
+ printf( "\n--DominantCombinedSwitch() NOT IMPLEMENTED--\n" );
}
+//----------------------------------------------------------------------------
void
SVTK_InteractorStyle
-::IncrementalZoom( const int incr )
+::ProcessEvents( vtkObject* object,
+ unsigned long event,
+ void* clientData,
+ void* callData )
{
- this->DollyXY( incr, incr );
+ if ( clientData ) {
+ vtkObject* anObject = reinterpret_cast<vtkObject*>( clientData );
+ SVTK_InteractorStyle* self = dynamic_cast<SVTK_InteractorStyle*>( anObject );
+ int aSpeedIncrement=self->ControllerIncrement()->Current();
+ if ( self ) {
+ switch ( event ) {
+ case SVTK::SpaceMouseMoveEvent :
+ self->onSpaceMouseMove( (double*)callData );
+ return;
+ case SVTK::SpaceMouseButtonEvent :
+ self->onSpaceMouseButton( *((int*)callData) );
+ return;
+ case SVTK::PanLeftEvent:
+ self->IncrementalPan(-aSpeedIncrement, 0);
+ return;
+ case SVTK::PanRightEvent:
+ self->IncrementalPan(aSpeedIncrement, 0);
+ return;
+ case SVTK::PanUpEvent:
+ self->IncrementalPan(0, aSpeedIncrement);
+ return;
+ case SVTK::PanDownEvent:
+ self->IncrementalPan(0, -aSpeedIncrement);
+ return;
+ case SVTK::ZoomInEvent:
+ self->IncrementalZoom(aSpeedIncrement);
+ return;
+ case SVTK::ZoomOutEvent:
+ self->IncrementalZoom(-aSpeedIncrement);
+ return;
+ case SVTK::RotateLeftEvent:
+ self->IncrementalRotate(-aSpeedIncrement, 0);
+ return;
+ case SVTK::RotateRightEvent:
+ self->IncrementalRotate(aSpeedIncrement, 0);
+ return;
+ case SVTK::RotateUpEvent:
+ self->IncrementalRotate(0, -aSpeedIncrement);
+ return;
+ case SVTK::RotateDownEvent:
+ self->IncrementalRotate(0, aSpeedIncrement);
+ return;
+ case SVTK::PlusSpeedIncrementEvent:
+ self->ControllerIncrement()->Increase();
+ return;
+ case SVTK::MinusSpeedIncrementEvent:
+ self->ControllerIncrement()->Decrease();
+ return;
+ case SVTK::SetSpeedIncrementEvent:
+ self->ControllerIncrement()->SetStartValue(*((int*)callData));
+ return;
+
+ case SVTK::SetSMDecreaseSpeedEvent:
+ self->mySMDecreaseSpeedBtn = *((int*)callData);
+ return;
+ case SVTK::SetSMIncreaseSpeedEvent:
+ self->mySMIncreaseSpeedBtn = *((int*)callData);
+ return;
+ case SVTK::SetSMDominantCombinedSwitchEvent:
+ self->mySMDominantCombinedSwitchBtn = *((int*)callData);
+ return;
+
+ case SVTK::StartZoom:
+ self->startZoom();
+ return;
+ case SVTK::StartPan:
+ self->startPan();
+ return;
+ case SVTK::StartRotate:
+ self->startRotate();
+ return;
+ case SVTK::StartGlobalPan:
+ self->startGlobalPan();
+ return;
+ case SVTK::StartFitArea:
+ self->startFitArea();
+ return;
+ }
+ }
+ }
+
+ Superclass::ProcessEvents( object, event, clientData, callData );
+}
+//----------------------------------------------------------------------------
+void SVTK_InteractorStyle::OnChar()
+{
+}
+//----------------------------------------------------------------------------
+void SVTK_InteractorStyle::OnKeyDown()
+{
+ bool bInvokeSuperclass=myControllerOnKeyDown->OnKeyDown(this);
+ if (bInvokeSuperclass){
+ Superclass::OnKeyDown();
+ }
+}
+//----------------------------------------------------------------------------
+void SVTK_InteractorStyle::ActionPicking()
+{
+ int x, y;
+ Interactor->GetEventPosition( x, y );
+ FindPokedRenderer( x, y );
+
+ myOtherPoint = myPoint = QPoint(x, y);
+
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT);
+ onFinishOperation();
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
+}
+//----------------------------------------------------------------------------
+void SVTK_InteractorStyle::SetControllerOnKeyDown(SVTK_ControllerOnKeyDown* theController)
+{
+ myControllerOnKeyDown=theController;
+}
+//----------------------------------------------------------------------------
+SVTK_ControllerOnKeyDown* SVTK_InteractorStyle::ControllerOnKeyDown()
+{
+ return myControllerOnKeyDown.GetPointer();
+}
+//----------------------------------------------------------------------------
+void SVTK_InteractorStyle::SetControllerIncrement(SVTK_ControllerIncrement* theController)
+{
+ myControllerIncrement=theController;
+}
+//----------------------------------------------------------------------------
+SVTK_ControllerIncrement* SVTK_InteractorStyle::ControllerIncrement()
+{
+ return myControllerIncrement.GetPointer();
}
-void
-SVTK_InteractorStyle
-::IncrementalRotate( const int incrX, const int incrY )
+vtkStandardNewMacro(SVTK_ControllerIncrement);
+//----------------------------------------------------------------------------
+SVTK_ControllerIncrement::SVTK_ControllerIncrement()
{
- this->RotateXY( incrX, -incrY );
+ myIncrement=10;
+}
+//----------------------------------------------------------------------------
+SVTK_ControllerIncrement::~SVTK_ControllerIncrement()
+{
+}
+//----------------------------------------------------------------------------
+void SVTK_ControllerIncrement::SetStartValue(const int theValue)
+{
+ myIncrement=theValue;
+}
+//----------------------------------------------------------------------------
+int SVTK_ControllerIncrement::Current()const
+{
+ return myIncrement;
+}
+//----------------------------------------------------------------------------
+int SVTK_ControllerIncrement::Increase()
+{
+ ++myIncrement;
+ return myIncrement;
+}
+//----------------------------------------------------------------------------
+int SVTK_ControllerIncrement::Decrease()
+{
+ if (myIncrement>1){
+ --myIncrement;
+ }
+ return myIncrement;
+}
+
+vtkStandardNewMacro(SVTK_ControllerOnKeyDown);
+//----------------------------------------------------------------------------
+SVTK_ControllerOnKeyDown::SVTK_ControllerOnKeyDown()
+{
+}
+//----------------------------------------------------------------------------
+SVTK_ControllerOnKeyDown::~SVTK_ControllerOnKeyDown()
+{
+}
+//----------------------------------------------------------------------------
+bool SVTK_ControllerOnKeyDown::OnKeyDown(vtkInteractorStyle* theIS)
+{
+ return true;
}
#include "SVTK.h"
-#include <vtkInteractorStyle.h>
+#include "SVTK_SelectionEvent.h"
-class vtkCell;
-class vtkRenderWindowInteractor;
+#include <boost/shared_ptr.hpp>
+
+#include <vtkInteractorStyle.h>
+#include <vtkSmartPointer.h>
-#include <qobject.h>
#include <qcursor.h>
+#include <qevent.h>
#include <map>
-#include "VTKViewer_Filter.h"
+#include <vtkObject.h>
+//
+//-------------------------------------------
+//! Control the value of increment in SALOME way.
+/*!
+ This class controls of value of increment,
+ for pan/rotate/zoom operations in SALOME way
+*/
+class SVTK_ControllerIncrement : public vtkObject{
+ public:
+ vtkTypeMacro(SVTK_ControllerIncrement, vtkObject);
+ static SVTK_ControllerIncrement* New();
+
+ //! Set start value of increment
+ void SetStartValue(const int );
+
+ //! Get current value of increment
+ int Current()const;
-class VTKViewer_Trihedron;
+ //! Increace the increment value by add 1
+ virtual int Increase();
+
+ //! Decreace the increment value by subtract 1
+ virtual int Decrease();
+ protected:
+ SVTK_ControllerIncrement();
+ virtual ~SVTK_ControllerIncrement();
+ protected:
+ int myIncrement;
+ private:
+ SVTK_ControllerIncrement(const SVTK_ControllerIncrement&);//Not implemented
+ void operator=(const SVTK_ControllerIncrement&); //Not implemented
+};
+//
+//-------------------------------------------
+//! Control the behaviour of KeyDown event in SALOME way.
+/*!
+ This class controls the behaviour of KeyDown event
+ in SALOME way
+*/
+class SVTK_ControllerOnKeyDown : public vtkObject{
+ public:
+ vtkTypeMacro(SVTK_ControllerOnKeyDown, vtkObject);
+ static SVTK_ControllerOnKeyDown* New();
+
+ //! Provides the action on event
+ virtual bool OnKeyDown(vtkInteractorStyle* );
+
+ protected:
+ SVTK_ControllerOnKeyDown();
+ virtual ~SVTK_ControllerOnKeyDown();
+
+ private:
+ SVTK_ControllerOnKeyDown(const SVTK_ControllerOnKeyDown&);//Not implemented
+ void operator=(const SVTK_ControllerOnKeyDown&); //Not implemented
+};
+//-------------------------------------------
+
+class vtkCell;
+class vtkPicker;
class SALOME_Actor;
-class SVTK_Actor;
-class SVTK_Viewer;
+
class SVTK_Selector;
-class SVTK_ViewWindow;
-class SVTK_RenderWindowInteractor;
+class SVTK_GenericRenderWindowInteractor;
#define VTK_INTERACTOR_STYLE_CAMERA_NONE 0
#define VTK_INTERACTOR_STYLE_CAMERA_ROTATE 1
#define VTK_INTERACTOR_STYLE_CAMERA_SELECT 6
#define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
-class SVTK_EXPORT SVTK_InteractorStyle : public QObject,
- public vtkInteractorStyle
+//! Introduce SALOME way of user interaction
+/*!
+ This class defines SALOME way of user interaction for VTK viewer, as well,
+ as introduce a new selection mechanism
+*/
+class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle
{
- Q_OBJECT;
-
public:
- // Description:
- // This class must be supplied with a vtkRenderWindowInteractor wrapper or
- // parent. This class should not normally be instantiated by application
- // programmers.
static SVTK_InteractorStyle *New();
vtkTypeMacro(SVTK_InteractorStyle, vtkInteractorStyle);
- virtual void SetInteractor(vtkRenderWindowInteractor *theInteractor);
- void setViewWindow(SVTK_ViewWindow* theViewWindow);
- void setGUIWindow(QWidget* theWindow);
+ typedef boost::shared_ptr<SVTK_SelectionEvent> PSelectionEvent;
- virtual int GetState();
+
- //merge with V2_2_0_VISU_improvements:void setTriedron(VTKViewer_Trihedron* theTrihedron);
- void setPreselectionProp(const double& theRed = 0,
- const double& theGreen = 1,
- const double& theBlue = 1,
- const int& theWidth = 5);
+ //! Generate special #SVTK_SelectionEvent
+ virtual
+ SVTK_SelectionEvent*
+ GetSelectionEvent();
- // Generic event bindings must be overridden in subclasses
- void OnMouseMove (int ctrl, int shift, int x, int y);
- void OnLeftButtonDown(int ctrl, int shift, int x, int y);
- void OnLeftButtonUp (int ctrl, int shift, int x, int y);
- void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
- void OnMiddleButtonUp (int ctrl, int shift, int x, int y);
- void OnRightButtonDown(int ctrl, int shift, int x, int y);
- void OnRightButtonUp (int ctrl, int shift, int x, int y);
-
- void OnSelectionModeChanged();
-
- //merge with V2_2_0_VISU_improvements:void ViewFitAll();
-
- void SetFilter( const Handle(VTKViewer_Filter)& );
- Handle(VTKViewer_Filter) GetFilter( const int );
- bool IsFilterPresent( const int );
- void RemoveFilter( const int );
- bool IsValid( SALOME_Actor* theActor,
- const int theId,
- const bool theIsNode = false );
+ //! Generate special #SVTK_SelectionEvent with flipped Y coordinate
+ virtual
+ SVTK_SelectionEvent*
+ GetSelectionEventFlipY();
+
+ //! Redefined in order to add an observer (callback) for custorm event (space mouse event)
+ virtual
+ void
+ SetInteractor( vtkRenderWindowInteractor* );
+
+ //! To invoke #vtkRenderWindowInteractor::CreateTimer
+ virtual
+ void
+ Render();
+
+ //! To implement cached rendering
+ virtual
+ void
+ OnTimer();
+
+ //! To reset reset view
+ virtual
+ void
+ OnConfigure();
+
+ //! To handle mouse move event
+ virtual
+ void
+ OnMouseMove();
+
+ //! To handle left mouse button down event (reimplemented from #vtkInteractorStyle)
+ virtual
+ void
+ OnLeftButtonDown();
+
+ //! To handle left mouse button up event (reimplemented from #vtkInteractorStyle)
+ virtual
+ void
+ OnLeftButtonUp();
+
+ //! To handle middle mouse button down event (reimplemented from #vtkInteractorStyle)
+ virtual
+ void
+ OnMiddleButtonDown();
+
+ //! To handle middle mouse button up event (reimplemented from #vtkInteractorStyle)
+ virtual
+ void
+ OnMiddleButtonUp();
+
+ //! To handle right mouse button down event (reimplemented from #vtkInteractorStyle)
+ virtual
+ void
+ OnRightButtonDown();
+
+ //! To handle right mouse button up event (reimplemented from #vtkInteractorStyle)
+ virtual
+ void
+ OnRightButtonUp();
+
+ //! To handle keyboard event (reimplemented from #vtkInteractorStyle)
+ virtual
+ void
+ OnChar();
+
+ //! To set current increment controller
+ void SetControllerIncrement(SVTK_ControllerIncrement*);
+
+ //! To get current increment controller
+ SVTK_ControllerIncrement* ControllerIncrement();
+
+ //! Redefine vtkInteractorStyle::OnKeyDown
+ virtual void OnKeyDown();
+
+ //! Provide instructions for Picking
+ void ActionPicking();
+
+ //! To set current OnKeyDown controller
+ void SetControllerOnKeyDown(SVTK_ControllerOnKeyDown*);
+
+ //! To get current OnKeyDown controller
+ SVTK_ControllerOnKeyDown* ControllerOnKeyDown();
- void IncrementalPan ( const int incrX, const int incrY );
- void IncrementalZoom ( const int incr );
- void IncrementalRotate( const int incrX, const int incrY );
+ SVTK_Selector* GetSelector();
protected:
SVTK_InteractorStyle();
~SVTK_InteractorStyle();
- SVTK_InteractorStyle(const SVTK_InteractorStyle&) {};
- void operator=(const SVTK_InteractorStyle&) {};
- SVTK_Selector* GetSelector();
+ QWidget*
+ GetRenderWidget();
+
+ // Generic event bindings must be overridden in subclasses
+ virtual void OnMouseMove (int ctrl, int shift, int x, int y);
+ virtual void OnLeftButtonDown(int ctrl, int shift, int x, int y);
+ virtual void OnLeftButtonUp (int ctrl, int shift, int x, int y);
+ virtual void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
+ virtual void OnMiddleButtonUp (int ctrl, int shift, int x, int y);
+ virtual void OnRightButtonDown(int ctrl, int shift, int x, int y);
+ virtual void OnRightButtonUp (int ctrl, int shift, int x, int y);
void RotateXY(int dx, int dy);
void PanXY(int x, int y, int oldX, int oldY);
void fitRect(const int left, const int top, const int right, const int bottom);
void Place(const int theX, const int theY);
void TranslateView(int toX, int toY, int fromX, int fromY);
- bool IsInRect(vtkActor* theActor,
- const int left, const int top,
- const int right, const int bottom);
- bool IsInRect(vtkCell* theCell,
- const int left, const int top,
- const int right, const int bottom);
- bool IsInRect(float* thePoint,
- const int left, const int top,
- const int right, const int bottom);
+
+ void
+ IncrementalPan( const int incrX, const int incrY );
+
+ void
+ IncrementalZoom( const int incr );
+
+ void
+ IncrementalRotate( const int incrX, const int incrY );
+
+ // Main process event method (reimplemented from #vtkInteractorStyle)
+ static
+ void
+ ProcessEvents(vtkObject* object,
+ unsigned long event,
+ void* clientData,
+ void* callData );
float MotionFactor;
float RadianToDegree; // constant: for conv from deg to rad
double myScale;
- SALOME_Actor* myPreViewActor;
-
- SVTK_Actor* myPreSelectionActor;
- SALOME_Actor* mySelectedActor;
- int myElemId;
- int myEdgeId;
- int myNodeId;
-
- public:
- bool eventFilter(QObject* object, QEvent* event);
+ protected:
void startZoom();
void startPan();
void startGlobalPan();
void startRotate();
void startFitArea();
void startSpin();
- bool needsRedrawing();
protected:
void loadCursors();
void startOperation(int operation);
void onStartOperation();
- void onFinishOperation();
+ virtual void onFinishOperation();
void onOperation(QPoint mousePos);
void onCursorMove(QPoint mousePos);
void setCursor(const int operation);
+ void onSpaceMouseMove( double* data );
+ virtual void onSpaceMouseButton( int button );
+
+ void DominantCombinedSwitch();
+
protected:
QCursor myDefCursor;
QCursor myPanCursor;
bool myCursorState;
bool myShiftState;
int ForcedState;
+
+ vtkSmartPointer<SALOME_Actor> myLastHighlitedActor;
+ vtkSmartPointer<SALOME_Actor> myLastPreHighlitedActor;
+
+ //! "Increment" controller for pan/rotate/zoom operations
+ vtkSmartPointer<SVTK_ControllerIncrement> myControllerIncrement;
+
+ //!controls the behaviour of KeyDown event in SALOME way
+ vtkSmartPointer<SVTK_ControllerOnKeyDown> myControllerOnKeyDown;
+
+ // SpaceMouse short cuts
+ int mySMDecreaseSpeedBtn;
+ int mySMIncreaseSpeedBtn;
+ int mySMDominantCombinedSwitchBtn;
- SVTK_RenderWindowInteractor* myInteractor;
- SVTK_ViewWindow* myViewWindow;
- //merge with V2_2_0_VISU_improvements:VTKViewer_Trihedron* myTrihedron;
- QWidget* myGUIWindow;
-
- std::map<int, Handle(VTKViewer_Filter)> myFilters;
+ vtkSmartPointer<SVTK_GenericRenderWindowInteractor> myInteractor;
+
+ PSelectionEvent mySelectionEvent;
- // members from old version
- double DeltaElevation;
- double DeltaAzimuth;
- int LastPos[2];
+ vtkSmartPointer<vtkPicker> myPicker;
};
#endif
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+
+#include "SALOME_Actor.h"
+
+#include <vtkGenericRenderWindowInteractor.h>
+#include <vtkRenderer.h>
+
+#include "QtxAction.h"
+
+#include "SUIT_ToolButton.h"
+#include "SUIT_MessageBox.h"
+
+#include "SUIT_Tools.h"
+#include "SUIT_ResourceMgr.h"
+#include "SVTK_NonIsometricDlg.h"
+#include "SVTK_CubeAxesDlg.h"
+
+#include "SVTK_MainWindow.h"
+#include "SVTK_Event.h"
+#include "SVTK_Renderer.h"
+#include "SVTK_RenderWindowInteractor.h"
+
+#include "SVTK_Selector.h"
+
+#include <qimage.h>
+
+#include "utilities.h"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
+SVTK_MainWindow
+::SVTK_MainWindow(QWidget* theParent,
+ const char* theName,
+ SUIT_ResourceMgr* theResourceMgr) :
+ QMainWindow(theParent,theName,0)
+{
+ if(MYDEBUG) INFOS("SVTK_MainWindow() - "<<this);
+
+ myToolBar = new QToolBar(this);
+ myToolBar->setCloseMode(QDockWindow::Undocked);
+ myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
+
+ createActions(theResourceMgr);
+ createToolBar();
+}
+
+void
+SVTK_MainWindow
+::Initialize(SVTK_RenderWindowInteractor* theInteractor)
+{
+ myInteractor = theInteractor;
+ SetEventDispatcher(myInteractor->GetDevice());
+
+ setCentralWidget(myInteractor);
+ myInteractor->setBackgroundMode(Qt::NoBackground);
+
+ myInteractor->setFocusPolicy(StrongFocus);
+ myInteractor->setFocus();
+ setFocusProxy(myInteractor);
+}
+
+
+//----------------------------------------------------------------------------
+SVTK_MainWindow
+::~SVTK_MainWindow()
+{
+ if(MYDEBUG) INFOS("~SVTK_MainWindow() - "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+SVTK_RenderWindowInteractor*
+SVTK_MainWindow
+::GetInteractor()
+{
+ return myInteractor;
+}
+
+vtkRenderWindowInteractor*
+SVTK_MainWindow
+::getInteractor()
+{
+ return GetInteractor()->GetDevice();
+}
+
+vtkRenderWindow*
+SVTK_MainWindow
+::getRenderWindow()
+{
+ return GetInteractor()->getRenderWindow();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::Repaint(bool theUpdateTrihedron)
+{
+ if(theUpdateTrihedron)
+ GetRenderer()->OnAdjustTrihedron();
+
+ GetInteractor()->update();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::InvokeEvent(unsigned long theEvent, void* theCallData)
+{
+ GetInteractor()->InvokeEvent(theEvent,theCallData);
+}
+
+//----------------------------------------------------------------------------
+vtkInteractorStyle*
+SVTK_MainWindow
+::GetInteractorStyle()
+{
+ return GetInteractor()->GetInteractorStyle();
+}
+
+void
+SVTK_MainWindow
+::PushInteractorStyle(vtkInteractorStyle* theStyle)
+{
+ GetInteractor()->PushInteractorStyle(theStyle);
+}
+
+void
+SVTK_MainWindow
+::PopInteractorStyle()
+{
+ GetInteractor()->PopInteractorStyle();
+}
+
+//----------------------------------------------------------------------------
+SVTK_Selector*
+SVTK_MainWindow
+::GetSelector()
+{
+ return GetInteractor()->GetSelector();
+}
+
+Selection_Mode
+SVTK_MainWindow
+::SelectionMode()
+{
+ return GetSelector()->SelectionMode();
+}
+
+void
+SVTK_MainWindow
+::SetSelectionMode(Selection_Mode theMode)
+{
+ GetSelector()->SetSelectionMode(theMode);
+}
+
+
+//----------------------------------------------------------------------------
+SVTK_Renderer*
+SVTK_MainWindow
+::GetRenderer()
+{
+ return GetInteractor()->GetRenderer();
+}
+
+vtkRenderer*
+SVTK_MainWindow
+::getRenderer()
+{
+ return GetInteractor()->getRenderer();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::SetBackgroundColor(const QColor& theColor)
+{
+ getRenderer()->SetBackground(theColor.red()/255.0,
+ theColor.green()/255.0,
+ theColor.blue()/255.0);
+}
+
+QColor
+SVTK_MainWindow
+::BackgroundColor()
+{
+ float aBackgroundColor[3];
+ getRenderer()->GetBackground(aBackgroundColor);
+ return QColor(int(aBackgroundColor[0]*255),
+ int(aBackgroundColor[1]*255),
+ int(aBackgroundColor[2]*255));
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::GetScale( double theScale[3] )
+{
+ GetRenderer()->GetScale( theScale );
+}
+
+void
+SVTK_MainWindow
+::SetScale( double theScale[3] )
+{
+ GetRenderer()->SetScale( theScale );
+ Repaint();
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::AddActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate)
+{
+ GetRenderer()->AddActor(theActor);
+ if(theIsUpdate)
+ Repaint();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::RemoveActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate)
+{
+ GetRenderer()->RemoveActor(theActor);
+ if(theIsUpdate)
+ Repaint();
+}
+
+
+//----------------------------------------------------------------------------
+int
+SVTK_MainWindow
+::GetTrihedronSize()
+{
+ return GetRenderer()->GetTrihedronSize();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::SetTrihedronSize( const int theSize )
+{
+ GetRenderer()->SetTrihedronSize(theSize);
+ Repaint();
+}
+
+
+//----------------------------------------------------------------------------
+/*! If parameter theIsForcedUpdate is true, recalculate parameters for
+ * trihedron and cube axes, even if trihedron and cube axes is invisible.
+ */
+void
+SVTK_MainWindow
+::AdjustActors()
+{
+ GetRenderer()->AdjustActors();
+ Repaint();
+}
+
+//----------------------------------------------------------------------------
+bool
+SVTK_MainWindow
+::IsTrihedronDisplayed()
+{
+ return GetRenderer()->IsTrihedronDisplayed();
+}
+
+//----------------------------------------------------------------------------
+bool
+SVTK_MainWindow
+::IsCubeAxesDisplayed()
+{
+ return GetRenderer()->IsCubeAxesDisplayed();
+}
+
+//----------------------------------------------------------------------------
+VTKViewer_Trihedron*
+SVTK_MainWindow
+::GetTrihedron()
+{
+ return GetRenderer()->GetTrihedron();
+}
+
+//----------------------------------------------------------------------------
+SVTK_CubeAxesActor2D*
+SVTK_MainWindow
+::GetCubeAxes()
+{
+ return GetRenderer()->GetCubeAxes();
+}
+
+
+//----------------------------------------------------------------------------
+QToolBar*
+SVTK_MainWindow
+::getToolBar()
+{
+ return myToolBar;
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::SetEventDispatcher(vtkObject* theDispatcher)
+{
+ myEventDispatcher = theDispatcher;
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::createActions(SUIT_ResourceMgr* theResourceMgr)
+{
+ if(!myActionsMap.isEmpty())
+ return;
+
+ QtxAction* anAction;
+
+ // Dump view
+ anAction = new QtxAction(tr("MNU_DUMP_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
+ tr( "MNU_DUMP_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onDumpView()));
+ myActionsMap[ DumpId ] = anAction;
+
+ // FitAll
+ anAction = new QtxAction(tr("MNU_FITALL"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
+ tr( "MNU_FITALL" ), 0, this);
+ anAction->setStatusTip(tr("DSC_FITALL"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onFitAll()));
+ myActionsMap[ FitAllId ] = anAction;
+
+ // FitRect
+ anAction = new QtxAction(tr("MNU_FITRECT"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
+ tr( "MNU_FITRECT" ), 0, this);
+ anAction->setStatusTip(tr("DSC_FITRECT"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
+ myActionsMap[ FitRectId ] = anAction;
+
+ // Zoom
+ anAction = new QtxAction(tr("MNU_ZOOM_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
+ tr( "MNU_ZOOM_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(activateZoom()));
+ myActionsMap[ ZoomId ] = anAction;
+
+ // Panning
+ anAction = new QtxAction(tr("MNU_PAN_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
+ tr( "MNU_PAN_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_PAN_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(activatePanning()));
+ myActionsMap[ PanId ] = anAction;
+
+ // Global Panning
+ anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
+ tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
+ myActionsMap[ GlobalPanId ] = anAction;
+
+ // Rotation
+ anAction = new QtxAction(tr("MNU_ROTATE_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
+ tr( "MNU_ROTATE_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(activateRotation()));
+ myActionsMap[ RotationId ] = anAction;
+
+ // Projections
+ anAction = new QtxAction(tr("MNU_FRONT_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
+ tr( "MNU_FRONT_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onFrontView()));
+ myActionsMap[ FrontId ] = anAction;
+
+ anAction = new QtxAction(tr("MNU_BACK_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
+ tr( "MNU_BACK_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_BACK_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onBackView()));
+ myActionsMap[ BackId ] = anAction;
+
+ anAction = new QtxAction(tr("MNU_TOP_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
+ tr( "MNU_TOP_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_TOP_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onTopView()));
+ myActionsMap[ TopId ] = anAction;
+
+ anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
+ tr( "MNU_BOTTOM_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onBottomView()));
+ myActionsMap[ BottomId ] = anAction;
+
+ anAction = new QtxAction(tr("MNU_LEFT_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
+ tr( "MNU_LEFT_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onLeftView()));
+ myActionsMap[ LeftId ] = anAction;
+
+ anAction = new QtxAction(tr("MNU_RIGHT_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
+ tr( "MNU_RIGHT_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onRightView()));
+ myActionsMap[ RightId ] = anAction;
+
+ // Reset
+ anAction = new QtxAction(tr("MNU_RESET_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
+ tr( "MNU_RESET_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_RESET_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onResetView()));
+ myActionsMap[ ResetId ] = anAction;
+
+ // onViewTrihedron: Shows - Hides Trihedron
+ anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
+ tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
+ anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
+ myActionsMap[ ViewTrihedronId ] = anAction;
+
+ // onNonIsometric: Manage non-isometric params
+ anAction = new QtxAction(tr("MNU_SVTK_SCALING"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SCALING" ) ),
+ tr( "MNU_SVTK_SCALING" ), 0, this);
+ anAction->setStatusTip(tr("DSC_SVTK_SCALING"));
+ anAction->setToggleAction(true);
+ connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool)));
+ myActionsMap[ NonIsometric ] = anAction;
+
+ myNonIsometricDlg = new SVTK_NonIsometricDlg(this,"SVTK_NonIsometricDlg",anAction);
+
+ // onGraduatedAxes: Manage graduated axes params
+ anAction = new QtxAction(tr("MNU_SVTK_GRADUATED_AXES"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_GRADUATED_AXES" ) ),
+ tr( "MNU_SVTK_GRADUATED_AXES" ), 0, this);
+ anAction->setStatusTip(tr("DSC_SVTK_GRADUATED_AXES"));
+ anAction->setToggleAction(true);
+ connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool)));
+ myActionsMap[ GraduatedAxes ] = anAction;
+
+ myCubeAxesDlg = new SVTK_CubeAxesDlg(this,"SVTK_CubeAxesDlg",anAction);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::createToolBar()
+{
+ myActionsMap[DumpId]->addTo(myToolBar);
+ myActionsMap[ViewTrihedronId]->addTo(myToolBar);
+
+ SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar);
+ aScaleBtn->AddAction(myActionsMap[FitAllId]);
+ aScaleBtn->AddAction(myActionsMap[FitRectId]);
+ aScaleBtn->AddAction(myActionsMap[ZoomId]);
+
+ SUIT_ToolButton* aPanningBtn = new SUIT_ToolButton(myToolBar);
+ aPanningBtn->AddAction(myActionsMap[PanId]);
+ aPanningBtn->AddAction(myActionsMap[GlobalPanId]);
+
+ myActionsMap[RotationId]->addTo(myToolBar);
+
+ SUIT_ToolButton* aViewsBtn = new SUIT_ToolButton(myToolBar);
+ aViewsBtn->AddAction(myActionsMap[FrontId]);
+ aViewsBtn->AddAction(myActionsMap[BackId]);
+ aViewsBtn->AddAction(myActionsMap[TopId]);
+ aViewsBtn->AddAction(myActionsMap[BottomId]);
+ aViewsBtn->AddAction(myActionsMap[LeftId]);
+ aViewsBtn->AddAction(myActionsMap[RightId]);
+
+ myActionsMap[ResetId]->addTo(myToolBar);
+
+ myActionsMap[NonIsometric]->addTo(myToolBar);
+ myActionsMap[GraduatedAxes]->addTo(myToolBar);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::activateZoom()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::activatePanning()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::activateRotation()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::activateGlobalPanning()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::activateWindowFit()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onFrontView()
+{
+ GetRenderer()->OnFrontView();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onBackView()
+{
+ GetRenderer()->OnBackView();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onTopView()
+{
+ GetRenderer()->OnTopView();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onBottomView()
+{
+ GetRenderer()->OnBottomView();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onLeftView()
+{
+ GetRenderer()->OnLeftView();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onRightView()
+{
+ GetRenderer()->OnRightView();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onResetView()
+{
+ GetRenderer()->OnResetView();
+ Repaint();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onFitAll()
+{
+ GetRenderer()->OnFitAll();
+ Repaint();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onViewTrihedron()
+{
+ GetRenderer()->OnViewTrihedron();
+ Repaint();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onViewCubeAxes()
+{
+ GetRenderer()->OnViewCubeAxes();
+ Repaint();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onNonIsometric(bool theIsActivate)
+{
+ if(theIsActivate){
+ myNonIsometricDlg->Update();
+ myNonIsometricDlg->show();
+ }else
+ myNonIsometricDlg->hide();
+}
+
+void
+SVTK_MainWindow
+::onGraduatedAxes(bool theIsActivate)
+{
+ if(theIsActivate){
+ myCubeAxesDlg->Update();
+ myCubeAxesDlg->show();
+ }else
+ myCubeAxesDlg->hide();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onAdjustTrihedron()
+{
+ GetRenderer()->OnAdjustTrihedron();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onAdjustCubeAxes()
+{
+ GetRenderer()->OnAdjustCubeAxes();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_MainWindow
+::onDumpView()
+{}
+
+//----------------------------------------------------------------------------
+QImage
+SVTK_MainWindow
+::dumpView()
+{
+ QPixmap px = QPixmap::grabWindow( GetInteractor()->winId() );
+ return px.convertToImage();
+}
--- /dev/null
+#ifndef SVTK_MAINWINDOW_H
+#define SVTK_MAINWINDOW_H
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+#include "SVTK.h"
+#include "SVTK_Selection.h"
+
+#include <vtkSmartPointer.h>
+
+#include <qmainwindow.h>
+
+class QtxAction;
+
+class vtkObject;
+class vtkRenderer;
+class vtkRenderWindow;
+class vtkInteractorStyle;
+class vtkRenderWindowInteractor;
+
+class SUIT_ResourceMgr;
+
+class SVTK_RenderWindowInteractor;
+class SVTK_NonIsometricDlg;
+class SVTK_CubeAxesActor2D;
+class SVTK_CubeAxesDlg;
+
+class VTKViewer_Trihedron;
+class VTKViewer_Transform;
+class VTKViewer_Actor;
+
+class SVTK_Renderer;
+class SVTK_Selector;
+
+
+//----------------------------------------------------------------------------
+//! The class is a container for #SVTK_RenderWindowInteractor.
+/*!
+ The class contains #SVTK_RenderWindowInteractor instance and
+ adds predefined viewer actions and toolbar for user interaction.
+*/
+class SVTK_EXPORT SVTK_MainWindow: public QMainWindow
+{
+ Q_OBJECT;
+
+public:
+ SVTK_MainWindow(QWidget* theParent,
+ const char* theName,
+ SUIT_ResourceMgr* theResourceMgr);
+
+ //! To initialize the class
+ virtual
+ void
+ Initialize(SVTK_RenderWindowInteractor* theInteractor);
+
+ virtual
+ ~SVTK_MainWindow();
+
+ //----------------------------------------------------------------------------
+ //! Get used #SVTK_RenderWindowInteractor
+ SVTK_RenderWindowInteractor*
+ GetInteractor();
+
+ //! Get used #vtkRenderWindowInteractor (obsolete)
+ vtkRenderWindowInteractor*
+ getInteractor();
+
+ //! Get used #vtkRenderWindow (obsolete)
+ vtkRenderWindow*
+ getRenderWindow();
+
+ //! To repaint the view
+ void
+ Repaint(bool theUpdateTrihedron = true);
+
+ //! To invoke a VTK event on #SVTK_RenderWindowInteractor instance
+ void
+ InvokeEvent(unsigned long theEvent, void* theCallData);
+
+ //----------------------------------------------------------------------------
+ //! Redirect the request to #SVTK_RenderWindowInteractor::GetInteractorStyle
+ vtkInteractorStyle*
+ GetInteractorStyle();
+
+ //! Redirect the request to #SVTK_RenderWindowInteractor::PushInteractorStyle
+ void
+ PushInteractorStyle(vtkInteractorStyle* theStyle);
+
+ //! Redirect the request to #SVTK_RenderWindowInteractor::PopInteractorStyle
+ void
+ PopInteractorStyle();
+
+ //----------------------------------------------------------------------------
+ //! Redirect the request to #SVTK_RenderWindowInteractor::GetSelector
+ SVTK_Selector*
+ GetSelector();
+
+ //! Redirect the request to #SVTK_RenderWindowInteractor::SelectionMode
+ Selection_Mode
+ SelectionMode();
+
+ //! Redirect the request to #SVTK_RenderWindowInteractor::SetSelectionMode
+ void
+ SetSelectionMode(Selection_Mode theMode);
+
+ //----------------------------------------------------------------------------
+ //! Redirect the request to #SVTK_RenderWindowInteractor::GetRenderer
+ SVTK_Renderer*
+ GetRenderer();
+
+ //! Redirect the request to #SVTK_RenderWindowInteractor::getRenderer
+ vtkRenderer*
+ getRenderer();
+
+ //! Set background color to the view
+ void
+ SetBackgroundColor(const QColor& theColor);
+
+ //! Get background color of the view
+ QColor
+ BackgroundColor();
+
+ //! Redirect the request to #SVTK_Renderer::SetScale
+ void
+ SetScale(double theScale[3]);
+
+ //! Redirect the request to #SVTK_Renderer::GetScale
+ void
+ GetScale(double theScale[3]);
+
+ //! Redirect the request to #SVTK_Renderer::AddActor
+ virtual
+ void
+ AddActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
+
+ //! Redirect the request to #SVTK_Renderer::RemoveActor
+ virtual
+ void
+ RemoveActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
+
+ //! Redirect the request to #SVTK_Renderer::GetTrihedronSize
+ int
+ GetTrihedronSize();
+
+ //! Redirect the request to #SVTK_Renderer::SetTrihedronSize
+ void
+ SetTrihedronSize(const int theSize);
+
+ //! Redirect the request to #SVTK_Renderer::AdjustActors
+ void
+ AdjustActors();
+
+ //! Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
+ bool
+ IsTrihedronDisplayed();
+
+ //! Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
+ bool
+ IsCubeAxesDisplayed();
+
+ //! Redirect the request to #SVTK_Renderer::GetTrihedron
+ VTKViewer_Trihedron*
+ GetTrihedron();
+
+ //! Redirect the request to #SVTK_Renderer::GetCubeAxes
+ SVTK_CubeAxesActor2D*
+ GetCubeAxes();
+
+ //----------------------------------------------------------------------------
+ QToolBar* getToolBar();
+
+ public slots:
+ void activateZoom();
+ void activateWindowFit();
+ void activateRotation();
+ void activatePanning();
+ void activateGlobalPanning();
+
+ void onFrontView();
+ void onBackView();
+ void onTopView();
+ void onBottomView();
+ void onRightView();
+ void onLeftView();
+
+ void onResetView();
+ void onFitAll();
+
+ void onViewTrihedron();
+ void onViewCubeAxes();
+
+ void onNonIsometric(bool theIsActivate);
+ void onGraduatedAxes(bool theIsActivate);
+
+ void onAdjustTrihedron();
+ void onAdjustCubeAxes();
+
+ void onDumpView();
+
+ public:
+ QImage dumpView();
+
+ protected:
+ void
+ createActions(SUIT_ResourceMgr* theResourceMgr);
+
+ void
+ createToolBar();
+
+ void
+ SetEventDispatcher(vtkObject* theDispatcher);
+
+ enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
+ FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId,
+ ViewTrihedronId, NonIsometric, GraduatedAxes};
+ typedef QMap<int, QtxAction*> TActionsMap;
+
+ SVTK_NonIsometricDlg* myNonIsometricDlg;
+ SVTK_CubeAxesDlg* myCubeAxesDlg;
+
+ vtkSmartPointer<vtkObject> myEventDispatcher;
+ TActionsMap myActionsMap;
+ QToolBar* myToolBar;
+
+ SVTK_RenderWindowInteractor* myInteractor;
+};
+
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+
+#include "SVTK_NonIsometricDlg.h"
+#include "SVTK_MainWindow.h"
+#include "SVTK_Renderer.h"
+
+#include "QtxDblSpinBox.h"
+#include "QtxAction.h"
+
+#include "utilities.h"
+
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+
+using namespace std;
+
+/*!
+ Constructor
+*/
+SVTK_NonIsometricDlg
+::SVTK_NonIsometricDlg(SVTK_MainWindow* theParent,
+ const char* theName,
+ QtxAction* theAction):
+ QDialog(theParent,
+ theName,
+ false,
+ WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
+ m_MainWindow(theParent),
+ m_Action(theAction)
+{
+ setCaption(tr("DLG_TITLE"));
+ setSizeGripEnabled(TRUE);
+
+ // Create layout for this dialog
+ QGridLayout* layoutDlg = new QGridLayout (this);
+ layoutDlg->setSpacing(6);
+ layoutDlg->setMargin(11);
+
+ // Create croup box with grid layout
+ QGroupBox* GroupBox = new QGroupBox(this, "GroupBox");
+ QGridLayout* glGroupBox = new QGridLayout(GroupBox);
+ glGroupBox->setMargin(11);
+ glGroupBox->setSpacing(6);
+
+ // "X" scaling
+ QLabel* TextLabelX = new QLabel (tr("LBL_X"), GroupBox, "TextLabelX");
+ m_sbXcoeff = new QtxDblSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, GroupBox);
+ m_sbXcoeff->setMinimumWidth(80);
+ m_sbXcoeff->setValue(1.0);
+
+ // "Y" scaling
+ QLabel* TextLabelY = new QLabel (tr("LBL_Y"), GroupBox, "TextLabelY");
+ m_sbYcoeff = new QtxDblSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, GroupBox);
+ m_sbYcoeff->setMinimumWidth(80);
+ m_sbYcoeff->setValue(1.0);
+
+ // "Z" scaling
+ QLabel* TextLabelZ = new QLabel (tr("LBL_Z"), GroupBox, "TextLabelZ");
+ m_sbZcoeff = new QtxDblSpinBox(-VTK_LARGE_FLOAT, VTK_LARGE_FLOAT, 0.1, GroupBox);
+ m_sbZcoeff->setMinimumWidth(80);
+ m_sbZcoeff->setValue(1.0);
+
+ // Create <Reset> button
+ m_bReset = new QPushButton(tr("&Reset"), GroupBox, "m_bReset");
+
+ // Layout widgets in the group box
+ glGroupBox->addWidget(TextLabelX, 0, 0);
+ glGroupBox->addWidget(m_sbXcoeff, 0, 1);
+ glGroupBox->addWidget(TextLabelY, 0, 2);
+ glGroupBox->addWidget(m_sbYcoeff, 0, 3);
+ glGroupBox->addWidget(TextLabelZ, 0, 4);
+ glGroupBox->addWidget(m_sbZcoeff, 0, 5);
+ glGroupBox->addWidget(m_bReset, 0, 6);
+
+ // OK, CANCEL, Apply button
+ QGroupBox* aWgt = new QGroupBox(this);
+ QHBoxLayout* aHBoxLayout = new QHBoxLayout(aWgt);
+ aHBoxLayout->setMargin(11);
+ aHBoxLayout->setSpacing(6);
+ // Create <OK> button
+ QPushButton* m_bOk = new QPushButton(tr("O&K"), aWgt, "m_bOk");
+ m_bOk->setDefault(TRUE);
+ m_bOk->setAutoDefault(TRUE);
+ // Create <Apply> button
+ QPushButton* m_bApply = new QPushButton(tr("&Apply"), aWgt, "m_bApply");
+ m_bApply->setAutoDefault(TRUE);
+ // Create <Cancel> button
+ QPushButton* m_bCancel = new QPushButton(tr("&Cancel"), aWgt, "m_bCancel");
+ m_bCancel->setAutoDefault(TRUE);
+
+ // Layout buttons
+ aHBoxLayout->addWidget(m_bOk);
+ aHBoxLayout->addWidget(m_bApply);
+ aHBoxLayout->addStretch();
+ aHBoxLayout->addWidget(m_bCancel);
+
+ // Layout top level widgets
+ layoutDlg->addWidget(GroupBox,0,0);
+ layoutDlg->addWidget(aWgt,1,0);
+
+ // signals and slots connections
+ connect(m_bCancel, SIGNAL(clicked()), this, SLOT(onClickClose()));
+ connect(m_bOk, SIGNAL(clicked()), this, SLOT(onClickOk()));
+ connect(m_bApply, SIGNAL(clicked()), this, SLOT(onClickApply()));
+ connect(m_bReset, SIGNAL(clicked()), this, SLOT(onClickReset()));
+
+ this->resize(100, this->sizeHint().height());
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+SVTK_NonIsometricDlg
+::~SVTK_NonIsometricDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+void
+SVTK_NonIsometricDlg
+::Update()
+{
+ // Get values from the VTK view
+ double aScaleFactor[3];
+ m_MainWindow->GetScale(aScaleFactor);
+ m_sbXcoeff->setValue(aScaleFactor[0]);
+ m_sbYcoeff->setValue(aScaleFactor[1]);
+ m_sbZcoeff->setValue(aScaleFactor[2]);
+}
+
+void
+SVTK_NonIsometricDlg
+::onClickOk()
+{
+ //apply changes
+ onClickApply();
+ //Close dialog
+ accept();
+}
+
+void
+SVTK_NonIsometricDlg
+::onClickApply()
+{
+ double aScale[3] = {m_sbXcoeff->value(), m_sbYcoeff->value(), m_sbZcoeff->value()};
+ m_MainWindow->SetScale(aScale);
+}
+
+void
+SVTK_NonIsometricDlg
+::onClickReset()
+{
+ m_bReset->setFocus();
+ m_sbXcoeff->setValue(1.0);
+ m_sbYcoeff->setValue(1.0);
+ m_sbZcoeff->setValue(1.0);
+}
+
+void
+SVTK_NonIsometricDlg
+::onClickClose()
+{
+ reject();
+
+ m_Action->setOn( false );
+}
+
+void
+SVTK_NonIsometricDlg
+::done( int r )
+{
+ m_Action->setOn( false );
+ QDialog::done( r );
+}
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+
+#ifndef SVTK_NONISOMETRICDLG_H
+#define SVTK_NONISOMETRICDLG_H
+
+#include <qdialog.h>
+
+class SVTK_MainWindow;
+
+class QtxDblSpinBox;
+class QtxAction;
+
+class QPushButton;
+
+
+class SVTK_NonIsometricDlg : public QDialog
+{
+ Q_OBJECT;
+
+public:
+ SVTK_NonIsometricDlg(SVTK_MainWindow* theParent,
+ const char* theName,
+ QtxAction* theAction);
+
+ ~SVTK_NonIsometricDlg();
+
+ void Update();
+
+protected:
+ SVTK_MainWindow *m_MainWindow;
+ QtxAction* m_Action;
+
+ QtxDblSpinBox* m_sbXcoeff;
+ QtxDblSpinBox* m_sbYcoeff;
+ QtxDblSpinBox* m_sbZcoeff;
+ QPushButton* m_bReset;
+
+protected slots:
+ void onClickApply();
+ void onClickReset();
+ void onClickOk();
+ void onClickClose();
+
+ virtual void done( int );
+};
+
+#endif // SVTK_NONISOMETRICDLG_H
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
-#include "SVTK_RenderWindow.h"
-
-#include <qcolordialog.h>
-#include <qpopupmenu.h>
-
-#include <stdlib.h>
-#include <math.h>
-
-#include <vtkRenderWindowInteractor.h>
-#include <vtkRendererCollection.h>
-#include <vtkCamera.h>
-#ifndef WNT
-#include <vtkXOpenGLRenderWindow.h>
-//#include <GL/gl.h>
-//#include <GL/glu.h>
-//#include <qgl.h>
-#else
-#include <vtkRenderWindow.h>
-#endif
-
-#if QT_VERSION > 300
-#include <qcursor.h>
-#endif
-
-//==========================================================
-SVTK_RenderWindow
-::SVTK_RenderWindow(QWidget* parent, const char* name) :
- QWidget(parent, name,
- Qt::WStyle_NoBorder | Qt::WDestructiveClose |
- Qt::WResizeNoErase | Qt::WRepaintNoErase)
-{
- myRW = vtkRenderWindow::New();
-#ifndef WNT
- myRW->SetDisplayId((void*)x11Display());
-#endif
- myRW->SetWindowId((void*)winId());
- myRW->DoubleBufferOn();
- setMouseTracking(true);
-}
-
-//==========================================================
-SVTK_RenderWindow
-::~SVTK_RenderWindow()
-{
- myRW->Delete();
-}
-
-//==========================================================
-void
-SVTK_RenderWindow
-::paintEvent(QPaintEvent* theEvent)
-{
- myRW->Render();
-}
-
-//==========================================================
-void
-SVTK_RenderWindow
-::resizeEvent(QResizeEvent* theEvent)
-{
- int aWidth = myRW->GetSize()[0], aHeight = myRW->GetSize()[1];
- if(vtkRenderWindowInteractor* aRWI = myRW->GetInteractor())
- aRWI->UpdateSize(width(), height());
- if(aWidth != width() || aHeight != height()){
- vtkRendererCollection * aRenderers = myRW->GetRenderers();
- aRenderers->InitTraversal();
- double aCoeff = 1.0;
- if(vtkRenderer *aRenderer = aRenderers->GetNextItem()){
- vtkCamera *aCamera = aRenderer->GetActiveCamera();
- double aScale = aCamera->GetParallelScale();
- if((aWidth - width())*(aHeight - height()) > 0)
- aCoeff = sqrt(double(aWidth)/double(width())*double(height())/double(aHeight));
- else
- aCoeff = double(aWidth)/double(width());
- aCamera->SetParallelScale(aScale*aCoeff);
- }
- }
-}
-
-//==========================================================
-void
-SVTK_RenderWindow
-::mouseMoveEvent(QMouseEvent* event)
-{
- emit MouseMove(event) ;
-}
-
-//==========================================================
-void
-SVTK_RenderWindow
-::mousePressEvent(QMouseEvent* event)
-{
- emit MouseButtonPressed( event );
-}
-
-//==========================================================
-void
-SVTK_RenderWindow
-::mouseReleaseEvent( QMouseEvent *event )
-{
- emit MouseButtonReleased( event );
-}
-
-//==========================================================
-void
-SVTK_RenderWindow::mouseDoubleClickEvent( QMouseEvent* event )
-{
- emit MouseDoubleClicked( event );
-}
-
-//==========================================================
-void
-SVTK_RenderWindow
-::keyPressEvent (QKeyEvent* event)
-{
- emit KeyPressed(event) ;
-}
-
-//==========================================================
-void
-SVTK_RenderWindow
-::keyReleaseEvent (QKeyEvent * event)
-{
- emit KeyReleased(event) ;
-}
-
-//==========================================================
-void
-SVTK_RenderWindow
-::wheelEvent(QWheelEvent* event)
-{
- emit WheelMoved(event) ;
-}
-
-//==========================================================
-void
-SVTK_RenderWindow
-::onChangeBackgroundColor()
-{
- //float red, green, blue;
- float backint[3];
-
- vtkRendererCollection * theRenderers = myRW->GetRenderers();
- theRenderers->InitTraversal();
- vtkRenderer * theRenderer = theRenderers->GetNextItem();
- theRenderer->GetBackground(backint);
-
- QColor selColor = QColorDialog::getColor ( QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255)), NULL );
- if ( selColor.isValid() ) {
- theRenderer->SetBackground( selColor.red()/255., selColor.green()/255., selColor.blue()/255. );
- }
-}
-
-//==========================================================
-void
-SVTK_RenderWindow
-::contextMenuEvent ( QContextMenuEvent * e )
-{
- if ( e->reason() != QContextMenuEvent::Mouse )
- emit contextMenuRequested( e );
-}
+++ /dev/null
-// SALOME VTKViewer : build VTK viewer into Salome desktop
-//
-// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : VTKViewer_RenderWindow.h
-// Author : Nicolas REJNERI
-// Module : SALOME
-// $Header$
-
-#ifndef SVTK_RenderWindow_h
-#define SVTK_RenderWindow_h
-
-#include <qwidget.h>
-
-#include "SVTK.h"
-
-class vtkRenderWindow;
-
-class SVTK_EXPORT SVTK_RenderWindow : public QWidget
-{
- Q_OBJECT;
-
-public:
- SVTK_RenderWindow(QWidget *parent, const char *name);
- virtual ~SVTK_RenderWindow() ;
-
- vtkRenderWindow* getRenderWindow() { return myRW; }
-
- protected:
- virtual void mouseMoveEvent( QMouseEvent* );
- virtual void mousePressEvent( QMouseEvent* );
- virtual void mouseReleaseEvent( QMouseEvent* );
- virtual void mouseDoubleClickEvent( QMouseEvent* );
- virtual void wheelEvent( QWheelEvent* );
- virtual void keyPressEvent( QKeyEvent* );
- virtual void keyReleaseEvent( QKeyEvent* );
- virtual void paintEvent( QPaintEvent* );
- virtual void resizeEvent( QResizeEvent* );
- virtual void onChangeBackgroundColor();
- virtual void contextMenuEvent( QContextMenuEvent * e );
-
- signals:
- void MouseMove( QMouseEvent* );
- void MouseButtonPressed( QMouseEvent* );
- void MouseButtonReleased( QMouseEvent* );
- void MouseDoubleClicked( QMouseEvent* );
- void WheelMoved( QWheelEvent* );
- void LeftButtonPressed(const QMouseEvent *event) ;
- void LeftButtonReleased(const QMouseEvent *event) ;
- void MiddleButtonPressed(const QMouseEvent *event) ;
- void MiddleButtonReleased(const QMouseEvent *event) ;
- void RightButtonPressed(const QMouseEvent *event) ;
- void RightButtonReleased(const QMouseEvent *event) ;
- void ButtonPressed(const QMouseEvent *event);
- void ButtonReleased(const QMouseEvent *event);
- void KeyPressed( QKeyEvent* );
- void KeyReleased( QKeyEvent* );
- void contextMenuRequested( QContextMenuEvent *e );
-
- protected:
- vtkRenderWindow* myRW;
-};
-
-#endif
//
//
//
-// File : VTKViewer_RenderWindowInteractor.cxx
-// Author : Nicolas REJNERI
+// File :
+// Author :
// Module : SALOME
// $Header$
#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_GenericRenderWindowInteractor.h"
#include "SVTK_InteractorStyle.h"
-#include "SVTK_RenderWindow.h"
-#include "SVTK_ViewWindow.h"
-
-#include "VTKViewer_Algorithm.h"
+#include "SVTK_Renderer.h"
#include "SVTK_Functor.h"
-#include "SVTK_Actor.h"
+#include "SALOME_Actor.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
+#include "SVTK_SpaceMouse.h"
+#include "SVTK_Event.h"
+
+#include "VTKViewer_Algorithm.h"
// VTK Includes
#include <vtkObjectFactory.h>
-#include <vtkPicker.h>
-#include <vtkCellPicker.h>
-#include <vtkPointPicker.h>
#include <vtkRendererCollection.h>
#include <vtkRenderWindow.h>
+#include <vtkGenericRenderWindowInteractor.h>
+#include <vtkCallbackCommand.h>
+#include <vtkCommand.h>
+#include <vtkPicker.h>
+#include <vtkCamera.h>
// QT Includes
-#include <qkeycode.h>
+#include <qtimer.h>
+#include <qapplication.h>
+#include <qcolordialog.h>
+#include <qpaintdevice.h>
-#include <TColStd_IndexedMapOfInteger.hxx>
+#include "utilities.h"
using namespace std;
-SVTK_RenderWindowInteractor*
-SVTK_RenderWindowInteractor
-::New()
-{
- vtkObject *ret = vtkObjectFactory::CreateInstance("SVTK_RenderWindowInteractor") ;
- if( ret ) {
- return dynamic_cast<SVTK_RenderWindowInteractor *>(ret) ;
- }
- return new SVTK_RenderWindowInteractor;
-}
-
-SVTK_RenderWindowInteractor
-::SVTK_RenderWindowInteractor()
-{
- this->Enabled = 0 ;
- this->mTimer = new QTimer( this ) ;
- myDisplayMode = 0;
- myGUIWindow = 0;
-
- myBasicPicker = vtkPicker::New();
- myCellPicker = vtkCellPicker::New();
- myPointPicker = vtkPointPicker::New();
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+static int MYVTKDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+static int MYVTKDEBUG = 0;
+#endif
- myCellActor = SVTK_Actor::New();
- myCellActor->PickableOff();
- myCellActor->GetProperty()->SetColor(1,1,0);
- myCellActor->GetProperty()->SetLineWidth(5);
- myCellActor->GetProperty()->SetRepresentationToSurface();
+static bool GENERATE_SUIT_EVENTS = false;
- myEdgeActor = SVTK_Actor::New();
- myEdgeActor->PickableOff();
- myEdgeActor->GetProperty()->SetColor(1,0,0);
- myEdgeActor->GetProperty()->SetLineWidth(5);
- myEdgeActor->GetProperty()->SetRepresentationToWireframe();
- myPointActor = SVTK_Actor::New();
- myPointActor->PickableOff();
- myPointActor->GetProperty()->SetColor(1,1,0);
- myPointActor->GetProperty()->SetPointSize(5);
- myPointActor->GetProperty()->SetRepresentationToPoints();
+//----------------------------------------------------------------------------
+QVTK_RenderWindowInteractor
+::QVTK_RenderWindowInteractor(QWidget* theParent,
+ const char* theName):
+ QWidget(theParent,theName,Qt::WNoAutoErase),
+ myRenderWindow(vtkRenderWindow::New())
+{
+ if(MYDEBUG) INFOS("QVTK_RenderWindowInteractor() - "<<this);
+ setMouseTracking(true);
- connect(mTimer, SIGNAL(timeout()), this, SLOT(TimerFunc())) ;
+ myRenderWindow->Delete();
+ myRenderWindow->DoubleBufferOn();
}
-SVTK_RenderWindowInteractor
-::~SVTK_RenderWindowInteractor()
+void
+QVTK_RenderWindowInteractor
+::Initialize(vtkGenericRenderWindowInteractor* theDevice)
{
- delete mTimer ;
-
- myViewWindow->RemoveActor(myCellActor);
- myViewWindow->RemoveActor(myEdgeActor);
- myViewWindow->RemoveActor(myPointActor);
+ if(GetDevice())
+ myDevice->SetRenderWindow(NULL);
- myCellActor->Delete();
- myEdgeActor->Delete();
- myPointActor->Delete();
+ myDevice = theDevice;
- myBasicPicker->Delete();
- myCellPicker->Delete();
- myPointPicker->Delete();
+ if(theDevice)
+ theDevice->SetRenderWindow(getRenderWindow());
}
-//
-// We never allow the SVTK_RenderWindowInteractor to control
-// the event loop. The application always has the control.
-//
-void
-SVTK_RenderWindowInteractor
-::Initialize()
-{
- //
- // We cannot do much unless there is a render window
- // associated with this interactor.
- //
- if( ! RenderWindow ) {
- vtkErrorMacro(<< "SVTK_RenderWindowInteractor::Initialize(): No render window attached!") ;
- return ;
- }
-
- //
- // We cannot hand a render window which is not a VTKViewer_RenderWindow.
- // One way to force this is to use dynamic_cast and hope that
- // it works. If the dynamic_cast does not work, we flag an error
- // and get the hell out.
- //
- vtkRenderWindow *aRenderWindow = dynamic_cast<vtkRenderWindow *>(RenderWindow) ;
- if( !aRenderWindow ) {
- vtkErrorMacro(<< "SVTK_RenderWindowInteractor::Initialize() can only handle VTKViewer_RenderWindow.") ;
- return ;
- }
-
- //
- // If the render window has zero size, then set it to a default
- // value of 300x300.
- //
- int* aSize = aRenderWindow->GetSize();
- this->Size[0] = ((aSize[0] > 0) ? aSize[0] : 300);
- this->Size[1] = ((aSize[1] > 0) ? aSize[1] : 300);
-
- this->SetPicker(myBasicPicker);
-
- SetSelectionTolerance();
-
- //
- // Enable the interactor.
- //
- this->Enable() ;
+//----------------------------------------------------------------------------
+QVTK_RenderWindowInteractor
+::~QVTK_RenderWindowInteractor()
+{
+ if(MYDEBUG) INFOS("~QVTK_RenderWindowInteractor() - "<<this);
- //
- // Start the rendering of the window.
- //
- aRenderWindow->Start() ;
+ if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance())
+ if(aSpaceMouse->isSpaceMouseOn())
+ aSpaceMouse->close(x11Display());
+}
- //
- // The interactor has been initialized.
- //
- this->Initialized = 1 ;
- return ;
+//----------------------------------------------------------------------------
+vtkGenericRenderWindowInteractor*
+QVTK_RenderWindowInteractor
+::GetDevice()
+{
+ return myDevice.GetPointer();
}
+//----------------------------------------------------------------------------
+vtkRenderWindow*
+QVTK_RenderWindowInteractor
+::getRenderWindow()
+{
+ return myRenderWindow.GetPointer();
+}
//----------------------------------------------------------------------------
void
-SVTK_RenderWindowInteractor
-::setGUIWindow(QWidget* theWindow)
+QVTK_RenderWindowInteractor
+::InvokeEvent(unsigned long theEvent, void* theCallData)
{
- myGUIWindow = theWindow;
+ GetDevice()->InvokeEvent(theEvent,theCallData);
}
//----------------------------------------------------------------------------
void
-SVTK_RenderWindowInteractor
-::setViewWindow(SVTK_ViewWindow* theViewWindow)
+QVTK_RenderWindowInteractor
+::show()
{
- myViewWindow = theViewWindow;
-
- myViewWindow->InsertActor(myCellActor);
- myViewWindow->InsertActor(myEdgeActor);
- myViewWindow->InsertActor(myPointActor);
+ QWidget::show();
+ update(); // needed for initial contents display on Win32
}
//----------------------------------------------------------------------------
void
-SVTK_RenderWindowInteractor
-::MoveInternalActors()
+QVTK_RenderWindowInteractor
+::polish()
{
- myViewWindow->MoveActor(myCellActor);
- myViewWindow->MoveActor(myEdgeActor);
- myViewWindow->MoveActor(myPointActor);
+ // Final initialization just before the widget is displayed
+ GetDevice()->SetSize(width(),height());
+#ifndef WNT
+ getRenderWindow()->SetDisplayId((void*)x11Display());
+#endif
+ getRenderWindow()->SetWindowId((void*)winId());
+ GetDevice()->Enable();
}
//----------------------------------------------------------------------------
void
-SVTK_RenderWindowInteractor
-::SetInteractorStyle(vtkInteractorObserver *theInteractor)
+QVTK_RenderWindowInteractor
+::resize(int w, int h)
{
- myInteractorStyle = dynamic_cast<SVTK_InteractorStyle*>(theInteractor);
- vtkRenderWindowInteractor::SetInteractorStyle(theInteractor);
+ GetDevice()->UpdateSize(w,h);
}
-
+//----------------------------------------------------------------------------
void
-SVTK_RenderWindowInteractor
-::SetSelectionMode(Selection_Mode theMode)
+QVTK_RenderWindowInteractor
+::paintEvent( QPaintEvent* theEvent )
{
- myCellActor->SetVisibility(false);
- myEdgeActor->SetVisibility(false);
- myPointActor->SetVisibility(false);
-
- switch(theMode){
- case ActorSelection:
- this->SetPicker(myBasicPicker);
- break;
- case NodeSelection:
- this->SetPicker(myPointPicker);
- break;
- case CellSelection:
- case EdgeSelection:
- case FaceSelection:
- case VolumeSelection:
- case EdgeOfCellSelection:
- this->SetPicker(myCellPicker);
- break;
+ if(GetDevice()->GetEnabled()){
+ if(!GetDevice()->GetInitialized()){
+ GetDevice()->Initialize();
+ GetDevice()->ConfigureEvent();
+ }
+ GetDevice()->Render();
}
-
- myInteractorStyle->OnSelectionModeChanged();
}
+
+//----------------------------------------------------------------------------
void
-SVTK_RenderWindowInteractor
-::SetSelectionProp(const double& theRed,
- const double& theGreen,
- const double& theBlue,
- const int& theWidth)
-{
- myCellActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
- myCellActor->GetProperty()->SetLineWidth(theWidth);
+QVTK_RenderWindowInteractor
+::resizeEvent( QResizeEvent* theEvent )
+{
+ int* aSize = getRenderWindow()->GetSize();
+ int aWidth = aSize[0];
+ int aHeight = aSize[1];
+
+ GetDevice()->UpdateSize(width(),height());
+
+ if(isVisible() && aWidth && aHeight){
+ if( aWidth != width() || aHeight != height() ) {
+ vtkRendererCollection * aRenderers = getRenderWindow()->GetRenderers();
+ aRenderers->InitTraversal();
+ double aCoeff = 1.0;
+ if(vtkRenderer *aRenderer = aRenderers->GetNextItem()) {
+ vtkCamera *aCamera = aRenderer->GetActiveCamera();
+ double aScale = aCamera->GetParallelScale();
+ if((aWidth - width())*(aHeight - height()) > 0)
+ aCoeff = sqrt(double(aWidth)/double(width())*double(height())/double(aHeight));
+ else
+ aCoeff = double(aWidth)/double(width());
+ aCamera->SetParallelScale(aScale*aCoeff);
+ }
+ }
+ }
- myPointActor->GetProperty()->SetColor(theRed, theGreen, theBlue);
- myPointActor->GetProperty()->SetPointSize(theWidth);
+ update();
}
-void
-SVTK_RenderWindowInteractor
-::SetSelectionTolerance(const double& theTolNodes,
- const double& theTolItems)
-{
- myTolNodes = theTolNodes;
- myTolItems = theTolItems;
- myBasicPicker->SetTolerance(myTolItems);
- myCellPicker->SetTolerance(myTolItems);
- myPointPicker->SetTolerance(myTolNodes);
+//----------------------------------------------------------------------------
+void
+QVTK_RenderWindowInteractor
+::contextMenuEvent( QContextMenuEvent* event )
+{}
-}
-// ==================================
+//----------------------------------------------------------------------------
void
-SVTK_RenderWindowInteractor
-::Start()
+QVTK_RenderWindowInteractor
+::mouseMoveEvent( QMouseEvent* event )
{
- //
- // We do not allow this interactor to control the
- // event loop. Only the QtApplication objects are
- // allowed to do that.
- //
- vtkErrorMacro(<<"SVTK_RenderWindowInteractor::Start() not allowed to start event loop.") ;
- return ;
+ GetDevice()->SetEventInformationFlipY(event->x(),
+ event->y(),
+ event->state() & ControlButton,
+ event->state() & ShiftButton);
+ GetDevice()->MouseMoveEvent();
}
+
+//----------------------------------------------------------------------------
void
-SVTK_RenderWindowInteractor
-::UpdateSize(int w, int h)
+QVTK_RenderWindowInteractor
+::mousePressEvent( QMouseEvent* event )
{
- // if the size changed send this on to the RenderWindow
- if ((w != this->Size[0])||(h != this->Size[1])) {
- this->Size[0] = w;
- this->Size[1] = h;
- this->RenderWindow->SetSize(w,h);
- }
+ GetDevice()->SetEventInformationFlipY(event->x(),
+ event->y(),
+ event->state() & ControlButton,
+ event->state() & ShiftButton);
+ if( event->button() & LeftButton )
+ GetDevice()->LeftButtonPressEvent();
+ else if( event->button() & MidButton )
+ GetDevice()->MiddleButtonPressEvent();
+ else if( event->button() & RightButton )
+ GetDevice()->RightButtonPressEvent();
}
-int
-SVTK_RenderWindowInteractor
-::CreateTimer(int vtkNotUsed(timertype))
+
+//----------------------------------------------------------------------------
+void
+QVTK_RenderWindowInteractor
+::mouseReleaseEvent( QMouseEvent *event )
{
- //
- // Start a one-shot timer for 10ms.
- //
- mTimer->start(10, TRUE) ;
- return 1 ;
-}
+ GetDevice()->SetEventInformationFlipY(event->x(),
+ event->y(),
+ event->state() & ControlButton,
+ event->state() & ShiftButton);
-int
-SVTK_RenderWindowInteractor
-::DestroyTimer(void)
-{
- //
- // :TRICKY: Tue May 2 00:17:32 2000 Pagey
- //
- // QTimer will automatically expire after 10ms. So
- // we do not need to do anything here. In fact, we
- // should not even Stop() the QTimer here because doing
- // this will skip some of the processing that the TimerFunc()
- // does and will result in undesirable effects. For
- // example, this will result in vtkLODActor to leave
- // the models in low-res mode after the mouse stops
- // moving.
- //
- return 1 ;
+ if( event->button() & LeftButton )
+ GetDevice()->LeftButtonReleaseEvent();
+ else if( event->button() & MidButton )
+ GetDevice()->MiddleButtonReleaseEvent();
+ else if( event->button() & RightButton )
+ GetDevice()->RightButtonReleaseEvent();
}
+
+//----------------------------------------------------------------------------
void
-SVTK_RenderWindowInteractor
-::TimerFunc()
-{
- if( ! this->Enabled ) {
- return ;
- }
+QVTK_RenderWindowInteractor
+::mouseDoubleClickEvent( QMouseEvent* event )
+{}
- myInteractorStyle->OnTimer();
- emit RenderWindowModified();
-}
+//----------------------------------------------------------------------------
+void
+QVTK_RenderWindowInteractor
+::wheelEvent( QWheelEvent* event )
+{}
+
+//----------------------------------------------------------------------------
void
-SVTK_RenderWindowInteractor
-::MouseMove(const QMouseEvent *event)
+QVTK_RenderWindowInteractor
+::keyPressEvent( QKeyEvent* event )
{
- if( ! this->Enabled ) {
- return ;
- }
- myInteractorStyle->OnMouseMove(0, 0, event->x(), event->y()/*this->Size[1] - event->y() - 1*/) ;
- if (myInteractorStyle->needsRedrawing() )
- emit RenderWindowModified() ;
+ GetDevice()->SetKeyEventInformation(event->state() & ControlButton,
+ event->state() & ShiftButton,
+ event->key());
+ GetDevice()->KeyPressEvent();
+ GetDevice()->CharEvent();
}
+//----------------------------------------------------------------------------
void
-SVTK_RenderWindowInteractor
-::LeftButtonPressed(const QMouseEvent *event)
+QVTK_RenderWindowInteractor
+::keyReleaseEvent( QKeyEvent * event )
{
- if( ! this->Enabled ) {
- return ;
- }
- myInteractorStyle->OnLeftButtonDown((event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y());
+ GetDevice()->SetKeyEventInformation(event->state() & ControlButton,
+ event->state() & ShiftButton,
+ event->key());
+ GetDevice()->KeyReleaseEvent();
}
-void
-SVTK_RenderWindowInteractor
-::LeftButtonReleased(const QMouseEvent *event) {
- if( ! this->Enabled ) {
- return ;
- }
- myInteractorStyle->OnLeftButtonUp( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
-}
-void
-SVTK_RenderWindowInteractor
-::MiddleButtonPressed(const QMouseEvent *event)
+//----------------------------------------------------------------------------
+void
+QVTK_RenderWindowInteractor
+::enterEvent( QEvent* event )
{
- if( ! this->Enabled ) {
- return ;
- }
- myInteractorStyle->OnMiddleButtonDown((event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+ setActiveWindow();
+ setFocus();
+
+ GetDevice()->EnterEvent();
}
-void
-SVTK_RenderWindowInteractor
-::MiddleButtonReleased(const QMouseEvent *event)
+//----------------------------------------------------------------------------
+void
+QVTK_RenderWindowInteractor
+::leaveEvent( QEvent * )
{
- if( ! this->Enabled ) {
- return ;
- }
- myInteractorStyle->OnMiddleButtonUp( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
+ GetDevice()->LeaveEvent();
}
-void
-SVTK_RenderWindowInteractor
-::RightButtonPressed(const QMouseEvent *event)
-{
- if( ! this->Enabled ) {
- return ;
+
+//----------------------------------------------------------------------------
+void
+QVTK_RenderWindowInteractor
+::focusInEvent( QFocusEvent* event )
+{
+ QWidget::focusInEvent( event );
+
+ // register set space mouse events receiver
+ if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance()){
+ if(!aSpaceMouse->isSpaceMouseOn()) {// initialize 3D space mouse driver
+ aSpaceMouse->initialize(x11Display(),winId());
+ }else{
+ aSpaceMouse->setWindow(x11Display(),winId());
+ }
}
- myInteractorStyle->OnRightButtonDown( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
}
-void
-SVTK_RenderWindowInteractor
-::RightButtonReleased(const QMouseEvent *event)
+//----------------------------------------------------------------------------
+void
+QVTK_RenderWindowInteractor
+::focusOutEvent ( QFocusEvent* event )
{
- if( ! this->Enabled ) {
- return ;
- }
- myInteractorStyle->OnRightButtonUp( (event->state() & ControlButton),
- (event->state() & ShiftButton),
- event->x(), event->y() ) ;
-
- if(myInteractorStyle->GetState() == VTK_INTERACTOR_STYLE_CAMERA_NONE && !( event->state() & KeyButtonMask )){
- QContextMenuEvent aEvent( QContextMenuEvent::Mouse,
- event->pos(), event->globalPos(),
- event->state() );
- emit contextMenuRequested( &aEvent );
+ QWidget::focusOutEvent( event );
+
+ // unregister set space mouse events receiver
+ if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance()){
+ if(aSpaceMouse->isSpaceMouseOn())
+ aSpaceMouse->setWindow(x11Display(),0);
}
}
-void
-SVTK_RenderWindowInteractor
-::ButtonPressed(const QMouseEvent *event)
-{
- return ;
-}
-void
-SVTK_RenderWindowInteractor
-::ButtonReleased(const QMouseEvent *event)
-{
- return ;
+//----------------------------------------------------------------------------
+bool
+QVTK_RenderWindowInteractor
+::x11Event( XEvent *xEvent )
+{
+ // handle 3d space mouse events
+ if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance()){
+ if(aSpaceMouse->isSpaceMouseOn() && xEvent->type == ClientMessage){
+ SVTK_SpaceMouse::MoveEvent anEvent;
+ int type = aSpaceMouse->translateEvent( x11Display(), xEvent, &anEvent, 1.0, 1.0 );
+ switch( type ){
+ case SVTK_SpaceMouse::SpaceMouseMove :
+ GetDevice()->InvokeEvent(SVTK::SpaceMouseMoveEvent, anEvent.data );
+ break;
+ case SVTK_SpaceMouse::SpaceButtonPress :
+ GetDevice()->InvokeEvent( SVTK::SpaceMouseButtonEvent, &anEvent.button );
+ break;
+ case SVTK_SpaceMouse::SpaceButtonRelease :
+ break;
+ }
+ return true; // stop handling the event
+ }
+ }
+
+ return QWidget::x11Event( xEvent );
}
-int
+//----------------------------------------------------------------------------
SVTK_RenderWindowInteractor
-::GetDisplayMode()
+::SVTK_RenderWindowInteractor(QWidget* theParent,
+ const char* theName):
+ QVTK_RenderWindowInteractor(theParent,theName),
+ myEventCallbackCommand(vtkCallbackCommand::New())
{
- return myDisplayMode;
-}
+ if(MYDEBUG) INFOS("SVTK_RenderWindowInteractor() - "<<this);
-void
-SVTK_RenderWindowInteractor
-::SetDisplayMode(int theMode)
-{
- if(theMode == 0)
- ChangeRepresentationToWireframe();
- else
- ChangeRepresentationToSurface();
- myDisplayMode = theMode;
-}
+ myEventCallbackCommand->Delete();
+ myEventCallbackCommand->SetClientData(this);
+ myPriority = 0.0;
-void
-SVTK_RenderWindowInteractor
-::SetDisplayMode(const Handle(SALOME_InteractiveObject)& theIObject,
- int theMode)
-{
- using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
- TIsSameIObject<SALOME_Actor>(theIObject),
- TSetFunction<SALOME_Actor,int>
- (&SALOME_Actor::setDisplayMode,theMode));
+ myEventCallbackCommand->SetCallback(SVTK_RenderWindowInteractor::ProcessEvents);
}
-
void
SVTK_RenderWindowInteractor
-::ChangeRepresentationToWireframe()
+::Initialize(vtkGenericRenderWindowInteractor* theDevice,
+ SVTK_Renderer* theRenderer,
+ SVTK_Selector* theSelector)
{
- ChangeRepresentationToWireframe(GetRenderer()->GetActors());
+ QVTK_RenderWindowInteractor::Initialize(theDevice);
+ SetRenderer(theRenderer);
+ SetSelector(theSelector);
}
-void
+//----------------------------------------------------------------------------
SVTK_RenderWindowInteractor
-::ChangeRepresentationToSurface()
+::~SVTK_RenderWindowInteractor()
{
- ChangeRepresentationToSurface(GetRenderer()->GetActors());
-}
+ if(MYDEBUG) INFOS("~SVTK_RenderWindowInteractor() - "<<this);
+ // Sequence of the destruction call are fixed and should be changed.
+ // vtkRenderWindow instance should be destroyed after all vtkRenderer's
+ if(MYVTKDEBUG){
+ getRenderWindow()->DebugOn();
+ getRenderer()->DebugOn();
+ GetDevice()->DebugOn();
+ }
+ GetDevice()->SetInteractorStyle(NULL);
+ while(!myInteractorStyles.empty()){
+ const PInteractorStyle& aStyle = myInteractorStyles.top();
+ aStyle->SetInteractor(NULL);
+ if(MYVTKDEBUG) aStyle->DebugOn();
+ myInteractorStyles.pop();
+ }
-void
-SVTK_RenderWindowInteractor
-::ChangeRepresentationToWireframe(vtkActorCollection* theCollection)
-{
- using namespace VTK;
- ForEach<SALOME_Actor>(theCollection,
- TSetFunction<SALOME_Actor,int>
- (&SALOME_Actor::setDisplayMode,0));
- emit RenderWindowModified();
+ SetRenderer(NULL);
+
+ GetDevice()->SetRenderWindow(NULL);
}
-void
+//----------------------------------------------------------------------------
+SVTK_Renderer*
SVTK_RenderWindowInteractor
-::ChangeRepresentationToSurface(vtkActorCollection* theCollection)
+::GetRenderer()
{
- using namespace VTK;
- ForEach<SALOME_Actor>(theCollection,
- TSetFunction<SALOME_Actor,int>
- (&SALOME_Actor::setDisplayMode,1));
- emit RenderWindowModified();
+ return myRenderer.GetPointer();
}
-
vtkRenderer*
SVTK_RenderWindowInteractor
-::GetRenderer()
+::getRenderer()
{
- vtkRendererCollection * theRenderers = this->RenderWindow->GetRenderers();
- theRenderers->InitTraversal();
- return theRenderers->GetNextItem();
+ return GetRenderer()->GetDevice();
}
-
-struct TErase{
- VTK::TSetFunction<vtkActor,int> mySetFunction;
- TErase():
- mySetFunction(&vtkActor::SetVisibility,false)
- {}
- void operator()(SALOME_Actor* theActor){
- theActor->SetVisibility(false);
- // Erase dependent actors
- vtkActorCollection* aCollection = vtkActorCollection::New();
- theActor->GetChildActors(aCollection);
- VTK::ForEach<vtkActor>(aCollection,mySetFunction);
- aCollection->Delete();
- }
-};
-
void
SVTK_RenderWindowInteractor
-::EraseAll()
-{
- using namespace VTK;
- ForEach<SALOME_Actor>(GetRenderer()->GetActors(),
- TErase());
+::SetRenderer(SVTK_Renderer* theRenderer)
+{
+ if(theRenderer == myRenderer.GetPointer())
+ return;
- emit RenderWindowModified() ;
-}
+ if(GetRenderer())
+ myRenderWindow->RemoveRenderer(getRenderer());
-void
-SVTK_RenderWindowInteractor
-::DisplayAll()
-{
- vtkActorCollection* aCollection = GetRenderer()->GetActors();
- using namespace VTK;
- ForEach<SALOME_Actor>(aCollection,TSetVisibility<SALOME_Actor>(true));
+ myRenderer = theRenderer;
- emit RenderWindowModified() ;
+ if(GetRenderer())
+ myRenderWindow->AddRenderer(getRenderer());
}
+//----------------------------------------------------------------------------
void
SVTK_RenderWindowInteractor
-::Erase(SALOME_Actor* theActor, bool update)
+::InitInteractorStyle(vtkInteractorStyle* theStyle)
{
- TErase()(theActor);
-
- if(update)
- emit RenderWindowModified();
+ GetDevice()->SetInteractorStyle(theStyle);
}
+//----------------------------------------------------------------------------
void
SVTK_RenderWindowInteractor
-::Erase(const Handle(SALOME_InteractiveObject)& theIObject,
- bool update)
+::PushInteractorStyle(vtkInteractorStyle* theStyle)
{
- using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
- TIsSameIObject<SALOME_Actor>(theIObject),
- TErase());
-
- if(update)
- emit RenderWindowModified();
+ myInteractorStyles.push(PInteractorStyle(theStyle));
+ InitInteractorStyle(theStyle);
}
-struct TRemoveAction{
- vtkRenderer* myRen;
- TRemoveAction(vtkRenderer* theRen): myRen(theRen){}
- void operator()(SALOME_Actor* theActor){
- myRen->RemoveActor(theActor);
- }
-};
-
-void
-SVTK_RenderWindowInteractor
-::Remove(const Handle(SALOME_InteractiveObject)& theIObject,
- bool update)
-{
- vtkRenderer* aRen = GetRenderer();
-
- using namespace VTK;
- ForEachIf<SALOME_Actor>(aRen->GetActors(),
- TIsSameIObject<SALOME_Actor>(theIObject),
- TRemoveAction(aRen));
-}
-
+//----------------------------------------------------------------------------
void
SVTK_RenderWindowInteractor
-::Remove( SALOME_Actor* SActor, bool updateViewer )
+::PopInteractorStyle()
{
- if ( SActor != 0 )
- {
- GetRenderer()->RemoveProp( SActor );
- if ( updateViewer )
- emit RenderWindowModified();
- }
-}
-
-void
-SVTK_RenderWindowInteractor
-::RemoveAll( const bool updateViewer )
-{
- vtkRenderer* aRenderer = GetRenderer();
- vtkActorCollection* anActors = aRenderer->GetActors();
- if ( anActors )
- {
- anActors->InitTraversal();
- while ( vtkActor *anAct = anActors->GetNextActor() )
- {
- if ( anAct->IsA( "SALOME_Actor" ) )
- {
- SALOME_Actor* aSAct = (SALOME_Actor*)anAct;
- if ( aSAct->hasIO() && aSAct->getIO()->hasEntry() )
- aRenderer->RemoveActor( anAct );
- }
- }
-
- if ( updateViewer )
- emit RenderWindowModified();
- }
+ if(GetInteractorStyle())
+ myInteractorStyles.pop();
+
+ if(GetInteractorStyle())
+ InitInteractorStyle(GetInteractorStyle());
}
-float
+//----------------------------------------------------------------------------
+vtkInteractorStyle*
SVTK_RenderWindowInteractor
-::GetTransparency(const Handle(SALOME_InteractiveObject)& theIObject)
+::GetInteractorStyle()
{
- using namespace VTK;
- SALOME_Actor* anActor =
- Find<SALOME_Actor>(GetRenderer()->GetActors(),
- TIsSameIObject<SALOME_Actor>(theIObject));
- if(anActor)
- return 1.0 - anActor->GetOpacity();
- return -1.0;
+ return myInteractorStyles.empty() ? 0 : myInteractorStyles.top().GetPointer();
}
-void
+//----------------------------------------------------------------------------
+SVTK_Selector*
SVTK_RenderWindowInteractor
-::SetTransparency(const Handle(SALOME_InteractiveObject)& theIObject,
- float theTrans)
-{
- float anOpacity = 1.0 - theTrans;
- using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
- TIsSameIObject<SALOME_Actor>(theIObject),
- TSetFunction<SALOME_Actor,float>
- (&SALOME_Actor::SetOpacity,anOpacity));
+::GetSelector()
+{
+ return mySelector.GetPointer();
}
void
SVTK_RenderWindowInteractor
-::Display(SALOME_Actor* theActor, bool update)
-{
- GetRenderer()->AddActor(theActor);
- theActor->SetVisibility(true);
+::SetSelector(SVTK_Selector* theSelector)
+{
+ if(mySelector.GetPointer())
+ mySelector->RemoveObserver(myEventCallbackCommand.GetPointer());
- if(update)
- emit RenderWindowModified();
+ mySelector = theSelector;
+
+ if(mySelector.GetPointer())
+ mySelector->AddObserver(vtkCommand::EndPickEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
}
-void
+//----------------------------------------------------------------------------
+void
SVTK_RenderWindowInteractor
-::Display(const Handle(SALOME_InteractiveObject)& theIObject, bool update)
+::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* vtkNotUsed(theCallData))
{
- using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
- TIsSameIObject<SALOME_Actor>(theIObject),
- TSetVisibility<SALOME_Actor>(true));
+ SVTK_RenderWindowInteractor* self = reinterpret_cast<SVTK_RenderWindowInteractor*>(theClientData);
- if(update)
- emit RenderWindowModified() ;
+ switch(theEvent){
+ case vtkCommand::EndPickEvent:
+ self->onEmitSelectionChanged();
+ break;
+ }
}
+//----------------------------------------------------------------
void
SVTK_RenderWindowInteractor
-::KeyPressed(QKeyEvent *event)
-{}
-
-
-struct THighlightAction{
- bool myIsHighlight;
- SVTK_InteractorStyle* myInteractorStyle;
- THighlightAction(SVTK_InteractorStyle* theInteractorStyle,
- bool theIsHighlight):
- myInteractorStyle(theInteractorStyle),
- myIsHighlight(theIsHighlight)
- {}
- void operator()(SALOME_Actor* theActor){
- if(theActor->GetMapper()){
- if(theActor->hasHighlight())
- theActor->highlight(myIsHighlight);
- else{
- if(theActor->GetVisibility() && myIsHighlight)
- myInteractorStyle->HighlightProp(theActor);
- else if(!myIsHighlight)
- myInteractorStyle->HighlightProp(NULL);
- }
- }
- }
-};
-
-bool
-SVTK_RenderWindowInteractor
-::highlight( const Handle(SALOME_InteractiveObject)& theIObject,
- bool hilight,
- bool update)
+::SetSelectionMode(Selection_Mode theMode)
{
- using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
- TIsSameIObject<SALOME_Actor>(theIObject),
- THighlightAction(myInteractorStyle,hilight));
-
- if(update)
- emit RenderWindowModified();
-
- return false;
+ mySelector->SetSelectionMode(theMode);
}
-struct TUpdateAction{
- void operator()(vtkActor* theActor){
- theActor->ApplyProperties();
- }
-};
-
-void
+//----------------------------------------------------------------
+Selection_Mode
SVTK_RenderWindowInteractor
-::Update()
+::SelectionMode() const
{
- vtkRenderer* aRen = GetRenderer();
-
- using namespace VTK;
- ForEach<vtkActor>(aRen->GetActors(),TUpdateAction());
-
- aRen->ResetCamera();
-
- emit RenderWindowModified();
+ return mySelector->SelectionMode();
}
+//----------------------------------------------------------------
void
SVTK_RenderWindowInteractor
-::unHighlightSubSelection()
+::onEmitSelectionChanged()
{
- myPointActor->SetVisibility(false);
- myEdgeActor->SetVisibility(false);
- myCellActor->SetVisibility(false);
+ return emit selectionChanged();
}
-bool
+//----------------------------------------------------------------------------
+void
SVTK_RenderWindowInteractor
-::unHighlightAll()
+::mouseMoveEvent( QMouseEvent* event )
{
- unHighlightSubSelection();
-
- using namespace VTK;
- ForEach<SALOME_Actor>(GetRenderer()->GetActors(),
- THighlightAction(myInteractorStyle,false));
-
- emit RenderWindowModified() ;
+ QVTK_RenderWindowInteractor::mouseMoveEvent(event);
- return false;
+ if(GENERATE_SUIT_EVENTS)
+ emit MouseMove( event );
}
-//-----------------
-// Color methods
-//-----------------
+//----------------------------------------------------------------------------
void
SVTK_RenderWindowInteractor
-::SetColor(const Handle(SALOME_InteractiveObject)& theIObject,QColor theColor)
+::mousePressEvent( QMouseEvent* event )
{
- float aColor[3] = {theColor.red()/255., theColor.green()/255., theColor.blue()/255.};
- using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
- TIsSameIObject<SALOME_Actor>(theIObject),
- TSetFunction<SALOME_Actor,const float*>
- (&SALOME_Actor::SetColor,aColor));
-}
-
+ QVTK_RenderWindowInteractor::mousePressEvent(event);
-QColor
-SVTK_RenderWindowInteractor
-::GetColor(const Handle(SALOME_InteractiveObject)& theIObject)
-{
- using namespace VTK;
- SALOME_Actor* anActor =
- Find<SALOME_Actor>(GetRenderer()->GetActors(),
- TIsSameIObject<SALOME_Actor>(theIObject));
- if(anActor){
- float r,g,b;
- anActor->GetColor(r,g,b);
- return QColor(int(r*255),int(g*255),int(b*255));
- }
- return QColor(0,0,0);
+ if(GENERATE_SUIT_EVENTS)
+ emit MouseButtonPressed( event );
}
-bool
+//----------------------------------------------------------------------------
+void
SVTK_RenderWindowInteractor
-::isInViewer(const Handle(SALOME_InteractiveObject)& theIObject)
+::mouseReleaseEvent( QMouseEvent *event )
{
- using namespace VTK;
- SALOME_Actor* anActor =
- Find<SALOME_Actor>(GetRenderer()->GetActors(),
- TIsSameIObject<SALOME_Actor>(theIObject));
- return anActor != NULL;
-}
-
+ QVTK_RenderWindowInteractor::mouseReleaseEvent(event);
-bool
-SVTK_RenderWindowInteractor
-::isVisible(const Handle(SALOME_InteractiveObject)& theIObject)
-{
- using namespace VTK;
- SALOME_Actor* anActor =
- Find<SALOME_Actor>(GetRenderer()->GetActors(),
- TIsSameIObject<SALOME_Actor>(theIObject));
- return anActor != NULL && anActor->GetVisibility();
+ if(GENERATE_SUIT_EVENTS)
+ emit MouseButtonReleased( event );
}
+//----------------------------------------------------------------------------
void
SVTK_RenderWindowInteractor
-::rename(const Handle(SALOME_InteractiveObject)& theIObject, QString theName)
+::mouseDoubleClickEvent( QMouseEvent* event )
{
- using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
- TIsSameIObject<SALOME_Actor>(theIObject),
- TSetFunction<SALOME_Actor,const char*,QString>
- (&SALOME_Actor::setName,theName.latin1()));
+ QVTK_RenderWindowInteractor::mouseDoubleClickEvent(event);
+
+ if(GENERATE_SUIT_EVENTS)
+ emit MouseDoubleClicked( event );
}
//----------------------------------------------------------------------------
-bool
-SVTK_RenderWindowInteractor
-::highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
- SALOME_Actor* theMapActor,
- SVTK_Actor* theActor,
- TUpdateActor theFun,
- bool hilight,
- bool update)
-{
- if(theMapIndex.Extent() == 0) return false;
-
- if (hilight) {
- setActorData(theMapIndex,theMapActor,theActor,theFun);
- theActor->SetVisibility(true);
- }
- else {
- theActor->SetVisibility(false);
- }
-
- if(update){
- this->RenderWindow->Render();
- emit RenderWindowModified() ;
- }
-
- return false;
-}
-
void
SVTK_RenderWindowInteractor
-::setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
- SALOME_Actor* theMapActor,
- SVTK_Actor *theActor,
- TUpdateActor theFun)
+::wheelEvent( QWheelEvent* event )
{
- (*theFun)(theMapIndex,theMapActor,theActor);
- float aPos[3];
- theMapActor->GetPosition(aPos);
- theActor->SetPosition(aPos);
+ QVTK_RenderWindowInteractor::wheelEvent(event);
+ if(event->delta() > 0)
+ GetDevice()->InvokeEvent(SVTK::ZoomInEvent,NULL);
+ else
+ GetDevice()->InvokeEvent(SVTK::ZoomOutEvent,NULL);
+
+ if(GENERATE_SUIT_EVENTS)
+ emit WheelMoved( event );
}
//----------------------------------------------------------------------------
-static void CellsUpdateActor(const TColStd_IndexedMapOfInteger& theMapIndex,
- SALOME_Actor* theMapActor,
- SVTK_Actor* theActor)
-{
- theActor->MapCells(theMapActor,theMapIndex);
-}
-
-bool
-SVTK_RenderWindowInteractor
-::highlightCell(const TColStd_IndexedMapOfInteger& theMapIndex,
- SALOME_Actor* theMapActor,
- bool hilight,
- bool update)
-{
- return highlight(theMapIndex,theMapActor,myCellActor,&CellsUpdateActor,hilight,update);
-}
-
-void
+void
SVTK_RenderWindowInteractor
-::setCellData(const int& theIndex,
- SALOME_Actor* theMapActor,
- SVTK_Actor* theActor)
+::keyPressEvent( QKeyEvent* event )
{
- TColStd_IndexedMapOfInteger MapIndex;
- MapIndex.Add(theIndex);
- theActor->MapCells(theMapActor,MapIndex);
-}
+ QVTK_RenderWindowInteractor::keyPressEvent(event);
+ if(GENERATE_SUIT_EVENTS)
+ emit KeyPressed( event );
+}
//----------------------------------------------------------------------------
-static void PointsUpdateActor(const TColStd_IndexedMapOfInteger& theMapIndex,
- SALOME_Actor* theMapActor,
- SVTK_Actor* theActor)
-{
- theActor->MapPoints(theMapActor,theMapIndex);
-}
-
-bool
-SVTK_RenderWindowInteractor
-::highlightPoint(const TColStd_IndexedMapOfInteger& theMapIndex,
- SALOME_Actor* theMapActor,
- bool hilight,
- bool update)
-{
- return highlight(theMapIndex,theMapActor,myPointActor,&PointsUpdateActor,hilight,update);
-}
-
void
SVTK_RenderWindowInteractor
-::setPointData(const int& theIndex,
- SALOME_Actor* theMapActor,
- SVTK_Actor* theActor)
+::keyReleaseEvent( QKeyEvent * event )
{
- TColStd_IndexedMapOfInteger MapIndex;
- MapIndex.Add(theIndex);
- theActor->MapPoints(theMapActor,MapIndex);
+ QVTK_RenderWindowInteractor::keyReleaseEvent(event);
+
+ if(GENERATE_SUIT_EVENTS)
+ emit KeyReleased( event );
}
-
//----------------------------------------------------------------------------
-static void EdgesUpdateActor(const TColStd_IndexedMapOfInteger& theMapIndex,
- SALOME_Actor* theMapActor,
- SVTK_Actor* theActor)
-{
- theActor->MapEdge(theMapActor,theMapIndex);
-}
-
-bool
+void
SVTK_RenderWindowInteractor
-::highlightEdge(const TColStd_IndexedMapOfInteger& theMapIndex,
- SALOME_Actor* theMapActor,
- bool hilight,
- bool update)
+::contextMenuEvent( QContextMenuEvent* event )
{
- return highlight(theMapIndex,theMapActor,myEdgeActor,&EdgesUpdateActor,hilight,update);
-}
-
-void
-SVTK_RenderWindowInteractor
-::setEdgeData(const int& theCellIndex,
- SALOME_Actor* theMapActor,
- const int& theEdgeIndex,
- SVTK_Actor* theActor )
-{
- TColStd_IndexedMapOfInteger MapIndex;
- MapIndex.Add(theCellIndex);
- MapIndex.Add(theEdgeIndex);
- theActor->MapEdge(theMapActor,MapIndex);
+ if( !( event->state() & KeyButtonMask ) )
+ emit contextMenuRequested( event );
}
//
//
//
-// File : SVTK_RenderWindowInteractor.h
-// Author : Nicolas REJNERI
+// File :
+// Author :
// Module : SALOME
// $Header$
#define SVTK_RenderWindowInteractor_h
#include "SVTK.h"
-
#include "SVTK_Selection.h"
-#include "SALOME_InteractiveObject.hxx"
-
-// QT Includes
-#include <qobject.h>
-#include <qtimer.h>
-
-// VTK Includes
-#include <vtkVersion.h>
-#include <vtkRenderWindowInteractor.h>
-
-// Open CASCADE Includes
-#include <TColStd_MapOfInteger.hxx>
-#include <TColStd_IndexedMapOfInteger.hxx>
-#include <TColStd_MapIteratorOfMapOfInteger.hxx>
-
-class vtkPicker;
-class vtkCellPicker;
-class vtkPointPicker;
-class vtkActorCollection;
-
-class SALOME_Actor;
-class SVTK_Actor;
-
-class SVTK_ViewWindow;
-class SVTK_RenderWindow;
-class SVTK_InteractorStyle;
-
-// ------------------------------------------------------------
-// :TRICKY: Fri Apr 21 22:19:27 2000 Pagey
-// The Signal/Slot mechanism used by Qt requires that QObject
-// appear as the first class when using multiple inheritance.
-// Hence the order of the two classes QObject and vtkRenderWindowInteractor
-// matters here. Be careful not to change it by accident.
-// ------------------------------------------------------------
-class SVTK_EXPORT SVTK_RenderWindowInteractor: public QObject,
- public vtkRenderWindowInteractor
+
+#include <vtkSmartPointer.h>
+#include <qwidget.h>
+
+// undefining min and max because CASCADE's defines them and
+// it clashes with std::min(), std::max()
+#undef min
+#undef max
+
+#include <stack>
+
+class vtkGenericRenderWindowInteractor;
+class vtkInteractorStyle;
+class vtkCallbackCommand;
+class vtkRenderWindow;
+class vtkRenderer;
+class vtkObject;
+
+class SVTK_Selector;
+class SVTK_Renderer;
+
+//============================================================================
+//! Implemements Qt based vtkRenderWindowInteractor.
+/*!
+ The class inherits #QWidget class in order to be possible process Qt events.
+ It invokes corresponding VTK events through usage of its device - a #vtkGenericRenderWindowInteractor.
+ Also, it creates, initialize and holds vtkRenderWindow instance.
+*/
+class SVTK_EXPORT QVTK_RenderWindowInteractor: public QWidget
{
- Q_OBJECT ;
- friend class SVTK_ViewWindow;
-public:
-
- static SVTK_RenderWindowInteractor *New() ;
-
- vtkTypeMacro(SVTK_RenderWindowInteractor,vtkRenderWindowInteractor);
-
- // Description:
- // Initializes the event handlers without an XtAppContext. This is
- // good for when you don`t have a user interface, but you still
- // want to have mouse interaction.
- virtual void Initialize();
-
- virtual void SetInteractorStyle(vtkInteractorObserver *);
- SVTK_InteractorStyle* GetSInteractorStyle(){ return myInteractorStyle;}
-
- // Description:
- // This will start up the X event loop and never return. If you
- // call this method it will loop processing X events until the
- // application is exited.
- virtual void Start();
-
- // Description:
- // Event loop notification member for Window size change
- virtual void UpdateSize(int x,int y);
-
- // Description:
- // Timer methods must be overridden by platform dependent subclasses.
- // flag is passed to indicate if this is first timer set or an update
- // as Win32 uses repeating timers, whereas X uses One shot more timer
- // if flag==VTKXI_TIMER_FIRST Win32 and X should createtimer
- // otherwise Win32 should exit and X should perform AddTimeOut()
- virtual int CreateTimer(int ) ;
- virtual int DestroyTimer() ;
-
- /* Selection Management */
- bool highlightCell(const TColStd_IndexedMapOfInteger& MapIndex,
- SALOME_Actor* theMapActor,
- bool hilight,
- bool update = true );
- bool highlightEdge(const TColStd_IndexedMapOfInteger& MapIndex,
- SALOME_Actor* theMapActor,
- bool hilight,
- bool update = true );
- bool highlightPoint(const TColStd_IndexedMapOfInteger& MapIndex,
- SALOME_Actor* theMapActor,
- bool hilight,
- bool update = true );
- bool highlight(const Handle(SALOME_InteractiveObject)& IObject,
- bool hiligth,
- bool immediatly = true );
- void unHighlightSubSelection();
- bool unHighlightAll();
-
- bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject);
- bool isVisible( const Handle(SALOME_InteractiveObject)& IObject);
- void rename(const Handle(SALOME_InteractiveObject)& IObject, QString newName);
-
- void SetSelectionMode(Selection_Mode mode);
- void SetSelectionProp(const double& theRed = 1,
- const double& theGreen = 1,
- const double& theBlue = 0,
- const int& theWidth = 5);
- void SetSelectionTolerance(const double& theTolNodes = 0.025,
- const double& theTolCell = 0.001);
-
- // Displaymode management
- int GetDisplayMode();
- void SetDisplayMode(int);
-
- // Switch representation wireframe/shading
- void SetDisplayMode(const Handle(SALOME_InteractiveObject)& IObject, int theMode);
-
- // Change all actors to wireframe or surface
- void ChangeRepresentationToWireframe();
- void ChangeRepresentationToSurface();
-
- // Change to wireframe or surface a list of vtkactor
- void ChangeRepresentationToWireframe(vtkActorCollection* ListofActors);
- void ChangeRepresentationToSurface(vtkActorCollection* ListofActors);
-
- // Erase Display functions
- void EraseAll();
- void DisplayAll();
- void RemoveAll( const bool immediatly );
- void Erase(const Handle(SALOME_InteractiveObject)& IObject,
- bool immediatly=true);
- void Remove(const Handle(SALOME_InteractiveObject)& IObject,
- bool immediatly=true);
- void Display(const Handle(SALOME_InteractiveObject)& IObject,
- bool immediatly=true);
-
- void Display( SALOME_Actor* SActor,
- bool immediatly = true );
- void Erase( SALOME_Actor* SActor,
- bool immediatly = true );
- void Remove( SALOME_Actor* SActor,
- bool updateViewer = true );
-
- // Transparency
- void SetTransparency(const Handle(SALOME_InteractiveObject)& IObject,
- float trans);
- float GetTransparency(const Handle(SALOME_InteractiveObject)& IObject);
-
- // Color
- void SetColor(const Handle(SALOME_InteractiveObject)& IObject,
- QColor thecolor);
- QColor GetColor(const Handle(SALOME_InteractiveObject)& IObject);
-
- void Update();
-
- vtkRenderer* GetRenderer();
-
- void setGUIWindow(QWidget* theWindow);
-
- void setViewWindow(SVTK_ViewWindow* theViewWindow);
-
- void setCellData(const int& theIndex,
- SALOME_Actor* theMapActor,
- SVTK_Actor* theActor);
- void setEdgeData(const int& theCellIndex,
- SALOME_Actor* theMapActor,
- const int& theEdgeIndex,
- SVTK_Actor* theActor ); //NB
- void setPointData(const int& theIndex,
- SALOME_Actor* theMapActor,
- SVTK_Actor* theActor);
-
- typedef void (*TUpdateActor)(const TColStd_IndexedMapOfInteger& theMapIndex,
- SALOME_Actor* theMapActor,
- SVTK_Actor* theActor);
- protected:
+ Q_OBJECT;
- SVTK_RenderWindowInteractor();
- ~SVTK_RenderWindowInteractor();
+ public:
+ QVTK_RenderWindowInteractor(QWidget* theParent,
+ const char* theName);
+
+ ~QVTK_RenderWindowInteractor();
+
+ //! To initialize by #vtkGenericRenderWindowInteractor instance
+ virtual
+ void
+ Initialize(vtkGenericRenderWindowInteractor* theDevice);
- SVTK_InteractorStyle* myInteractorStyle;
-
- bool highlight(const TColStd_IndexedMapOfInteger& theMapIndex,
- SALOME_Actor* theMapActor,
- SVTK_Actor* theActor,
- TUpdateActor theFun,
- bool hilight,
- bool update);
- void setActorData(const TColStd_IndexedMapOfInteger& theMapIndex,
- SALOME_Actor* theMapActor,
- SVTK_Actor *theActor,
- TUpdateActor theFun);
-
- // Timer used during various mouse events to figure
- // out mouse movements.
- QTimer *mTimer ;
-
- int myDisplayMode;
-
- //NRI: Selection mode
- SVTK_Actor* myPointActor;
- SVTK_Actor* myEdgeActor;
- SVTK_Actor* myCellActor;
- void MoveInternalActors();
-
- vtkPicker* myBasicPicker;
- vtkCellPicker* myCellPicker;
- vtkPointPicker* myPointPicker;
-
- // User for switching to stereo mode.
- int PositionBeforeStereo[2];
+ vtkGenericRenderWindowInteractor*
+ GetDevice();
+
+ vtkRenderWindow*
+ getRenderWindow();
+
+ //! Just to simplify usage of its device (#vtkGenericRenderWindowInteractor)
+ virtual
+ void
+ InvokeEvent(unsigned long theEvent, void* theCallData);
public slots:
- void MouseMove(const QMouseEvent *event) ;
- void LeftButtonPressed(const QMouseEvent *event) ;
- void LeftButtonReleased(const QMouseEvent *event) ;
- void MiddleButtonPressed(const QMouseEvent *event) ;
- void MiddleButtonReleased(const QMouseEvent *event) ;
- void RightButtonPressed(const QMouseEvent *event) ;
- void RightButtonReleased(const QMouseEvent *event) ;
- void ButtonPressed(const QMouseEvent *event) ;
- void ButtonReleased(const QMouseEvent *event) ;
- void KeyPressed(QKeyEvent *event) ;
-
- private slots:
- // Not all of these slots are needed in VTK_MAJOR_VERSION=3,
- // but moc does not understand "#if VTK_MAJOR_VERSION". Hence,
- // we have to include all of these for the time being. Once,
- // this bug in MOC is fixed, we can separate these.
- void TimerFunc() ;
+ //! Need for initial contents display on Win32
+ virtual void show();
+
+ //! To implement final initialization, just before the widget is displayed
+ virtual void polish();
+ //! To adjust widget and vtkRenderWindow size
+ virtual void resize(int w, int h);
+
+ protected:
+ virtual void paintEvent( QPaintEvent* );
+ virtual void resizeEvent( QResizeEvent* );
+
+ virtual void mouseMoveEvent( QMouseEvent* );
+ virtual void mousePressEvent( QMouseEvent* );
+ virtual void mouseReleaseEvent( QMouseEvent* );
+ virtual void mouseDoubleClickEvent( QMouseEvent* );
+ virtual void wheelEvent( QWheelEvent* );
+ virtual void keyPressEvent( QKeyEvent* );
+ virtual void keyReleaseEvent( QKeyEvent* );
+ virtual void enterEvent( QEvent * );
+ virtual void leaveEvent( QEvent * );
+
+ virtual void contextMenuEvent( QContextMenuEvent * e );
+
+ // reimplemented from QWidget in order to set window - receiver
+ // of space mouse events.
+ virtual void focusInEvent( QFocusEvent* );
+ virtual void focusOutEvent( QFocusEvent* );
+
+ //! To handle native X11 events (from such devices as SpaceMouse)
+ virtual bool x11Event( XEvent *e );
+
+ vtkSmartPointer<vtkRenderWindow> myRenderWindow;
+ vtkSmartPointer<vtkGenericRenderWindowInteractor> myDevice;
+};
+
+
+//============================================================================
+//! Extends QVTK_RenderWindowInteractor functionality.
+/*!
+ Implements such features as
+ support of selection,
+ run-time interactor style management,
+ one render window per one renderer collaboration and
+ SUIT_ViewWindow events invocation.
+*/
+class SVTK_EXPORT SVTK_RenderWindowInteractor: public QVTK_RenderWindowInteractor
+{
+ Q_OBJECT;
+
+ public:
+ SVTK_RenderWindowInteractor(QWidget* theParent,
+ const char* theName);
+
+ ~SVTK_RenderWindowInteractor();
+
+ //! To initialize properly the class
+ virtual
+ void
+ Initialize(vtkGenericRenderWindowInteractor* theDevice,
+ SVTK_Renderer* theRenderer,
+ SVTK_Selector* theSelector);
+
+ //----------------------------------------------------------------------------
+ //! To get corresponding SVTK_Renderer instance
+ SVTK_Renderer*
+ GetRenderer();
+
+ //! To get corresponding SVTK_Renderer device (just to simplify collobaration with SVTK_Renderer)
+ vtkRenderer*
+ getRenderer();
+
+ //----------------------------------------------------------------------------
+ //! To get current interactor style
+ vtkInteractorStyle*
+ GetInteractorStyle();
+
+ //! To change current interactor style by pushing the new one into the container
+ void
+ PushInteractorStyle(vtkInteractorStyle* theStyle);
+
+ //! To restore previous interactor style
+ void
+ PopInteractorStyle();
+
+ //----------------------------------------------------------------------------
+ //! To get corresponding SVTK_Selector
+ SVTK_Selector*
+ GetSelector();
+
+ //! To get current selection mode (just to simplify collobaration with SVTK_Selector)
+ Selection_Mode
+ SelectionMode() const;
+
+ //! To change selection mode (just to simplify collobaration with SVTK_Selector)
+ void
+ SetSelectionMode(Selection_Mode theMode);
+
+ public:
+ //! To transform vtkCommand::EndPickEvent to Qt selectionChanged signal
+ void
+ onEmitSelectionChanged();
+
+ public:
signals:
- void RenderWindowModified() ;
+ void MouseMove( QMouseEvent* );
+ void MouseButtonPressed( QMouseEvent* );
+ void MouseButtonReleased( QMouseEvent* );
+ void MouseDoubleClicked( QMouseEvent* );
+ void ButtonPressed(const QMouseEvent *event);
+ void ButtonReleased(const QMouseEvent *event);
+ void WheelMoved( QWheelEvent* );
+ void KeyPressed( QKeyEvent* );
+ void KeyReleased( QKeyEvent* );
void contextMenuRequested( QContextMenuEvent *e );
- private:
- SVTK_ViewWindow* myViewWindow;
- QWidget* myGUIWindow;
- double myTolNodes;
- double myTolItems;
+ void selectionChanged();
+
+ protected:
+ virtual void mouseMoveEvent( QMouseEvent* );
+ virtual void mousePressEvent( QMouseEvent* );
+ virtual void mouseReleaseEvent( QMouseEvent* );
+ virtual void mouseDoubleClickEvent( QMouseEvent* );
+ virtual void wheelEvent( QWheelEvent* );
+ virtual void keyPressEvent( QKeyEvent* );
+ virtual void keyReleaseEvent( QKeyEvent* );
+ virtual void contextMenuEvent( QContextMenuEvent * e );
+
+ void
+ SetRenderer(SVTK_Renderer *theRenderer);
+
+ void
+ SetSelector(SVTK_Selector* theSelector);
+
+ void
+ InitInteractorStyle(vtkInteractorStyle* theStyle);
+
+ //----------------------------------------------------------------
+ // Main process VTK event method
+ static
+ void
+ ProcessEvents(vtkObject* theObject,
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData);
+
+ // Used to process VTK events
+ vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
+
+ // Priority at which events are processed
+ float myPriority;
+
+ //----------------------------------------------------------------
+ vtkSmartPointer<SVTK_Selector> mySelector;
+
+ vtkSmartPointer<SVTK_Renderer> myRenderer;
+
+ typedef vtkSmartPointer<vtkInteractorStyle> PInteractorStyle;
+ typedef std::stack<PInteractorStyle> TInteractorStyles;
+ TInteractorStyles myInteractorStyles;
};
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module :
+// $Header$
+
+#include "SVTK_Renderer.h"
+
+#include "SVTK_Trihedron.h"
+#include "SVTK_CubeAxesActor2D.h"
+#include "VTKViewer_CellRectPicker.h"
+
+#include "SALOME_Actor.h"
+#include "VTKViewer_Actor.h"
+#include "VTKViewer_Transform.h"
+#include "VTKViewer_Utilities.h"
+
+#include <vtkCamera.h>
+#include <vtkRenderer.h>
+#include <vtkTextProperty.h>
+#include <vtkObjectFactory.h>
+#include <vtkCallbackCommand.h>
+
+#include <vtkPicker.h>
+#include <vtkPointPicker.h>
+#include <vtkCellPicker.h>
+
+#include <vtkProperty.h>
+
+// undefining min and max because CASCADE's defines them and
+// it clashes with std::min(), std::max() included in utilities.h
+#undef min
+#undef max
+
+#include "utilities.h"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(SVTK_Renderer);
+
+//----------------------------------------------------------------------------
+SVTK_Renderer
+::SVTK_Renderer():
+ myDevice(vtkRenderer::New()),
+ myInteractor(NULL),
+ myPriority(0.0),
+ myEventCallbackCommand(vtkCallbackCommand::New()),
+ myPointPicker(vtkPointPicker::New()),
+ myCellPicker(vtkCellPicker::New()),
+ myCellRectPicker(VTKViewer_CellRectPicker::New()),
+ myPreHighlightProperty(vtkProperty::New()),
+ myHighlightProperty(vtkProperty::New()),
+ myTransform(VTKViewer_Transform::New()),
+ myCubeAxes(SVTK_CubeAxesActor2D::New()),
+ myTrihedron(SVTK_Trihedron::New()),
+ myTrihedronSize(105)
+{
+ if(MYDEBUG) INFOS("SVTK_Renderer() - "<<this);
+
+ myDevice->Delete();
+ myTransform->Delete();
+
+ SetSelectionTolerance();
+ myPointPicker->Delete();
+ myCellPicker->Delete();
+ myCellRectPicker->Delete();
+
+ //SetPreselectionProp();
+ myPreHighlightProperty->Delete();
+ myPreHighlightProperty->SetColor(0,1,1);
+ myPreHighlightProperty->SetPointSize(SALOME_POINT_SIZE+2);
+ myPreHighlightProperty->SetLineWidth(SALOME_LINE_WIDTH+2);
+ myPreHighlightProperty->SetRepresentationToPoints();
+
+ //SetSelectionProp();
+ myHighlightProperty->Delete();
+ myHighlightProperty->SetColor(1,1,0);
+ myHighlightProperty->SetPointSize(SALOME_POINT_SIZE+2);
+ myHighlightProperty->SetLineWidth(SALOME_LINE_WIDTH+2);
+ myHighlightProperty->SetRepresentationToPoints();
+
+ myTrihedron->Delete();
+ myCubeAxes->Delete();
+ myEventCallbackCommand->Delete();
+
+ myTrihedron->AddToRender(GetDevice());
+ GetDevice()->AddProp(GetCubeAxes());
+
+ myBndBox[0] = myBndBox[2] = myBndBox[4] = 0;
+ myBndBox[1] = myBndBox[3] = myBndBox[5] = myTrihedron->GetSize();
+
+ myCubeAxes->SetBounds(myBndBox);
+ myCubeAxes->SetCamera(GetDevice()->GetActiveCamera());
+
+ myCubeAxes->SetLabelFormat("%6.4g");
+ myCubeAxes->SetFlyModeToOuterEdges(); // ENK remarks: it must bee
+ myCubeAxes->SetFontFactor(0.8);
+ myCubeAxes->SetCornerOffset(0);
+ myCubeAxes->SetScaling(0);
+ myCubeAxes->SetNumberOfLabels(5);
+ myCubeAxes->VisibilityOff();
+ myCubeAxes->SetTransform(GetTransform());
+
+ vtkTextProperty* aTextProp = vtkTextProperty::New();
+ aTextProp->SetColor(1, 1, 1);
+ aTextProp->ShadowOn();
+ myCubeAxes->SetAxisTitleTextProperty(aTextProp);
+ myCubeAxes->SetAxisLabelTextProperty(aTextProp);
+ aTextProp->Delete();
+
+ GetDevice()->GetActiveCamera()->ParallelProjectionOn();
+ GetDevice()->LightFollowCameraOn();
+ GetDevice()->TwoSidedLightingOn();
+
+ myEventCallbackCommand->SetClientData(this);
+ myEventCallbackCommand->SetCallback(SVTK_Renderer::ProcessEvents);
+ GetDevice()->AddObserver(vtkCommand::ConfigureEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+ GetDevice()->AddObserver(vtkCommand::ResetCameraEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+ GetDevice()->AddObserver(vtkCommand::ResetCameraClippingRangeEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+}
+
+SVTK_Renderer
+::~SVTK_Renderer()
+{
+ if(MYDEBUG) INFOS("~SVTK_Renderer() - "<<this);
+ vtkActorCollection* anActors = GetDevice()->GetActors();
+ anActors->InitTraversal();
+ while(vtkActor* anAct = anActors->GetNextActor()){
+ if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct)){
+ RemoveActor(anActor);
+ }
+ }
+}
+
+
+void
+SVTK_Renderer
+::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* vtkNotUsed(theCallData))
+{
+ SVTK_Renderer* self = reinterpret_cast<SVTK_Renderer*>(theClientData);
+
+ switch(theEvent){
+ case vtkCommand::ConfigureEvent:
+ self->OnResetView();
+ break;
+ case vtkCommand::ResetCameraEvent:
+ self->OnFitAll();
+ break;
+ case vtkCommand::ResetCameraClippingRangeEvent:
+ self->OnResetClippingRange();
+ break;
+ }
+}
+
+//----------------------------------------------------------------------------
+vtkRenderer*
+SVTK_Renderer
+::GetDevice()
+{
+ return myDevice.GetPointer();
+}
+
+void
+SVTK_Renderer
+::Initialize(vtkRenderWindowInteractor* theInteractor,
+ SVTK_Selector* theSelector)
+{
+ myInteractor = theInteractor;
+ mySelector = theSelector;
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_Renderer
+::AddActor(VTKViewer_Actor* theActor)
+{
+ if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theActor)){
+ anActor->SetInteractor(myInteractor);
+ anActor->SetTransform(GetTransform());
+ anActor->SetSelector(mySelector.GetPointer());
+
+ anActor->SetPointPicker(myPointPicker.GetPointer());
+ anActor->SetCellPicker(myCellPicker.GetPointer());
+ anActor->SetCellRectPicker(myCellRectPicker.GetPointer());
+
+ anActor->SetPreHighlightProperty(myPreHighlightProperty.GetPointer());
+ anActor->SetHighlightProperty(myHighlightProperty.GetPointer());
+
+ anActor->AddToRender(GetDevice());
+ AdjustActors();
+ }
+}
+
+void
+SVTK_Renderer
+::RemoveActor(VTKViewer_Actor* theActor)
+{
+ if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theActor)){
+ // Order of the calls are important because VTKViewer_Actor::RemoveFromRender
+ // can leads do destruction of the actor
+ anActor->SetInteractor(NULL);
+ anActor->SetTransform(NULL);
+ anActor->SetSelector(NULL);
+
+ anActor->SetPointPicker(NULL);
+ anActor->SetCellPicker(NULL);
+ anActor->SetCellRectPicker(NULL);
+
+ anActor->SetPreHighlightProperty(NULL);
+ anActor->SetHighlightProperty(NULL);
+
+ anActor->RemoveFromRender(GetDevice());
+ AdjustActors();
+ }
+}
+
+VTKViewer_Transform*
+SVTK_Renderer
+::GetTransform()
+{
+ return myTransform.GetPointer();
+}
+
+void
+SVTK_Renderer
+::GetScale( double theScale[3] )
+{
+ myTransform->GetMatrixScale( theScale );
+}
+
+void
+SVTK_Renderer
+::SetScale( double theScale[3] )
+{
+ myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
+ AdjustActors();
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Renderer
+::SetSelectionProp(const double& theRed,
+ const double& theGreen,
+ const double& theBlue,
+ const int& theWidth)
+{
+ myHighlightProperty->SetColor( theRed, theGreen, theBlue );
+ myHighlightProperty->SetLineWidth( theWidth );
+ myHighlightProperty->SetPointSize( theWidth );
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_Renderer
+::SetPreselectionProp(const double& theRed,
+ const double& theGreen,
+ const double& theBlue,
+ const int& theWidth)
+{
+ myPreHighlightProperty->SetColor( theRed, theGreen, theBlue );
+ myPreHighlightProperty->SetLineWidth( theWidth );
+ myPreHighlightProperty->SetPointSize( theWidth );
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_Renderer
+::SetSelectionTolerance(const double& theTolNodes,
+ const double& theTolCell)
+{
+ myPointPicker->SetTolerance( theTolNodes );
+ myCellPicker->SetTolerance( theTolCell );
+ myCellRectPicker->SetTolerance( theTolCell );
+}
+
+
+//----------------------------------------------------------------------------
+/*! If parameter theIsForcedUpdate is true, recalculate parameters for
+ * trihedron and cube axes, even if trihedron and cube axes is invisible.
+ */
+
+inline
+bool
+CheckBndBox(const float theBounds[6])
+{
+ if(theBounds[0] > -VTK_LARGE_FLOAT && theBounds[1] < VTK_LARGE_FLOAT &&
+ theBounds[2] > -VTK_LARGE_FLOAT && theBounds[3] < VTK_LARGE_FLOAT &&
+ theBounds[4] > -VTK_LARGE_FLOAT && theBounds[5] < VTK_LARGE_FLOAT)
+ return true;
+ return false;
+}
+
+bool
+SVTK_Renderer
+::OnAdjustActors()
+{
+ bool aTDisplayed = IsTrihedronDisplayed();
+ bool aCDisplayed = IsCubeAxesDisplayed();
+
+ float aNewBndBox[6];
+ aNewBndBox[ 0 ] = aNewBndBox[ 2 ] = aNewBndBox[ 4 ] = VTK_LARGE_FLOAT;
+ aNewBndBox[ 1 ] = aNewBndBox[ 3 ] = aNewBndBox[ 5 ] = -VTK_LARGE_FLOAT;
+
+ int aVisibleNum = myTrihedron->GetVisibleActorCount(GetDevice());
+ if(aVisibleNum){
+ if(aTDisplayed)
+ myTrihedron->VisibilityOff();
+
+ if(aCDisplayed)
+ myCubeAxes->VisibilityOff();
+
+ // if the new trihedron size have sufficient difference, then apply the value
+ double aSize = myTrihedron->GetSize();
+ ComputeTrihedronSize(GetDevice(),aSize,aSize,myTrihedronSize);
+ myTrihedron->SetSize(aSize);
+
+ // iterate through displayed objects and set size if necessary
+ vtkActorCollection* anActors = GetDevice()->GetActors();
+ anActors->InitTraversal();
+ while(vtkActor* anAct = anActors->GetNextActor()){
+ if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct)){
+ if(anActor->IsResizable())
+ anActor->SetSize(0.5*aSize);
+ if(anActor->GetVisibility() && !anActor->IsInfinitive()){
+ float *aBounds = anActor->GetBounds();
+ if(CheckBndBox(aBounds))
+ for(int i = 0; i < 5; i = i + 2){
+ if(aBounds[i] < aNewBndBox[i])
+ aNewBndBox[i] = aBounds[i];
+ if(aBounds[i+1] > aNewBndBox[i+1])
+ aNewBndBox[i+1] = aBounds[i+1];
+ }
+ }
+ }
+ }
+
+ if(aTDisplayed)
+ myTrihedron->VisibilityOn();
+
+ if(aCDisplayed)
+ myCubeAxes->VisibilityOn();
+
+ }else{
+ double aSize = myTrihedron->GetSize();
+ aNewBndBox[0] = aNewBndBox[2] = aNewBndBox[4] = 0;
+ aNewBndBox[1] = aNewBndBox[3] = aNewBndBox[5] = aSize;
+ }
+
+ if(CheckBndBox(aNewBndBox)){
+ for(int i = 0; i < 6; i++)
+ myBndBox[i] = aNewBndBox[i];
+ myCubeAxes->SetBounds(myBndBox);
+ return true;
+ }
+
+ return false;
+}
+
+void
+SVTK_Renderer
+::AdjustActors()
+{
+ if(OnAdjustActors())
+ ::ResetCameraClippingRange(GetDevice());
+}
+
+void
+SVTK_Renderer
+::SetTrihedronSize(int theSize)
+{
+ if(myTrihedronSize != theSize){
+ myTrihedronSize = theSize;
+ AdjustActors();
+ }
+}
+
+int
+SVTK_Renderer
+::GetTrihedronSize() const
+{
+ return myTrihedronSize;
+}
+
+
+//----------------------------------------------------------------------------
+VTKViewer_Trihedron*
+SVTK_Renderer
+::GetTrihedron()
+{
+ return myTrihedron.GetPointer();
+}
+
+bool
+SVTK_Renderer
+::IsTrihedronDisplayed()
+{
+ return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
+}
+
+void
+SVTK_Renderer
+::OnViewTrihedron()
+{
+ if(IsTrihedronDisplayed())
+ myTrihedron->VisibilityOff();
+ else
+ myTrihedron->VisibilityOn();
+}
+
+void
+SVTK_Renderer
+::OnAdjustTrihedron()
+{
+ AdjustActors();
+}
+
+
+//----------------------------------------------------------------------------
+SVTK_CubeAxesActor2D*
+SVTK_Renderer
+::GetCubeAxes()
+{
+ return myCubeAxes.GetPointer();
+}
+
+bool
+SVTK_Renderer
+::IsCubeAxesDisplayed()
+{
+ return myCubeAxes->GetVisibility() == 1;
+}
+
+void
+SVTK_Renderer
+::OnViewCubeAxes()
+{
+ if(IsCubeAxesDisplayed())
+ myCubeAxes->VisibilityOff();
+ else
+ myCubeAxes->VisibilityOn();
+}
+
+void
+SVTK_Renderer
+::OnAdjustCubeAxes()
+{
+ AdjustActors();
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Renderer
+::OnResetView()
+{
+ int aTrihedronIsVisible = IsTrihedronDisplayed();
+ int aCubeAxesIsVisible = IsCubeAxesDisplayed();
+
+ myTrihedron->SetVisibility( VTKViewer_Trihedron::eOnlyLineOn );
+ myCubeAxes->SetVisibility(0);
+
+ ::ResetCamera(GetDevice(),true);
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
+ aCamera->SetPosition(1,-1,1);
+ aCamera->SetViewUp(0,0,1);
+ ::ResetCamera(GetDevice(),true);
+
+ if(aTrihedronIsVisible)
+ myTrihedron->VisibilityOn();
+ else
+ myTrihedron->VisibilityOff();
+
+ if(aCubeAxesIsVisible)
+ myCubeAxes->VisibilityOn();
+ else
+ myCubeAxes->VisibilityOff();
+
+ static float aCoeff = 3.0;
+ aCamera->SetParallelScale(aCoeff*aCamera->GetParallelScale());
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Renderer
+::OnFitAll()
+{
+ int aTrihedronWasVisible = false;
+ int aCubeAxesWasVisible = false;
+
+ aTrihedronWasVisible = IsTrihedronDisplayed();
+ if(aTrihedronWasVisible)
+ myTrihedron->VisibilityOff();
+
+ aCubeAxesWasVisible = IsCubeAxesDisplayed();
+ if(aCubeAxesWasVisible)
+ myCubeAxes->VisibilityOff();
+
+ if(myTrihedron->GetVisibleActorCount(GetDevice())){
+ myTrihedron->VisibilityOff();
+ myCubeAxes->VisibilityOff();
+ ::ResetCamera(GetDevice());
+ }else{
+ myTrihedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
+ myCubeAxes->SetVisibility(2);
+ ::ResetCamera(GetDevice(),true);
+ }
+
+ if(aTrihedronWasVisible)
+ myTrihedron->VisibilityOn();
+ else
+ myTrihedron->VisibilityOff();
+
+ if(aCubeAxesWasVisible)
+ myCubeAxes->VisibilityOn();
+ else
+ myCubeAxes->VisibilityOff();
+
+ ::ResetCameraClippingRange(GetDevice());
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Renderer
+::OnResetClippingRange()
+{
+ return;
+ ::ResetCameraClippingRange(GetDevice());
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Renderer
+::OnFrontView()
+{
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
+ aCamera->SetPosition(1,0,0);
+ aCamera->SetViewUp(0,0,1);
+ aCamera->SetFocalPoint(0,0,0);
+ this->OnFitAll();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_Renderer
+::OnBackView()
+{
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
+ aCamera->SetPosition(-1,0,0);
+ aCamera->SetViewUp(0,0,1);
+ aCamera->SetFocalPoint(0,0,0);
+ this->OnFitAll();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_Renderer
+::OnTopView()
+{
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
+ aCamera->SetPosition(0,0,1);
+ aCamera->SetViewUp(0,1,0);
+ aCamera->SetFocalPoint(0,0,0);
+ this->OnFitAll();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_Renderer
+::OnBottomView()
+{
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
+ aCamera->SetPosition(0,0,-1);
+ aCamera->SetViewUp(0,1,0);
+ aCamera->SetFocalPoint(0,0,0);
+ this->OnFitAll();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_Renderer
+::OnLeftView()
+{
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
+ aCamera->SetPosition(0,-1,0);
+ aCamera->SetViewUp(0,0,1);
+ aCamera->SetFocalPoint(0,0,0);
+ this->OnFitAll();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_Renderer
+::OnRightView()
+{
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
+ aCamera->SetPosition(0,1,0);
+ aCamera->SetViewUp(0,0,1);
+ aCamera->SetFocalPoint(0,0,0);
+ this->OnFitAll();
+}
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+
+#ifndef SVTK_Renderer_h
+#define SVTK_Renderer_h
+
+#include "SVTK.h"
+
+#include <vtkObject.h>
+#include <vtkSmartPointer.h>
+
+class vtkRenderer;
+class vtkCallbackCommand;
+class vtkRenderWindowInteractor;
+
+class vtkPicker;
+class vtkPointPicker;
+class vtkCellPicker;
+class vtkProperty;
+
+class VTKViewer_CellRectPicker;
+
+class VTKViewer_Trihedron;
+class VTKViewer_Transform;
+class SVTK_CubeAxesActor2D;
+class VTKViewer_Actor;
+class SVTK_Selector;
+
+
+//! The class is a container for #vtkRenderer instance.
+/*!
+ Main goal of the class is to apply common behaviour to all #SALOME_Actor, like
+ selection and preselection colors.
+ Also, the class is responsible for management of internal actors like trihedron an so on.
+ */
+//============================================================================
+class SVTK_EXPORT SVTK_Renderer : public vtkObject
+{
+ public:
+ vtkTypeMacro(SVTK_Renderer,vtkObject);
+ static SVTK_Renderer* New();
+
+ //----------------------------------------------------------------------------
+ //! Get its device
+ vtkRenderer*
+ GetDevice();
+
+ //! Initialize the class
+ virtual
+ void
+ Initialize(vtkRenderWindowInteractor* theInteractor,
+ SVTK_Selector* theSelector);
+
+ //----------------------------------------------------------------------------
+ //! This method publishes pointed actor into the renderer
+ virtual
+ void
+ AddActor(VTKViewer_Actor* theActor);
+
+ //! This method removes pointed actor from the renderer
+ virtual
+ void
+ RemoveActor(VTKViewer_Actor* theActor);
+
+ //! Get special container that keeps scaling of the scene
+ VTKViewer_Transform*
+ GetTransform();
+
+ //! This method allow to apply a scale on the whole scene
+ virtual
+ void
+ SetScale( double theScale[3] );
+
+ //! This method allow to get a scale that is applied on the whole scene
+ void
+ GetScale( double theScale[3] );
+
+ //----------------------------------------------------------------------------
+ //! Applies color and size (PointSize and LineWidth) of primitives in selection mode
+ void
+ SetSelectionProp(const double& theRed = 1,
+ const double& theGreen = 1,
+ const double& theBlue = 0,
+ const int& theWidth = 5);
+
+ //! Applies color and size (PointSize and LineWidth) of primitives in preselection mode
+ void
+ SetPreselectionProp(const double& theRed = 0,
+ const double& theGreen = 1,
+ const double& theBlue = 1,
+ const int& theWidth = 5);
+
+ //! Setup requested tollerance for the picking
+ void
+ SetSelectionTolerance(const double& theTolNodes = 0.025,
+ const double& theTolCell = 0.001);
+
+ //----------------------------------------------------------------------------
+ //! Adjust all intenal actors (trihedron and graduated rules) to the scene
+ void
+ AdjustActors();
+
+ //! Set size of the trihedron in percents from bounding box of the scene
+ void
+ SetTrihedronSize(int theSize);
+
+ //! Get size of the trihedron in percents from bounding box of the scene
+ int
+ GetTrihedronSize() const;
+
+ //----------------------------------------------------------------------------
+ //! Get trihedron control
+ VTKViewer_Trihedron*
+ GetTrihedron();
+
+ //! Is trihedron displayed
+ bool
+ IsTrihedronDisplayed();
+
+ //! Toggle trihedron visibility
+ void
+ OnViewTrihedron();
+
+ //! Adjust size of the trihedron to the bounding box of the scene
+ void
+ OnAdjustTrihedron();
+
+ //----------------------------------------------------------------------------
+ //! Get graduated rules control
+ SVTK_CubeAxesActor2D*
+ GetCubeAxes();
+
+ //! Is graduated rules displayed
+ bool
+ IsCubeAxesDisplayed();
+
+ //! Toggle graduated rules visibility
+ void
+ OnViewCubeAxes();
+
+ //! Adjust size of the graduated rules to the bounding box of the scene
+ void
+ OnAdjustCubeAxes();
+
+ //----------------------------------------------------------------------------
+ //! Fit all presentation in the scene into the window
+ void OnFitAll();
+
+ //! Set camera into predefined state
+ void OnResetView();
+
+ //! Reset camera clipping range to adjust the range to the bounding box of the scene
+ void OnResetClippingRange();
+
+ //! To reset direction of the camera to front view
+ void OnFrontView();
+
+ //! To reset direction of the camera to back view
+ void OnBackView();
+
+ //! To reset direction of the camera to top view
+ void OnTopView();
+
+ //! To reset direction of the camera to bottom view
+ void OnBottomView();
+
+ //! To reset direction of the camera to right view
+ void OnRightView();
+
+ //! To reset direction of the camera to left view
+ void OnLeftView();
+
+ protected:
+ SVTK_Renderer();
+ ~SVTK_Renderer();
+
+ virtual
+ bool
+ OnAdjustActors();
+
+ //----------------------------------------------------------------------------
+ // Priority at which events are processed
+ float myPriority;
+
+ // Used to process events
+ vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
+
+ // Description:
+ // Main process event method
+ static void ProcessEvents(vtkObject* object,
+ unsigned long event,
+ void* clientdata,
+ void* calldata);
+
+ vtkSmartPointer<vtkRenderer> myDevice;
+ vtkRenderWindowInteractor* myInteractor;
+ vtkSmartPointer<SVTK_Selector> mySelector;
+
+ //----------------------------------------------------------------------------
+ vtkSmartPointer<VTKViewer_Transform> myTransform;
+
+ //----------------------------------------------------------------------------
+ // Highlight/ Prehighlight devices
+ vtkSmartPointer<vtkPointPicker> myPointPicker;
+ vtkSmartPointer<vtkCellPicker> myCellPicker;
+ vtkSmartPointer<VTKViewer_CellRectPicker> myCellRectPicker;
+
+ vtkSmartPointer<vtkProperty> myPreHighlightProperty;
+ vtkSmartPointer<vtkProperty> myHighlightProperty;
+
+ //----------------------------------------------------------------------------
+ vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
+ vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;
+ int myTrihedronSize;
+ float myBndBox[6];
+};
+
+#endif
#define SVTK_SELECTION_H
-enum Selection_Mode
-{
- NodeSelection,
- CellSelection,
- EdgeOfCellSelection,
- EdgeSelection,
- FaceSelection,
- VolumeSelection,
- ActorSelection
-};
+//! It is possible to introduce new type of selection
+typedef int Selection_Mode;
+
+const Selection_Mode NodeSelection = 0;
+const Selection_Mode CellSelection = 1;
+const Selection_Mode EdgeOfCellSelection = 2;
+const Selection_Mode EdgeSelection = 3;
+const Selection_Mode FaceSelection = 4;
+const Selection_Mode VolumeSelection = 5;
+const Selection_Mode ActorSelection = 6;
#endif
--- /dev/null
+// SALOME SALOMEGUI : implementation of desktop and GUI kernel
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SVTK_SelectionEvent.h
+// Author :
+// Module : SALOME
+// $Header$
+
+#ifndef SVTK_SELECTIONEVENT_H
+#define SVTK_SELECTIONEVENT_H
+
+#include "SVTK_Selection.h"
+
+//! The structure is used for passing all infromation necessary for claculation of the selection.
+/*!
+ The SVTK_SelectionEvent is generated by #SVTK_InteractorStyle.
+ In its turn the #SVTK_InteractorStyle uses for it generation #vtkRenderWindowInteractor and
+ #SVTK_Selector instances.
+ */
+struct SVTK_SelectionEvent
+{
+ //! Through usage of the parameter any new type of selection can be introduced
+ Selection_Mode mySelectionMode;
+ int myX; //!< Current X position of the mouse
+ int myY; //!< Current Y position of the mouse
+ int myLastX; //!< Last X position of the mouse before starting any complex operation (like rectangle selection)
+ int myLastY; //!< Last Y position of the mouse before starting any complex operation
+ bool myIsRectangle; //!< A flag to define is it necessary provide rectangle selection for current #Selection_Mode
+ bool myIsCtrl; //!< Is Ctrl key are pressed
+ bool myIsShift; //!< Is Shift key are pressed
+ int myKeyCode; //!< Code of the pressed key
+ int myRepeatCount; //!< Number of repetion of the key pressing
+};
+
+#endif
// $Header$
+#include "SVTK_SelectorDef.h"
+
+#include "SALOME_Actor.h"
+
+#include "utilities.h"
+
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
+#include <vtkCallbackCommand.h>
-#include "SALOME_Actor.h"
-#include "SVTK_ViewModel.h"
-#include "SVTK_ViewWindow.h"
-
-#include "SVTK_SelectorDef.h"
+SVTK_Selector*
+SVTK_Selector
+::New()
+{
+ return new SVTK_SelectorDef();
+}
+//----------------------------------------------------------------------------
SVTK_SelectorDef
::SVTK_SelectorDef()
{
+ mySelectionMode = ActorSelection;
}
SVTK_SelectorDef
{
}
+//----------------------------------------------------------------------------
+void
+SVTK_SelectorDef
+::StartPickCallback()
+{
+ this->InvokeEvent(vtkCommand::StartPickEvent,NULL);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_SelectorDef
+::EndPickCallback()
+{
+ this->InvokeEvent(vtkCommand::EndPickEvent,NULL);
+}
+
+//----------------------------------------------------------------------------
void
SVTK_SelectorDef
::SetSelectionMode(Selection_Mode theMode)
{
- mySelectionMode = theMode;
+ if(mySelectionMode != theMode){
+ mySelectionMode = theMode;
+ myMapIOSubIndex.clear();
+ this->EndPickCallback();
+ }
}
void
SVTK_SelectorDef
::IsSelected(const Handle(SALOME_InteractiveObject)& theIO) const
{
- return myIObjects.find(theIO) != myIObjects.end();
+ return !theIO.IsNull() && (myIObjects.find(theIO) != myIObjects.end());
}
bool
{
myMapIOSubIndex.clear();
}
+
+//----------------------------------------------------------------------------
+void
+SVTK_SelectorDef
+::SetFilter(const Handle(VTKViewer_Filter)& theFilter)
+{
+ myFilters.insert(TFilters::value_type(theFilter->GetId(),theFilter));
+}
+
+//----------------------------------------------------------------------------
+bool
+SVTK_SelectorDef
+::IsFilterPresent(const TFilterID theId) const
+{
+ return myFilters.find(theId) != myFilters.end();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_SelectorDef
+::RemoveFilter(const TFilterID theId)
+{
+ if(IsFilterPresent(theId))
+ myFilters.erase(theId);
+}
+
+//----------------------------------------------------------------------------
+bool
+SVTK_SelectorDef
+::IsValid(SALOME_Actor* theActor,
+ const TFilterID theId,
+ const bool theIsNode) const
+{
+ TFilters::const_iterator anIter = myFilters.begin();
+ for(; anIter != myFilters.end(); ++anIter){
+ const Handle(VTKViewer_Filter)& aFilter = anIter->second;
+ if(theIsNode == aFilter->IsNodeFilter() &&
+ !aFilter->IsValid(theActor,theId))
+ return false;
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------------
+Handle(VTKViewer_Filter)
+SVTK_SelectorDef
+::GetFilter(const TFilterID theId) const
+{
+ TFilters::const_iterator anIter = myFilters.find(theId);
+ if(anIter != myFilters.end()){
+ const Handle(VTKViewer_Filter)& aFilter = anIter->second;
+ return aFilter;
+ }
+ return Handle(VTKViewer_Filter)();
+}
+
#ifndef SVTK_SELECTOR_H
#define SVTK_SELECTOR_H
+#include "SVTK_Selection.h"
+#include "SALOME_ListIO.hxx"
+#include "VTKViewer_Filter.h"
+#include "SALOME_InteractiveObject.hxx"
+
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
-#include "SVTK_Selection.h"
-#include "SALOME_ListIO.hxx"
+#include <vtkObject.h>
class SALOME_Actor;
-class SVTK_Selector
+//! Define an abstract interface for selection in SVTK package
+/*!
+ The class implements selection functionality through storing corresponding
+ references to #SALOME_InteractiveObject. For implementation of subselection
+ modes it keeps a corresponding map of sub indexes.
+ \note
+ Also, for each #SALOME_InteractiveObject it tries to keep corresponding refenrence to #SALOME_Actor
+ */
+class SVTK_Selector: public vtkObject
{
public:
- virtual ~SVTK_Selector() {};
+ static SVTK_Selector* New();
+
+ vtkTypeMacro(SVTK_Selector,vtkObject);
+ //! To change current Selection_Mode (as outside effect, it invokes selectionChange signal)
virtual
void
- SetSelectionMode( Selection_Mode theMode ) = 0;
+ SetSelectionMode(Selection_Mode theMode) = 0;
+ //! Get current Selection_Mode
virtual
Selection_Mode
SelectionMode() const = 0;
+ //! Clear selection
virtual
void
ClearIObjects() = 0;
+ //! Try to find corresponding #SALOME_Actor for given reference on #SALOME_InteractiveObject
virtual
SALOME_Actor*
GetActor(const Handle(SALOME_InteractiveObject)& theIO) const = 0;
+ //! Check, is the #SALOME_InteractiveObject is present into selection
virtual
bool
IsSelected(const Handle(SALOME_InteractiveObject)& theIO) const = 0;
+ //! Check, is the #SALOME_Actor is present into selection
virtual
bool
IsSelected(SALOME_Actor* theActor) const = 0;
+ //! Modify the selection by adding new reference on #SALOME_InteractiveObject
virtual
bool
AddIObject(const Handle(SALOME_InteractiveObject)& theIO) = 0;
+ //! Modify the selection by adding new reference on #SALOME_Actor
virtual
bool
AddIObject(SALOME_Actor* theActor) = 0;
+ //! Modify the selection by removing a reference on #SALOME_InteractiveObject
virtual
bool
RemoveIObject(const Handle(SALOME_InteractiveObject)& theIO) = 0;
+ //! Modify the selection by removing a reference on #SALOME_Actor
virtual
bool
RemoveIObject(SALOME_Actor* theActor) = 0;
+ //! Get all #SALOME_InteractiveObject references that is present into selection
virtual
const SALOME_ListIO&
StoredIObjects() const = 0;
+ //! Get number of selected objects
virtual
int
IObjectCount() const = 0;
+ //! Check, if the #SALOME_InteractiveObject has a subselection
virtual
bool
HasIndex(const Handle(SALOME_InteractiveObject)& theIO ) const = 0;
+ //! Get indexes of subslection for given #SALOME_InteractiveObject
virtual
void
GetIndex( const Handle(SALOME_InteractiveObject)& theIO,
TColStd_IndexedMapOfInteger& theIndex ) = 0;
+ //! Change indexes of subslection for given #SALOME_InteractiveObject
virtual
bool
AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
const TColStd_IndexedMapOfInteger& theIndices,
bool theIsModeShift) = 0;
+
+ //! Change indexes of subslection for given #SALOME_InteractiveObject
virtual
bool
AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
const TColStd_MapOfInteger& theIndices,
bool theIsModeShift) = 0;
+
+ //! Change index of subslection for given #SALOME_InteractiveObject
virtual
bool
AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
int theIndex,
bool theIsModeShift) = 0;
+
+ //! Change index of subslection for given #SALOME_InteractiveObject
virtual
void
RemoveIndex( const Handle(SALOME_InteractiveObject)& theIO,
int theIndex) = 0;
+
+ //! Check, if the given index is present in subslection
virtual
bool
IsIndexSelected(const Handle(SALOME_InteractiveObject)& theIO,
int theIndex) const = 0;
+
+ //! Clear subselection
virtual
void
ClearIndex() = 0;
+
+ //----------------------------------------------------------------------------
+ typedef int TFilterID;
+
+ //! To apply a filter on the selection
+ virtual
+ void
+ SetFilter(const Handle(VTKViewer_Filter)& theFilter) = 0;
+
+ //! To get a section filter by its number
+ virtual
+ Handle(VTKViewer_Filter)
+ GetFilter(const TFilterID theId) const = 0;
+
+ //! Check, if a filter with given number is applyed
+ virtual
+ bool
+ IsFilterPresent(const TFilterID theId) const = 0;
+
+ //! To remove a filter from the selection
+ virtual
+ void
+ RemoveFilter(const TFilterID theId) = 0;
+
+ //! Check, if the index satisfy to the installed filters
+ virtual
+ bool
+ IsValid(SALOME_Actor* theActor,
+ const int theId,
+ const bool theIsNode = false) const = 0;
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ StartPickCallback() = 0;
+
+ //! To invoke selectionChanged signals
+ virtual
+ void
+ EndPickCallback() = 0;
};
virtual
void
- SetSelectionMode( Selection_Mode theMode );
+ SetSelectionMode(Selection_Mode theMode);
virtual
Selection_Mode
void
ClearIndex();
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetFilter(const Handle(VTKViewer_Filter)& theFilter);
+
+ virtual
+ Handle(VTKViewer_Filter)
+ GetFilter(const TFilterID theId) const;
+
+ virtual
+ bool
+ IsFilterPresent(const TFilterID theId) const;
+
+ virtual
+ void
+ RemoveFilter(const int theId);
+
+ virtual
+ bool
+ IsValid(SALOME_Actor* theActor,
+ const TFilterID theId,
+ const bool theIsNode = false) const;
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ StartPickCallback();
+
+ virtual
+ void
+ EndPickCallback();
+
private:
- Selection_Mode mySelectionMode;
+ int mySelectionMode;
struct TIOLessThan
{
}
};
- struct TIndexedMapOfInteger{
+ struct TIndexedMapOfInteger
+ {
TColStd_IndexedMapOfInteger myMap;
TIndexedMapOfInteger()
{}
TIndexedMapOfInteger,
TIOLessThan> TMapIOSubIndex;
TMapIOSubIndex myMapIOSubIndex;
-};
+ typedef std::map<TFilterID,Handle(VTKViewer_Filter)> TFilters;
+ TFilters myFilters;
+};
#endif
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SVTK_SpaceMouse.cxx
+// Author : Alexander SLADKOV
+// Module : SALOME
+// $Header$
+
+#include <string.h>
+#include <math.h>
+#include <stdio.h>
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/keysym.h>
+
+#include "SVTK_SpaceMouse.h"
+
+//---------------------------------------------
+SVTK_SpaceMouse* SVTK_SpaceMouse::myInstance = 0;
+
+//---------------------------------------------
+SVTK_SpaceMouse* SVTK_SpaceMouse::getInstance()
+{
+ if ( !myInstance )
+ myInstance = new SVTK_SpaceMouse();
+ return myInstance;
+}
+
+//---------------------------------------------
+SVTK_SpaceMouse::SVTK_SpaceMouse()
+{
+ win = InputFocus;
+ spaceMouseOn = 0;
+}
+
+//---------------------------------------------
+int SVTK_SpaceMouse::initialize( Display *display, Window window )
+{
+ XMotionEvent = XInternAtom( display, "MotionEvent", 1 );
+ XButtonPressEvent = XInternAtom( display, "ButtonPressEvent", 1 );
+ XButtonReleaseEvent = XInternAtom( display, "ButtonReleaseEvent", 1 );
+ XCommandEvent = XInternAtom( display, "CommandEvent", 1 );
+
+ spaceMouseOn = (XMotionEvent != 0) &&
+ (XButtonPressEvent != 0) &&
+ (XButtonReleaseEvent != 0) &&
+ (XCommandEvent != 0);
+ if ( !spaceMouseOn )
+ return 0;
+
+ spaceMouseOn = setWindow( display, window );
+ if ( !spaceMouseOn )
+ return 0;
+
+ return spaceMouseOn;
+}
+
+//---------------------------------------------
+static int errorCallback( Display *display, XErrorEvent *Error )
+{
+ char msg[ 128 ];
+ if ( Error->error_code != BadWindow ) {
+ XGetErrorText( display,Error->error_code,msg,sizeof( msg ) );
+ fprintf( stderr, "SpaceMouse reported error = %s. Exit ... \n", msg );
+ }
+ return 0;
+}
+
+//---------------------------------------------
+int SVTK_SpaceMouse::setWindow( Display *display, Window window )
+{
+ XTextProperty winName;
+ XEvent xEvent;
+ Atom type;
+ int format;
+ unsigned long NItems, BytesReturn;
+ unsigned char *PropReturn;
+ Window root;
+ int result;
+ int (*errorHandler)(Display *,XErrorEvent *);
+
+ result = 1;
+ errorHandler = XSetErrorHandler( errorCallback );
+
+ root = RootWindow( display, DefaultScreen(display) );
+
+ PropReturn = NULL;
+ XGetWindowProperty( display, root, XCommandEvent, 0,1, 0,
+ AnyPropertyType, &type, &format, &NItems,
+ &BytesReturn, &PropReturn );
+
+ win = InputFocus;
+ if ( PropReturn != NULL ) {
+ win = *(Window *) PropReturn;
+ XFree( PropReturn );
+ }
+ else
+ return result = 0;
+
+ if ( XGetWMName( display, win, &winName ) == 0 )
+ return result = 0;
+
+ if ( strcmp( (char *) "Magellan Window", (char *) winName.value) != 0 )
+ return result = 0;
+
+ xEvent.type = ClientMessage;
+ xEvent.xclient.format = 16;
+ xEvent.xclient.send_event = 0;
+ xEvent.xclient.display = display;
+ xEvent.xclient.window = win;
+ xEvent.xclient.message_type = XCommandEvent;
+
+ xEvent.xclient.data.s[0] = (short) ((window>>16)&0x0000FFFF);
+ xEvent.xclient.data.s[1] = (short) (window&0x0000FFFF);
+ xEvent.xclient.data.s[2] = 27695;
+
+ if ( XSendEvent( display, win, 0, 0x0000, &xEvent ) == 0 )
+ return result = 0;
+
+ XFlush( display );
+
+ XSetErrorHandler( errorHandler );
+ return result;
+}
+
+//---------------------------------------------
+int SVTK_SpaceMouse::close(Display *display)
+{
+ initialize( display, (Window)InputFocus );
+ spaceMouseOn = 0;
+
+ return 1;
+}
+
+//---------------------------------------------
+int SVTK_SpaceMouse::translateEvent( Display* display, XEvent* xEvent, MoveEvent* spaceMouseEvent,
+ double scale, double rScale )
+{
+ if ( !spaceMouseOn )
+ return 0;
+
+ if ( xEvent->type == ClientMessage ) {
+ if ( xEvent->xclient.message_type == XMotionEvent ) {
+ spaceMouseEvent->type = SpaceMouseMove;
+ spaceMouseEvent->data[ x ] =
+ xEvent->xclient.data.s[2] * scale;
+ spaceMouseEvent->data[ y ] =
+ xEvent->xclient.data.s[3] * scale;
+ spaceMouseEvent->data[ z ] =
+ xEvent->xclient.data.s[4] * scale;
+ spaceMouseEvent->data[ a ] =
+ xEvent->xclient.data.s[5] * rScale;
+ spaceMouseEvent->data[ b ] =
+ xEvent->xclient.data.s[6] * rScale;
+ spaceMouseEvent->data[ c ] =
+ xEvent->xclient.data.s[7] * rScale;
+ spaceMouseEvent->period = xEvent->xclient.data.s[8];
+ return 1;
+ }
+ else if ( xEvent->xclient.message_type == XButtonPressEvent ) {
+ spaceMouseEvent->type = SpaceButtonPress;
+ spaceMouseEvent->button = xEvent->xclient.data.s[2];
+ return 2;
+ }
+ else if ( xEvent->xclient.message_type == XButtonReleaseEvent ) {
+ spaceMouseEvent->type = SpaceButtonRelease;
+ spaceMouseEvent->button = xEvent->xclient.data.s[2];
+ return 3;
+ }
+ }
+ return (!display);
+}
+
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SVTK_SpaceMouse.h
+// Author : Alexander SLADKOV
+// Module : SALOME
+// $Header$
+
+#ifndef SVTK_SpaceMouse_h
+#define SVTK_SpaceMouse_h
+
+extern "C"
+{
+#include <X11/X.h>
+#include <X11/Xlib.h>
+}
+
+class SVTK_SpaceMouse
+{
+ public:
+
+ // access to SpaceMouse utility class
+ static SVTK_SpaceMouse* getInstance();
+
+ enum MoveData { x, y, z, a, b, c };
+ enum EventType { SpaceMouseMove = 1, SpaceButtonPress, SpaceButtonRelease };
+
+ typedef struct {
+ int type;
+ int button;
+ double data[6];
+ int period;
+ } MoveEvent;
+
+ bool isSpaceMouseOn() const { return spaceMouseOn != 0; }
+
+ int initialize ( Display*, Window );
+ int setWindow ( Display*, Window );
+ int translateEvent ( Display*, XEvent*, MoveEvent*, double, double );
+ int close ( Display* );
+
+ private:
+ SVTK_SpaceMouse();
+ static SVTK_SpaceMouse* myInstance;
+
+ Atom XMotionEvent;
+ Atom XButtonPressEvent;
+ Atom XButtonReleaseEvent;
+ Atom XCommandEvent;
+
+ Window win;
+ int spaceMouseOn;
+};
+
+#endif
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+
+#include "SALOME_Actor.h"
+
+#include "SVTK_View.h"
+#include "SVTK_Renderer.h"
+#include "SVTK_MainWindow.h"
+#include "SVTK_RenderWindowInteractor.h"
+#include "SALOME_ListIteratorOfListIO.hxx"
+
+#include "VTKViewer_Algorithm.h"
+#include "SVTK_Functor.h"
+
+#include <vtkActorCollection.h>
+#include <vtkRenderer.h>
+
+#include "utilities.h"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
+SVTK_SignalHandler
+::SVTK_SignalHandler(SVTK_MainWindow* theMainWindow):
+ QObject(theMainWindow),
+ myMainWindow(theMainWindow)
+{
+ if(MYDEBUG) INFOS("SVTK_SignalHandler() - "<<this);
+
+ SVTK_RenderWindowInteractor* anInteractor = theMainWindow->GetInteractor();
+
+ connect(anInteractor,SIGNAL(KeyPressed(QKeyEvent*)),
+ this,SIGNAL(KeyPressed(QKeyEvent*)) );
+ connect(anInteractor,SIGNAL(KeyReleased(QKeyEvent*)),
+ this,SIGNAL(KeyReleased(QKeyEvent*)));
+ connect(anInteractor,SIGNAL(MouseButtonPressed(QMouseEvent*)),
+ this,SIGNAL(MouseButtonPressed(QMouseEvent*)));
+ connect(anInteractor,SIGNAL(MouseButtonReleased(QMouseEvent*)),
+ this,SIGNAL(MouseButtonReleased(QMouseEvent*)));
+ connect(anInteractor,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
+ this,SIGNAL(MouseDoubleClicked(QMouseEvent*)));
+ connect(anInteractor,SIGNAL(MouseMove(QMouseEvent*)),
+ this,SIGNAL(MouseMove(QMouseEvent*)));
+ connect(anInteractor,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
+ this,SIGNAL(contextMenuRequested(QContextMenuEvent*)));
+ connect(anInteractor,SIGNAL(selectionChanged()),
+ this,SIGNAL(selectionChanged()));
+}
+
+SVTK_SignalHandler
+::~SVTK_SignalHandler()
+{
+ if(MYDEBUG) INFOS("~SVTK_SignalHandler() - "<<this);
+}
+
+SVTK_MainWindow*
+SVTK_SignalHandler
+::GetMainWindow()
+{
+ return myMainWindow;
+}
+
+
+//----------------------------------------------------------------
+void
+SVTK_SignalHandler
+::Repaint(bool theUpdateTrihedron)
+{
+ myMainWindow->Repaint(theUpdateTrihedron);
+}
+
+//----------------------------------------------------------------------------
+SVTK_Renderer*
+SVTK_SignalHandler
+::GetRenderer()
+{
+ return myMainWindow->GetRenderer();
+}
+
+vtkRenderer*
+SVTK_SignalHandler
+::getRenderer()
+{
+ return myMainWindow->getRenderer();
+}
+
+//----------------------------------------------------------------
+namespace SVTK
+{
+ struct THighlightAction
+ {
+ bool myIsHighlight;
+ THighlightAction( bool theIsHighlight ):
+ myIsHighlight( theIsHighlight )
+ {}
+
+ void
+ operator()( SALOME_Actor* theActor)
+ {
+ if(theActor->GetMapper() && theActor->hasIO()){
+ theActor->Highlight( myIsHighlight );
+ }
+ }
+ };
+}
+
+void
+SVTK_SignalHandler
+::onSelectionChanged()
+{
+ vtkActorCollection* anActors = myMainWindow->getRenderer()->GetActors();
+
+ using namespace SVTK;
+ ForEach<SALOME_Actor>(anActors,
+ THighlightAction( false ));
+ SVTK_Selector* aSelector = myMainWindow->GetSelector();
+ const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
+ SALOME_ListIteratorOfListIO anIter(aListIO);
+ for(; anIter.More(); anIter.Next()){
+ ForEachIf<SALOME_Actor>(anActors,
+ TIsSameIObject<SALOME_Actor>(anIter.Value()),
+ THighlightAction(true));
+ }
+
+ myMainWindow->Repaint(false);
+}
+
+
+//----------------------------------------------------------------------------
+SVTK_View
+::SVTK_View(SVTK_MainWindow* theMainWindow) :
+ SVTK_SignalHandler(theMainWindow)
+{
+ if(MYDEBUG) INFOS("SVTK_View() - "<<this);
+}
+
+//----------------------------------------------------------------------------
+SVTK_View
+::~SVTK_View()
+{
+ if(MYDEBUG) INFOS("~SVTK_View() - "<<this);
+}
+
+//----------------------------------------------------------------
+void
+SVTK_View
+::unHighlightAll()
+{
+ using namespace SVTK;
+ ForEach<SALOME_Actor>(getRenderer()->GetActors(),
+ THighlightAction( false ));
+ Repaint();
+}
+
+//----------------------------------------------------------------
+void
+SVTK_View
+::highlight( const Handle(SALOME_InteractiveObject)& theIO,
+ bool theIsHighlight,
+ bool theIsUpdate )
+{
+ using namespace SVTK;
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>( theIO ),
+ THighlightAction(theIsHighlight));
+ Repaint();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_View
+::SetSelectionProp(const double& theRed,
+ const double& theGreen,
+ const double& theBlue,
+ const int& theWidth)
+{
+ GetRenderer()->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_View
+::SetPreselectionProp(const double& theRed,
+ const double& theGreen,
+ const double& theBlue,
+ const int& theWidth)
+{
+ GetRenderer()->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_View
+::SetSelectionTolerance(const double& theTolNodes,
+ const double& theTolCell)
+{
+ GetRenderer()->SetSelectionTolerance(theTolNodes,theTolCell);
+}
+
+//----------------------------------------------------------------------------
+bool
+SVTK_View
+::isInViewer(const Handle(SALOME_InteractiveObject)& theIObject)
+{
+ using namespace SVTK;
+ SALOME_Actor* anActor =
+ Find<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject));
+ return anActor != NULL;
+}
+
+//----------------------------------------------------------------------------
+bool
+SVTK_View
+::isVisible(const Handle(SALOME_InteractiveObject)& theIObject)
+{
+ using namespace SVTK;
+ SALOME_Actor* anActor =
+ Find<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject));
+ return anActor != NULL && anActor->GetVisibility();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_View
+::rename(const Handle(SALOME_InteractiveObject)& theIObject,
+ const QString& theName)
+{
+ using namespace SVTK;
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TSetFunction<SALOME_Actor,const char*,QString>
+ (&SALOME_Actor::setName,theName.latin1()));
+}
+
+//----------------------------------------------------------------------------
+int
+SVTK_View
+::GetDisplayMode()
+{
+ return myDisplayMode;
+}
+
+void
+SVTK_View
+::SetDisplayMode(int theMode)
+{
+ if(theMode == 0)
+ ChangeRepresentationToWireframe();
+ else
+ ChangeRepresentationToSurface();
+ myDisplayMode = theMode;
+}
+
+void
+SVTK_View
+::SetDisplayMode(const Handle(SALOME_InteractiveObject)& theIObject,
+ int theMode)
+{
+ using namespace SVTK;
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TSetFunction<SALOME_Actor,int>
+ (&SALOME_Actor::setDisplayMode,theMode));
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_View
+::ChangeRepresentationToWireframe()
+{
+ ChangeRepresentationToWireframe(getRenderer()->GetActors());
+}
+
+void
+SVTK_View
+::ChangeRepresentationToSurface()
+{
+ ChangeRepresentationToSurface(getRenderer()->GetActors());
+}
+
+
+void
+SVTK_View
+::ChangeRepresentationToWireframe(vtkActorCollection* theCollection)
+{
+ using namespace SVTK;
+ ForEach<SALOME_Actor>(theCollection,
+ TSetFunction<SALOME_Actor,int>
+ (&SALOME_Actor::setDisplayMode,0));
+ Repaint();
+}
+
+void
+SVTK_View
+::ChangeRepresentationToSurface(vtkActorCollection* theCollection)
+{
+ using namespace SVTK;
+ ForEach<SALOME_Actor>(theCollection,
+ TSetFunction<SALOME_Actor,int>
+ (&SALOME_Actor::setDisplayMode,1));
+ Repaint();
+}
+
+//----------------------------------------------------------------------------
+namespace SVTK
+{
+ struct TErase
+ {
+ VTK::TSetFunction<vtkActor,int> mySetFunction;
+ TErase():
+ mySetFunction(&vtkActor::SetVisibility,false)
+ {}
+ void
+ operator()(SALOME_Actor* theActor)
+ {
+ theActor->SetVisibility(false);
+ // Erase dependent actors
+ vtkActorCollection* aCollection = vtkActorCollection::New();
+ theActor->GetChildActors(aCollection);
+ VTK::ForEach<vtkActor>(aCollection,mySetFunction);
+ aCollection->Delete();
+ }
+ };
+}
+
+void
+SVTK_View
+::EraseAll()
+{
+ using namespace SVTK;
+ ForEach<SALOME_Actor>(getRenderer()->GetActors(),
+ TErase());
+ Repaint();
+}
+
+void
+SVTK_View
+::DisplayAll()
+{
+ using namespace SVTK;
+ ForEach<SALOME_Actor>(getRenderer()->GetActors(),
+ TSetVisibility<SALOME_Actor>(true));
+ Repaint();
+}
+
+
+void
+SVTK_View
+::Erase(SALOME_Actor* theActor,
+ bool theIsUpdate)
+{
+ SVTK::TErase()(theActor);
+
+ if(theIsUpdate)
+ Repaint();
+}
+
+
+void
+SVTK_View
+::Erase(const Handle(SALOME_InteractiveObject)& theIObject,
+ bool theIsUpdate)
+{
+ using namespace SVTK;
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TErase());
+ if(theIsUpdate)
+ Repaint();
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_View
+::Display(SALOME_Actor* theActor,
+ bool theIsUpdate)
+{
+ GetRenderer()->AddActor(theActor);
+ theActor->SetVisibility(true);
+
+ if(theIsUpdate)
+ Repaint();
+}
+
+void
+SVTK_View
+::Display(const Handle(SALOME_InteractiveObject)& theIObject,
+ bool theIsUpdate)
+{
+ using namespace SVTK;
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TSetVisibility<SALOME_Actor>(true));
+
+ if(theIsUpdate)
+ Repaint();
+}
+
+void
+SVTK_View
+::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject)
+{
+ EraseAll();
+ Display(theIObject);
+}
+
+
+//----------------------------------------------------------------------------
+namespace SVTK
+{
+ struct TRemoveAction
+ {
+ SVTK_Renderer* myRenderer;
+ TRemoveAction(SVTK_Renderer* theRenderer):
+ myRenderer(theRenderer)
+ {}
+ void
+ operator()(SALOME_Actor* theActor)
+ {
+ myRenderer->RemoveActor(theActor);
+ }
+ };
+}
+
+void
+SVTK_View
+::Remove(const Handle(SALOME_InteractiveObject)& theIObject,
+ bool theIsUpdate)
+{
+ using namespace SVTK;
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TRemoveAction(GetRenderer()));
+ if(theIsUpdate)
+ Repaint();
+}
+
+void
+SVTK_View
+::Remove(SALOME_Actor* theActor,
+ bool theIsUpdate)
+{
+ GetRenderer()->RemoveActor(theActor);
+ if(theIsUpdate)
+ Repaint();
+}
+
+void
+SVTK_View
+::RemoveAll(bool theIsUpdate)
+{
+ vtkRenderer* aRenderer = getRenderer();
+ if(vtkActorCollection* anActors = aRenderer->GetActors()){
+ anActors->InitTraversal();
+ while(vtkActor *anAct = anActors->GetNextActor()){
+ if(SALOME_Actor* aSAct = SALOME_Actor::SafeDownCast(anAct)){
+ if(aSAct->hasIO() && aSAct->getIO()->hasEntry())
+ aRenderer->RemoveActor( anAct );
+ }
+ }
+
+ if(theIsUpdate)
+ Repaint();
+ }
+}
+
+//----------------------------------------------------------------------------
+float
+SVTK_View
+::GetTransparency(const Handle(SALOME_InteractiveObject)& theIObject)
+{
+ using namespace SVTK;
+ SALOME_Actor* anActor =
+ Find<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject));
+ if(anActor)
+ return 1.0 - anActor->GetOpacity();
+ return -1.0;
+}
+
+
+void
+SVTK_View
+::SetTransparency(const Handle(SALOME_InteractiveObject)& theIObject,
+ float theTrans)
+{
+ float anOpacity = 1.0 - theTrans;
+ using namespace SVTK;
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TSetFunction<SALOME_Actor,float>
+ (&SALOME_Actor::SetOpacity,anOpacity));
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_View
+::SetColor(const Handle(SALOME_InteractiveObject)& theIObject,
+ const QColor& theColor)
+{
+ float aColor[3] = {theColor.red()/255., theColor.green()/255., theColor.blue()/255.};
+
+ using namespace SVTK;
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject),
+ TSetFunction<SALOME_Actor,const float*>
+ (&SALOME_Actor::SetColor,aColor));
+}
+
+
+QColor
+SVTK_View
+::GetColor(const Handle(SALOME_InteractiveObject)& theIObject)
+{
+ using namespace SVTK;
+ SALOME_Actor* anActor =
+ Find<SALOME_Actor>(getRenderer()->GetActors(),
+ TIsSameIObject<SALOME_Actor>(theIObject));
+ if(anActor){
+ float r,g,b;
+ anActor->GetColor(r,g,b);
+ return QColor(int(r*255),int(g*255),int(b*255));
+ }
+
+ return QColor(0,0,0);
+}
+
--- /dev/null
+#ifndef SVTK_VIEW_H
+#define SVTK_VIEW_H
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+#include "SVTK.h"
+#include "SALOME_InteractiveObject.hxx"
+
+#include <qobject.h>
+
+class vtkActorCollection;
+class vtkRenderer;
+
+class SVTK_MainWindow;
+class SVTK_Renderer;
+
+class SALOME_Actor;
+
+//----------------------------------------------------------------------------
+//! Main purpose of the class is to provide a way to customize #SVTK_MainWindow.
+/*!
+ This class is initialized by #SVTK_MainWindow and just pass Qt signals from
+ corresponding #SVTK_RenderWindowInteractor of the #SVTK_MainWindow.
+ Its main purpose is to provide a simple and flexible way to customize the #SVTK_MainWindow.
+ So, in your own viewer it is possible to derive new #SVTK_MainWindow and
+ use existing functionality without any modifications.
+ */
+class SVTK_EXPORT SVTK_SignalHandler : public QObject
+{
+ Q_OBJECT;
+
+public:
+ SVTK_SignalHandler(SVTK_MainWindow* theMainWindow);
+
+ virtual
+ ~SVTK_SignalHandler();
+
+ //! Get reference to its #SVTK_MainWindow
+ SVTK_MainWindow*
+ GetMainWindow();
+
+ //----------------------------------------------------------------------------
+ //! Redirect the request to #SVTK_MainWindow::Repaint (just for flexibility)
+ void
+ Repaint(bool theUpdateTrihedron = true);
+
+ //----------------------------------------------------------------------------
+ //! Redirect the request to #SVTK_MainWindow::GetRenderer (just for flexibility)
+ SVTK_Renderer*
+ GetRenderer();
+
+ //! Redirect the request to #SVTK_MainWindow::getRenderer (just for flexibility)
+ vtkRenderer*
+ getRenderer();
+
+ //----------------------------------------------------------------------------
+ public slots:
+ void onSelectionChanged();
+
+ public:
+ signals:
+ void MouseMove( QMouseEvent* );
+ void MouseButtonPressed( QMouseEvent* );
+ void MouseButtonReleased( QMouseEvent* );
+ void MouseDoubleClicked( QMouseEvent* );
+ void ButtonPressed(const QMouseEvent *event);
+ void ButtonReleased(const QMouseEvent *event);
+ void WheelMoved( QWheelEvent* );
+ void KeyPressed( QKeyEvent* );
+ void KeyReleased( QKeyEvent* );
+ void contextMenuRequested( QContextMenuEvent *e );
+ void selectionChanged();
+
+ protected:
+ SVTK_MainWindow* myMainWindow;
+};
+
+
+//----------------------------------------------------------------------------
+//! This class is introduced just for compatibility with old code.
+/*!
+ This class contains frequantly used functionality in old code.
+ Now, you are supposed to extend existing functionality through
+ writing corresponding functors (see SVTK_Functor.h for example).
+ */
+class SVTK_EXPORT SVTK_View : public SVTK_SignalHandler
+{
+ Q_OBJECT;
+
+public:
+ SVTK_View(SVTK_MainWindow* theMainWindow);
+
+ virtual
+ ~SVTK_View();
+
+ /* interactive object management */
+ //! To highlight a VTK presentation with the same #SALOME_InteractiveObject
+ void
+ highlight(const Handle(SALOME_InteractiveObject)& IObject,
+ bool highlight,
+ bool immediatly = true);
+
+ //! To unhighlight all VTK presentations
+ void
+ unHighlightAll();
+
+ /* Selection Management */
+ Handle(SALOME_InteractiveObject)
+ FindIObject(const char* Entry);
+
+ //! Check, if the viewer contains a presentatin with defined #SALOME_InteractiveObject
+ bool
+ isInViewer(const Handle(SALOME_InteractiveObject)& IObject);
+
+ //! Check, if a presentatin with defined #SALOME_InteractiveObject is visible
+ bool
+ isVisible(const Handle(SALOME_InteractiveObject)& IObject);
+
+ void
+ rename(const Handle(SALOME_InteractiveObject)& IObject,
+ const QString& newName);
+
+ //----------------------------------------------------------------------------
+ // Displaymode management
+ //! Get current display mode (obsolete)
+ int
+ GetDisplayMode();
+
+ //! Set current display mode
+ void
+ SetDisplayMode(int);
+
+ //! Switch representation wireframe/shading
+ void
+ SetDisplayMode(const Handle(SALOME_InteractiveObject)& IObject,
+ int theMode);
+
+ //! Change all actors to wireframe
+ void
+ ChangeRepresentationToWireframe();
+
+ //! Change all actors to surface
+ void
+ ChangeRepresentationToSurface();
+
+ //! Change to wireframe a list of vtkactor
+ void
+ ChangeRepresentationToWireframe(vtkActorCollection* theListofActors);
+
+ //! Change to surface a list of vtkactor
+ void
+ ChangeRepresentationToSurface(vtkActorCollection* theListofActors);
+
+ //! Change transparency
+ void
+ SetTransparency(const Handle(SALOME_InteractiveObject)& theIObject,
+ float trans);
+
+ //! Get current transparency
+ float
+ GetTransparency(const Handle(SALOME_InteractiveObject)& theIObject);
+
+ //! Change color
+ void
+ SetColor(const Handle(SALOME_InteractiveObject)& theIObject,
+ const QColor& theColor);
+
+ //! Get current color
+ QColor
+ GetColor(const Handle(SALOME_InteractiveObject)& theIObject);
+
+ //----------------------------------------------------------------------------
+ // Erase Display functions
+ //! To erase all existing VTK presentations
+ void
+ EraseAll();
+
+ //! To display all existing VTK presentations
+ void
+ DisplayAll();
+
+ //! To remove from the view all existing VTK presentations
+ void
+ RemoveAll( const bool immediatly );
+
+ //! To erase VTK presentation with defined #SALOME_InteractiveObject
+ void
+ Erase(const Handle(SALOME_InteractiveObject)& IObject,
+ bool immediatly = true);
+ void
+ Remove(const Handle(SALOME_InteractiveObject)& IObject,
+ bool immediatly = true);
+
+ //! To display VTK presentation with defined #SALOME_InteractiveObject
+ void
+ Display(const Handle(SALOME_InteractiveObject)& IObject,
+ bool immediatly = true);
+
+ //! To display VTK presentation with defined #SALOME_InteractiveObject and erase all anothers
+ void
+ DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject);
+
+ //! To display the VTK presentation
+ void
+ Display(SALOME_Actor* SActor,
+ bool immediatly = true);
+
+ //! To erase the VTK presentation
+ void
+ Erase(SALOME_Actor* SActor,
+ bool immediatly = true);
+
+ //! To remove the VTK presentation
+ void
+ Remove(SALOME_Actor* SActor,
+ bool updateViewer = true);
+
+ //----------------------------------------------------------------------------
+ //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
+ void
+ SetSelectionProp(const double& theRed = 1,
+ const double& theGreen = 1,
+ const double& theBlue = 0,
+ const int& theWidth = 5);
+
+ //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
+ void
+ SetPreselectionProp(const double& theRed = 0,
+ const double& theGreen = 1,
+ const double& theBlue = 1,
+ const int& theWidth = 5);
+
+ //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
+ void
+ SetSelectionTolerance(const double& theTolNodes = 0.025,
+ const double& theTolCell = 0.001);
+
+ protected:
+ int myDisplayMode;
+};
+
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include "SVTK_ViewManager.h"
#include "SVTK_ViewModel.h"
+#include <VTKViewer_ViewManager.h>
+
int SVTK_ViewManager::_SVTKViewMgr_Id = 0;
//***************************************************************
void SVTK_ViewManager::setViewName(SUIT_ViewWindow* theView)
{
int aPos = myViews.find(theView);
- theView->setCaption( tr( "VTK_VIEW_TITLE" ).arg( myId ).arg( aPos + 1 ) );
+ theView->setCaption( VTKViewer_ViewManager::tr( "VTK_VIEW_TITLE" ).arg( myId ).arg( aPos + 1 ) );
}
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef SVTK_VIEWMANAGER_H
#define SVTK_VIEWMANAGER_H
class SUIT_Desktop;
+//! Extend SUIT_ViewManager to deal with SVTK_Viewer
class SVTK_EXPORT SVTK_ViewManager : public SUIT_ViewManager
{
Q_OBJECT
public:
+ //! Construct the view manager
SVTK_ViewManager( SUIT_Study* study, SUIT_Desktop* );
+
+ //! Destroy the view manager
virtual ~SVTK_ViewManager();
protected:
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
-#include <qpopupmenu.h>\r
-#include <qcolordialog.h>\r
-\r
-#include <vtkCamera.h>\r
-#include <vtkRenderer.h>\r
-#include <vtkActorCollection.h>\r
-\r
-#include "SUIT_Session.h"\r
-\r
-#include "SVTK_Selection.h"\r
-#include "SVTK_ViewModel.h"\r
-#include "SVTK_ViewWindow.h"\r
-#include "SVTK_Prs.h"\r
-\r
-#include "VTKViewer_ViewModel.h"\r
-\r
-#include "SVTK_RenderWindowInteractor.h"\r
-#include "SVTK_RenderWindow.h"\r
-\r
-//#include <ToolsGUI.h>\r
-\r
-#include <SALOME_Actor.h>\r
-#include <SALOME_InteractiveObject.hxx>\r
-\r
-// Temporarily commented to avoid awful dependecy on SALOMEDS\r
-// TODO: better mechanism of storing display/erse status in a study\r
-// should be provided...\r
-//#include "Utils_ORB_INIT.hxx"\r
-//#include "Utils_SINGLETON.hxx"\r
-//#include "SALOME_ModuleCatalog_impl.hxx"\r
-//#include "SALOME_NamingService.hxx"\r
-\r
-//#include "SALOMEDSClient.hxx"\r
-//#include "SALOMEDS_StudyManager.hxx"\r
-\r
-// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study.\r
-// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from \r
-// SALOMEDS::StudyManager - no linkage with SalomeApp. \r
-\r
-// Temporarily commented to avoid awful dependecy on SALOMEDS\r
-// TODO: better mechanism of storing display/erse status in a study\r
-// should be provided...\r
-//static _PTR(Study) getStudyDS() \r
-//{\r
-// SALOMEDSClient_Study* aStudy = NULL;\r
-// _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() );\r
- // get id of SUIT_Study, if it's a SalomeApp_Study, it will return\r
- // id of its underlying SALOMEDS::Study\r
-// SUIT_Application* app = SUIT_Session::session()->activeApplication();\r
-// if ( !app ) return _PTR(Study)(aStudy); \r
-// SUIT_Study* stud = app->activeStudy();\r
-// if ( !stud ) return _PTR(Study)(aStudy); \r
-// const int id = stud->id(); // virtual method, must return SALOMEDS_Study id\r
- // get SALOMEDS_Study with this id from StudyMgr\r
-// return aMgr->GetStudyByID( id );\r
-//}\r
-\r
-//==========================================================\r
-SVTK_Viewer::SVTK_Viewer()\r
-{\r
- myTrihedronSize = 100;\r
-}\r
-\r
-//==========================================================\r
-SVTK_Viewer::~SVTK_Viewer() \r
-{\r
-}\r
-\r
-QColor SVTK_Viewer::backgroundColor() const\r
-{\r
- return myBgColor;\r
-}\r
-\r
-void SVTK_Viewer::setBackgroundColor( const QColor& c )\r
-{\r
- if ( c.isValid() )\r
- myBgColor = c;\r
-}\r
-\r
-//==========================================================\r
-SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop )\r
-{\r
- SVTK_ViewWindow* vw = new SVTK_ViewWindow( theDesktop, this );\r
- vw->setBackgroundColor( backgroundColor() );\r
- vw->SetTrihedronSize( trihedronSize() );\r
- return vw;\r
-}\r
-\r
-int SVTK_Viewer::trihedronSize() const\r
-{\r
- return myTrihedronSize;\r
-}\r
-\r
-void SVTK_Viewer::setTrihedronSize( const int sz )\r
-{\r
- myTrihedronSize = sz;\r
-\r
- SUIT_ViewManager* vm = getViewManager();\r
- if ( !vm )\r
- return;\r
-\r
- QPtrVector<SUIT_ViewWindow> vec = vm->getViews();\r
- for ( int i = 0; i < vec.count(); i++ )\r
- {\r
- SUIT_ViewWindow* win = vec.at( i );\r
- if ( !win || !win->inherits( "SVTK_ViewWindow" ) )\r
- continue;\r
-\r
- SVTK_ViewWindow* vw = (SVTK_ViewWindow*)win;\r
- vw->SetTrihedronSize( sz );\r
- }\r
-}\r
-\r
-//==========================================================\r
-void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager)\r
-{\r
- SUIT_ViewModel::setViewManager(theViewManager);\r
-\r
- if ( !theViewManager )\r
- return;\r
-\r
- connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), \r
- this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));\r
- \r
- connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), \r
- this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));\r
- \r
- connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), \r
- this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));\r
-}\r
-\r
-//==========================================================\r
-void SVTK_Viewer::contextMenuPopup( QPopupMenu* thePopup )\r
-{\r
- thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );\r
- thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) );\r
-\r
- thePopup->insertSeparator();\r
-\r
- SVTK_ViewWindow* aView = (SVTK_ViewWindow*)(myViewManager->getActiveView());\r
- if ( aView && !aView->getToolBar()->isVisible() )\r
- thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) );\r
-}\r
-\r
-//==========================================================\r
-void SVTK_Viewer::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event)\r
-{\r
- if(SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(vw)){\r
- if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){\r
- switch(event->button()) {\r
- case LeftButton:\r
- aRWI->LeftButtonPressed(event) ;\r
- break ;\r
- case MidButton:\r
- aRWI->MiddleButtonPressed(event) ;\r
- break ;\r
- case RightButton:\r
- aRWI->RightButtonPressed(event) ;\r
- break;\r
- default:\r
- break ;\r
- }\r
- }\r
- }\r
-}\r
-\r
-//==========================================================\r
-void \r
-SVTK_Viewer\r
-::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event)\r
-{\r
- if(SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(vw)){\r
- if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){\r
- aRWI->MouseMove( event );\r
- }\r
- }\r
-}\r
-\r
-//==========================================================\r
-void \r
-SVTK_Viewer\r
-::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event)\r
-{\r
- if(SVTK_ViewWindow* aVW = dynamic_cast<SVTK_ViewWindow*>(vw)){\r
- if(SVTK_RenderWindowInteractor* aRWI = aVW->getRWInteractor()){\r
- switch(event->button()) {\r
- case LeftButton:\r
- aRWI->LeftButtonReleased(event) ;\r
- break ;\r
- case MidButton:\r
- aRWI->MiddleButtonReleased(event) ;\r
- break ;\r
- case RightButton:\r
- aRWI->RightButtonReleased(event) ;\r
- break;\r
- default:\r
- break ;\r
- }\r
- }\r
- }\r
-}\r
-\r
-//==========================================================\r
-void \r
-SVTK_Viewer\r
-::enableSelection(bool isEnabled)\r
-{\r
- mySelectionEnabled = isEnabled;\r
- //!! To be done for view windows\r
-}\r
-\r
-//==========================================================\r
-void\r
-SVTK_Viewer\r
-::enableMultiselection(bool isEnable)\r
-{\r
- myMultiSelectionEnabled = isEnable;\r
- //!! To be done for view windows\r
-}\r
-\r
-void SVTK_Viewer::onDumpView()\r
-{\r
- SVTK_ViewWindow* aView = (SVTK_ViewWindow*)(myViewManager->getActiveView());\r
- if ( aView )\r
- aView->onDumpView();\r
-}\r
-\r
-//==========================================================\r
-void SVTK_Viewer::onChangeBgColor()\r
-{\r
- QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();\r
- for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)\r
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i))\r
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)){\r
- QColor aColor = QColorDialog::getColor( aView->backgroundColor(), aView);\r
- if ( aColor.isValid() )\r
- aView->setBackgroundColor(aColor);\r
- }\r
-}\r
-\r
-//==========================================================\r
-void\r
-SVTK_Viewer\r
-::onShowToolbar() \r
-{\r
- QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();\r
- for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)\r
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i))\r
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))\r
- aView->getToolBar()->show(); \r
-}\r
-\r
-//==========================================================\r
-void\r
-SVTK_Viewer\r
-::Display( const SALOME_VTKPrs* prs )\r
-{\r
- // try do downcast object\r
- if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>( prs )){\r
- if(aPrs->IsNull())\r
- return;\r
- if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){\r
- // get SALOMEDS Study\r
- // Temporarily commented to avoid awful dependecy on SALOMEDS\r
- // TODO: better mechanism of storing display/erse status in a study\r
- // should be provided...\r
- // _PTR(Study) aStudy(getStudyDS());\r
- anActorCollection->InitTraversal();\r
- while(vtkActor* anActor = anActorCollection->GetNextActor()){\r
- if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){\r
- // Set visibility flag\r
- // Temporarily commented to avoid awful dependecy on SALOMEDS\r
- // TODO: better mechanism of storing display/erse status in a study\r
- // should be provided...\r
- //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();\r
- //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){\r
- // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this);\r
- //}\r
- // just display the object\r
- QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();\r
- for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){\r
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){\r
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)){\r
- if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor()){\r
- aRWI->Display(anAct,false);\r
- if(anAct->IsSetCamera()){\r
- vtkRenderer* aRenderer = aView->getRenderer();\r
- anAct->SetCamera( aRenderer->GetActiveCamera() );\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
-}\r
-\r
-//==========================================================\r
-void\r
-SVTK_Viewer\r
-::Erase( const SALOME_VTKPrs* prs, const bool forced )\r
-{\r
- // try do downcast object\r
- if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>( prs )){\r
- if(aPrs->IsNull())\r
- return;\r
- if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){\r
- // get SALOMEDS Study\r
- // Temporarily commented to avoid awful dependecy on SALOMEDS\r
- // TODO: better mechanism of storing display/erse status in a study\r
- // should be provided...\r
- //_PTR(Study) aStudy(getStudyDS());\r
- anActorCollection->InitTraversal();\r
- while(vtkActor* anActor = anActorCollection->GetNextActor())\r
- if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){\r
- // Set visibility flag\r
- // Temporarily commented to avoid awful dependecy on SALOMEDS\r
- // TODO: better mechanism of storing display/erse status in a study\r
- // should be provided...\r
- //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();\r
- //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){\r
- // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);\r
- //}\r
- // just display the object\r
- QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();\r
- for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){\r
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i))\r
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))\r
- if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor())\r
- if ( forced )\r
- aRWI->Remove(anAct,false);\r
- else\r
- aRWI->Erase(anAct,forced);\r
- }\r
- }\r
- }\r
- }\r
-}\r
- \r
-//==========================================================\r
-void\r
-SVTK_Viewer\r
-::EraseAll( const bool forced )\r
-{\r
- // Temporarily commented to avoid awful dependecy on SALOMEDS\r
- // TODO: better mechanism of storing display/erse status in a study\r
- // should be provided...\r
- //_PTR(Study) aStudy(getStudyDS());\r
- QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();\r
- for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){\r
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){\r
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)){\r
- vtkRenderer* aRenderer = aView->getRenderer();\r
- vtkActorCollection* anActorCollection = aRenderer->GetActors();\r
- anActorCollection->InitTraversal();\r
- while(vtkActor* anActor = anActorCollection->GetNextActor()){\r
- if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){\r
- // Set visibility flag\r
- // Temporarily commented to avoid awful dependecy on SALOMEDS\r
- // TODO: better mechanism of storing display/erse status in a study\r
- // should be provided...\r
- //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();\r
- //if(!anObj.IsNull() && anObj->hasEntry() && aStudy)\r
- // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);\r
- if(forced)\r
- aRenderer->RemoveActor(anAct);\r
- else{\r
- // just erase actor\r
- anAct->SetVisibility( false );\r
- // erase dependent actors\r
- vtkActorCollection* aCollection = vtkActorCollection::New();\r
- anAct->GetChildActors( aCollection );\r
- aCollection->InitTraversal();\r
- while(vtkActor* aSubAct = aCollection->GetNextActor())\r
- aSubAct->SetVisibility( false );\r
- aCollection->Delete();\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- Repaint();\r
-}\r
-\r
-//==========================================================\r
-SALOME_Prs* \r
-SVTK_Viewer\r
-::CreatePrs( const char* entry )\r
-{\r
- SVTK_Prs* prs = new SVTK_Prs();\r
- if ( entry ) {\r
- vtkRenderer* rnr = ( (SVTK_ViewWindow*) getViewManager()->getActiveView() )->getRenderer();\r
- vtkActorCollection* theActors = rnr->GetActors();\r
- theActors->InitTraversal();\r
- vtkActor* ac;\r
- while( ( ac = theActors->GetNextActor() ) ) {\r
- SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );\r
- if ( anActor && anActor->hasIO() && !strcmp( anActor->getIO()->getEntry(), entry ) ) {\r
- prs->AddObject( ac );\r
- }\r
- }\r
- }\r
- return prs;\r
-}\r
-\r
-//==========================================================\r
-void\r
-SVTK_Viewer\r
-::BeforeDisplay( SALOME_Displayer* d )\r
-{\r
- d->BeforeDisplay( this, SALOME_VTKViewType() );\r
-}\r
-\r
-//==========================================================\r
-void\r
-SVTK_Viewer::AfterDisplay( SALOME_Displayer* d )\r
-{\r
- d->AfterDisplay( this, SALOME_VTKViewType() );\r
-}\r
-\r
-//==========================================================\r
-bool\r
-SVTK_Viewer\r
-::isVisible( const Handle(SALOME_InteractiveObject)& io )\r
-{\r
- QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();\r
- for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)\r
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i))\r
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))\r
- if(SVTK_RenderWindowInteractor* aRWI = aView->getRWInteractor())\r
- if(!aRWI->isVisible( io ))\r
- return false;\r
- return true;\r
-}\r
-\r
-//==========================================================\r
-void \r
-SVTK_Viewer\r
-::Repaint()\r
-{\r
-// if (theUpdateTrihedron) onAdjustTrihedron();\r
- QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();\r
- for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)\r
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i))\r
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))\r
- if(SVTK_RenderWindow* aRW = aView->getRenderWindow())\r
- aRW->update();\r
-}\r
-\r
-void \r
-SVTK_Viewer\r
-::onSelectionChanged()\r
-{\r
- emit selectionChanged();\r
-}\r
-\r
+#include <qpopupmenu.h>
+#include <qcolordialog.h>
+
+#include <vtkCamera.h>
+#include <vtkRenderer.h>
+#include <vtkActorCollection.h>
+
+#include "SUIT_Session.h"
+
+#include "SVTK_Selection.h"
+#include "SVTK_ViewModel.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_View.h"
+#include "SVTK_MainWindow.h"
+#include "SVTK_Prs.h"
+
+#include "VTKViewer_ViewModel.h"
+
+#include "SALOME_Actor.h"
+#include "SALOME_InteractiveObject.hxx"
+
+// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study.
+// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from
+// SALOMEDS::StudyManager - no linkage with SalomeApp.
+
+// Temporarily commented to avoid awful dependecy on SALOMEDS
+// TODO: better mechanism of storing display/erse status in a study
+// should be provided...
+//static _PTR(Study) getStudyDS()
+//{
+// SALOMEDSClient_Study* aStudy = NULL;
+// _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() );
+ // get id of SUIT_Study, if it's a SalomeApp_Study, it will return
+ // id of its underlying SALOMEDS::Study
+// SUIT_Application* app = SUIT_Session::session()->activeApplication();
+// if ( !app ) return _PTR(Study)(aStudy);
+// SUIT_Study* stud = app->activeStudy();
+// if ( !stud ) return _PTR(Study)(aStudy);
+// const int id = stud->id(); // virtual method, must return SALOMEDS_Study id
+ // get SALOMEDS_Study with this id from StudyMgr
+// return aMgr->GetStudyByID( id );
+//}
+
+//==========================================================
+SVTK_Viewer::SVTK_Viewer()
+{
+ myTrihedronSize = 105;
+}
+
+//==========================================================
+SVTK_Viewer::~SVTK_Viewer()
+{
+}
+
+QColor
+SVTK_Viewer
+::backgroundColor() const
+{
+ return myBgColor;
+}
+
+void
+SVTK_Viewer
+::setBackgroundColor( const QColor& theColor )
+{
+ if ( !theColor.isValid() )
+ return;
+
+ QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+ if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){
+ if(TViewWindow* aView = dynamic_cast<TViewWindow*>(aViewWindow)){
+ aView->getMainWindow()->SetBackgroundColor(theColor);
+ }
+ }
+ }
+
+ myBgColor = theColor;
+}
+
+//==========================================================
+SUIT_ViewWindow*
+SVTK_Viewer::
+createView( SUIT_Desktop* theDesktop )
+{
+ SVTK_ViewWindow* aViewWindow = new SVTK_ViewWindow(theDesktop);
+ aViewWindow->Initialize(this);
+
+ aViewWindow->setBackgroundColor( backgroundColor() );
+ aViewWindow->SetTrihedronSize( trihedronSize() );
+
+ return aViewWindow;
+}
+
+int SVTK_Viewer::trihedronSize() const
+{
+ return myTrihedronSize;
+}
+
+void SVTK_Viewer::setTrihedronSize( const int sz )
+{
+ myTrihedronSize = sz;
+
+ SUIT_ViewManager* vm = getViewManager();
+ if ( !vm )
+ return;
+
+ QPtrVector<SUIT_ViewWindow> vec = vm->getViews();
+ for ( int i = 0; i < vec.count(); i++ )
+ {
+ SUIT_ViewWindow* win = vec.at( i );
+ if ( !win || !win->inherits( "SVTK_ViewWindow" ) )
+ continue;
+
+ SVTK_ViewWindow* vw = (SVTK_ViewWindow*)win;
+ vw->SetTrihedronSize( sz );
+ }
+}
+
+//==========================================================
+void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
+{
+ SUIT_ViewModel::setViewManager(theViewManager);
+
+ if ( !theViewManager )
+ return;
+
+ connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
+
+ connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
+
+ connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
+}
+
+//==========================================================
+void
+SVTK_Viewer
+::contextMenuPopup( QPopupMenu* thePopup )
+{
+ thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
+ thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) );
+
+ thePopup->insertSeparator();
+
+ if(TViewWindow* aView = dynamic_cast<TViewWindow*>(myViewManager->getActiveView())){
+ if ( !aView->getView()->GetMainWindow()->getToolBar()->isVisible() ){
+ thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) );
+ }
+ }
+}
+
+//==========================================================
+void
+SVTK_Viewer
+::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event)
+{}
+
+//==========================================================
+void
+SVTK_Viewer
+::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event)
+{}
+
+//==========================================================
+void
+SVTK_Viewer
+::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event)
+{}
+
+//==========================================================
+void
+SVTK_Viewer
+::enableSelection(bool isEnabled)
+{
+ mySelectionEnabled = isEnabled;
+ //!! To be done for view windows
+}
+
+//==========================================================
+void
+SVTK_Viewer
+::enableMultiselection(bool isEnable)
+{
+ myMultiSelectionEnabled = isEnable;
+ //!! To be done for view windows
+}
+
+void
+SVTK_Viewer
+::onDumpView()
+{
+ if(SUIT_ViewWindow* aView = myViewManager->getActiveView())
+ aView->onDumpView();
+}
+
+//==========================================================
+void
+SVTK_Viewer
+::onChangeBgColor()
+{
+ if(SUIT_ViewWindow* aView = myViewManager->getActiveView()){
+ QColor aColor = QColorDialog::getColor( backgroundColor(), aView);
+ setBackgroundColor(aColor);
+ }
+}
+
+//==========================================================
+void
+SVTK_Viewer
+::onShowToolbar()
+{
+ QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+ if(TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at(i))){
+ aView->getView()->GetMainWindow()->getToolBar()->show();
+ }
+ }
+}
+
+//==========================================================
+void
+SVTK_Viewer
+::Display( const SALOME_VTKPrs* prs )
+{
+ // try do downcast object
+ if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>( prs )){
+ if(aPrs->IsNull())
+ return;
+ if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){
+ // get SALOMEDS Study
+ // Temporarily commented to avoid awful dependecy on SALOMEDS
+ // TODO: better mechanism of storing display/erse status in a study
+ // should be provided...
+ // _PTR(Study) aStudy(getStudyDS());
+ anActorCollection->InitTraversal();
+ while(vtkActor* anActor = anActorCollection->GetNextActor()){
+ if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
+ // Set visibility flag
+ // Temporarily commented to avoid awful dependecy on SALOMEDS
+ // TODO: better mechanism of storing display/erse status in a study
+ // should be provided...
+ //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
+ //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){
+ // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),true,this);
+ //}
+ // just display the object
+ QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
+ if(SVTK_View* aView = aViewWindow->getView()){
+ aView->Display(anAct,false);
+ if(anAct->IsSetCamera()){
+ vtkRenderer* aRenderer = aView->getRenderer();
+ anAct->SetCamera( aRenderer->GetActiveCamera() );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//==========================================================
+void
+SVTK_Viewer
+::Erase( const SALOME_VTKPrs* prs, const bool forced )
+{
+ // try do downcast object
+ if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>( prs )){
+ if(aPrs->IsNull())
+ return;
+ if(vtkActorCollection* anActorCollection = aPrs->GetObjects()){
+ // get SALOMEDS Study
+ // Temporarily commented to avoid awful dependecy on SALOMEDS
+ // TODO: better mechanism of storing display/erse status in a study
+ // should be provided...
+ //_PTR(Study) aStudy(getStudyDS());
+ anActorCollection->InitTraversal();
+ while(vtkActor* anActor = anActorCollection->GetNextActor())
+ if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
+ // Set visibility flag
+ // Temporarily commented to avoid awful dependecy on SALOMEDS
+ // TODO: better mechanism of storing display/erse status in a study
+ // should be provided...
+ //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
+ //if(!anObj.IsNull() && anObj->hasEntry() && aStudy){
+ // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
+ //}
+ // just display the object
+ QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
+ if(SVTK_View* aView = aViewWindow->getView())
+ if ( forced )
+ aView->Remove(anAct,false);
+ else
+ aView->Erase(anAct,forced);
+ }
+ }
+ }
+ }
+}
+
+//==========================================================
+void
+SVTK_Viewer
+::EraseAll( const bool forced )
+{
+ // Temporarily commented to avoid awful dependecy on SALOMEDS
+ // TODO: better mechanism of storing display/erse status in a study
+ // should be provided...
+ //_PTR(Study) aStudy(getStudyDS());
+ QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
+ if(SVTK_View* aView = aViewWindow->getView()){
+ vtkRenderer* aRenderer = aView->getRenderer();
+ vtkActorCollection* anActorCollection = aRenderer->GetActors();
+ anActorCollection->InitTraversal();
+ while(vtkActor* anActor = anActorCollection->GetNextActor()){
+ if(SALOME_Actor* anAct = SALOME_Actor::SafeDownCast(anActor)){
+ // Set visibility flag
+ // Temporarily commented to avoid awful dependecy on SALOMEDS
+ // TODO: better mechanism of storing display/erse status in a study
+ // should be provided...
+ //Handle(SALOME_InteractiveObject) anObj = anAct->getIO();
+ //if(!anObj.IsNull() && anObj->hasEntry() && aStudy)
+ // ToolsGUI::SetVisibility(aStudy,anObj->getEntry(),false,this);
+ if(forced)
+ aRenderer->RemoveActor(anAct);
+ else{
+ // just erase actor
+ anAct->SetVisibility( false );
+ // erase dependent actors
+ vtkActorCollection* aCollection = vtkActorCollection::New();
+ anAct->GetChildActors( aCollection );
+ aCollection->InitTraversal();
+ while(vtkActor* aSubAct = aCollection->GetNextActor())
+ aSubAct->SetVisibility( false );
+ aCollection->Delete();
+ }
+ }
+ }
+ }
+ }
+ Repaint();
+}
+
+//==========================================================
+SALOME_Prs*
+SVTK_Viewer
+::CreatePrs( const char* entry )
+{
+ SVTK_Prs* prs = new SVTK_Prs();
+ if ( entry ) {
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(getViewManager()->getActiveView()))
+ if(SVTK_View* aView = aViewWindow->getView()){
+ vtkRenderer* aRenderer = aView->getRenderer();
+ vtkActorCollection* theActors = aRenderer->GetActors();
+ theActors->InitTraversal();
+ vtkActor* ac;
+ while( ( ac = theActors->GetNextActor() ) ) {
+ SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac );
+ if ( anActor && anActor->hasIO() && !strcmp( anActor->getIO()->getEntry(), entry ) ) {
+ prs->AddObject( ac );
+ }
+ }
+ }
+ }
+ return prs;
+}
+
+//==========================================================
+void
+SVTK_Viewer
+::BeforeDisplay( SALOME_Displayer* d )
+{
+ d->BeforeDisplay( this, SALOME_VTKViewType() );
+}
+
+//==========================================================
+void
+SVTK_Viewer::AfterDisplay( SALOME_Displayer* d )
+{
+ d->AfterDisplay( this, SALOME_VTKViewType() );
+}
+
+//==========================================================
+bool
+SVTK_Viewer
+::isVisible( const Handle(SALOME_InteractiveObject)& io )
+{
+ QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
+ if(SVTK_View* aView = aViewWindow->getView())
+ if(!aView->isVisible( io ))
+ return false;
+
+ return true;
+}
+
+//==========================================================
+void
+SVTK_Viewer
+::Repaint()
+{
+// if (theUpdateTrihedron) onAdjustTrihedron();
+ QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i)))
+ if(SVTK_View* aView = aViewWindow->getView())
+ aView->Repaint();
+}
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef SVTK_VIEWMODEL_H
#define SVTK_VIEWMODEL_H
#include "SVTK.h"
#include "SUIT_ViewModel.h"
+#include "SVTK_ViewModelBase.h"
#include "SALOME_Prs.h"
#include "SALOME_InteractiveObject.hxx"
#include <qcolor.h>
-class SVTK_EXPORT SVTK_Viewer : public SUIT_ViewModel, public SALOME_View
+class SVTK_ViewWindow;
+
+//! Extends two interfaces #SVTK_ViewModelBase and #SALOME_View
+class SVTK_EXPORT SVTK_Viewer : public SVTK_ViewModelBase, public SALOME_View
{
Q_OBJECT;
public:
+ typedef SVTK_ViewWindow TViewWindow;
+
+ //! Define string representation of the viewer type
static QString Type() { return "VTKViewer"; }
SVTK_Viewer();
virtual ~SVTK_Viewer();
+ //! See #SUIT_ViewModel::createView
virtual SUIT_ViewWindow* createView(SUIT_Desktop*);
- virtual void setViewManager(SUIT_ViewManager* theViewManager);
- virtual void contextMenuPopup( QPopupMenu* );
- virtual QString getType() const { return Type(); }
+ //! See #SUIT_ViewModel::createView
+ virtual void setViewManager(SUIT_ViewManager* theViewManager);
+
+ //! See #SUIT_ViewModel::contextMenuPopup
+ virtual void contextMenuPopup( QPopupMenu* );
+ //! See #SUIT_ViewModel::getType
+ virtual QString getType() const { return Type(); }
+
+ //! Get background color of the viewer
QColor backgroundColor() const;
- void setBackgroundColor( const QColor& );
- int trihedronSize() const;
- void setTrihedronSize( const int );
+ //! Set background color to the viewer
+ void setBackgroundColor( const QColor& );
+
+ //! Get size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
+ int trihedronSize() const;
+
+ //! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
+ void setTrihedronSize( const int );
public:
void enableSelection(bool isEnabled);
int getSelectionCount() const;
/* Reimplemented from SALOME_View */
- void Display( const SALOME_VTKPrs* );
- void Erase( const SALOME_VTKPrs*, const bool = false );
- void EraseAll( const bool = false );
- SALOME_Prs* CreatePrs( const char* entry = 0 );
- virtual void BeforeDisplay( SALOME_Displayer* d );
- virtual void AfterDisplay ( SALOME_Displayer* d );
- virtual bool isVisible( const Handle(SALOME_InteractiveObject)& );
- virtual void Repaint();
-
- //implemented in SOCC, but were not found in VTKVIEwer_ViewFrame, so not implemented here..
- //?virtual void LocalSelection( const SALOME_OCCPrs*, const int );
- //?virtual void GlobalSelection( const bool = false ) const;
-
-public slots:
- void onSelectionChanged();
-
- signals:
- void selectionChanged();
+
+ //! See #SALOME_View::Display( const SALOME_Prs* )
+ void Display( const SALOME_VTKPrs* );
+
+ //! See #SALOME_View::Erase( const SALOME_VTKPrs*, const bool = false )
+ void Erase( const SALOME_VTKPrs*, const bool = false );
+
+ //! See #SALOME_View::EraseAll( const bool = false )
+ void EraseAll( const bool = false );
+
+ //! See #SALOME_View::CreatePrs( const char* entry = 0 )
+ SALOME_Prs* CreatePrs( const char* entry = 0 );
+
+ //! See #SALOME_View::BeforeDisplay( SALOME_Displayer* d )
+ virtual void BeforeDisplay( SALOME_Displayer* d );
+
+ //! See #SALOME_View::AfterDisplay( SALOME_Displayer* d )
+ virtual void AfterDisplay( SALOME_Displayer* d );
+
+ //! See #SALOME_View::isVisible( const Handle(SALOME_InteractiveObject)& )
+ virtual bool isVisible( const Handle(SALOME_InteractiveObject)& );
+
+ //! See #SALOME_View::Repaint()
+ virtual void Repaint();
protected slots:
void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
--- /dev/null
+#ifndef SVTK_SELECTIONCHANGED_H
+#define SVTK_SELECTIONCHANGED_H
+
+#include <qobject.h>
+
+#include "SVTK.h"
+#include "SUIT_ViewModel.h"
+
+
+//! To define minimal interface for #SVTK_ViewWindow initialization
+class SVTK_EXPORT SVTK_ViewModelBase: public SUIT_ViewModel
+{
+ Q_OBJECT;
+
+public slots:
+ //! To invoke Qt #selectionChanged signal
+ void onSelectionChanged()
+ {
+ emit selectionChanged();
+ }
+
+ signals:
+ //! To declare signal on selection changed
+ void selectionChanged();
+};
+
+#endif
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include "SALOME_Actor.h"
#include <qapplication.h>
+#include <qpushbutton.h>
+#include <qsplitter.h>
+#include <qlayout.h>
#include <qimage.h>
#include <vtkTextProperty.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkCamera.h>
+#include <vtkPointPicker.h>
+#include <vtkCellPicker.h>
#include "QtxAction.h"
#include "SUIT_Session.h"
#include "SUIT_ToolButton.h"
#include "SUIT_MessageBox.h"
-#include "SUIT_Accel.h"
#include "SUIT_Tools.h"
#include "SUIT_ResourceMgr.h"
+#include "SUIT_Accel.h"
-#include "VTKViewer_Transform.h"
#include "VTKViewer_Utilities.h"
+#include "VTKViewer_CellRectPicker.h"
-#include "SVTK_Trihedron.h"
-#include "SVTK_CubeAxesActor2D.h"
+#include "SVTK_View.h"
+#include "SVTK_MainWindow.h"
+#include "SVTK_Selector.h"
+
+#include "SVTK_Event.h"
+#include "SVTK_Renderer.h"
#include "SVTK_ViewWindow.h"
-#include "SVTK_ViewModel.h"
-#include "SVTK_RenderWindow.h"
-#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_ViewModelBase.h"
#include "SVTK_InteractorStyle.h"
+#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_GenericRenderWindowInteractor.h"
#include "SALOME_ListIteratorOfListIO.hxx"
-#include "SVTK_SelectorDef.h"
-
#include "VTKViewer_Algorithm.h"
#include "SVTK_Functor.h"
//----------------------------------------------------------------------------
SVTK_ViewWindow
-::SVTK_ViewWindow( SUIT_Desktop* theDesktop,
- SVTK_Viewer* theModel)
- : SUIT_ViewWindow( theDesktop ),
- myTrihedronSize( 100 )
-{
- myModel = theModel;
- mySelector = new SVTK_SelectorDef();
- connect(this,SIGNAL(selectionChanged()),theModel,SLOT(onSelectionChanged()));
-
- myTransform = VTKViewer_Transform::New();
- myTrihedron = SVTK_Trihedron::New();
- myCubeAxes = SVTK_CubeAxesActor2D::New();
- myRenderer = vtkRenderer::New() ;
-
- myTrihedron->AddToRender( myRenderer );
- myRenderer->AddProp(myCubeAxes);
-
- myRenderWindow = new SVTK_RenderWindow( this, "RenderWindow" );
- setCentralWidget(myRenderWindow);
- myRenderWindow->setFocusPolicy( StrongFocus );
- myRenderWindow->setFocus();
-
- myRenderWindow->getRenderWindow()->AddRenderer( myRenderer );
-
- myRenderer->GetActiveCamera()->ParallelProjectionOn();
- myRenderer->LightFollowCameraOn();
- myRenderer->TwoSidedLightingOn();
-
- // Set BackgroundColor
- QString BgrColorRed = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorRed");
- QString BgrColorGreen = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorGreen");
- QString BgrColorBlue = "0";//SUIT_CONFIG->getSetting("VTKViewer:BackgroundColorBlue");
-
- if( !BgrColorRed.isEmpty() && !BgrColorGreen.isEmpty() && !BgrColorBlue.isEmpty() )
- myRenderer->SetBackground( BgrColorRed.toInt()/255., BgrColorGreen.toInt()/255., BgrColorBlue.toInt()/255. );
- else
- myRenderer->SetBackground( 0, 0, 0 );
-
- // Create an interactor.
- myRWInteractor = SVTK_RenderWindowInteractor::New();
- myRWInteractor->SetRenderWindow( myRenderWindow->getRenderWindow() );
- myRWInteractor->setViewWindow( this );
-
- SVTK_InteractorStyle* RWS = SVTK_InteractorStyle::New();
- RWS->setGUIWindow( myRenderWindow );
- RWS->setViewWindow( this );
-
- myRWInteractor->SetInteractorStyle( RWS );
- myRWInteractor->Initialize();
-
- //merge with V2_2_0_VISU_improvements:RWS->setTriedron( myTrihedron );
- RWS->FindPokedRenderer( 0, 0 );
-
- SetSelectionMode(ActorSelection);
-
- vtkTextProperty* tprop = vtkTextProperty::New();
- tprop->SetColor(1, 1, 1);
- tprop->ShadowOn();
-
- float bnd[6];
- bnd[0] = bnd[2] = bnd[4] = 0;
- bnd[1] = bnd[3] = bnd[5] = myTrihedron->GetSize();
- myCubeAxes->SetLabelFormat("%6.4g");
- myCubeAxes->SetBounds(bnd);
- myCubeAxes->SetCamera(myRenderer->GetActiveCamera());
- myCubeAxes->SetFlyModeToOuterEdges(); // ENK remarks: it must bee
- myCubeAxes->SetFontFactor(0.8);
- myCubeAxes->SetAxisTitleTextProperty(tprop);
- myCubeAxes->SetAxisLabelTextProperty(tprop);
- myCubeAxes->SetCornerOffset(0);
- myCubeAxes->SetScaling(0);
- myCubeAxes->SetNumberOfLabels(5);
- myCubeAxes->VisibilityOff();
- myCubeAxes->SetTransform(myTransform);
- tprop->Delete();
-
- setCentralWidget( myRenderWindow );
-
- myToolBar = new QToolBar(this);
- myToolBar->setCloseMode(QDockWindow::Undocked);
- myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
-
- createActions();
- createToolBar();
-
- connect( myRenderWindow, SIGNAL(KeyPressed( QKeyEvent* )),
- this, SLOT(onKeyPressed( QKeyEvent* )) );
- connect( myRenderWindow, SIGNAL(KeyReleased( QKeyEvent* )),
- this, SLOT(onKeyReleased( QKeyEvent* )) );
- connect( myRenderWindow, SIGNAL(MouseButtonPressed( QMouseEvent* )),
- this, SLOT(onMousePressed( QMouseEvent* )) );
- connect( myRenderWindow, SIGNAL(MouseButtonReleased( QMouseEvent* )),
- this, SLOT(onMouseReleased( QMouseEvent* )) );
- connect( myRenderWindow, SIGNAL(MouseDoubleClicked( QMouseEvent* )),
- this, SLOT(onMouseDoubleClicked( QMouseEvent* )) );
- connect( myRenderWindow, SIGNAL(MouseMove( QMouseEvent* )),
- this, SLOT(onMouseMoving( QMouseEvent* )) );
-
- connect( myRWInteractor, SIGNAL(RenderWindowModified()),
- myRenderWindow, SLOT(update()) );
- connect( myRWInteractor, SIGNAL(contextMenuRequested( QContextMenuEvent * )),
- this, SIGNAL(contextMenuRequested( QContextMenuEvent * )) );
-
- onResetView();
-}
+::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
+ SUIT_ViewWindow(theDesktop),
+ myMainWindow(NULL),
+ myView(NULL)
+{}
-//----------------------------------------------------------------------------
+void
SVTK_ViewWindow
-::~SVTK_ViewWindow()
+::Initialize(SVTK_ViewModelBase* theModel)
{
- myTransform->Delete();
- // In order to ensure that the interactor unregisters
- // this RenderWindow, we assign a NULL RenderWindow to
- // it before deleting it.
- myRWInteractor->SetRenderWindow( NULL );
- myRWInteractor->Delete();
-
- //m_RW->Delete() ;
- myRenderer->RemoveAllProps();
- //m_Renderer->Delete();
- myTrihedron->Delete();
- myCubeAxes->Delete();
+ if(SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr()){
+ myMainWindow = new SVTK_MainWindow(this,"SVTK_MainWindow",aResourceMgr);
+
+ SVTK_RenderWindowInteractor* anIteractor =
+ new SVTK_RenderWindowInteractor(myMainWindow,"SVTK_RenderWindowInteractor");
+
+ SVTK_Selector* aSelector = SVTK_Selector::New();
+
+ SVTK_GenericRenderWindowInteractor* aDevice =
+ SVTK_GenericRenderWindowInteractor::New();
+ aDevice->SetRenderWidget(anIteractor);
+ aDevice->SetSelector(aSelector);
+
+ SVTK_Renderer* aRenderer = SVTK_Renderer::New();
+ aRenderer->Initialize(aDevice,aSelector);
+
+ anIteractor->Initialize(aDevice,aRenderer,aSelector);
+
+ aDevice->Delete();
+ aRenderer->Delete();
+ aSelector->Delete();
+
+ myMainWindow->Initialize(anIteractor);
+
+ SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New();
+ anIteractor->PushInteractorStyle(aStyle);
+ aStyle->Delete();
+
+ setCentralWidget(myMainWindow);
+
+ myView = new SVTK_View(myMainWindow);
+ Initialize(myView,theModel);
+ }
}
-//----------------------------------------------------------------------------
void
SVTK_ViewWindow
-::activateZoom()
+::Initialize(SVTK_View* theView,
+ SVTK_ViewModelBase* theModel)
{
- myRWInteractor->GetSInteractorStyle()->startZoom();
+ connect(theView,SIGNAL(KeyPressed(QKeyEvent*)),
+ this,SLOT(onKeyPressed(QKeyEvent*)) );
+ connect(theView,SIGNAL(KeyReleased(QKeyEvent*)),
+ this,SLOT(onKeyReleased(QKeyEvent*)));
+ connect(theView,SIGNAL(MouseButtonPressed(QMouseEvent*)),
+ this,SLOT(onMousePressed(QMouseEvent*)));
+ connect(theView,SIGNAL(MouseButtonReleased(QMouseEvent*)),
+ this,SLOT(onMouseReleased(QMouseEvent*)));
+ connect(theView,SIGNAL(MouseDoubleClicked(QMouseEvent*)),
+ this,SLOT(onMouseDoubleClicked(QMouseEvent*)));
+ connect(theView,SIGNAL(MouseMove(QMouseEvent*)),
+ this,SLOT(onMouseMoving(QMouseEvent*)));
+ connect(theView,SIGNAL(contextMenuRequested(QContextMenuEvent*)),
+ this,SIGNAL(contextMenuRequested(QContextMenuEvent *)));
+ connect(theView,SIGNAL(selectionChanged()),
+ theModel,SLOT(onSelectionChanged()));
}
-//----------------------------------------------------------------------------
-void
SVTK_ViewWindow
-::activatePanning()
-{
- myRWInteractor->GetSInteractorStyle()->startPan();
-}
+::~SVTK_ViewWindow()
+{}
+
//----------------------------------------------------------------------------
-void
+SVTK_View*
SVTK_ViewWindow
-::activateRotation()
-{
- myRWInteractor->GetSInteractorStyle()->startRotate();
+::getView()
+{
+ return myView;
}
-//----------------------------------------------------------------------------
-void
+SVTK_MainWindow*
SVTK_ViewWindow
-::activateGlobalPanning()
-{
- if(myTrihedron->GetVisibleActorCount(myRenderer))
- myRWInteractor->GetSInteractorStyle()->startGlobalPan();
+::getMainWindow()
+{
+ return myMainWindow;
}
-//----------------------------------------------------------------------------
-void
+vtkRenderWindow*
SVTK_ViewWindow
-::activateWindowFit()
+::getRenderWindow()
{
- myRWInteractor->GetSInteractorStyle()->startFitArea();
+ return getMainWindow()->getRenderWindow();
}
-//----------------------------------------------------------------------------
-#if defined(WIN32) && !defined(_DEBUG)
-#pragma optimize( "", off )
-#endif
-void
+vtkRenderWindowInteractor*
SVTK_ViewWindow
-::createActions()
+::getInteractor()
{
- if (!myActionsMap.isEmpty()) return;
-
- SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
-
- QtxAction* aAction;
-
- // Dump view
- aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
- tr( "MNU_DUMP_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
- myActionsMap[ DumpId ] = aAction;
-
- // FitAll
- aAction = new QtxAction(tr("MNU_FITALL"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
- tr( "MNU_FITALL" ), 0, this);
- aAction->setStatusTip(tr("DSC_FITALL"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onFitAll()));
- myActionsMap[ FitAllId ] = aAction;
-
- // FitRect
- aAction = new QtxAction(tr("MNU_FITRECT"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
- tr( "MNU_FITRECT" ), 0, this);
- aAction->setStatusTip(tr("DSC_FITRECT"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
- myActionsMap[ FitRectId ] = aAction;
-
- // Zoom
- aAction = new QtxAction(tr("MNU_ZOOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
- tr( "MNU_ZOOM_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activateZoom()));
- myActionsMap[ ZoomId ] = aAction;
-
- // Panning
- aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
- tr( "MNU_PAN_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_PAN_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activatePanning()));
- myActionsMap[ PanId ] = aAction;
-
- // Global Panning
- aAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
- tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
- myActionsMap[ GlobalPanId ] = aAction;
-
- // Rotation
- aAction = new QtxAction(tr("MNU_ROTATE_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
- tr( "MNU_ROTATE_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(activateRotation()));
- myActionsMap[ RotationId ] = aAction;
-
- // Projections
- aAction = new QtxAction(tr("MNU_FRONT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
- tr( "MNU_FRONT_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_FRONT_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onFrontView()));
- myActionsMap[ FrontId ] = aAction;
-
- aAction = new QtxAction(tr("MNU_BACK_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
- tr( "MNU_BACK_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_BACK_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onBackView()));
- myActionsMap[ BackId ] = aAction;
-
- aAction = new QtxAction(tr("MNU_TOP_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
- tr( "MNU_TOP_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_TOP_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onTopView()));
- myActionsMap[ TopId ] = aAction;
-
- aAction = new QtxAction(tr("MNU_BOTTOM_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
- tr( "MNU_BOTTOM_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onBottomView()));
- myActionsMap[ BottomId ] = aAction;
-
- aAction = new QtxAction(tr("MNU_LEFT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
- tr( "MNU_LEFT_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_LEFT_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onLeftView()));
- myActionsMap[ LeftId ] = aAction;
-
- aAction = new QtxAction(tr("MNU_RIGHT_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
- tr( "MNU_RIGHT_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onRightView()));
- myActionsMap[ RightId ] = aAction;
-
- // Reset
- aAction = new QtxAction(tr("MNU_RESET_VIEW"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
- tr( "MNU_RESET_VIEW" ), 0, this);
- aAction->setStatusTip(tr("DSC_RESET_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onResetView()));
- myActionsMap[ ResetId ] = aAction;
-
- // onViewTrihedron: Shows - Hides Trihedron
- aAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"), aResMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
- tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
- aAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
- myActionsMap[ ViewTrihedronId ] = aAction;
+ return getMainWindow()->getInteractor();
}
-#if defined(WIN32) && !defined(_DEBUG)
-#pragma optimize( "", on )
-#endif
-//----------------------------------------------------------------------------
-void
+vtkRenderer*
SVTK_ViewWindow
-::createToolBar()
+::getRenderer()
{
- myActionsMap[DumpId]->addTo(myToolBar);
- myActionsMap[ViewTrihedronId]->addTo(myToolBar);
-
- SUIT_ToolButton* aScaleBtn = new SUIT_ToolButton(myToolBar);
- aScaleBtn->AddAction(myActionsMap[FitAllId]);
- aScaleBtn->AddAction(myActionsMap[FitRectId]);
- aScaleBtn->AddAction(myActionsMap[ZoomId]);
-
- SUIT_ToolButton* aPanningBtn = new SUIT_ToolButton(myToolBar);
- aPanningBtn->AddAction(myActionsMap[PanId]);
- aPanningBtn->AddAction(myActionsMap[GlobalPanId]);
-
- myActionsMap[RotationId]->addTo(myToolBar);
-
- SUIT_ToolButton* aViewsBtn = new SUIT_ToolButton(myToolBar);
- aViewsBtn->AddAction(myActionsMap[FrontId]);
- aViewsBtn->AddAction(myActionsMap[BackId]);
- aViewsBtn->AddAction(myActionsMap[TopId]);
- aViewsBtn->AddAction(myActionsMap[BottomId]);
- aViewsBtn->AddAction(myActionsMap[LeftId]);
- aViewsBtn->AddAction(myActionsMap[RightId]);
+ return myMainWindow->getRenderer();
+}
- myActionsMap[ResetId]->addTo(myToolBar);
+SVTK_Selector*
+SVTK_ViewWindow
+::GetSelector()
+{
+ return myMainWindow->GetSelector();
}
+
//----------------------------------------------------------------------------
void
SVTK_ViewWindow
::onFrontView()
{
- vtkCamera* camera = myRenderer->GetActiveCamera();
- camera->SetPosition(1,0,0);
- camera->SetViewUp(0,0,1);
- camera->SetFocalPoint(0,0,0);
- onFitAll();
+ myMainWindow->onFrontView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onBackView()
{
- vtkCamera* camera = myRenderer->GetActiveCamera();
- camera->SetPosition(-1,0,0);
- camera->SetViewUp(0,0,1);
- camera->SetFocalPoint(0,0,0);
- onFitAll();
+ myMainWindow->onBackView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onTopView()
{
- vtkCamera* camera = myRenderer->GetActiveCamera();
- camera->SetPosition(0,0,1);
- camera->SetViewUp(0,1,0);
- camera->SetFocalPoint(0,0,0);
- onFitAll();
+ myMainWindow->onTopView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onBottomView()
{
- vtkCamera* camera = myRenderer->GetActiveCamera();
- camera->SetPosition(0,0,-1);
- camera->SetViewUp(0,1,0);
- camera->SetFocalPoint(0,0,0);
- onFitAll();
+ myMainWindow->onBottomView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onLeftView()
{
- vtkCamera* camera = myRenderer->GetActiveCamera();
- camera->SetPosition(0,-1,0);
- camera->SetViewUp(0,0,1);
- camera->SetFocalPoint(0,0,0);
- onFitAll();
+ myMainWindow->onLeftView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onRightView()
{
- vtkCamera* camera = myRenderer->GetActiveCamera();
- camera->SetPosition(0,1,0);
- camera->SetViewUp(0,0,1);
- camera->SetFocalPoint(0,0,0);
- onFitAll();
+ myMainWindow->onRightView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onResetView()
{
- int aTrihedronIsVisible = isTrihedronDisplayed();
- int aCubeAxesIsVisible = isCubeAxesDisplayed();
-
- myTrihedron->SetVisibility( VTKViewer_Trihedron::eOnlyLineOn );
- myCubeAxes->SetVisibility(0);
-
- ::ResetCamera(myRenderer,true);
- vtkCamera* aCamera = myRenderer->GetActiveCamera();
- aCamera->SetPosition(1,-1,1);
- aCamera->SetViewUp(0,0,1);
- ::ResetCamera(myRenderer,true);
-
- if (aTrihedronIsVisible) myTrihedron->VisibilityOn();
- else myTrihedron->VisibilityOff();
-
- if (aCubeAxesIsVisible) myCubeAxes->VisibilityOn();
- else myCubeAxes->VisibilityOff();
-
- static float aCoeff = 3.0;
- aCamera->SetParallelScale(aCoeff*aCamera->GetParallelScale());
- Repaint();
+ myMainWindow->onResetView();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onFitAll()
{
- int aTrihedronWasVisible = false;
- int aCubeAxesWasVisible = false;
- if (myTrihedron) {
- aTrihedronWasVisible = isTrihedronDisplayed();
- if (aTrihedronWasVisible)
- myTrihedron->VisibilityOff();
- }
-
- if (myCubeAxes) {
- aCubeAxesWasVisible = isCubeAxesDisplayed();
- if (aCubeAxesWasVisible)
- myCubeAxes->VisibilityOff();
- }
-
- if (myTrihedron->GetVisibleActorCount(myRenderer)) {
- myTrihedron->VisibilityOff();
- myCubeAxes->VisibilityOff();
- ::ResetCamera(myRenderer);
- } else {
- myTrihedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
- myCubeAxes->SetVisibility(2);
- ::ResetCamera(myRenderer,true);
- }
-
- if (aTrihedronWasVisible)
- myTrihedron->VisibilityOn();
- else
- myTrihedron->VisibilityOff();
-
- if (aCubeAxesWasVisible)
- myCubeAxes->VisibilityOn();
- else
- myCubeAxes->VisibilityOff();
-
- ::ResetCameraClippingRange(myRenderer);
-
- Repaint();
+ myMainWindow->onFitAll();
}
//----------------------------------------------------------------
SVTK_ViewWindow
::onSelectionChanged()
{
- unHighlightAll();
-
- const SALOME_ListIO& aListIO = mySelector->StoredIObjects();
- SALOME_ListIteratorOfListIO anIter(aListIO);
- for(; anIter.More(); anIter.Next()){
- highlight(anIter.Value(),true,!anIter.More());
- }
-
- emit selectionChanged();
+ myView->onSelectionChanged();
}
//----------------------------------------------------------------
SVTK_ViewWindow
::SetSelectionMode(Selection_Mode theMode)
{
- mySelector->SetSelectionMode(theMode);
- myRWInteractor->SetSelectionMode(theMode);
+ myMainWindow->SetSelectionMode( theMode );
}
//----------------------------------------------------------------
SVTK_ViewWindow
::SelectionMode() const
{
- return mySelector->SelectionMode();
+ return myMainWindow->SelectionMode();
}
//----------------------------------------------------------------
SVTK_ViewWindow
::unHighlightAll()
{
- myRWInteractor->unHighlightAll();
+ myView->unHighlightAll();
}
//----------------------------------------------------------------
void
SVTK_ViewWindow
-::highlight( const Handle(SALOME_InteractiveObject)& theIO,
- bool theIsHighlight,
- bool theIsUpdate )
+::highlight(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theIsHighlight,
+ bool theIsUpdate )
{
- myRWInteractor->highlight(theIO, theIsHighlight, theIsUpdate);
-
- if(mySelector->HasIndex(theIO) && theIO->hasEntry()){
- TColStd_IndexedMapOfInteger aMapIndex;
- mySelector->GetIndex(theIO,aMapIndex);
- using namespace VTK;
- const char* anEntry = theIO->getEntry();
- vtkActorCollection* aCollection = myRenderer->GetActors();
- if(SALOME_Actor* anActor = Find<SALOME_Actor>(aCollection,TIsSameEntry<SALOME_Actor>(anEntry))){
- switch (mySelector->SelectionMode()) {
- case NodeSelection:
- myRWInteractor->highlightPoint(aMapIndex,anActor,theIsHighlight,theIsUpdate);
- break;
- case EdgeOfCellSelection:
- myRWInteractor->highlightEdge(aMapIndex,anActor,theIsHighlight,theIsUpdate);
- break;
- case CellSelection:
- case EdgeSelection:
- case FaceSelection:
- case VolumeSelection:
- myRWInteractor->highlightCell(aMapIndex,anActor,theIsHighlight,theIsUpdate);
- break;
- }
- }
- }else{
- myRWInteractor->unHighlightSubSelection();
- }
+ myView->highlight( theIO, theIsHighlight, theIsUpdate );
}
//----------------------------------------------------------------
SVTK_ViewWindow
::isInViewer( const Handle(SALOME_InteractiveObject)& theIO )
{
- return myRWInteractor->isInViewer( theIO );
+ return myView->isInViewer( theIO );
}
//----------------------------------------------------------------
SVTK_ViewWindow
::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
{
- return myRWInteractor->isVisible( theIO );
+ return myView->isVisible( theIO );
+}
+
+//----------------------------------------------------------------
+void
+SVTK_ViewWindow
+::Display(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theImmediatly)
+{
+ myView->Display(theIO,theImmediatly);
+}
+
+void
+SVTK_ViewWindow
+::Erase(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theImmediatly)
+{
+ myView->Erase(theIO,theImmediatly);
+}
+
+void
+SVTK_ViewWindow
+::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO)
+{
+ myView->DisplayOnly(theIO);
+}
+
+void
+SVTK_ViewWindow
+::DisplayAll()
+{
+ myView->DisplayAll();
+}
+
+void
+SVTK_ViewWindow
+::EraseAll()
+{
+ myView->EraseAll();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::setBackgroundColor( const QColor& color )
{
- if ( myRenderer )
- myRenderer->SetBackground( color.red()/255., color.green()/255., color.blue()/255. );
+ myMainWindow->SetBackgroundColor( color );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::backgroundColor() const
{
- float backint[3];
- if ( myRenderer ) {
- myRenderer->GetBackground( backint );
- return QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255));
- }
- return SUIT_ViewWindow::backgroundColor();
+ return myMainWindow->BackgroundColor();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::Repaint(bool theUpdateTrihedron)
{
- if (theUpdateTrihedron)
- onAdjustTrihedron();
- myRenderWindow->update();
+ myMainWindow->Repaint( theUpdateTrihedron );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::GetScale( double theScale[3] )
{
- myTransform->GetMatrixScale( theScale );
+ myMainWindow->GetScale( theScale );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::SetScale( double theScale[3] )
{
- myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
- myRWInteractor->Render();
- Repaint();
+ myMainWindow->SetScale( theScale );
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::isTrihedronDisplayed()
{
- return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
+ return myMainWindow->IsTrihedronDisplayed();
}
bool
SVTK_ViewWindow
::isCubeAxesDisplayed()
{
- return myCubeAxes->GetVisibility() == 1;
+ return myMainWindow->IsCubeAxesDisplayed();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onViewTrihedron()
{
- if(!myTrihedron)
- return;
-
- if(isTrihedronDisplayed())
- myTrihedron->VisibilityOff();
- else
- myTrihedron->VisibilityOn();
-
- Repaint();
+ myMainWindow->onViewTrihedron();
}
void
SVTK_ViewWindow
::onViewCubeAxes()
{
- if(!myCubeAxes)
- return;
-
- if(isCubeAxesDisplayed())
- myCubeAxes->VisibilityOff();
- else
- myCubeAxes->VisibilityOn();
-
- Repaint();
+ myMainWindow->onViewCubeAxes();
}
//----------------------------------------------------------------------------
-/*bool
-SVTK_ViewWindow
-::ComputeTrihedronSize( double& theNewSize, double& theSize )
+VTKViewer_Trihedron*
+SVTK_ViewWindow::
+GetTrihedron()
{
- // calculating diagonal of visible props of the renderer
- float aBndBox[ 6 ];
- myTrihedron->VisibilityOff();
-
- if ( ::ComputeVisiblePropBounds( myRenderer, aBndBox ) == 0 ) {
- aBndBox[ 1 ] = aBndBox[ 3 ] = aBndBox[ 5 ] = 100;
- aBndBox[ 0 ] = aBndBox[ 2 ] = aBndBox[ 4 ] = 0;
- }
-
- myTrihedron->VisibilityOn();
- float aLength = 0;
- static bool aCalcByDiag = false;
- if ( aCalcByDiag ) {
- aLength = sqrt( ( aBndBox[1]-aBndBox[0])*(aBndBox[1]-aBndBox[0] )+
- ( aBndBox[3]-aBndBox[2])*(aBndBox[3]-aBndBox[2] )+
- ( aBndBox[5]-aBndBox[4])*(aBndBox[5]-aBndBox[4] ) );
- } else {
- aLength = aBndBox[ 1 ]-aBndBox[ 0 ];
- aLength = max( ( aBndBox[ 3 ] - aBndBox[ 2 ] ),aLength );
- aLength = max( ( aBndBox[ 5 ] - aBndBox[ 4 ] ),aLength );
- }
-
- float aSizeInPercents = myTrihedronSize;
-
- static float EPS_SIZE = 5.0E-3;
- theSize = myTrihedron->GetSize();
- theNewSize = aLength * aSizeInPercents / 100.0;
-
- // if the new trihedron size have sufficient difference, then apply the value
- return fabs( theNewSize - theSize) > theSize * EPS_SIZE ||
- fabs( theNewSize-theSize ) > theNewSize * EPS_SIZE;
-}*/
+ return myMainWindow->GetTrihedron();
+}
-//----------------------------------------------------------------------------
-int SVTK_ViewWindow::GetTrihedronSize() const
+SVTK_CubeAxesActor2D*
+SVTK_ViewWindow
+::GetCubeAxes()
{
- return myTrihedronSize;
+ return myMainWindow->GetCubeAxes();
}
-void SVTK_ViewWindow::SetTrihedronSize( const int sz )
+int
+SVTK_ViewWindow
+::GetTrihedronSize() const
{
- if ( myTrihedronSize == sz )
- return;
+ return myMainWindow->GetTrihedronSize();
+}
- myTrihedronSize = sz;
- AdjustTrihedrons( true );
+void
+SVTK_ViewWindow
+::SetTrihedronSize(const int theSize)
+{
+ myMainWindow->SetTrihedronSize(theSize);
}
/*! If parameter theIsForcedUpdate is true, recalculate parameters for
SVTK_ViewWindow
::AdjustTrihedrons(const bool theIsForcedUpdate)
{
- if ((!isCubeAxesDisplayed() && !isTrihedronDisplayed()) && !theIsForcedUpdate)
- return;
-
- float bnd[ 6 ];
- float newbnd[6];
- newbnd[ 0 ] = newbnd[ 2 ] = newbnd[ 4 ] = VTK_LARGE_FLOAT;
- newbnd[ 1 ] = newbnd[ 3 ] = newbnd[ 5 ] = -VTK_LARGE_FLOAT;
-
- myCubeAxes->GetBounds(bnd);
-
- int aVisibleNum = myTrihedron->GetVisibleActorCount( myRenderer );
- //if (aVisibleNum || theIsForcedUpdate) {
- if (aVisibleNum) {
- // if the new trihedron size have sufficient difference, then apply the value
- double aNewSize = 100, anOldSize=myTrihedron->GetSize();
- bool aTDisplayed = isTrihedronDisplayed();
- bool aCDisplayed = isCubeAxesDisplayed();
- if(aTDisplayed) myTrihedron->VisibilityOff();
- if(aCDisplayed) myCubeAxes->VisibilityOff();
-
- SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
- QString aSetting = aResMgr->stringValue("Viewer", "TrihedronSize", "105");
- static float aSizeInPercents = aSetting.toFloat();
-
- //bool isComputeTrihedronSize =
- ::ComputeTrihedronSize(myRenderer, aNewSize, anOldSize, aSizeInPercents);
-
- myTrihedron->SetSize( aNewSize );
-
- // iterate through displayed objects and set size if necessary
- vtkActorCollection* anActors = getRenderer()->GetActors();
- anActors->InitTraversal();
- while (vtkActor* anActor = anActors->GetNextActor())
- {
- if (SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast( anActor ))
- {
- if (aSActor->IsResizable())
- aSActor->SetSize( 0.5 * aNewSize );
- if (aSActor->GetVisibility() && !aSActor->IsInfinitive()) {
- float *abounds = aSActor->GetBounds();
- if (abounds[0] > -VTK_LARGE_FLOAT && abounds[1] < VTK_LARGE_FLOAT &&
- abounds[2] > -VTK_LARGE_FLOAT && abounds[3] < VTK_LARGE_FLOAT &&
- abounds[4] > -VTK_LARGE_FLOAT && abounds[5] < VTK_LARGE_FLOAT)
- for (int i = 0; i < 5; i = i + 2) {
- if (abounds[i] < newbnd[i]) newbnd[i] = abounds[i];
- if (abounds[i+1] > newbnd[i+1]) newbnd[i+1] = abounds[i+1];
- }
- }
- }
- }
- if (aTDisplayed) myTrihedron->VisibilityOn();
- if (aCDisplayed) myCubeAxes->VisibilityOn();
-
- } else {
- double aSize = myTrihedron->GetSize();
- newbnd[0] = newbnd[2] = newbnd[4] = 0;
- newbnd[1] = newbnd[3] = newbnd[5] = aSize;
- }
-
- if (newbnd[0] < VTK_LARGE_FLOAT && newbnd[2] < VTK_LARGE_FLOAT && newbnd[4] < VTK_LARGE_FLOAT &&
- newbnd[1] >-VTK_LARGE_FLOAT && newbnd[3] >-VTK_LARGE_FLOAT && newbnd[5] >-VTK_LARGE_FLOAT) {
- for(int i=0;i<6;i++) bnd[i] = newbnd[i];
- myCubeAxes->SetBounds(bnd);
- }
-
- myCubeAxes->SetBounds(bnd);
-
- ::ResetCameraClippingRange(myRenderer);
+ myMainWindow->AdjustActors();
}
//----------------------------------------------------------------------------
SVTK_ViewWindow
::onAdjustTrihedron()
{
- AdjustTrihedrons( false );
+ myMainWindow->onAdjustTrihedron();
}
void
SVTK_ViewWindow
::onAdjustCubeAxes()
{
- AdjustTrihedrons(false);
-}
-
-#define INCREMENT_FOR_OP 10
-
-//=======================================================================
-// name : onPanLeft
-// Purpose : Performs incremental panning to the left
-//=======================================================================
-void
-SVTK_ViewWindow
-::onPanLeft()
-{
- myRWInteractor->GetSInteractorStyle()->IncrementalPan( -INCREMENT_FOR_OP, 0 );
-}
-
-//=======================================================================
-// name : onPanRight
-// Purpose : Performs incremental panning to the right
-//=======================================================================
-void
-SVTK_ViewWindow
-::onPanRight()
-{
- myRWInteractor->GetSInteractorStyle()->IncrementalPan( INCREMENT_FOR_OP, 0 );
-}
-
-//=======================================================================
-// name : onPanUp
-// Purpose : Performs incremental panning to the top
-//=======================================================================
-void
-SVTK_ViewWindow
-::onPanUp()
-{
- myRWInteractor->GetSInteractorStyle()->IncrementalPan( 0, INCREMENT_FOR_OP );
-}
-
-//=======================================================================
-// name : onPanDown
-// Purpose : Performs incremental panning to the bottom
-//=======================================================================
-void
-SVTK_ViewWindow
-::onPanDown()
-{
- myRWInteractor->GetSInteractorStyle()->IncrementalPan( 0, -INCREMENT_FOR_OP );
-}
-
-//=======================================================================
-// name : onZoomIn
-// Purpose : Performs incremental zooming in
-//=======================================================================
-void
-SVTK_ViewWindow
-::onZoomIn()
-{
- myRWInteractor->GetSInteractorStyle()->IncrementalZoom( INCREMENT_FOR_OP );
-}
-
-//=======================================================================
-// name : onZoomOut
-// Purpose : Performs incremental zooming out
-//=======================================================================
-void
-SVTK_ViewWindow
-::onZoomOut()
-{
- myRWInteractor->GetSInteractorStyle()->IncrementalZoom( -INCREMENT_FOR_OP );
-}
-
-//=======================================================================
-// name : onRotateLeft
-// Purpose : Performs incremental rotating to the left
-//=======================================================================
-void
-SVTK_ViewWindow
-::onRotateLeft()
-{
- myRWInteractor->GetSInteractorStyle()->IncrementalRotate( -INCREMENT_FOR_OP, 0 );
-}
-
-//=======================================================================
-// name : onRotateRight
-// Purpose : Performs incremental rotating to the right
-//=======================================================================
-void
-SVTK_ViewWindow
-::onRotateRight()
-{
- myRWInteractor->GetSInteractorStyle()->IncrementalRotate( INCREMENT_FOR_OP, 0 );
-}
-
-//=======================================================================
-// name : onRotateUp
-// Purpose : Performs incremental rotating to the top
-//=======================================================================
-void
-SVTK_ViewWindow
-::onRotateUp()
-{
- myRWInteractor->GetSInteractorStyle()->IncrementalRotate( 0, -INCREMENT_FOR_OP );
+ myMainWindow->onAdjustCubeAxes();
}
//=======================================================================
emit mouseDoubleClicked( this, event );
}
-//=======================================================================
-// name : onRotateDown
-// Purpose : Performs incremental rotating to the bottom
-//=======================================================================
+//----------------------------------------------------------------------------
void
SVTK_ViewWindow
-::onRotateDown()
+::AddActor( VTKViewer_Actor* theActor,
+ bool theUpdate )
{
- myRWInteractor->GetSInteractorStyle()->IncrementalRotate( 0, INCREMENT_FOR_OP );
+ myMainWindow->AddActor( theActor, theUpdate );
}
//----------------------------------------------------------------------------
void
SVTK_ViewWindow
-::InsertActor( SALOME_Actor* theActor, bool theMoveInternalActors )
+::RemoveActor( VTKViewer_Actor* theActor,
+ bool theUpdate )
{
- theActor->AddToRender(myRenderer);
- theActor->SetTransform(myTransform);
- if(theMoveInternalActors)
- myRWInteractor->MoveInternalActors();
+ myMainWindow->RemoveActor( theActor, theUpdate );
}
//----------------------------------------------------------------------------
-void
+QImage
SVTK_ViewWindow
-::AddActor( SALOME_Actor* theActor, bool theUpdate /*=false*/ )
+::dumpView()
{
- InsertActor(theActor);
- if(theUpdate)
- Repaint();
+ return myMainWindow->dumpView();
}
//----------------------------------------------------------------------------
void
SVTK_ViewWindow
-::RemoveActor( SALOME_Actor* theActor, bool theUpdate /*=false*/ )
+::SetSelectionProp(const double& theRed,
+ const double& theGreen,
+ const double& theBlue,
+ const int& theWidth)
{
- theActor->RemoveFromRender(myRenderer);
- if(theUpdate)
- Repaint();
+ myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
}
//----------------------------------------------------------------------------
void
SVTK_ViewWindow
-::MoveActor( SALOME_Actor* theActor)
+::SetPreselectionProp(const double& theRed,
+ const double& theGreen,
+ const double& theBlue,
+ const int& theWidth)
{
- RemoveActor(theActor);
- InsertActor(theActor,true);
+ myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
}
//----------------------------------------------------------------------------
-QImage
+void
SVTK_ViewWindow
-::dumpView()
+::SetSelectionTolerance(const double& theTolNodes,
+ const double& theTolItems)
{
- QPixmap px = QPixmap::grabWindow( myRenderWindow->winId() );
- return px.convertToImage();
+ myView->SetSelectionTolerance(theTolNodes,theTolItems);
+}
+
+//----------------------------------------------------------------------------
+int convertAction( const int accelAction )
+{
+ switch ( accelAction ) {
+ case SUIT_Accel::PanLeft : return SVTK::PanLeftEvent;
+ case SUIT_Accel::PanRight : return SVTK::PanRightEvent;
+ case SUIT_Accel::PanUp : return SVTK::PanUpEvent;
+ case SUIT_Accel::PanDown : return SVTK::PanDownEvent;
+ case SUIT_Accel::ZoomIn : return SVTK::ZoomInEvent;
+ case SUIT_Accel::ZoomOut : return SVTK::ZoomOutEvent;
+ case SUIT_Accel::RotateLeft : return SVTK::RotateLeftEvent;
+ case SUIT_Accel::RotateRight : return SVTK::RotateRightEvent;
+ case SUIT_Accel::RotateUp : return SVTK::RotateUpEvent;
+ case SUIT_Accel::RotateDown : return SVTK::RotateDownEvent;
+ }
+ return accelAction;
}
//----------------------------------------------------------------------------
void
SVTK_ViewWindow
-::action( const int theAction )
+::action( const int accelAction )
{
- switch ( theAction ) {
- case SUIT_Accel::PanLeft : onPanLeft(); break;
- case SUIT_Accel::PanRight : onPanRight(); break;
- case SUIT_Accel::PanUp : onPanUp(); break;
- case SUIT_Accel::PanDown : onPanDown(); break;
- case SUIT_Accel::ZoomIn : onZoomIn(); break;
- case SUIT_Accel::ZoomOut : onZoomOut(); break;
- case SUIT_Accel::ZoomFit : onFitAll(); break;
- case SUIT_Accel::RotateLeft : onRotateLeft(); break;
- case SUIT_Accel::RotateRight : onRotateRight(); break;
- case SUIT_Accel::RotateUp : onRotateUp(); break;
- case SUIT_Accel::RotateDown : onRotateDown(); break;
- }
+ if ( accelAction == SUIT_Accel::ZoomFit )
+ onFitAll();
+ else {
+ int anEvent = convertAction( accelAction );
+ myMainWindow->InvokeEvent( anEvent, 0 );
+ }
}
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef SVTK_VIEWWINDOW_H
#define SVTK_VIEWWINDOW_H
#endif
#include "SVTK.h"
-#include "SUIT_ViewWindow.h"
-
#include "SVTK_Selection.h"
+#include "SUIT_ViewWindow.h"
#include "SALOME_InteractiveObject.hxx"
-class vtkRenderer;
-
-class QtxAction;
class SUIT_Desktop;
+class VTKViewer_Actor;
class VTKViewer_Trihedron;
-class VTKViewer_Transform;
-
-class SALOME_Actor;
-class SVTK_Viewer;
+class SVTK_ViewModelBase;
+class SVTK_MainWindow;
class SVTK_Selector;
+class SVTK_View;
+
+class SVTK_InteractorStyle;
class SVTK_CubeAxesActor2D;
class SVTK_RenderWindow;
-class SVTK_InteractorStyle;
class SVTK_RenderWindowInteractor;
+class vtkRenderer;
+class vtkRenderWindow;
+class vtkRenderWindowInteractor;
+
+//! Define a container for SALOME VTK view window
class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
{
Q_OBJECT;
-public:
- SVTK_ViewWindow( SUIT_Desktop*, SVTK_Viewer* );
- virtual ~SVTK_ViewWindow();
+ public:
+ //! To construct #SVTK_ViewWindow instance
+ SVTK_ViewWindow(SUIT_Desktop* theDesktop);
+
+ virtual
+ ~SVTK_ViewWindow();
- QToolBar* getToolBar() { return myToolBar; }
+ //! To initialize #SVTK_ViewWindow instance
+ virtual
+ void
+ Initialize(SVTK_ViewModelBase* theModel);
+
+ //! Get #SVTK_View
+ SVTK_View*
+ getView();
+
+ //! Get #SVTK_MainWindow
+ SVTK_MainWindow*
+ getMainWindow();
+
+ //! Redirect the request to #SVTK_MainWindow::getRenderWindow
+ vtkRenderWindow*
+ getRenderWindow();
+
+ //! Redirect the request to #SVTK_MainWindow::getInteractor
+ vtkRenderWindowInteractor*
+ getInteractor();
+
+ //! Redirect the request to #SVTK_MainWindow::getRenderer
+ vtkRenderer*
+ getRenderer();
+
+ //! Redirect the request to #SVTK_MainWindow::GetSelector
+ SVTK_Selector*
+ GetSelector();
- void setBackgroundColor( const QColor& );
- QColor backgroundColor() const;
-
- vtkRenderer* getRenderer() {return myRenderer;}
- SVTK_Selector* GetSelector() {return mySelector;}
- SVTK_RenderWindow* getRenderWindow() {return myRenderWindow;}
- SVTK_RenderWindowInteractor* getRWInteractor() {return myRWInteractor;}
- Selection_Mode SelectionMode() const;
- void SetSelectionMode(Selection_Mode theMode);
-
- bool isTrihedronDisplayed();
- bool isCubeAxesDisplayed();
+ //! Redirect the request to #SVTK_Selector::SelectionMode
+ Selection_Mode
+ SelectionMode() const;
+
+ //! Change selection mode
+ virtual
+ void
+ SetSelectionMode(Selection_Mode theMode);
+
+ //! Redirect the request to #SVTK_MainWindow::SetBackgroundColor
+ virtual
+ void
+ setBackgroundColor( const QColor& );
+
+ //! Redirect the request to #SVTK_MainWindow::SetBackgroundColor
+ QColor
+ backgroundColor() const;
+
+ //! Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
+ bool
+ isTrihedronDisplayed();
+
+ //! Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
+ bool
+ isCubeAxesDisplayed();
/* interactive object management */
- void highlight( const Handle(SALOME_InteractiveObject)& IObject,
- bool highlight, bool immediatly = true );
- void unHighlightAll();
- bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
- bool isVisible( const Handle(SALOME_InteractiveObject)& IObject );
+ //! Redirect the request to #SVTK_View::highlight (to support old code)
+ virtual
+ void
+ highlight(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theIsHighlight = true,
+ bool theIsUpdate = true);
+
+ //! Redirect the request to #SVTK_View::unHighlightAll (to support old code)
+ virtual
+ void
+ unHighlightAll();
+
+ //! Redirect the request to #SVTK_View::isInViewer (to support old code)
+ bool
+ isInViewer(const Handle(SALOME_InteractiveObject)& theIObject);
+
+ //! Redirect the request to #SVTK_View::isVisible (to support old code)
+ bool
+ isVisible(const Handle(SALOME_InteractiveObject)& theIObject);
/* selection */
- Handle(SALOME_InteractiveObject) FindIObject(const char* Entry);
+ //----------------------------------------------------------------------------
+ Handle(SALOME_InteractiveObject)
+ FindIObject(const char* theEntry);
/* display */
- void Display( const Handle(SALOME_InteractiveObject)& IObject,
- bool immediatly = true );
- void DisplayOnly( const Handle(SALOME_InteractiveObject)& IObject );
- void Erase( const Handle(SALOME_InteractiveObject)& IObject,
- bool immediatly = true );
- void DisplayAll();
- void EraseAll();
- void Repaint( bool theUpdateTrihedron );
- void Repaint() { Repaint(true); }
-
- //apply existing transformation on adding SALOME_Actor
- void SetScale( double theScale[3] );
- void GetScale( double theScale[3] );
- void AddActor( SALOME_Actor*, bool update = false );
- void RemoveActor(SALOME_Actor*, bool update = false);
-
- void AdjustTrihedrons( const bool forced );
- //merge with V2_2_0_VISU_improvements:bool ComputeTrihedronSize( double& theNewSize,
- //merge with V2_2_0_VISU_improvements: double& theOldSize );
-
- int GetTrihedronSize() const;
- void SetTrihedronSize( const int );
-
- VTKViewer_Trihedron* GetTrihedron() {return this->myTrihedron;};
- SVTK_CubeAxesActor2D* GetCubeAxes() {return this->myCubeAxes;};
-
+ //----------------------------------------------------------------------------
+ //! Redirect the request to #SVTK_View::Display (to support old code)
+ virtual
+ void
+ Display(const Handle(SALOME_InteractiveObject)& theIObject,
+ bool theImmediatly = true);
+
+ //! Redirect the request to #SVTK_View::DisplayOnly (to support old code)
+ virtual
+ void
+ DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject);
+
+ //! Redirect the request to #SVTK_View::Erase (to support old code)
+ virtual
+ void
+ Erase(const Handle(SALOME_InteractiveObject)& theIObject,
+ bool theImmediatly = true);
+
+ //! Redirect the request to #SVTK_View::DisplayAll (to support old code)
+ virtual
+ void
+ DisplayAll();
+
+ //! Redirect the request to #SVTK_View::EraseAll (to support old code)
+ virtual
+ void
+ EraseAll();
+
+ //! To repaint the viewer
+ virtual
+ void
+ Repaint(bool theUpdateTrihedron = true);
+
+ //----------------------------------------------------------------------------
+ //! Redirect the request to #SVTK_Renderer::SetScale
+ virtual
+ void
+ SetScale( double theScale[3] );
+
+ //! Redirect the request to #SVTK_Renderer::GetScale
+ virtual
+ void
+ GetScale( double theScale[3] );
+
+ //! Redirect the request to #SVTK_Renderer::AddActor
+ virtual
+ void
+ AddActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
+
+ //! Redirect the request to #SVTK_Renderer::RemoveActor
+ virtual
+ void
+ RemoveActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
+
+ //----------------------------------------------------------------------------
+ //! Redirect the request to #SVTK_Renderer::AdjustActors
+ virtual
+ void
+ AdjustTrihedrons(const bool theIsForced);
+
+ //! Redirect the request to #SVTK_Renderer::GetTrihedron
+ VTKViewer_Trihedron*
+ GetTrihedron();
+
+ //! Redirect the request to #SVTK_Renderer::GetCubeAxes
+ SVTK_CubeAxesActor2D*
+ GetCubeAxes();
+
+ //! Redirect the request to #SVTK_Renderer::GetTrihedronSize
+ int
+ GetTrihedronSize() const;
+
+ //! Redirect the request to #SVTK_Renderer::SetTrihedronSize
+ virtual
+ void
+ SetTrihedronSize( const int );
+
+ //! Redirect the request to #SVTK_Renderer::SetSelectionProp
+ virtual
+ void
+ SetSelectionProp(const double& theRed = 1,
+ const double& theGreen = 1,
+ const double& theBlue = 0,
+ const int& theWidth = 5);
+
+ //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
+ virtual
+ void
+ SetPreselectionProp(const double& theRed = 0,
+ const double& theGreen = 1,
+ const double& theBlue = 1,
+ const int& theWidth = 5);
+
+ //! Redirect the request to #SVTK_Renderer::SetSelectionTolerance
+ virtual
+ void
+ SetSelectionTolerance(const double& theTolNodes = 0.025,
+ const double& theTolCell = 0.001);
+
public slots:
- void onSelectionChanged();
+ virtual
+ void
+ onSelectionChanged();
signals:
void selectionChanged();
public slots:
- void onFrontView();
- void onBackView();
- void onTopView();
- void onBottomView();
- void onRightView();
- void onLeftView();
-
- void onResetView();
- void onFitAll();
-
- void onViewTrihedron();
- void onViewCubeAxes();
-
- void onAdjustTrihedron();
- void onAdjustCubeAxes();
-
- void onPanLeft();
- void onPanRight();
- void onPanUp();
- void onPanDown();
- void onZoomIn();
- void onZoomOut();
- void onRotateLeft();
- void onRotateRight();
- void onRotateUp();
- void onRotateDown();
-
- void activateZoom();
- void activateWindowFit();
- void activateRotation();
- void activatePanning();
- void activateGlobalPanning();
-
-protected:
- QImage dumpView();
- virtual void action( const int );
+ //! Redirect the request to #SVTK_Renderer::OnFrontView
+ virtual
+ void
+ onFrontView();
+
+ //! Redirect the request to #SVTK_Renderer::OnBackView
+ virtual
+ void
+ onBackView();
+
+ //! Redirect the request to #SVTK_Renderer::OnTopView
+ virtual
+ void
+ onTopView();
+
+ //! Redirect the request to #SVTK_Renderer::OnBottomView
+ virtual
+ void
+ onBottomView();
+
+ //! Redirect the request to #SVTK_Renderer::OnRightView
+ virtual
+ void
+ onRightView();
+
+ //! Redirect the request to #SVTK_Renderer::OnLeftView
+ virtual
+ void
+ onLeftView();
+
+ //! Redirect the request to #SVTK_Renderer::OnResetView
+ virtual
+ void
+ onResetView();
+
+ //! Redirect the request to #SVTK_Renderer::OnFitAll
+ virtual
+ void
+ onFitAll();
+
+ //! Redirect the request to #SVTK_Renderer::OnViewTrihedron
+ virtual
+ void
+ onViewTrihedron();
+
+ //! Redirect the request to #SVTK_Renderer::OnViewCubeAxes
+ virtual
+ void
+ onViewCubeAxes();
+
+ //! Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
+ virtual
+ void
+ onAdjustTrihedron();
+
+ //! Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
+ virtual
+ void
+ onAdjustCubeAxes();
protected slots:
void onKeyPressed(QKeyEvent* event);
void onMouseReleased(QMouseEvent* event);
void onMouseMoving(QMouseEvent* event);
-private:
- void InitialSetup();
- void InsertActor( SALOME_Actor* theActor,
- bool theMoveInternalActors = false );
- void MoveActor( SALOME_Actor* theActor );
-
-private:
- enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
- FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, ViewTrihedronId };
- typedef QMap<int, QtxAction*> ActionsMap;
-
- void createActions();
- void createToolBar();
-
- vtkRenderer* myRenderer;
-
- SVTK_Viewer* myModel;
- SVTK_Selector* mySelector;
-
- SVTK_RenderWindow* myRenderWindow;
- SVTK_RenderWindowInteractor* myRWInteractor;
+protected:
+ virtual
+ void
+ Initialize(SVTK_View* theView,
+ SVTK_ViewModelBase* theModel);
- VTKViewer_Transform* myTransform;
- VTKViewer_Trihedron* myTrihedron;
- int myTrihedronSize;
- SVTK_CubeAxesActor2D* myCubeAxes;
-
- QToolBar* myToolBar;
- ActionsMap myActionsMap;
-
- double myCurScale;
+ QImage dumpView();
+ virtual void action( const int );
- friend class SVTK_RenderWindowInteractor;
+ SVTK_View* myView;
+ SVTK_MainWindow* myMainWindow;
+ SVTK_ViewModelBase* myModel;
};
#ifdef WIN32
// Function : update
/*! Purpose : Update application.*/
//================================================================
-void SalomeApp_DataModel::update( LightApp_DataObject*, LightApp_Study* study )
+namespace
{
- SalomeApp_Study* aSStudy = dynamic_cast<SalomeApp_Study*>(study);
- LightApp_RootObject* studyRoot = 0;
- _PTR(SObject) sobj;
- SalomeApp_DataObject* modelRoot = dynamic_cast<SalomeApp_DataObject*>( root() );
- if ( !modelRoot ){ // not yet connected to a study -> try using <study> argument
+ LightApp_DataObject* FindDataObject(const _PTR(SObject)& theSObject,
+ SUIT_DataObject* theDataObject)
+ {
+ std::string anID = theSObject->GetID();
+ DataObjectList aList;
+ theDataObject->children(aList);
+ DataObjectListIterator aDataObjectIter(aList);
+ while(SUIT_DataObject* aDataObject = aDataObjectIter.current()){
+ if(LightApp_DataObject* aChildDataObject = dynamic_cast<LightApp_DataObject*>(aDataObject)){
+ QString anEntry = aChildDataObject->entry();
+ if(anID == anEntry.latin1())
+ return aChildDataObject;
+ }
+ ++aDataObjectIter;
+ }
+ return NULL;
+ }
+
+ void BuildTree(const _PTR(SObject)& theSObject,
+ SUIT_DataObject* theDataObject,
+ const _PTR(Study)& theStudyDS)
+ {
+ _PTR(ChildIterator) aSObjectIter(theStudyDS->NewChildIterator(theSObject));
+ for(; aSObjectIter->More(); aSObjectIter->Next()){
+ _PTR(SObject) aChildSObject(aSObjectIter->Value());
+ std::string aName = aChildSObject->GetName();
+ if(aName.empty())
+ continue;
+ SUIT_DataObject* aChildDataObject = FindDataObject(aChildSObject,theDataObject);
+ if(!aChildDataObject)
+ aChildDataObject = new SalomeApp_DataObject(aChildSObject,theDataObject);
+ BuildTree(aChildSObject,aChildDataObject,theStudyDS);
+ }
+ }
+}
+
+void SalomeApp_DataModel::update( LightApp_DataObject* theDataObject, LightApp_Study* theStudy )
+{
+ SalomeApp_Study* aSStudy = dynamic_cast<SalomeApp_Study*>(theStudy);
+ _PTR(SObject) aSObject;
+ LightApp_RootObject* aRootObject = NULL;
+ SalomeApp_DataObject* aModelRoot = dynamic_cast<SalomeApp_DataObject*>( root() );
+ if ( !aModelRoot ){ // not yet connected to a study -> try using <study> argument
if ( !aSStudy )
aSStudy = dynamic_cast<SalomeApp_Study*>( getModule()->getApp()->activeStudy() );
if ( aSStudy ){
- studyRoot = dynamic_cast<LightApp_RootObject*>( aSStudy->root() );
+ aRootObject = dynamic_cast<LightApp_RootObject*>( aSStudy->root() );
QString anId = getRootEntry( aSStudy );
if ( !anId.isEmpty() ){ // if nothing is published in the study for this module -> do nothing
_PTR(Study) aStudy ( aSStudy->studyDS() );
- sobj = aStudy->FindComponentID( std::string( anId.latin1() ) );
+ aSObject = aStudy->FindComponentID( std::string( anId.latin1() ) );
}
}
}
else{
- studyRoot = dynamic_cast<LightApp_RootObject*>( modelRoot->root() );
- if ( studyRoot ) {
- aSStudy = dynamic_cast<SalomeApp_Study*>( studyRoot->study() ); // <study> value should not change here theoretically, but just to make sure
+ aRootObject = dynamic_cast<LightApp_RootObject*>( aModelRoot->root() );
+ if ( aRootObject ) {
+ aSStudy = dynamic_cast<SalomeApp_Study*>( aRootObject->study() ); // <study> value should not change here theoretically, but just to make sure
if ( aSStudy ) {
_PTR(Study) aStudy ( aSStudy->studyDS() );
- // modelRoot->object() cannot be reused here: it is about to be deleted by buildTree() soon
- sobj = aStudy->FindComponentID( std::string( modelRoot->entry().latin1() ) );
+ // aModelRoot->object() cannot be reused here: it is about to be deleted by buildTree() soon
+ aSObject = aStudy->FindComponentID( aModelRoot->entry().latin1() );
}
}
}
- buildTree( sobj, studyRoot, aSStudy );
+ if(!theDataObject)
+ buildTree( aSObject, aRootObject, aSStudy );
+ else{
+ _PTR(Study) aStudyDS(aSStudy->studyDS());
+ QString anEntry = theDataObject->entry();
+ if(_PTR(SObject) aSObject = aStudyDS->FindObjectID(anEntry.latin1())){
+ std::string aName = aSObject->GetName();
+ if(aName.empty()){
+ if(SUIT_DataObject* aParentDataObject = theDataObject->parent())
+ aParentDataObject->removeChild(theDataObject);
+ }else
+ ::BuildTree(aSObject,theDataObject,aStudyDS);
+ }
+ }
}
//================================================================
</section>
<section name="language">
<parameter name="language" value="en"/>
- <parameter name="translators" value="%P_msg_%L.qm|%P_icons.qm|%P_images.qm"/>
+ <parameter name="translators" value="%P_msg_%L.qm|%PM_msg_%L.qm|%P_icons.qm|%P_images.qm|%PM_images.qm"/>
</section>
<section name="resources">
<parameter name="SUIT" value="${SUITRoot}/resources"/>
<parameter value="true" name="DisplayMode" />
<parameter value="true" name="auto_update" />
<parameter value="1" name="display_mode" />
- <parameter value="false" name="auto_groups" />
</section>
<section name="VISU" >
<parameter value="false" name="full_med_loading" />
<parameter value="1" name="sweeping_number_cycles" />
<parameter value="20" name="sweeping_number_steps" />
<parameter value="0.2" name="sweeping_time_step" />
+ <parameter value="0" name="mouse_behaviour" />
+ <parameter value="10" name="speed_increment" />
+ <parameter value="1" name="spacemouse_func1_btn" />
+ <parameter value="2" name="spacemouse_func2_btn" />
+ <parameter value="10" name="spacemouse_func3_btn" />
+ <parameter value="11" name="spacemouse_func4_btn" />
+ <parameter value="9" name="spacemouse_func5_btn" />
+ <parameter value="10" name="camera_movement_steps" />
+ <parameter value="true" name="point_sprite_results" />
+ <parameter value="0" name="point_sprite_primitive_type" />
+ <parameter value="256" name="point_sprite_clamp" />
+ <parameter value="${VISU_ROOT_DIR}/share/salome/resources/sprite_texture.bmp" name="point_sprite_main_texture"/>
+ <parameter value="${VISU_ROOT_DIR}/share/salome/resources/sprite_alpha.bmp" name="point_sprite_alpha_texture"/>
+ <parameter value="0.5" name="point_sprite_alpha_threshold" />
+ <parameter value="10" name="point_sprite_min_size" />
+ <parameter value="33" name="point_sprite_max_size" />
+ <parameter value="100" name="point_sprite_magnification" />
+ <parameter value="2" name="point_sprite_increment" />
+ <parameter value="15" name="point_sprite_size" />
+ <parameter value="0, 0, 255" name="point_sprite_color" />
+ <parameter value="8" name="geom_sphere_resolution" />
+ <parameter value="true" name="scalar_bar_display_global" />
+ <parameter value="0" name="scalar_bar_active_local" />
+ <parameter value="1" name="scalar_bar_bicolor" />
+ <parameter value="0.01" name="scalar_bar_spacing" />
+ <parameter value="0" name="inside_point_sprite_primitive_type" />
+ <parameter value="256" name="inside_point_sprite_clamp" />
+ <parameter value="${VISU_ROOT_DIR}/share/salome/resources/sprite_texture.bmp" name="inside_point_sprite_main_texture"/>
+ <parameter value="${VISU_ROOT_DIR}/share/salome/resources/sprite_alpha.bmp" name="inside_point_sprite_alpha_texture"/>
+ <parameter value="0.5" name="inside_point_sprite_alpha_threshold" />
+ <parameter value="10" name="inside_point_sprite_min_size" />
+ <parameter value="33" name="inside_point_sprite_max_size" />
+ <parameter value="100" name="inside_point_sprite_magnification" />
+ <parameter value="2" name="inside_point_sprite_increment" />
+ <parameter value="8" name="inside_geom_sphere_resolution" />
+ <parameter value="0" name="outside_point_sprite_primitive_type" />
+ <parameter value="256" name="outside_point_sprite_clamp" />
+ <parameter value="${VISU_ROOT_DIR}/share/salome/resources/sprite_texture.bmp" name="outside_point_sprite_main_texture"/>
+ <parameter value="${VISU_ROOT_DIR}/share/salome/resources/sprite_alpha.bmp" name="outside_point_sprite_alpha_texture"/>
+ <parameter value="0.5" name="outside_point_sprite_alpha_threshold" />
+ <parameter value="25" name="outside_point_sprite_size" />
+ <parameter value="true" name="outside_point_sprite_uniform" />
+ <parameter value="85, 0, 127" name="outside_point_sprite_color" />
+ <parameter value="8" name="outside_geom_sphere_resolution" />
+ <parameter value="0.5" name="picking_cursor_size" />
+ <parameter value="1.0" name="picking_pyramid_height" />
+ <parameter value="255, 255, 0" name="picking_selection_color" />
+ <parameter value="0.01" name="picking_point_tolerance" />
+ <parameter value="50" name="picking_transparency" />
+ <parameter value="0" name="picking_position" />
+ <parameter value="1.5" name="picking_zoom_factor" />
+ <parameter value="10" name="picking_step_number" />
+ <parameter value="false" name="picking_display_parent_mesh" />
+ <parameter value="false" name="build_at_once" />
+ <parameter value="true" name="close_at_finish" />
+ <parameter value="1" name="recorder_mode" />
+ <parameter value="17.3" name="recorder_fps" />
+ <parameter value="100" name="recorder_quality" />
+ <parameter value="true" name="recorder_progressive" />
</section>
<!-- Here go optional sections for other modules -->
<section name="resources">
VTKViewer_ConvexTool.h \
VTKViewer_Filter.h \
VTKViewer_GeometryFilter.h \
+ VTKViewer_AppendFilter.h \
VTKViewer_Algorithm.h \
VTKViewer.h \
VTKViewer_InteractorStyle.h \
VTKViewer_ViewWindow.h \
VTKViewer_Functor.h
-PO_FILES = VTKViewer_images.po \
- VTKViewer_msg_en.po
-
+PO_FILES = \
+ VTKViewer_images.po \
+ VTKViewer_msg_en.po \
+ VTKViewerM_images.po \
+ VTKViewerM_msg_en.po
+
# Libraries targets
LIB = libVTKViewer.la
VTKViewer_ExtractUnstructuredGrid.cxx \
VTKViewer_Filter.cxx \
VTKViewer_GeometryFilter.cxx \
+ VTKViewer_AppendFilter.cxx \
VTKViewer_InteractorStyle.cxx \
VTKViewer_PassThroughFilter.cxx \
VTKViewer_RectPicker.cxx \
VTKViewer_ViewManager.h \
VTKViewer_ViewModel.h \
VTKViewer_ViewWindow.h
-
-RESOURCES_FILES = \
- view_back.png \
- view_bottom.png \
- view_camera_dump.png \
- view_fitall.png \
- view_fitarea.png \
- view_front.png \
- view_glpan.png \
- view_left.png \
- view_pan.png \
- view_reset.png \
- view_right.png \
- view_rotate.png \
- view_top.png \
- view_triedre.png \
- view_zoom.png
CPPFLAGS+=$(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES)
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifdef WNT
#ifdef VTKVIEWER_EXPORTS
#define VTKVIEWER_EXPORT __declspec( dllexport )
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include "VTKViewer_Actor.h"
#include "VTKViewer_Transform.h"
#include "VTKViewer_GeometryFilter.h"
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEVER_ACTOR_H
#define VTKVIEVER_ACTOR_H
--- /dev/null
+// SALOME OBJECT : kernel of SALOME component
+//
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : VTKViewer_GeometryFilter.cxx
+// Author :
+// Module : SALOME
+// $Header$
+
+#include "VTKViewer_AppendFilter.h"
+
+#include "VTKViewer_ConvexTool.h"
+
+#include <vtkSmartPointer.h>
+#include <vtkCellArray.h>
+#include <vtkCellData.h>
+#include <vtkGenericCell.h>
+#include <vtkHexahedron.h>
+#include <vtkMergePoints.h>
+#include <vtkObjectFactory.h>
+#include <vtkPointData.h>
+#include <vtkPolyData.h>
+#include <vtkPyramid.h>
+#include <vtkStructuredGrid.h>
+#include <vtkTetra.h>
+#include <vtkUnsignedCharArray.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkVoxel.h>
+#include <vtkWedge.h>
+#include <vtkDataSetCollection.h>
+
+#include <vector>
+#include <map>
+using namespace std;
+
+
+#ifdef _DEBUG_
+//static int MYDEBUG = 0;
+//static int MYDEBUGWITHFILES = 0;
+#else
+//static int MYDEBUG = 0;
+//static int MYDEBUGWITHFILES = 0;
+#endif
+
+#if defined __GNUC__
+ #if __GNUC__ == 2
+ #define __GNUC_2__
+ #endif
+#endif
+
+vtkCxxRevisionMacro(VTKViewer_AppendFilter, "$Revision$");
+vtkStandardNewMacro(VTKViewer_AppendFilter);
+
+VTKViewer_AppendFilter
+::VTKViewer_AppendFilter()
+{
+ myDoMappingFlag=false;
+}
+
+VTKViewer_AppendFilter
+::~VTKViewer_AppendFilter()
+{}
+
+void
+VTKViewer_AppendFilter
+::SetDoMappingFlag(const bool theFlag)
+{
+ myDoMappingFlag=theFlag;
+}
+
+bool
+VTKViewer_AppendFilter
+::DoMappingFlag() const
+{
+ return myDoMappingFlag;
+}
+
+void
+VTKViewer_AppendFilter
+::SetPoints(vtkPoints* thePoints)
+{
+ myPoints = thePoints;
+}
+
+vtkPoints*
+VTKViewer_AppendFilter
+::GetPoints()
+{
+ return myPoints.GetPointer();
+}
+
+void
+VTKViewer_AppendFilter
+::Execute()
+{
+ if (myPoints.GetPointer()) {
+ MakeOutput();
+ }
+ else {
+ vtkAppendFilter::Execute();
+ }
+ if (myDoMappingFlag){
+ DoMapping();
+ }
+}
+
+void
+VTKViewer_AppendFilter
+::Reset()
+{
+ myNodeIds.clear();
+ myCellIds.clear();
+ myNodeRanges.clear();
+ myCellRanges.clear();
+ myNodeMapObjIDVtkID.clear();
+ myCellMapObjIDVtkID.clear();
+}
+//==================================================================
+// function: DoMapping
+// purpose :
+//==================================================================
+void
+VTKViewer_AppendFilter
+::DoMapping()
+{
+ int i, j, i1, i2, iNodeCnt, iCellCnt;
+ IteratorOfDataMapOfIntegerInteger aMapIt;
+ vtkIdType aNbPnts, aNbCells, aId;
+ vtkDataSet *pDS;
+ //
+ Reset();
+ //
+ iNodeCnt=0;
+ iCellCnt=0;
+ for (i=0; i<NumberOfInputs; ++i) {
+ pDS=(vtkDataSet *)Inputs[i];
+ //
+ // Nodes
+ if (!myPoints.GetPointer()) {
+ aNbPnts=pDS->GetNumberOfPoints();
+ i1=myNodeIds.size();
+ i2=i1+aNbPnts-1;
+ myNodeRanges.push_back(i1);
+ myNodeRanges.push_back(i2);
+ //
+ for(j=0; j<aNbPnts; ++j) {
+ aId=(vtkIdType)j;
+ myNodeIds.push_back(aId);
+ //
+ aMapIt=myNodeMapObjIDVtkID.find(aId);
+ if (aMapIt==myNodeMapObjIDVtkID.end()) {
+ // if not found
+ myNodeMapObjIDVtkID[aId]=iNodeCnt;
+ }
+ ++iNodeCnt;
+ }
+ }
+ //
+ // Cells
+ aNbCells=pDS->GetNumberOfCells();
+ i1=myCellIds.size();
+ i2=i1+aNbCells-1;
+ myCellRanges.push_back(i1);
+ myCellRanges.push_back(i2);
+ for(j=0; j<aNbCells; ++j) {
+ aId=(vtkIdType)j;
+ myCellIds.push_back(aId);
+ //
+ aMapIt=myCellMapObjIDVtkID.find(aId);
+ if (aMapIt==myCellMapObjIDVtkID.end()) {
+ // if not found
+ myCellMapObjIDVtkID[aId]=iCellCnt;
+ }
+ ++iCellCnt;
+ }
+ }
+}
+
+//---------------------------------------------------------------
+vtkIdType
+VTKViewer_AppendFilter
+::GetPointOutputID(vtkIdType theInputID)
+{
+ if (myPoints.GetPointer()) {
+ return theInputID;
+ }
+ //
+ int aVtkID=-1;
+ IteratorOfDataMapOfIntegerInteger aMapIt;
+ //
+ aMapIt=myNodeMapObjIDVtkID.find(theInputID);
+ if (aMapIt!=myNodeMapObjIDVtkID.end()) {
+ // found
+ PairOfDataMapOfIntegerInteger& aPair=(*aMapIt);
+ aVtkID=aPair.second;
+ }
+ return aVtkID;
+}
+
+
+//---------------------------------------------------------------
+vtkIdType
+VTKViewer_AppendFilter
+::GetCellOutputID(vtkIdType theInputID)
+{
+ int aVtkID=-1;
+ IteratorOfDataMapOfIntegerInteger aMapIt;
+ //
+ aMapIt=myCellMapObjIDVtkID.find(theInputID);
+ if (aMapIt!=myCellMapObjIDVtkID.end()) {
+ // found
+ PairOfDataMapOfIntegerInteger& aPair=(*aMapIt);
+ aVtkID=aPair.second;
+ }
+ return aVtkID;
+}
+
+
+//---------------------------------------------------------------
+vtkIdType
+VTKViewer_AppendFilter
+::GetPointInputID(vtkIdType theOutputID,
+ vtkIdType& theInputDataSetID)
+{
+ if (myPoints.GetPointer()) {
+ theInputDataSetID=0;
+ return theOutputID;
+ }
+ //
+ int aNb, aNbRanges, aRetID, i, i1, i2, j;
+ //
+ aRetID=-1;
+ theInputDataSetID=-1;
+ //
+ aNb=myNodeIds.size();
+ if (theOutputID<0 || theOutputID>=aNb) {
+ return aRetID;
+ }
+ //
+ aRetID=(int)myNodeIds[theOutputID];
+ //
+ aNbRanges=myNodeRanges.size()/2;
+ for (i=0; i<aNbRanges; ++i) {
+ j=2*i;
+ i1=myNodeRanges[j];
+ i2=myNodeRanges[j+1];
+ if (theOutputID>=i1 && theOutputID<=i2) {
+ theInputDataSetID=i;
+ }
+ }
+ //
+ return aRetID;
+}
+
+
+//---------------------------------------------------------------
+vtkIdType
+VTKViewer_AppendFilter
+::GetCellInputID(vtkIdType theOutputID,
+ vtkIdType& theInputDataSetID)
+{
+ int aNb, aNbRanges, aRetID, i, i1, i2, j;
+ //
+ aRetID=-1;
+ theInputDataSetID=-1;
+ //
+ aNb=myCellIds.size();
+ if (theOutputID<0 || theOutputID>=aNb) {
+ return aRetID;
+ }
+ //
+ aRetID=(int)myCellIds[theOutputID];
+ //
+ aNbRanges=myCellRanges.size()/2;
+ for (i=0; i<aNbRanges; ++i) {
+ j=2*i;
+ i1=myCellRanges[j];
+ i2=myCellRanges[j+1];
+ if (theOutputID>=i1 && theOutputID<=i2) {
+ theInputDataSetID=i;
+ }
+ }
+ //
+ return aRetID;
+}
+
+
+//---------------------------------------------------------------
+void
+VTKViewer_AppendFilter
+::MakeOutput()
+{
+ int idx;
+ vtkIdType numPts, numCells, newCellId, cellId;
+ vtkCellData *cd;
+ vtkIdList *ptIds;
+ vtkDataSet *ds;
+ vtkUnstructuredGrid *output = this->GetOutput();
+ //
+ numPts = myPoints->GetNumberOfPoints();
+ if (numPts < 1) {
+ return;
+ }
+ //
+ numCells = 0;
+ for (idx = 0; idx < this->NumberOfInputs; ++idx) {
+ ds = (vtkDataSet *)(this->Inputs[idx]);
+ if (ds != NULL) {
+ if ( ds->GetNumberOfPoints() <= 0 && ds->GetNumberOfCells() <= 0 ) {
+ continue; //no input, just skip
+ }
+ numCells += ds->GetNumberOfCells();
+ }//if non-empty dataset
+ }//for all inputs
+ if (numCells < 1) {
+ return;
+ }
+ //
+ // Now can allocate memory
+ output->Allocate(numCells);
+ ptIds = vtkIdList::New();
+ ptIds->Allocate(VTK_CELL_SIZE);
+ //
+ // Append each input dataset together
+ //
+ // 1.points
+ output->SetPoints(myPoints.GetPointer());
+ // 2.cells
+ for (idx = 0; idx < this->NumberOfInputs; ++idx) {
+ ds = (vtkDataSet *)(this->Inputs[idx]);
+ if (ds != NULL) {
+ numCells = ds->GetNumberOfCells();
+ cd = ds->GetCellData();
+ // copy cell and cell data
+ for (cellId=0; cellId<numCells; cellId++) {
+ ds->GetCellPoints(cellId, ptIds);
+ newCellId = output->InsertNextCell(ds->GetCellType(cellId), ptIds);
+ }
+ }
+ }
+ //
+ ptIds->Delete();
+}
+
--- /dev/null
+#ifndef VTKVIEWER_APPENDFILTER_H
+#define VTKVIEWER_APPENDFILTER_H
+
+#include "VTKViewer.h"
+
+#include <vtkAppendFilter.h>
+#include <vtkSmartPointer.h>
+
+#include <vector>
+#include <map>
+
+class vtkPoints;
+
+/*! \brief This class used same as vtkAppendFilter. See documentation on VTK for more information.
+ */
+class VTKVIEWER_EXPORT VTKViewer_AppendFilter : public vtkAppendFilter
+{
+public:
+ /*! \fn static VTKViewer_AppendFilter *New()
+ */
+ static VTKViewer_AppendFilter *New();
+
+ /*! \fn vtkTypeRevisionMacro(VTKViewer_AppendFilter, vtkAppendFilter)
+ * \brief VTK type revision macros.
+ */
+ vtkTypeRevisionMacro(VTKViewer_AppendFilter, vtkAppendFilter);
+
+ void SetDoMappingFlag(const bool theFlag);
+
+ bool DoMappingFlag() const;
+
+ void
+ SetPoints(vtkPoints* thePoints);
+
+ vtkPoints*
+ GetPoints();
+
+ vtkIdType
+ GetPointOutputID(vtkIdType theInputID);
+
+ vtkIdType
+ GetCellOutputID(vtkIdType theInputID);
+
+ vtkIdType
+ GetPointInputID(vtkIdType theOutputID,
+ vtkIdType& theInputDataSetID);
+
+ vtkIdType
+ GetCellInputID(vtkIdType theOutputID,
+ vtkIdType& theInputDataSetID);
+
+protected:
+ /*! \fn VTKViewer_AppendFilter();
+ * \brief Constructor
+ */
+ VTKViewer_AppendFilter();
+ /*! \fn ~VTKViewer_AppendFilter();
+ * \brief Destructor.
+ */
+ ~VTKViewer_AppendFilter();
+ /*! \fn void Execute();
+ * \brief Filter culculation method.
+ */
+ virtual void Execute();
+ //
+ void DoMapping();
+
+ void Reset();
+
+ void MakeOutput();
+
+ //
+ vtkSmartPointer<vtkPoints> myPoints;
+
+private:
+ typedef std::vector<vtkIdType> TVectorId;
+ typedef std::vector<int> VectorInt;
+ typedef std::map <int,int> DataMapOfIntegerInteger;
+ typedef DataMapOfIntegerInteger::iterator IteratorOfDataMapOfIntegerInteger;
+ typedef DataMapOfIntegerInteger::value_type PairOfDataMapOfIntegerInteger;
+private:
+ bool myDoMappingFlag;
+ TVectorId myNodeIds;
+ TVectorId myCellIds;
+ VectorInt myNodeRanges;
+ VectorInt myCellRanges;
+ DataMapOfIntegerInteger myNodeMapObjIDVtkID;
+ DataMapOfIntegerInteger myCellMapObjIDVtkID;
+};
+
+#endif
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include <VTKViewer_CellRectPicker.h>
#include "vtkGenericCell.h"
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
// 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
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEWER_EXTRACTUNSTRUCTUREDGRID_H
#define VTKVIEWER_EXTRACTUNSTRUCTUREDGRID_H
using namespace std;
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
-
#if defined __GNUC__
#if __GNUC__ == 2
#define __GNUC_2__
#endif
#endif
+//----------------------------------------------------------------------------
vtkCxxRevisionMacro(VTKViewer_GeometryFilter, "$Revision$");
vtkStandardNewMacro(VTKViewer_GeometryFilter);
VTKViewer_GeometryFilter::VTKViewer_GeometryFilter():
myShowInside(0),
- myStoreMapping(0)
+ myStoreMapping(0),
+ myIsWireframeMode(0)
{}
{}
+//----------------------------------------------------------------------------
void VTKViewer_GeometryFilter::Execute()
{
vtkDataSet *input= this->GetInput();
}
-void VTKViewer_GeometryFilter::SetStoreMapping(int theStoreMapping){
- myStoreMapping = theStoreMapping;
- this->Modified();
-}
-
-
-vtkIdType VTKViewer_GeometryFilter::GetElemObjId(int theVtkID){
- if(myVTK2ObjIds.empty() || theVtkID > myVTK2ObjIds.size()) return -1;
-#if defined __GNUC_2__
- return myVTK2ObjIds[theVtkID];
-#else
- return myVTK2ObjIds.at(theVtkID);
-#endif
-}
-
-
+//----------------------------------------------------------------------------
void VTKViewer_GeometryFilter::UnstructuredGridExecute()
{
vtkUnstructuredGrid *input= (vtkUnstructuredGrid *)this->GetInput();
vtkPointData *outputPD = output->GetPointData();
vtkCellData *outputCD = output->GetCellData();
- //vtkCellArray *Verts, *Lines, *Polys, *Strips;
vtkIdList *cellIds, *faceIds;
char *cellVis;
vtkIdType newCellId;
outputCD->CopyAllocate(cd,numCells,numCells/2);
output->Allocate(numCells/4+1,numCells);
- //Verts = vtkCellArray::New();
- //Verts->Allocate(numCells/4+1,numCells);
- //Lines = vtkCellArray::New();
- //Lines->Allocate(numCells/4+1,numCells);
- //Polys = vtkCellArray::New();
- //Polys->Allocate(numCells/4+1,numCells);
- //Strips = vtkCellArray::New();
- //Strips->Allocate(numCells/4+1,numCells);
// Loop over the cells determining what's visible
if (!allVisible)
case VTK_LINE:
case VTK_POLY_LINE:
newCellId = output->InsertNextCell(aCellType,npts,pts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
break;
case VTK_QUAD:
case VTK_POLYGON:
newCellId = output->InsertNextCell(aCellType,npts,pts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
break;
case VTK_TRIANGLE_STRIP:
newCellId = output->InsertNextCell(aCellType,npts,pts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
break;
case VTK_PIXEL:
newCellId = output->InsertNextCell(aCellType,npts,pts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
break;
faceIds->InsertNextId(pts[faceVerts[0]]);
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
- numFacePts = 3;
aCellType = VTK_TRIANGLE;
+ numFacePts = 3;
input->GetCellNeighbors(cellId, faceIds, cellIds);
- if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 ||
+ if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
for ( i=0; i < numFacePts; i++)
- {
aNewPts[i] = pts[faceVerts[i]];
- }
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
faceIds->InsertNextId(pts[faceVerts[3]]);
- numFacePts = 4;
aCellType = VTK_QUAD;
+ numFacePts = 4;
input->GetCellNeighbors(cellId, faceIds, cellIds);
- if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 ||
+ if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
for ( i=0; i < numFacePts; i++)
- {
aNewPts[i] = pts[faceVerts[PixelConvert[i]]];
- }
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
faceIds->InsertNextId(pts[faceVerts[3]]);
- numFacePts = 4;
aCellType = VTK_QUAD;
+ numFacePts = 4;
input->GetCellNeighbors(cellId, faceIds, cellIds);
- if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 ||
+ if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
for ( i=0; i < numFacePts; i++)
- {
aNewPts[i] = pts[faceVerts[i]];
- }
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
faceIds->InsertNextId(pts[faceVerts[0]]);
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
- numFacePts = 3;
aCellType = VTK_TRIANGLE;
+ numFacePts = 3;
if (faceVerts[3] >= 0)
{
faceIds->InsertNextId(pts[faceVerts[3]]);
- numFacePts = 4;
aCellType = VTK_QUAD;
+ numFacePts = 4;
}
input->GetCellNeighbors(cellId, faceIds, cellIds);
- if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 ||
+ if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
for ( i=0; i < numFacePts; i++)
- {
aNewPts[i] = pts[faceVerts[i]];
- }
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
faceIds->InsertNextId(pts[faceVerts[0]]);
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
- numFacePts = 3;
aCellType = VTK_TRIANGLE;
+ numFacePts = 3;
if (faceVerts[3] >= 0)
{
faceIds->InsertNextId(pts[faceVerts[3]]);
- numFacePts = 4;
aCellType = VTK_QUAD;
+ numFacePts = 4;
}
input->GetCellNeighbors(cellId, faceIds, cellIds);
- if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 ||
+ if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
for ( i=0; i < numFacePts; i++)
- {
aNewPts[i] = pts[faceVerts[i]];
- }
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
break;
}
//Quadratic cells
- case VTK_QUADRATIC_EDGE: {
- newCellId = output->InsertNextCell(VTK_POLY_LINE,npts,pts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- break;
- }
- case VTK_QUADRATIC_TRIANGLE: {
- numFacePts = 6;
- aCellType = VTK_POLYGON;
-
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[3];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[4];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[5];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
- break;
- }
- case VTK_QUADRATIC_QUAD: {
- numFacePts = 8;
- aCellType = VTK_POLYGON;
-
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[4];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[5];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[6];
- aNewPts[6] = pts[3];
- aNewPts[7] = pts[7];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
- break;
- }
- case VTK_QUADRATIC_TETRA: {
- numFacePts = 8;
- aCellType = VTK_POLYGON;
-
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[4];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[5];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[6];
- aNewPts[6] = pts[3];
- aNewPts[7] = pts[7];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
- break;
- }
- case VTK_QUADRATIC_HEXAHEDRON: {
- numFacePts = 8;
- aCellType = VTK_POLYGON;
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[8];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[17];
- aNewPts[4] = pts[5];
- aNewPts[5] = pts[12];
- aNewPts[6] = pts[4];
- aNewPts[7] = pts[16];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[1];
- aNewPts[1] = pts[9];
- aNewPts[2] = pts[2];
- aNewPts[3] = pts[18];
- aNewPts[4] = pts[6];
- aNewPts[5] = pts[13];
- aNewPts[6] = pts[5];
- aNewPts[7] = pts[17];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[2];
- aNewPts[1] = pts[10];
- aNewPts[2] = pts[3];
- aNewPts[3] = pts[19];
- aNewPts[4] = pts[7];
- aNewPts[5] = pts[14];
- aNewPts[6] = pts[6];
- aNewPts[7] = pts[18];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[3];
- aNewPts[1] = pts[11];
- aNewPts[2] = pts[0];
- aNewPts[3] = pts[16];
- aNewPts[4] = pts[4];
- aNewPts[5] = pts[15];
- aNewPts[6] = pts[7];
- aNewPts[7] = pts[19];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[8];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[9];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[10];
- aNewPts[6] = pts[3];
- aNewPts[7] = pts[11];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[4];
- aNewPts[1] = pts[12];
- aNewPts[2] = pts[5];
- aNewPts[3] = pts[13];
- aNewPts[4] = pts[6];
- aNewPts[5] = pts[14];
- aNewPts[6] = pts[7];
- aNewPts[7] = pts[15];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- break;
- }
- } //switch
+ case VTK_QUADRATIC_EDGE:
+ case VTK_QUADRATIC_TRIANGLE:
+ case VTK_QUADRATIC_QUAD:
+ case VTK_QUADRATIC_TETRA:
+ case VTK_QUADRATIC_HEXAHEDRON:
+ if(!myIsWireframeMode){
+ vtkGenericCell *cell = vtkGenericCell::New();
+ input->GetCell(cellId,cell);
+ vtkIdList *pts = vtkIdList::New();
+ vtkPoints *coords = vtkPoints::New();
+ vtkIdList *cellIds = vtkIdList::New();
+ vtkIdType newCellId;
+
+ if ( cell->GetCellDimension() == 1 ) {
+ aCellType = VTK_LINE;
+ numFacePts = 2;
+ cell->Triangulate(0,pts,coords);
+ for (i=0; i < pts->GetNumberOfIds(); i+=2) {
+ aNewPts[0] = pts->GetId(i);
+ aNewPts[1] = pts->GetId(i+1);
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+ outputCD->CopyData(cd,cellId,newCellId);
+ }
+ }
+ else if ( cell->GetCellDimension() == 2 ) {
+ aCellType = VTK_TRIANGLE;
+ numFacePts = 3;
+ cell->Triangulate(0,pts,coords);
+ for (i=0; i < pts->GetNumberOfIds(); i+=3) {
+ aNewPts[0] = pts->GetId(i);
+ aNewPts[1] = pts->GetId(i+1);
+ aNewPts[2] = pts->GetId(i+2);
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+ outputCD->CopyData(cd,cellId,newCellId);
+ }
+ }
+ else //3D nonlinear cell
+ {
+ aCellType = VTK_TRIANGLE;
+ numFacePts = 3;
+ for (int j=0; j < cell->GetNumberOfFaces(); j++){
+ vtkCell *face = cell->GetFace(j);
+ input->GetCellNeighbors(cellId, face->PointIds, cellIds);
+ if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ) {
+ face->Triangulate(0,pts,coords);
+ for (i=0; i < pts->GetNumberOfIds(); i+=3) {
+ aNewPts[0] = pts->GetId(i);
+ aNewPts[1] = pts->GetId(i+1);
+ aNewPts[2] = pts->GetId(i+2);
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+ outputCD->CopyData(cd,cellId,newCellId);
+ }
+ }
+ }
+ } //3d cell
+ cellIds->Delete();
+ coords->Delete();
+ pts->Delete();
+ cell->Delete();
+ break;
+ }else{
+ switch(aCellType){
+ case VTK_QUADRATIC_EDGE: {
+ aCellType = VTK_POLY_LINE;
+ numFacePts = 3;
+
+ aNewPts[0] = pts[0];
+ aNewPts[2] = pts[1];
+ aNewPts[1] = pts[2];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+ break;
+ }
+ case VTK_QUADRATIC_TRIANGLE: {
+ aCellType = VTK_POLYGON;
+ numFacePts = 6;
+
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[3];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[4];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[5];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+ break;
+ }
+ case VTK_QUADRATIC_QUAD: {
+ aCellType = VTK_POLYGON;
+ numFacePts = 8;
+
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[4];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[5];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[6];
+ aNewPts[6] = pts[3];
+ aNewPts[7] = pts[7];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+ break;
+ }
+ case VTK_QUADRATIC_TETRA: {
+ aCellType = VTK_POLYGON;
+ numFacePts = 6;
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[4];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[5];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[6];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[7];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[8];
+ aNewPts[4] = pts[1];
+ aNewPts[5] = pts[4];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[1];
+ aNewPts[1] = pts[8];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[9];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[5];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[2];
+ aNewPts[1] = pts[9];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[7];
+ aNewPts[4] = pts[0];
+ aNewPts[5] = pts[6];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ break;
+ }
+ case VTK_QUADRATIC_HEXAHEDRON: {
+ aCellType = VTK_POLYGON;
+ numFacePts = 8;
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[8];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[17];
+ aNewPts[4] = pts[5];
+ aNewPts[5] = pts[12];
+ aNewPts[6] = pts[4];
+ aNewPts[7] = pts[16];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[1];
+ aNewPts[1] = pts[9];
+ aNewPts[2] = pts[2];
+ aNewPts[3] = pts[18];
+ aNewPts[4] = pts[6];
+ aNewPts[5] = pts[13];
+ aNewPts[6] = pts[5];
+ aNewPts[7] = pts[17];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[2];
+ aNewPts[1] = pts[10];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[19];
+ aNewPts[4] = pts[7];
+ aNewPts[5] = pts[14];
+ aNewPts[6] = pts[6];
+ aNewPts[7] = pts[18];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[3];
+ aNewPts[1] = pts[11];
+ aNewPts[2] = pts[0];
+ aNewPts[3] = pts[16];
+ aNewPts[4] = pts[4];
+ aNewPts[5] = pts[15];
+ aNewPts[6] = pts[7];
+ aNewPts[7] = pts[19];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[8];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[9];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[10];
+ aNewPts[6] = pts[3];
+ aNewPts[7] = pts[11];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[4];
+ aNewPts[1] = pts[12];
+ aNewPts[2] = pts[5];
+ aNewPts[3] = pts[13];
+ aNewPts[4] = pts[6];
+ aNewPts[5] = pts[14];
+ aNewPts[6] = pts[7];
+ aNewPts[7] = pts[15];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ break;
+ }}
+ }
+ } //switch
} //if visible
} //for all cells
- if(MYDEBUG && myStoreMapping){
- for(int i = 0, iEnd = myVTK2ObjIds.size(); i < iEnd; i++){
- cout<<myVTK2ObjIds[i]<<", ";
- }
- cout<<"\n";
- }
-
- // Update ourselves and release memory
- //
- //output->SetVerts(Verts);
- //Verts->Delete();
- //output->SetLines(Lines);
- //Lines->Delete();
- //output->SetPolys(Polys);
- //Polys->Delete();
- //output->SetStrips(Strips);
- //Strips->Delete();
-
output->Squeeze();
vtkDebugMacro(<<"Extracted " << input->GetNumberOfPoints() << " points,"
}
-void VTKViewer_GeometryFilter::SetInside(int theShowInside){
- if(myShowInside == theShowInside) return;
+//----------------------------------------------------------------------------
+void
+VTKViewer_GeometryFilter
+::SetInside(int theShowInside)
+{
+ if(myShowInside == theShowInside)
+ return;
+
myShowInside = theShowInside;
this->Modified();
}
-int VTKViewer_GeometryFilter::GetInside(){
+
+int
+VTKViewer_GeometryFilter
+::GetInside()
+{
return myShowInside;
}
+
+
+//----------------------------------------------------------------------------
+void
+VTKViewer_GeometryFilter
+::SetWireframeMode(int theIsWireframeMode)
+{
+ if(myIsWireframeMode == theIsWireframeMode)
+ return;
+
+ myIsWireframeMode = theIsWireframeMode;
+ this->Modified();
+}
+
+int
+VTKViewer_GeometryFilter
+::GetWireframeMode()
+{
+ return myIsWireframeMode;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VTKViewer_GeometryFilter
+::SetStoreMapping(int theStoreMapping)
+{
+ if(myStoreMapping == theStoreMapping)
+ return;
+
+ myStoreMapping = theStoreMapping;
+ this->Modified();
+}
+
+int
+VTKViewer_GeometryFilter
+::GetStoreMapping()
+{
+ return myStoreMapping;
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType VTKViewer_GeometryFilter::GetElemObjId(int theVtkID){
+ if(myVTK2ObjIds.empty() || theVtkID > myVTK2ObjIds.size()) return -1;
+#if defined __GNUC_2__
+ return myVTK2ObjIds[theVtkID];
+#else
+ return myVTK2ObjIds.at(theVtkID);
+#endif
+}
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEWER_GEOMETRYFILTER_H
#define VTKVIEWER_GEOMETRYFILTER_H
* \retval myShowInside
*/
int GetInside();
+ /*! \fn void SetWireframeMode(int theIsWireframeMode)
+ * \brief Sets \a myIsWireframeMode flag. \a myIsWireframeMode is changed, call this->Modified().
+ * \param theIsWireframeMode - used for changing value of \a myIsWireframeMode variable.
+ */
+ void SetWireframeMode(int theIsWireframeMode);
+ /*! \fn int GetWireframeMode()
+ * \brief Return value of \a myIsWireframeMode
+ * \retval myIsWireframeMode
+ */
+ int GetWireframeMode();
/*! \fn void SetStoreMapping(int theStoreMapping);
* \brief Sets \a myStoreMapping flag and call this->Modified()
* \param theStoreMapping - used for changing value of \a myStoreMapping variable.
* \brief Return value of \a myStoreMapping
* \retval myStoreMapping
*/
- int GetStoreMapping(){ return myStoreMapping;}
+ int GetStoreMapping();
/*! \fn virtual vtkIdType GetNodeObjId(int theVtkID)
* \brief Return input value theVtkID
* \retval theVtkID
TVectorId myVTK2ObjIds;
int myShowInside;
int myStoreMapping;
+ int myIsWireframeMode;
};
#endif
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEWER_PASSTHROUGHFILTER_H
#define VTKVIEWER_PASSTHROUGHFILTER_H
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include "VTKViewer_RenderWindow.h"
#include <qcolordialog.h>
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEWER_RENDERWINDOW_H
#define VTKVIEWER_RENDERWINDOW_H
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include "VTKViewer_RenderWindowInteractor.h"
#include "VTKViewer_RenderWindow.h"
#include "VTKViewer_InteractorStyle.h"
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEWER_RENDERWINDOWINTERACTOR_H
#define VTKVIEWER_RENDERWINDOWINTERACTOR_H
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEWER_SHRINKFILTER_H
#define VTKVIEWER_SHRINKFILTER_H
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEWER_TRANSFORM_H
#define VTKVIEWER_TRANSFORM_H
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEWER_TRANSFORMFILTER_H
#define VTKVIEWER_TRANSFORMFILTER_H
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include "VTKViewer_Trihedron.h"
#include "VTKViewer_Actor.h"
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEWER_TRIHEDRON_H
#define VTKVIEWER_TRIHEDRON_H
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include "VTKViewer_Actor.h"
// VTK Includes
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEWER_UTILITIES_H
#define VTKVIEWER_UTILITIES_H
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
/*=========================================================================
Program: Visualization Toolkit
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
/*=========================================================================
Program: Visualization Toolkit
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include "VTKViewer_ViewManager.h"
#include "VTKViewer_ViewModel.h"
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEWER_VIEWMANAGER_H
#define VTKVIEWER_VIEWMANAGER_H
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include "VTKViewer_ViewModel.h"
#include "VTKViewer_ViewWindow.h"
#include "VTKViewer_ViewManager.h"
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEWER_VIEWMODEL_H
#define VTKVIEWER_VIEWMODEL_H
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#include "VTKViewer_ViewWindow.h"
#include "VTKViewer_ViewModel.h"
#include "VTKViewer_RenderWindow.h"
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// 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/
-//
#ifndef VTKVIEWER_VIEWWINDOW_H
#define VTKVIEWER_VIEWWINDOW_H
--- /dev/null
+# VISU VISUGUI : GUI of VISU component
+#
+# Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File :
+# Module :
+
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n"
+"PO-Revision-Date: 2005-05-10 15:20+0400\n"
+"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+
+msgid "ICON_SVTK_SCALING"
+msgstr "view_scaling.png"
+
+msgid "ICON_GRADUATED_AXES"
+msgstr "view_graduated_axes.png"
--- /dev/null
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2002-02-22 16:56:46 CET\n"
+"PO-Revision-Date: 2005-06-27 12:38+0400\n"
+"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+
+#: SVTK_NonIsometricDlg.cxx
+
+msgid "SVTK_NonIsometricDlg::MEN_SCALING"
+msgstr "Scaling"
+
+msgid "SVTK_NonIsometricDlg::O&K"
+msgstr ""
+
+msgid "SVTK_NonIsometricDlg::&Apply"
+msgstr ""
+
+msgid "SVTK_NonIsometricDlg::&Cancel"
+msgstr ""
+
+msgid "SVTK_NonIsometricDlg::&Reset"
+msgstr ""
+
+msgid "SVTK_NonIsometricDlg::DLG_TITLE"
+msgstr "Scaling"
+
+msgid "SVTK_NonIsometricDlg::LBL_X"
+msgstr "X :"
+
+msgid "SVTK_NonIsometricDlg::LBL_Y"
+msgstr "Y :"
+
+msgid "SVTK_NonIsometricDlg::LBL_Z"
+msgstr "Z :"
+
+msgid "SVTK_MainWindow::MNU_SVTK_SCALING"
+msgstr "Scaling"
+
+msgid "SVTK_MainWindow::DSC_SVTK_SCALING"
+msgstr "Scaling"
+
+msgid "SVTK_FontWidget::ARIAL"
+msgstr "Arial"
+
+msgid "SVTK_FontWidget::COURIER"
+msgstr "Courier"
+
+msgid "SVTK_FontWidget::TIMES"
+msgstr "Times"
+
+msgid "SVTK_FontWidget::BOLD"
+msgstr "Bold"
+
+msgid "SVTK_FontWidget::ITALIC"
+msgstr "Italic"
+
+msgid "SVTK_FontWidget::SHADOW"
+msgstr "Shadow"
+
+msgid "SVTK_CubeAxesDlg::CAPTION"
+msgstr "Graduated axes"
+
+msgid "SVTK_CubeAxesDlg::X_AXIS"
+msgstr "X axis"
+
+msgid "SVTK_CubeAxesDlg::Y_AXIS"
+msgstr "Y axis"
+
+msgid "SVTK_CubeAxesDlg::Z_AXIS"
+msgstr "Z axis"
+
+msgid "SVTK_CubeAxesDlg::IS_VISIBLE"
+msgstr "Is visible"
+
+msgid "SVTK_AxisWidget::AXIS_NAME"
+msgstr "Axis name"
+
+msgid "SVTK_AxisWidget::IS_VISIBLE"
+msgstr "Is visible"
+
+msgid "SVTK_AxisWidget::NAME"
+msgstr "Name"
+
+msgid "SVTK_AxisWidget::FONT"
+msgstr "Font"
+
+msgid "SVTK_AxisWidget::LABELS"
+msgstr "Labels"
+
+msgid "SVTK_AxisWidget::NUMBER"
+msgstr "Number"
+
+msgid "SVTK_AxisWidget::OFFSET"
+msgstr "Offset"
+
+msgid "SVTK_AxisWidget::TICK_MARKS"
+msgstr "Tick marks"
+
+msgid "SVTK_AxisWidget::LENGTH"
+msgstr "Length"
+
+msgid "SVTK_MainWindow::MNU_SVTK_GRADUATED_AXES"
+msgstr "Graduated axes"
+
+msgid "SVTK_MainWindow::DSC_SVTK_GRADUATED_AXES"
+msgstr "Graduated axes"
\ No newline at end of file