'T_Before_Join_BR-D5-38-2003'.
Sprout from OCC_development_generic_2006 2006-01-19 09:14:42 UTC stv <stv@opencascade.com> 'no message'
Delete:
src/OBJECT/SALOME_Actor.cxx
src/OBJECT/SALOME_Actor.h
src/SVTK/SVTK_RenderWindow.h
+++ /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
-
+++ /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