//---------------------------------------------------------------
typedef std::map<int,PValForTime> TValField;
- typedef std::pair<float,float> TMinMax;
struct TField: virtual TIntId
{
TValField myValField;
TNames myCompNames;
TNames myUnitNames;
- vtkIdType myNbComp;
-
- virtual
- TMinMax
- GetMinMax(vtkIdType theCompID) = 0;
+ int myNbComp;
TField(): myNbComp(0)
{}
myMinMaxArr.resize(theNbComp);
for(vtkIdType iComp = 0; iComp < theNbComp; iComp++){
TMinMax& aMinMax = myMinMaxArr[iComp];
- aMinMax.first = -VTK_LARGE_FLOAT;
- aMinMax.second = VTK_LARGE_FLOAT;
+ aMinMax.first = VTK_LARGE_FLOAT;
+ aMinMax.second = -VTK_LARGE_FLOAT;
}
}
myIsVTKMapping(false),
myParent(this),
myPrs3d(NULL),
- myPipeLine(NULL),
myActorFactory(NULL),
myMapper(vtkDataSetMapper::New()),
myIsShrunk(false),
{
SetDebug(MYVTKDEBUG);
+ myMapper->Delete();
+ myShrinkFilter->Delete();
+
myStoreMapping = true;
myShrinkFilter->SetStoreMapping(true);
::~VISU_Actor()
{
SALOME_Actor::SetProperty(NULL);
-
- myMapper->Delete();
-
- if(myPipeLine)
- myPipeLine->UnRegister(this);
-
- myShrinkFilter->Delete();
}
//----------------------------------------------------------------------------
}
//----------------------------------------------------------------------------
+void
+VISU_Actor
+::SetMapperInput(vtkDataSet* theDataSet)
+{
+ myMapper->SetInput(theDataSet);
+ SetMapper(myMapper.GetPointer());
+}
+
void
VISU_Actor
::SetPipeLine(VISU_PipeLine* thePipeLine)
{
- if (myPipeLine != thePipeLine){
- if (myPipeLine != NULL) myPipeLine->UnRegister(this);
- myPipeLine = thePipeLine;
- if (myPipeLine != NULL) myPipeLine->Register(this);
- this->Modified();
- vtkMapper *aMapper = myPipeLine->GetMapper();
- vtkDataSet *aDataSet = aMapper->GetInput();
- if(!aDataSet)
- throw std::runtime_error("VISU_Actor::SetPipeLine >> There is no input data !!!");
- aDataSet->Update();
- static float eps = VTK_LARGE_FLOAT * 0.1 ;
- if(aDataSet->GetLength() > eps)
- throw std::runtime_error("VISU_Actor::SetPipeLine >> Diagonal of the actor is too large !!!");
- if(!aDataSet->GetNumberOfCells())
- throw std::runtime_error("VISU_Actor::SetPipeLine >> There is no visible elements");
- SetShrinkable(thePipeLine->IsShrinkable());
-
- myMapper->SetInput(aDataSet);
- SetMapper(myMapper);
+ myPipeLine = thePipeLine;
+ if(thePipeLine){
+ if(vtkMapper *aMapper = myPipeLine->GetMapper()){
+ if(vtkDataSet *aDataSet = aMapper->GetInput()){
+ if(!aDataSet)
+ throw std::runtime_error("VISU_Actor::SetPipeLine >> There is no input data !!!");
+
+ aDataSet->Update();
+
+ static float EPS = VTK_LARGE_FLOAT * 0.1 ;
+ if(aDataSet->GetLength() > EPS)
+ throw std::runtime_error("VISU_Actor::SetPipeLine >> Diagonal of the actor is too large !!!");
+
+ if(!aDataSet->GetNumberOfCells())
+ throw std::runtime_error("VISU_Actor::SetPipeLine >> There is no visible elements");
+
+ SetShrinkable(thePipeLine->IsShrinkable());
+
+ SetMapperInput(aDataSet);
+ }
+ }
}
+ this->Modified();
}
VISU_PipeLine*
VISU_Actor
::GetPipeLine()
{
- return myPipeLine;
+ return myPipeLine.GetPointer();
}
//----------------------------------------------------------------------------
void
ShallowCopy(vtkProp *prop);
- virtual
- ~VISU_Actor();
-
//----------------------------------------------------------------------------
virtual
void
protected:
VISU_Actor();
+ virtual
+ ~VISU_Actor();
+ virtual
+ void
+ SetMapperInput(vtkDataSet* theDataSet);
+
bool myIsVTKMapping;
VISU_Actor* myParent;
VISU::Prs3d_i* myPrs3d;
- VISU_PipeLine* myPipeLine;
- vtkDataSetMapper* myMapper;
+ vtkSmartPointer<VISU_PipeLine> myPipeLine;
+ vtkSmartPointer<vtkDataSetMapper> myMapper;
VISU::TActorFactory* myActorFactory;
- VTKViewer_ShrinkFilter* myShrinkFilter;
+ vtkSmartPointer<VTKViewer_ShrinkFilter> myShrinkFilter;
bool myIsShrinkable;
bool myIsShrunk;
vtkSmartPointer<vtkTextMapper> myAnnotationMapper;
#include "SALOME_InteractiveObject.hxx"
class VISU_Actor;
-class vtkPlane;
+class vtkImplicitFunction;
namespace VISU
{
CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL) = 0;
virtual
- bool
- AddClippingPlane(VISU_Actor* theActor,
- vtkPlane* thePlane) = 0;
-
- virtual
- void
- RemoveAllClippingPlanes(VISU_Actor* theActor) = 0;
+ void
+ SetImplicitFunction(VISU_Actor* theActor,
+ vtkImplicitFunction* theImplicitFunction) = 0;
};
}
#include <vtkSphereSource.h>
#include <vtkPolyDataMapper.h>
+#include <vtkPolyData.h>
#include <vtkActor.h>
#include <vtkObjectFactory.h>
{
myTextMapper->Delete();
myTextActor->Delete();
+ myPSMapper->Delete();
vtkTextProperty* aTextProperty = myTextMapper->GetTextProperty();
aTextProperty->SetVerticalJustification(VTK_TEXT_BOTTOM);
VISU_GaussPtsAct
::~VISU_GaussPtsAct()
-{
- myPSMapper->Delete();
-}
+{}
//----------------------------------------------------------------
//----------------------------------------------------------------
+void
+VISU_GaussPtsAct
+::SetMapperInput(vtkDataSet* theDataSet)
+{
+ if(vtkPolyData* aPolyData = dynamic_cast<vtkPolyData*>(theDataSet)){
+ myPSMapper->SetInput(aPolyData);
+ SetMapper(myPSMapper.GetPointer());
+ }
+}
+
void
VISU_GaussPtsAct
::SetPipeLine(VISU_PipeLine* thePipeLine)
{
myGaussPointsPL = dynamic_cast<VISU_GaussPointsPL*>(thePipeLine);
- //Superclass::SetPipeLine(thePipeLine);
-
- VISU_OpenGLPointSpriteMapper* aPSMapper = (VISU_OpenGLPointSpriteMapper*)myGaussPointsPL->GetMapper();
-
- myPSMapper->SetInput( aPSMapper->GetInput() );
- SetMapper( myPSMapper );
+ Superclass::SetPipeLine(thePipeLine);
}
VISU_GaussPointsPL*
bool theIsHighlight );
protected:
-
VISU_GaussPtsAct();
- virtual ~VISU_GaussPtsAct();
- VISU_OpenGLPointSpriteMapper* myPSMapper;
+ virtual
+ ~VISU_GaussPtsAct();
+
+ virtual
+ void
+ SetMapperInput(vtkDataSet* theDataSet);
+
+ vtkSmartPointer<VISU_OpenGLPointSpriteMapper> myPSMapper;
vtkSmartPointer<VISU_GaussPointsPL> myGaussPointsPL;
@COMMENCE@
-EXPORT_HEADERS = VISU_PipeLine.hxx VISU_PipeLineUtils.hxx \
+EXPORT_HEADERS = \
+ VISU_PipeLine.hxx VISU_PipeLineUtils.hxx \
VISU_MeshPL.hxx VISU_ScalarMapPL.hxx \
VISU_CutPlanesPL.hxx VISU_CutLinesPL.hxx \
VISU_IsoSurfacesPL.hxx VISU_DeformedShapePL.hxx \
VISU_Extractor.hxx VISU_FieldTransform.hxx \
VISU_UsedPointsFilter.hxx VISU_GaussPointsPL.hxx \
VISU_Plot3DPL.hxx \
- VISU_OpenGLPointSpriteMapper.hxx
+ VISU_OpenGLPointSpriteMapper.hxx \
+ VISU_ImplicitFunctionWidget.h
# Libraries targets
LIB = libVisuPipeLine.la
-LIB_SRC = VISU_PipeLine.cxx VISU_PipeLineUtils.cxx \
+LIB_SRC = \
+ VISU_PipeLine.cxx VISU_PipeLineUtils.cxx \
VISU_MeshPL.cxx VISU_ScalarMapPL.cxx \
VISU_CutPlanesPL.cxx VISU_CutLinesPL.cxx \
VISU_IsoSurfacesPL.cxx VISU_DeformedShapePL.cxx \
VISU_Extractor.cxx VISU_FieldTransform.cxx \
VISU_UsedPointsFilter.cxx VISU_GaussPointsPL.cxx \
VISU_Plot3DPL.cxx SALOME_ExtractGeometry.cxx \
- VISU_OpenGLPointSpriteMapper.cxx
+ VISU_OpenGLPointSpriteMapper.cxx \
+ VISU_ImplicitFunctionWidget.cxx
# Executables targets
BIN = VISUPipeLine
BIN_SRC =
-CPPFLAGS+= $(VTK_INCLUDES) \
+CPPFLAGS+= \
+ $(VTK_INCLUDES) \
-I${KERNEL_ROOT_DIR}/include/salome \
-I${GUI_ROOT_DIR}/include/salome \
-I${MED_ROOT_DIR}/include/salome \
$(HDF5_INCLUDES) $(BOOST_CPPFLAGS)
-LDFLAGS+= $(VTK_LIBS) -lVTKViewer -lVisuConvertor \
+LDFLAGS+= \
+ $(VTK_LIBS) -lVTKViewer -lVisuConvertor \
-L${KERNEL_ROOT_DIR}/lib/salome -lSALOMELocalTrace \
-L${GUI_ROOT_DIR}/lib/salome \
-L${MED_ROOT_DIR}/lib/salome
#endif
+//----------------------------------------------------------------------------
vtkStandardNewMacro(SALOME_ExtractGeometry);
-SALOME_ExtractGeometry::SALOME_ExtractGeometry()
+//----------------------------------------------------------------------------
+SALOME_ExtractGeometry
+::SALOME_ExtractGeometry()
{}
-SALOME_ExtractGeometry::~SALOME_ExtractGeometry()
+SALOME_ExtractGeometry
+::~SALOME_ExtractGeometry()
{}
-vtkIdType SALOME_ExtractGeometry::GetElemObjId(int theVtkID)
+
+//----------------------------------------------------------------------------
+unsigned long int
+SALOME_ExtractGeometry
+::GetMTime()
+{
+ unsigned long int aTime = vtkExtractGeometry::GetMTime();
+ return aTime;
+}
+
+
+//----------------------------------------------------------------------------
+vtkImplicitBoolean*
+SALOME_ExtractGeometry
+::GetImplicitBoolean()
+{
+ return myImplicitBoolean.GetPointer();
+}
+
+
+void
+SALOME_ExtractGeometry
+::SetImplicitFunction(vtkImplicitFunction* theImplicitFunction)
+{
+ myImplicitBoolean = dynamic_cast<vtkImplicitBoolean*>(theImplicitFunction);
+ vtkExtractGeometry::SetImplicitFunction(theImplicitFunction);
+}
+
+
+//----------------------------------------------------------------------------
+void
+SALOME_ExtractGeometry
+::SetStoreMapping(bool theStoreMapping)
+{
+ myStoreMapping = theStoreMapping;
+ Modified();
+}
+
+bool
+SALOME_ExtractGeometry
+::GetStoreMapping() const
+{
+ return myStoreMapping;
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType
+SALOME_ExtractGeometry
+::GetElemObjId(int theVtkID)
{
if (myElemVTK2ObjIds.empty())
return theVtkID;
}
-vtkIdType SALOME_ExtractGeometry::GetNodeObjId(int theVtkID)
+vtkIdType
+SALOME_ExtractGeometry
+::GetNodeObjId(int theVtkID)
{
if (myNodeVTK2ObjIds.empty())
return theVtkID;
#endif
}
-//void SALOME_ExtractGeometry::SetImplicitBoolean(vtkImplicitBoolean* theImplicitBoolean)
-void SALOME_ExtractGeometry::SetImplicitFunction(vtkImplicitFunction* theImplicitFunction)
-{
- //myImplicitBoolean = theImplicitBoolean;
- //SetImplicitFunction(theImplicitBoolean);
- myImplicitBoolean=dynamic_cast<vtkImplicitBoolean*>(theImplicitFunction);
- vtkExtractGeometry::SetImplicitFunction(theImplicitFunction);
-}
-
-void SALOME_ExtractGeometry::SetStoreMapping(bool theStoreMapping)
-{
- myStoreMapping = theStoreMapping;
- Modified();
-}
-
-void SALOME_ExtractGeometry::Execute()
+//----------------------------------------------------------------------------
+void
+SALOME_ExtractGeometry
+::Execute()
{
+ myElemVTK2ObjIds.clear();
+ myNodeVTK2ObjIds.clear();
if(myImplicitBoolean.GetPointer()){
if(vtkImplicitFunctionCollection* aFunction = myImplicitBoolean->GetFunction()){
if(aFunction->GetNumberOfItems() == 0){
- myElemVTK2ObjIds.clear();
- myNodeVTK2ObjIds.clear();
- printf(" * SALOME_ExtractGeometry::Execute\n");
- vtkDebugMacro(<< "Extracting geometry - ShallowCopy");
+ vtkDebugMacro(<<"Extracting geometry - ShallowCopy");
GetOutput()->ShallowCopy(GetInput());
Modified();
return;
Execute2();
}
-void SALOME_ExtractGeometry::Execute2()
+void
+SALOME_ExtractGeometry
+::Execute2()
{
vtkIdType ptId, numPts, numCells, i, cellId, newCellId, newId, *pointMap;
vtkIdList *cellPts;
vtkFloatArray *newScalars = NULL;
if(myStoreMapping){
- myElemVTK2ObjIds.clear();
myElemVTK2ObjIds.reserve(numCells);
- myNodeVTK2ObjIds.clear();
myNodeVTK2ObjIds.reserve(numPts);
}
{
newId = newPts->InsertNextPoint(x);
pointMap[ptId] = newId;
- myNodeVTK2ObjIds.push_back(ptId);
+ if(myStoreMapping)
+ myNodeVTK2ObjIds.push_back(ptId);
outputPD->CopyData(pd,ptId,newId);
}
}
{
newId = newPts->InsertNextPoint(x);
pointMap[ptId] = newId;
- myNodeVTK2ObjIds.push_back(ptId);
+ if(myStoreMapping)
+ myNodeVTK2ObjIds.push_back(ptId);
outputPD->CopyData(pd,ptId,newId);
}
}
x = input->GetPoint(ptId);
newId = newPts->InsertNextPoint(x);
pointMap[ptId] = newId;
- myNodeVTK2ObjIds.push_back(ptId);
+ if(myStoreMapping)
+ myNodeVTK2ObjIds.push_back(ptId);
outputPD->CopyData(pd,ptId,newId);
}
newCellPts->InsertId(i,pointMap[ptId]);
if ( npts >= numCellPts || (this->ExtractBoundaryCells && npts > 0) )
{
newCellId = output->InsertNextCell(cell->GetCellType(),newCellPts);
- myElemVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myElemVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}//for all cells
#include <vtkExtractGeometry.h>
#include <vtkSmartPointer.h>
-#include <vtkImplicitBoolean.h>
#include <vector>
-//class vtkImplicitBoolean;
-class vtkImplicitFunction;
+class vtkImplicitBoolean;
class SALOME_ExtractGeometry : public vtkExtractGeometry
{
static SALOME_ExtractGeometry *New();
- //void SetImplicitBoolean(vtkImplicitBoolean* theImplicitBoolean);
- virtual void SetImplicitFunction(vtkImplicitFunction* theImplicitFunction);
+ virtual
+ void
+ SetImplicitFunction(vtkImplicitFunction* theImplicitFunction);
- vtkImplicitBoolean* GetImplicitBoolean() const {
- return myImplicitBoolean.GetPointer();
- }
+ virtual
+ unsigned long int
+ GetMTime();
- void SetStoreMapping(bool theStoreMapping);
- bool GetStoreMapping() const {
- return myStoreMapping;
- }
+ vtkImplicitBoolean*
+ GetImplicitBoolean();
+
+ bool
+ GetStoreMapping() const;
+ void
+ SetStoreMapping(bool theStoreMapping);
virtual vtkIdType GetNodeObjId(int theID);
virtual vtkIdType GetElemObjId(int theID);
return myGaussMesh;
}
+//----------------------------------------------------------------------------
+void
+VISU_GaussPointsPL
+::SetBicolor(bool theBicolor)
+{
+ myMapperTable->SetBicolor( theBicolor );
+ myBarTable->SetBicolor( theBicolor );
+
+ Modified();
+}
+
+//----------------------------------------------------------------------------
+bool
+VISU_GaussPointsPL
+::GetBicolor()
+{
+ return myMapperTable->GetBicolor();
+}
+
//----------------------------------------------------------------------------
void
VISU_GaussPointsPL
const VISU::PGaussMesh&
GetGaussMesh() const;
+ void
+ SetBicolor(bool theBicolor);
+
+ bool
+ GetBicolor();
+
void
SetRelativeMinSize(float theRelativeMinSize);
--- /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 : VVTK_ImplicitFunctionWidget.cxx
+// Author : Peter KURNEV
+// Module : SALOME
+// $Header$
+
+#include "VISU_ImplicitFunctionWidget.h"
+
+#include <vtkActor.h>
+#include <vtkAssemblyNode.h>
+#include <vtkAssemblyPath.h>
+#include <vtkCallbackCommand.h>
+#include <vtkCamera.h>
+#include <vtkCellPicker.h>
+#include <vtkConeSource.h>
+#include <vtkCutter.h>
+#include <vtkFeatureEdges.h>
+#include <vtkImageData.h>
+#include <vtkLineSource.h>
+#include <vtkMath.h>
+#include <vtkObjectFactory.h>
+#include <vtkOutlineFilter.h>
+#include <vtkPlane.h>
+#include <vtkPolyData.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkProperty.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkRenderer.h>
+#include <vtkSphereSource.h>
+#include <vtkTransform.h>
+#include <vtkTubeFilter.h>
+#include <vtkImplicitBoolean.h>
+#include <vtkImplicitFunctionCollection.h>
+
+static float DistanceToPlane(const float x[3],
+ const float n[3],
+ const float p0[3]);
+
+vtkCxxRevisionMacro(VISU_ImplicitFunctionWidget, "$Revision$");
+vtkStandardNewMacro(VISU_ImplicitFunctionWidget);
+
+//==================================================================
+// function: VISU_ImplicitFunctionWidget
+// purpose :
+//==================================================================
+VISU_ImplicitFunctionWidget::VISU_ImplicitFunctionWidget()
+:
+ vtkPolyDataSourceWidget()
+{
+ this->State = VISU_ImplicitFunctionWidget::Start;
+ this->EventCallbackCommand->SetCallback(VISU_ImplicitFunctionWidget::ProcessEvents);
+
+ this->NormalToXAxis = 0;
+ this->NormalToYAxis = 0;
+ this->NormalToZAxis = 0;
+
+ // Build the representation of the widget
+ //
+ this->Plane = vtkPlane::New();
+ this->Plane->SetNormal(0,0,1);
+ this->Plane->SetOrigin(0,0,0);
+ //
+ this->myDistance = 10.;
+ this->myPlane2 = vtkPlane::New();
+ this->myPlane2->SetNormal(0.,0.,-1.);
+ this->myPlane2->SetOrigin(0,0,this->myDistance);
+ //
+ this->myImplicitFunction = vtkImplicitBoolean::New();
+ this->myImplicitFunction->SetOperationType(VTK_UNION);
+ //
+ this->Box = vtkImageData::New();
+ this->Box->SetDimensions(2,2,2);
+ this->Outline = vtkOutlineFilter::New();
+ this->Outline->SetInput(this->Box);
+ this->OutlineMapper = vtkPolyDataMapper::New();
+ this->OutlineMapper->SetInput(this->Outline->GetOutput());
+ this->OutlineActor = vtkActor::New();
+ this->OutlineActor->SetMapper(this->OutlineMapper);
+ this->OutlineTranslation = 1;
+
+ this->Cutter = vtkCutter::New();
+ this->Cutter->SetInput(this->Box);
+ this->Cutter->SetCutFunction(this->Plane);
+ this->CutMapper = vtkPolyDataMapper::New();
+ this->CutMapper->SetInput(this->Cutter->GetOutput());
+ this->CutActor = vtkActor::New();
+ this->CutActor->SetMapper(this->CutMapper);
+ this->DrawPlane = 1;
+
+ this->myCutter2 = vtkCutter::New();
+ this->myCutter2->SetInput(this->Box);
+ this->myCutter2->SetCutFunction(this->myPlane2);
+ this->myCutMapper2 = vtkPolyDataMapper::New();
+ this->myCutMapper2->SetInput(this->myCutter2->GetOutput());
+ this->myCutActor2 = vtkActor::New();
+ this->myCutActor2->SetMapper(this->myCutMapper2);
+
+ this->Edges = vtkFeatureEdges::New();
+ this->Edges->SetInput(this->Cutter->GetOutput());
+ this->EdgesTuber = vtkTubeFilter::New();
+ this->EdgesTuber->SetInput(this->Edges->GetOutput());
+ this->EdgesTuber->SetNumberOfSides(12);
+ this->EdgesMapper = vtkPolyDataMapper::New();
+ this->EdgesMapper->SetInput(this->EdgesTuber->GetOutput());
+ this->EdgesActor = vtkActor::New();
+ this->EdgesActor->SetMapper(this->EdgesMapper);
+ this->Tubing = 1; //control whether tubing is on
+
+ // Create the + plane normal
+ this->LineSource = vtkLineSource::New();
+ this->LineSource->SetResolution(1);
+ this->LineMapper = vtkPolyDataMapper::New();
+ this->LineMapper->SetInput(this->LineSource->GetOutput());
+ this->LineActor = vtkActor::New();
+ this->LineActor->SetMapper(this->LineMapper);
+
+ this->ConeSource = vtkConeSource::New();
+ this->ConeSource->SetResolution(12);
+ this->ConeSource->SetAngle(25.0);
+ this->ConeMapper = vtkPolyDataMapper::New();
+ this->ConeMapper->SetInput(this->ConeSource->GetOutput());
+ this->ConeActor = vtkActor::New();
+ this->ConeActor->SetMapper(this->ConeMapper);
+
+ // Create the - plane normal
+ this->LineSource2 = vtkLineSource::New();
+ this->LineSource2->SetResolution(1);
+ this->LineMapper2 = vtkPolyDataMapper::New();
+ this->LineMapper2->SetInput(this->LineSource2->GetOutput());
+ this->LineActor2 = vtkActor::New();
+ this->LineActor2->SetMapper(this->LineMapper2);
+
+ this->ConeSource2 = vtkConeSource::New();
+ this->ConeSource2->SetResolution(12);
+ this->ConeSource2->SetAngle(25.0);
+ this->ConeMapper2 = vtkPolyDataMapper::New();
+ this->ConeMapper2->SetInput(this->ConeSource2->GetOutput());
+ this->ConeActor2 = vtkActor::New();
+ this->ConeActor2->SetMapper(this->ConeMapper2);
+
+ // Create the origin handle
+ this->Sphere = vtkSphereSource::New();
+ this->Sphere->SetThetaResolution(16);
+ this->Sphere->SetPhiResolution(8);
+ this->SphereMapper = vtkPolyDataMapper::New();
+ this->SphereMapper->SetInput(this->Sphere->GetOutput());
+ this->SphereActor = vtkActor::New();
+ this->SphereActor->SetMapper(this->SphereMapper);
+
+ this->Transform = vtkTransform::New();
+
+ // Define the point coordinates
+ float bounds[6];
+ bounds[0] = -0.5;
+ bounds[1] = 0.5;
+ bounds[2] = -0.5;
+ bounds[3] = 0.5;
+ bounds[4] = -0.5;
+ bounds[5] = 0.5;
+
+ // Initial creation of the widget, serves to initialize it
+ this->PlaceWidget(bounds);
+
+ //Manage the picking stuff
+ this->Picker = vtkCellPicker::New();
+ this->Picker->SetTolerance(0.005);
+ this->Picker->AddPickList(this->CutActor);
+ this->Picker->AddPickList(this->myCutActor2);
+ this->Picker->AddPickList(this->LineActor);
+ this->Picker->AddPickList(this->ConeActor);
+ this->Picker->AddPickList(this->LineActor2);
+ this->Picker->AddPickList(this->ConeActor2);
+ this->Picker->AddPickList(this->SphereActor);
+ this->Picker->AddPickList(this->OutlineActor);
+ this->Picker->PickFromListOn();
+
+ // Set up the initial properties
+ this->CreateDefaultProperties();
+}
+//==================================================================
+// function: ~
+// purpose :
+//==================================================================
+VISU_ImplicitFunctionWidget::~VISU_ImplicitFunctionWidget()
+{
+ this->Plane->Delete();
+
+ this->myPlane2->Delete();
+ this->myImplicitFunction->Delete();
+
+ this->Box->Delete();
+ this->Outline->Delete();
+ this->OutlineMapper->Delete();
+ this->OutlineActor->Delete();
+
+ this->Cutter->Delete();
+ this->CutMapper->Delete();
+ this->CutActor->Delete();
+
+ myCutter2->Delete();
+ myCutMapper2->Delete();
+ myCutActor2->Delete();
+
+ this->Edges->Delete();
+ this->EdgesTuber->Delete();
+ this->EdgesMapper->Delete();
+ this->EdgesActor->Delete();
+
+ this->LineSource->Delete();
+ this->LineMapper->Delete();
+ this->LineActor->Delete();
+
+ this->ConeSource->Delete();
+ this->ConeMapper->Delete();
+ this->ConeActor->Delete();
+
+ this->LineSource2->Delete();
+ this->LineMapper2->Delete();
+ this->LineActor2->Delete();
+
+ this->ConeSource2->Delete();
+ this->ConeMapper2->Delete();
+ this->ConeActor2->Delete();
+
+ this->Sphere->Delete();
+ this->SphereMapper->Delete();
+ this->SphereActor->Delete();
+
+ this->Transform->Delete();
+
+ this->Picker->Delete();
+
+ this->NormalProperty->Delete();
+ this->SelectedNormalProperty->Delete();
+ this->PlaneProperty->Delete();
+ this->SelectedPlaneProperty->Delete();
+ this->OutlineProperty->Delete();
+ this->SelectedOutlineProperty->Delete();
+ this->EdgesProperty->Delete();
+}
+//==================================================================
+// function: ImplicitFunction
+// purpose :
+//==================================================================
+vtkImplicitFunction* VISU_ImplicitFunctionWidget::ImplicitFunction()
+{
+ return this->myImplicitFunction;
+}
+//==================================================================
+// function: SetDistance
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::SetDistance(const float theDistance)
+{
+ myDistance=theDistance;
+ //
+ float *origin, *normal, oNew[3], aN2[3];
+ origin = Plane->GetOrigin();
+ normal = Plane->GetNormal();
+ vtkMath::Normalize(normal);
+ oNew[0] = origin[0] + myDistance*normal[0];
+ oNew[1] = origin[1] + myDistance*normal[1];
+ oNew[2] = origin[2] + myDistance*normal[2];
+ myPlane2->SetOrigin(oNew);
+ aN2[0] = -normal[0];
+ aN2[1] = -normal[1];
+ aN2[2] = -normal[2];
+ myPlane2->SetNormal(aN2);
+}
+//==================================================================
+// function: Distance
+// purpose :
+//==================================================================
+float VISU_ImplicitFunctionWidget::Distance()const
+{
+ return myDistance;
+}
+//==================================================================
+// function: SetEnabled
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::SetEnabled(int enabling)
+{
+ if ( ! this->Interactor ) {
+ vtkErrorMacro(<<"The interactor must be set prior to enabling/disabling widget");
+ return;
+ }
+
+ if ( enabling ) {//------------------------------------------------------------
+ vtkDebugMacro(<<"Enabling plane widget");
+
+ if ( this->Enabled ){ //already enabled, just return
+ return;
+ }
+
+ if ( ! this->CurrentRenderer ){
+ this->CurrentRenderer = this->Interactor->FindPokedRenderer(
+ this->Interactor->GetLastEventPosition()[0],
+ this->Interactor->GetLastEventPosition()[1]);
+ if (this->CurrentRenderer == NULL) {
+ return;
+ }
+ }
+
+ this->myImplicitFunction->AddFunction(this->Plane);
+ this->myImplicitFunction->AddFunction(this->myPlane2);
+
+ this->Enabled = 1;
+
+ // listen for the following events
+ vtkRenderWindowInteractor *i = this->Interactor;
+ i->AddObserver(vtkCommand::MouseMoveEvent, this->EventCallbackCommand,
+ this->Priority);
+ i->AddObserver(vtkCommand::LeftButtonPressEvent,
+ this->EventCallbackCommand, this->Priority);
+ i->AddObserver(vtkCommand::LeftButtonReleaseEvent,
+ this->EventCallbackCommand, this->Priority);
+ i->AddObserver(vtkCommand::MiddleButtonPressEvent,
+ this->EventCallbackCommand, this->Priority);
+ i->AddObserver(vtkCommand::MiddleButtonReleaseEvent,
+ this->EventCallbackCommand, this->Priority);
+ i->AddObserver(vtkCommand::RightButtonPressEvent,
+ this->EventCallbackCommand, this->Priority);
+ i->AddObserver(vtkCommand::RightButtonReleaseEvent,
+ this->EventCallbackCommand, this->Priority);
+
+ // add the outline
+ this->CurrentRenderer->AddActor(this->OutlineActor);
+ this->OutlineActor->SetProperty(this->OutlineProperty);
+
+ // add the edges
+ this->CurrentRenderer->AddActor(this->EdgesActor);
+ this->OutlineActor->SetProperty(this->EdgesProperty);
+
+ // add the normal vector
+ this->CurrentRenderer->AddActor(this->LineActor);
+ this->LineActor->SetProperty(this->NormalProperty);
+ this->CurrentRenderer->AddActor(this->ConeActor);
+ this->ConeActor->SetProperty(this->NormalProperty);
+
+ this->CurrentRenderer->AddActor(this->LineActor2);
+ this->LineActor2->SetProperty(this->NormalProperty);
+ this->CurrentRenderer->AddActor(this->ConeActor2);
+ this->ConeActor2->SetProperty(this->NormalProperty);
+
+ // add the origin handle
+ this->CurrentRenderer->AddActor(this->SphereActor);
+ this->SphereActor->SetProperty(this->NormalProperty);
+
+ // add the plane (if desired)
+ if ( this->DrawPlane )
+ {
+ this->CurrentRenderer->AddActor(this->CutActor);
+ this->CurrentRenderer->AddActor(this->myCutActor2);
+ }
+ this->CutActor->SetProperty(this->PlaneProperty);
+ myCutActor2->SetProperty(this->PlaneProperty);
+
+ this->UpdateRepresentation();
+ this->SizeHandles();
+ this->InvokeEvent(vtkCommand::EnableEvent,NULL);
+ }
+
+ else {//disabling----------------------------------------------------------
+ vtkDebugMacro(<<"Disabling plane widget");
+
+ if ( ! this->Enabled ) {//already disabled, just return
+ return;
+ }
+
+ if(vtkImplicitFunctionCollection* aFunction = this->myImplicitFunction->GetFunction()){
+ aFunction->RemoveAllItems();
+ this->myImplicitFunction->Modified(); // VTK bug
+ }
+
+ this->Enabled = 0;
+
+ // don't listen for events any more
+ this->Interactor->RemoveObserver(this->EventCallbackCommand);
+
+ // turn off the various actors
+ this->CurrentRenderer->RemoveActor(this->OutlineActor);
+ this->CurrentRenderer->RemoveActor(this->EdgesActor);
+ this->CurrentRenderer->RemoveActor(this->LineActor);
+ this->CurrentRenderer->RemoveActor(this->ConeActor);
+ this->CurrentRenderer->RemoveActor(this->LineActor2);
+ this->CurrentRenderer->RemoveActor(this->ConeActor2);
+ this->CurrentRenderer->RemoveActor(this->SphereActor);
+ this->CurrentRenderer->RemoveActor(this->CutActor);
+ this->CurrentRenderer->RemoveActor(myCutActor2);
+
+ this->InvokeEvent(vtkCommand::DisableEvent,NULL);
+ this->CurrentRenderer = NULL;
+ }
+
+ this->Interactor->Render();
+}
+//==================================================================
+// function: ProcessEvents
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::ProcessEvents(vtkObject* vtkNotUsed(object),
+ unsigned long event,
+ void* clientdata,
+ void* vtkNotUsed(calldata))
+{
+ VISU_ImplicitFunctionWidget* self =
+ reinterpret_cast<VISU_ImplicitFunctionWidget *>( clientdata );
+
+ //okay, let's do the right thing
+ switch(event)
+ {
+ case vtkCommand::LeftButtonPressEvent:
+ self->OnLeftButtonDown();
+ break;
+ case vtkCommand::LeftButtonReleaseEvent:
+ self->OnLeftButtonUp();
+ break;
+ case vtkCommand::MiddleButtonPressEvent:
+ self->OnMiddleButtonDown();
+ break;
+ case vtkCommand::MiddleButtonReleaseEvent:
+ self->OnMiddleButtonUp();
+ break;
+ case vtkCommand::RightButtonPressEvent:
+ self->OnRightButtonDown();
+ break;
+ case vtkCommand::RightButtonReleaseEvent:
+ self->OnRightButtonUp();
+ break;
+ case vtkCommand::MouseMoveEvent:
+ self->OnMouseMove();
+ break;
+ }
+}
+//==================================================================
+// function: HighlightNormal
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::HighlightNormal(int highlight)
+{
+ if ( highlight ) {
+ this->LineActor->SetProperty(this->SelectedNormalProperty);
+ this->ConeActor->SetProperty(this->SelectedNormalProperty);
+ this->LineActor2->SetProperty(this->SelectedNormalProperty);
+ this->ConeActor2->SetProperty(this->SelectedNormalProperty);
+ this->SphereActor->SetProperty(this->SelectedNormalProperty);
+ }
+ else
+ {
+ this->LineActor->SetProperty(this->NormalProperty);
+ this->ConeActor->SetProperty(this->NormalProperty);
+ this->LineActor2->SetProperty(this->NormalProperty);
+ this->ConeActor2->SetProperty(this->NormalProperty);
+ this->SphereActor->SetProperty(this->NormalProperty);
+ }
+}
+
+//==================================================================
+// function: HighlightPlane
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::HighlightPlane(int highlight)
+{
+ if ( highlight ) {
+ this->CutActor->SetProperty(this->SelectedPlaneProperty);
+ myCutActor2->SetProperty(this->SelectedPlaneProperty);
+ }
+ else {
+ this->CutActor->SetProperty(this->PlaneProperty);
+ myCutActor2->SetProperty(this->PlaneProperty);
+ }
+}
+//==================================================================
+// function: HighlightOutline
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::HighlightOutline(int highlight)
+{
+ if ( highlight ) {
+ this->OutlineActor->SetProperty(this->SelectedOutlineProperty);
+ }
+ else {
+ this->OutlineActor->SetProperty(this->OutlineProperty);
+ }
+}
+//==================================================================
+// function: OnLeftButtonDown
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::OnLeftButtonDown()
+{
+ // We're only here if we are enabled
+ int X = this->Interactor->GetEventPosition()[0];
+ int Y = this->Interactor->GetEventPosition()[1];
+ //
+ // Okay, we can process this. See if we've picked anything.
+ // Make sure it's in the activated renderer
+ vtkRenderer *ren = this->Interactor->FindPokedRenderer(X,Y);
+ if ( ren != this->CurrentRenderer ) {
+ this->State = VISU_ImplicitFunctionWidget::Outside;
+ return;
+ }
+
+ vtkAssemblyPath *path;
+ this->Picker->Pick(X,Y,0.0,this->CurrentRenderer);
+ path = this->Picker->GetPath();
+
+ if ( path == NULL ) {//not picking this widget
+ this->HighlightPlane(0);
+ this->HighlightNormal(0);
+ this->HighlightOutline(0);
+ this->State = VISU_ImplicitFunctionWidget::Outside;
+ return;
+ }
+
+ vtkProp *prop = path->GetFirstNode()->GetProp();
+ this->ValidPick = 1;
+ this->Picker->GetPickPosition(this->LastPickPosition);
+ //
+ if ( prop == this->ConeActor || prop == this->LineActor ||
+ prop == this->ConeActor2 || prop == this->LineActor2 ) {
+ this->HighlightPlane(1);
+ this->HighlightNormal(1);
+ this->State = VISU_ImplicitFunctionWidget::Rotating;
+ }
+ else if ( prop == this->CutActor) {
+ this->HighlightPlane(1);
+ this->State = VISU_ImplicitFunctionWidget::Pushing;
+ }
+ else if ( prop == this->SphereActor ) {
+ this->HighlightNormal(1);
+ this->State = VISU_ImplicitFunctionWidget::MovingOrigin;
+ }
+ else if (prop == myCutActor2) {
+ this->HighlightPlane(1);
+ this->State = VISU_ImplicitFunctionWidget::ChangeDistance;
+ }
+ else {
+ if ( this->OutlineTranslation ) {
+ this->HighlightOutline(1);
+ this->State = VISU_ImplicitFunctionWidget::MovingOutline;
+ }
+ }
+
+ this->EventCallbackCommand->SetAbortFlag(1);
+ this->StartInteraction();
+ this->InvokeEvent(vtkCommand::StartInteractionEvent,NULL);
+ this->Interactor->Render();
+}
+//==================================================================
+// function: OnLeftButtonUp
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::OnLeftButtonUp()
+{
+ if ( this->State == VISU_ImplicitFunctionWidget::Outside ) {
+ return;
+ }
+
+ this->State = VISU_ImplicitFunctionWidget::Start;
+ this->HighlightPlane(0);
+ this->HighlightOutline(0);
+ this->HighlightNormal(0);
+ this->SizeHandles();
+
+ this->EventCallbackCommand->SetAbortFlag(1);
+ this->EndInteraction();
+ this->InvokeEvent(vtkCommand::EndInteractionEvent,NULL);
+ this->Interactor->Render();
+}
+//==================================================================
+// function: OnMiddleButtonDown
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::OnMiddleButtonDown()
+{
+ int X = this->Interactor->GetEventPosition()[0];
+ int Y = this->Interactor->GetEventPosition()[1];
+
+ // Okay, we can process this. See if we've picked anything.
+ // Make sure it's in the activated renderer
+ vtkRenderer *ren = this->Interactor->FindPokedRenderer(X,Y);
+ if ( ren != this->CurrentRenderer ) {
+ this->State = VISU_ImplicitFunctionWidget::Outside;
+ return;
+ }
+
+ // Okay, we can process this.
+ vtkAssemblyPath *path;
+ this->Picker->Pick(X,Y,0.0,this->CurrentRenderer);
+ path = this->Picker->GetPath();
+
+ if ( path == NULL ) {//nothing picked
+ this->State = VISU_ImplicitFunctionWidget::Outside;
+ return;
+ }
+
+ this->ValidPick = 1;
+ this->Picker->GetPickPosition(this->LastPickPosition);
+ this->State = VISU_ImplicitFunctionWidget::MovingPlane;
+ this->HighlightNormal(1);
+ this->HighlightPlane(1);
+
+ this->EventCallbackCommand->SetAbortFlag(1);
+ this->StartInteraction();
+ this->InvokeEvent(vtkCommand::StartInteractionEvent,NULL);
+ this->Interactor->Render();
+}
+//==================================================================
+// function: OnMiddleButtonUp
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::OnMiddleButtonUp()
+{
+ if ( this->State == VISU_ImplicitFunctionWidget::Outside ) {
+ return;
+ }
+
+ this->State = VISU_ImplicitFunctionWidget::Start;
+ this->HighlightPlane(0);
+ this->HighlightOutline(0);
+ this->HighlightNormal(0);
+ this->SizeHandles();
+
+ this->EventCallbackCommand->SetAbortFlag(1);
+ this->EndInteraction();
+ this->InvokeEvent(vtkCommand::EndInteractionEvent,NULL);
+ this->Interactor->Render();
+}
+//==================================================================
+// function: OnRightButtonDown
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::OnRightButtonDown()
+{
+ this->State = VISU_ImplicitFunctionWidget::Scaling;
+
+ int X = this->Interactor->GetEventPosition()[0];
+ int Y = this->Interactor->GetEventPosition()[1];
+
+ // Okay, we can process this. See if we've picked anything.
+ // Make sure it's in the activated renderer
+ vtkRenderer *ren = this->Interactor->FindPokedRenderer(X,Y);
+ if ( ren != this->CurrentRenderer ) {
+ this->State = VISU_ImplicitFunctionWidget::Outside;
+ return;
+ }
+
+ // Okay, we can process this. Try to pick handles first;
+ // if no handles picked, then pick the bounding box.
+ vtkAssemblyPath *path;
+ this->Picker->Pick(X,Y,0.0,this->CurrentRenderer);
+ path = this->Picker->GetPath();
+ if ( path == NULL ){ //nothing picked
+ this->State = VISU_ImplicitFunctionWidget::Outside;
+ return;
+ }
+
+ this->ValidPick = 1;
+ this->Picker->GetPickPosition(this->LastPickPosition);
+ this->HighlightPlane(1);
+ this->HighlightOutline(1);
+ this->HighlightNormal(1);
+
+ this->EventCallbackCommand->SetAbortFlag(1);
+ this->StartInteraction();
+ this->InvokeEvent(vtkCommand::StartInteractionEvent,NULL);
+ this->Interactor->Render();
+}
+//==================================================================
+// function: OnRightButtonUp
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::OnRightButtonUp()
+{
+ if ( this->State == VISU_ImplicitFunctionWidget::Outside ) {
+ return;
+ }
+
+ this->State = VISU_ImplicitFunctionWidget::Start;
+ this->HighlightPlane(0);
+ this->HighlightOutline(0);
+ this->HighlightNormal(0);
+ this->SizeHandles();
+
+ this->EventCallbackCommand->SetAbortFlag(1);
+ this->EndInteraction();
+ this->InvokeEvent(vtkCommand::EndInteractionEvent,NULL);
+ this->Interactor->Render();
+}
+//==================================================================
+// function: OnMouseMove
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::OnMouseMove()
+{
+ // See whether we're active
+ if ( this->State == VISU_ImplicitFunctionWidget::Outside ||
+ this->State == VISU_ImplicitFunctionWidget::Start ) {
+ return;
+ }
+
+ int X = this->Interactor->GetEventPosition()[0];
+ int Y = this->Interactor->GetEventPosition()[1];
+
+ // Do different things depending on state
+ // Calculations everybody does
+ double focalPoint[4], pickPoint[4], prevPickPoint[4];
+ double z, vpn[3];
+
+ vtkCamera *camera = this->CurrentRenderer->GetActiveCamera();
+ if ( !camera ) {
+ return;
+ }
+
+ // Compute the two points defining the motion vector
+ this->ComputeWorldToDisplay(this->LastPickPosition[0], this->LastPickPosition[1],
+ this->LastPickPosition[2], focalPoint);
+ z = focalPoint[2];
+ this->ComputeDisplayToWorld(double(this->Interactor->GetLastEventPosition()[0]),
+ double(this->Interactor->GetLastEventPosition()[1]),
+ z, prevPickPoint);
+ this->ComputeDisplayToWorld(double(X), double(Y), z, pickPoint);
+
+ // Process the motion
+ if ( this->State == VISU_ImplicitFunctionWidget::MovingPlane ) {
+ this->TranslatePlane(prevPickPoint, pickPoint);
+ }
+ else if ( this->State == VISU_ImplicitFunctionWidget::MovingOutline ) {
+ this->TranslateOutline(prevPickPoint, pickPoint);
+ }
+ else if ( this->State == VISU_ImplicitFunctionWidget::MovingOrigin ) {
+ this->TranslateOrigin(prevPickPoint, pickPoint);
+ }
+ else if ( this->State == VISU_ImplicitFunctionWidget::Pushing ) {
+ this->Push(prevPickPoint, pickPoint);
+ }
+ else if ( this->State == VISU_ImplicitFunctionWidget::Scaling ) {
+ this->Scale(prevPickPoint, pickPoint, X, Y);
+ }
+ else if ( this->State == VISU_ImplicitFunctionWidget::Rotating ) {
+ camera->GetViewPlaneNormal(vpn);
+ this->Rotate(X, Y, prevPickPoint, pickPoint, vpn);
+ }
+ else if ( this->State == VISU_ImplicitFunctionWidget::ChangeDistance ) {
+ this->PushDistance(prevPickPoint, pickPoint);
+ }
+ // Interact, if desired
+ this->EventCallbackCommand->SetAbortFlag(1);
+ this->InvokeEvent(vtkCommand::InteractionEvent,NULL);
+
+ this->Interactor->Render();
+}
+//==================================================================
+// function: Rotate
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::Rotate(int X, int Y, double *p1, double *p2, double *vpn)
+{
+ double v[3]; //vector of motion
+ double axis[3]; //axis of rotation
+ double theta; //rotation angle
+
+ // mouse motion vector in world space
+ v[0] = p2[0] - p1[0];
+ v[1] = p2[1] - p1[1];
+ v[2] = p2[2] - p1[2];
+
+ float *origin = this->Plane->GetOrigin();
+ float *normal = this->Plane->GetNormal();
+
+ // Create axis of rotation and angle of rotation
+ vtkMath::Cross(vpn,v,axis);
+ if ( vtkMath::Normalize(axis) == 0.0 ) {
+ return;
+ }
+
+ int *size = this->CurrentRenderer->GetSize();
+ double l2 = (X-this->Interactor->GetLastEventPosition()[0])*
+ (X-this->Interactor->GetLastEventPosition()[0]) +
+ (Y-this->Interactor->GetLastEventPosition()[1])*
+ (Y-this->Interactor->GetLastEventPosition()[1]);
+ theta = 360.0 * sqrt(l2/((double)size[0]*size[0]+size[1]*size[1]));
+
+ //Manipulate the transform to reflect the rotation
+ this->Transform->Identity();
+ this->Transform->Translate(origin[0],origin[1],origin[2]);
+ this->Transform->RotateWXYZ(theta,axis);
+ this->Transform->Translate(-origin[0],-origin[1],-origin[2]);
+
+ //Set the new normal
+ float nNew[3], aN2[3];
+ this->Transform->TransformNormal(normal,nNew);
+ this->Plane->SetNormal(nNew);
+
+ aN2[0] = -nNew[0];
+ aN2[1] = -nNew[1];
+ aN2[2] = -nNew[2];
+ this->myPlane2->SetNormal(aN2);
+ float oNew[3];
+ vtkMath::Normalize(nNew);
+ oNew[0] = origin[0] + myDistance*nNew[0];
+ oNew[1] = origin[1] + myDistance*nNew[1];
+ oNew[2] = origin[2] + myDistance*nNew[2];
+ this->myPlane2->SetOrigin(oNew);
+
+ this->UpdateRepresentation();
+}
+//==================================================================
+// function: TranslatePlane
+// purpose : Loop through all points and translate them
+//==================================================================
+void VISU_ImplicitFunctionWidget::TranslatePlane(double *p1, double *p2)
+{
+ //Get the motion vector
+ double v[3];
+ v[0] = p2[0] - p1[0];
+ v[1] = p2[1] - p1[1];
+ v[2] = p2[2] - p1[2];
+
+ //Translate the plane
+ float oNew[3];
+ float *origin = this->Plane->GetOrigin();
+ oNew[0] = origin[0] + v[0];
+ oNew[1] = origin[1] + v[1];
+ oNew[2] = origin[2] + v[2];
+ this->Plane->SetOrigin(oNew);
+
+ origin = this->myPlane2->GetOrigin();
+ oNew[0] = origin[0] + v[0];
+ oNew[1] = origin[1] + v[1];
+ oNew[2] = origin[2] + v[2];
+ this->myPlane2->SetOrigin(oNew);
+
+ this->UpdateRepresentation();
+}
+//==================================================================
+// function: TranslateOutline
+// purpose :Loop through all points and translate them
+//==================================================================
+void VISU_ImplicitFunctionWidget::TranslateOutline(double *p1, double *p2)
+{
+ //Get the motion vector
+ double v[3];
+ v[0] = p2[0] - p1[0];
+ v[1] = p2[1] - p1[1];
+ v[2] = p2[2] - p1[2];
+
+ //Translate the bounding box
+ float *origin = this->Box->GetOrigin();
+ float oNew[3];
+ oNew[0] = origin[0] + v[0];
+ oNew[1] = origin[1] + v[1];
+ oNew[2] = origin[2] + v[2];
+ this->Box->SetOrigin(oNew);
+
+ //Translate the plane
+ origin = this->Plane->GetOrigin();
+ oNew[0] = origin[0] + v[0];
+ oNew[1] = origin[1] + v[1];
+ oNew[2] = origin[2] + v[2];
+ this->Plane->SetOrigin(oNew);
+
+ origin = this->myPlane2->GetOrigin();
+ oNew[0] = origin[0] + v[0];
+ oNew[1] = origin[1] + v[1];
+ oNew[2] = origin[2] + v[2];
+ this->myPlane2->SetOrigin(oNew);
+
+ this->UpdateRepresentation();
+}
+//==================================================================
+// function: TranslateOrigin
+// purpose :Loop through all points and translate them
+//==================================================================
+void VISU_ImplicitFunctionWidget::TranslateOrigin(double *p1, double *p2)
+{
+ //Get the motion vector
+ double v[3];
+ v[0] = p2[0] - p1[0];
+ v[1] = p2[1] - p1[1];
+ v[2] = p2[2] - p1[2];
+
+ //Add to the current point, project back down onto plane
+ float *o = this->Plane->GetOrigin();
+ float *n = this->Plane->GetNormal();
+ float newOrigin[3];
+
+ newOrigin[0] = o[0] + v[0];
+ newOrigin[1] = o[1] + v[1];
+ newOrigin[2] = o[2] + v[2];
+
+ vtkPlane::ProjectPoint(newOrigin,o,n,newOrigin);
+ this->SetOrigin(newOrigin);
+ this->UpdateRepresentation();
+}
+//==================================================================
+// function: Scale
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::Scale(double *p1, double *p2,
+ int vtkNotUsed(X), int Y)
+{
+ //Get the motion vector
+ double v[3];
+ v[0] = p2[0] - p1[0];
+ v[1] = p2[1] - p1[1];
+ v[2] = p2[2] - p1[2];
+
+ //int res = this->PlaneSource->GetXResolution();
+ float *o = this->Plane->GetOrigin();
+
+ // Compute the scale factor
+ float sf = vtkMath::Norm(v) / this->Outline->GetOutput()->GetLength();
+ if ( Y > this->Interactor->GetLastEventPosition()[1] ) {
+ sf = 1.0 + sf;
+ }
+ else {
+ sf = 1.0 - sf;
+ }
+
+ this->Transform->Identity();
+ this->Transform->Translate(o[0],o[1],o[2]);
+ this->Transform->Scale(sf,sf,sf);
+ this->Transform->Translate(-o[0],-o[1],-o[2]);
+
+ float *origin = this->Box->GetOrigin();
+ float *spacing = this->Box->GetSpacing();
+ float oNew[3], p[3], pNew[3];
+ p[0] = origin[0] + spacing[0];
+ p[1] = origin[1] + spacing[1];
+ p[2] = origin[2] + spacing[2];
+
+ this->Transform->TransformPoint(origin,oNew);
+ this->Transform->TransformPoint(p,pNew);
+
+ this->Box->SetOrigin(oNew);
+ this->Box->SetSpacing( (pNew[0]-oNew[0]), (pNew[1]-oNew[1]), (pNew[2]-oNew[2]) );
+
+ this->UpdateRepresentation();
+}
+//==================================================================
+// function: Push
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::Push(double *p1, double *p2)
+{
+ //Get the motion vector
+ float v[3];
+ v[0] = p2[0] - p1[0];
+ v[1] = p2[1] - p1[1];
+ v[2] = p2[2] - p1[2];
+
+ this->Plane->Push( vtkMath::Dot(v,this->Plane->GetNormal()) );
+ this->SetOrigin(this->Plane->GetOrigin());
+ myPlane2->Push( vtkMath::Dot(v,this->Plane->GetNormal()) );
+ this->UpdateRepresentation();
+}
+//==================================================================
+// function: PushDistance
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::PushDistance(double *p1, double *p2)
+{
+ float v[3], *anOrigin1, *aN1, *anOrigin2, aD;
+ //Get the motion vector
+ v[0] = p2[0] - p1[0];
+ v[1] = p2[1] - p1[1];
+ v[2] = p2[2] - p1[2];
+ //
+ myPlane2->Push( vtkMath::Dot(v, myPlane2->GetNormal()));
+ anOrigin1 = Plane->GetOrigin();
+ aN1 = Plane->GetNormal();
+ vtkMath::Normalize(aN1);
+ anOrigin2 = myPlane2->GetOrigin();
+ aD=DistanceToPlane(anOrigin2, aN1, anOrigin1);
+ //
+ myDistance=aD;
+ //
+ this->UpdateRepresentation();
+}
+
+//==================================================================
+// function: CreateDefaultProperties
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::CreateDefaultProperties()
+{
+ // Normal properties
+ this->NormalProperty = vtkProperty::New();
+ this->NormalProperty->SetColor(1,1,1);
+ this->NormalProperty->SetLineWidth(2);
+
+ this->SelectedNormalProperty = vtkProperty::New();
+ this->SelectedNormalProperty->SetColor(1,0,0);
+ this->NormalProperty->SetLineWidth(2);
+
+ // Plane properties
+ this->PlaneProperty = vtkProperty::New();
+ this->PlaneProperty->SetAmbient(1.0);
+ this->PlaneProperty->SetAmbientColor(1.0,1.0,1.0);
+
+ this->SelectedPlaneProperty = vtkProperty::New();
+ this->SelectedPlaneProperty->SetAmbient(1.0);
+ this->SelectedPlaneProperty->SetAmbientColor(0.0,1.0,0.0);
+ this->SelectedPlaneProperty->SetOpacity(0.25);
+
+ // Outline properties
+ this->OutlineProperty = vtkProperty::New();
+ this->OutlineProperty->SetAmbient(1.0);
+ this->OutlineProperty->SetAmbientColor(1.0,1.0,1.0);
+
+ this->SelectedOutlineProperty = vtkProperty::New();
+ this->SelectedOutlineProperty->SetAmbient(1.0);
+ this->SelectedOutlineProperty->SetAmbientColor(0.0,1.0,0.0);
+
+ // Edge property
+ this->EdgesProperty = vtkProperty::New();
+ this->EdgesProperty->SetAmbient(1.0);
+ this->EdgesProperty->SetAmbientColor(1.0,1.0,1.0);
+}
+//==================================================================
+// function: PlaceWidget
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::PlaceWidget(float bds[6])
+{
+ int i;
+ float bounds[6], origin[3];
+
+ this->AdjustBounds(bds, bounds, origin);
+
+ // Set up the bounding box
+ this->Box->SetOrigin(bounds[0],bounds[2],bounds[4]);
+ this->Box->SetSpacing((bounds[1]-bounds[0]),(bounds[3]-bounds[2]),
+ (bounds[5]-bounds[4]));
+ this->Outline->Update();
+
+ if (this->Input || this->Prop3D) {
+ this->LineSource->SetPoint1(this->Plane->GetOrigin());
+ if ( this->NormalToYAxis ) {
+ this->Plane->SetNormal(0,1,0);
+ myPlane2->SetNormal(0,-1,0);
+ this->LineSource->SetPoint2(0,1,0);
+ }
+ else if ( this->NormalToZAxis ) {
+ this->Plane->SetNormal(0,0,1);
+ myPlane2->SetNormal(0,0,-1);
+ this->LineSource->SetPoint2(0,0,1);
+ }
+ else{ //default or x-normal
+ this->Plane->SetNormal(1,0,0);
+ myPlane2->SetNormal(-1,0,0);
+ this->LineSource->SetPoint2(1,0,0);
+ }
+ }
+
+ for (i=0; i<6; i++) {
+ this->InitialBounds[i] = bounds[i];
+ }
+
+ this->InitialLength = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) +
+ (bounds[3]-bounds[2])*(bounds[3]-bounds[2]) +
+ (bounds[5]-bounds[4])*(bounds[5]-bounds[4]));
+
+ static float DIST_COEFF = 0.025;
+ SetDistance(this->InitialLength*DIST_COEFF);
+
+ this->UpdateRepresentation();
+}
+//==================================================================
+// function: SetOrigin
+// purpose :Set the origin of the plane.
+//==================================================================
+void VISU_ImplicitFunctionWidget::SetOrigin(float x, float y, float z)
+{
+ float origin[3];
+ origin[0] = x;
+ origin[1] = y;
+ origin[2] = z;
+ this->SetOrigin(origin);
+}
+//==================================================================
+// function: SetOrigin
+// purpose :Set the origin of the plane.
+//==================================================================
+void VISU_ImplicitFunctionWidget::SetOrigin(float x[3])
+{
+ float *bounds = this->Outline->GetOutput()->GetBounds();
+ for (int i=0; i<3; i++) {
+ if ( x[i] < bounds[2*i] ) {
+ x[i] = bounds[2*i];
+ }
+ else if ( x[i] > bounds[2*i+1] ) {
+ x[i] = bounds[2*i+1];
+ }
+ }
+ this->Plane->SetOrigin(x);
+ float *origin, *normal, oNew[3];
+ origin = Plane->GetOrigin();
+ normal = Plane->GetNormal();
+ vtkMath::Normalize(normal);
+ oNew[0] = origin[0] + myDistance*normal[0];
+ oNew[1] = origin[1] + myDistance*normal[1];
+ oNew[2] = origin[2] + myDistance*normal[2];
+ this->myPlane2->SetOrigin(oNew);
+ this->UpdateRepresentation();
+}
+//==================================================================
+// function: GetOrigin
+// purpose :Get the origin of the plane.
+//==================================================================
+float* VISU_ImplicitFunctionWidget::GetOrigin()
+{
+ return this->Plane->GetOrigin();
+}
+
+void VISU_ImplicitFunctionWidget::GetOrigin(float xyz[3])
+{
+ this->Plane->GetOrigin(xyz);
+}
+//==================================================================
+// function: SetNormal
+// purpose :Set the normal to the plane.
+//==================================================================
+void VISU_ImplicitFunctionWidget::SetNormal(float x, float y, float z)
+{
+ float n[3];
+ n[0] = x;
+ n[1] = y;
+ n[2] = z;
+ vtkMath::Normalize(n);
+ this->Plane->SetNormal(n);
+ n[0] =- x;
+ n[1] =- y;
+ n[2] =- z;
+ this->myPlane2->SetNormal(n);
+
+ this->UpdateRepresentation();
+}
+
+//==================================================================
+// function: SetNormal
+// purpose :Set the normal to the plane.
+//==================================================================
+void VISU_ImplicitFunctionWidget::SetNormal(float n[3])
+{
+ this->SetNormal(n[0], n[1], n[2]);
+}
+//==================================================================
+// function: GetNormal
+// purpose :Get the normal to the plane.
+//==================================================================
+float* VISU_ImplicitFunctionWidget::GetNormal()
+{
+ return this->Plane->GetNormal();
+}
+//==================================================================
+// function: GetNormal
+// purpose :Get the normal to the plane.
+//==================================================================
+void VISU_ImplicitFunctionWidget::GetNormal(float xyz[3])
+{
+ this->Plane->GetNormal(xyz);
+}
+//==================================================================
+// function: SetDrawPlane
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::SetDrawPlane(int drawPlane)
+{
+ if ( drawPlane == this->DrawPlane ) {
+ return;
+ }
+
+ this->Modified();
+ this->DrawPlane = drawPlane;
+ if ( this->Enabled ) {
+ if ( drawPlane ) {
+ this->CurrentRenderer->AddActor(this->CutActor);
+ this->CurrentRenderer->AddActor(myCutActor2);
+ }
+ else {
+ this->CurrentRenderer->RemoveActor(this->CutActor);
+ this->CurrentRenderer->RemoveActor(myCutActor2);
+ }
+ this->Interactor->Render();
+ }
+}
+//==================================================================
+// function: SetNormalToXAxis
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::SetNormalToXAxis (int var)
+{
+ if (this->NormalToXAxis != var) {
+ this->NormalToXAxis = var;
+ this->Modified();
+ }
+ if (var) {
+ this->NormalToYAxisOff();
+ this->NormalToZAxisOff();
+ }
+}
+//==================================================================
+// function: SetNormalToYAxis
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::SetNormalToYAxis (int var)
+{
+ if (this->NormalToYAxis != var) {
+ this->NormalToYAxis = var;
+ this->Modified();
+ }
+ if (var) {
+ this->NormalToXAxisOff();
+ this->NormalToZAxisOff();
+ }
+}
+//==================================================================
+// function: SetNormalToZAxis
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::SetNormalToZAxis (int var)
+{
+ if (this->NormalToZAxis != var) {
+ this->NormalToZAxis = var;
+ this->Modified();
+ }
+ if (var) {
+ this->NormalToXAxisOff();
+ this->NormalToYAxisOff();
+ }
+}
+//==================================================================
+// function: GetPolyData
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::GetPolyData(vtkPolyData *pd)
+{
+ pd->ShallowCopy(this->Cutter->GetOutput());
+}
+//==================================================================
+// function: GetPolyDataSource
+// purpose :
+//==================================================================
+vtkPolyDataSource *VISU_ImplicitFunctionWidget::GetPolyDataSource()
+{
+ return this->Cutter;
+}
+//==================================================================
+// function:GetPlane
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::GetPlane(vtkPlane *plane)
+{
+ if ( plane == NULL ) {
+ return;
+ }
+
+ plane->SetNormal(this->Plane->GetNormal());
+ plane->SetOrigin(this->Plane->GetOrigin());
+}
+//==================================================================
+// function:UpdatePlacement
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::UpdatePlacement(void)
+{
+ this->Outline->Update();
+ this->Cutter->Update();
+ this->Edges->Update();
+}
+//==================================================================
+// function:UpdateRepresentation
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::UpdateRepresentation()
+{
+ if ( ! this->CurrentRenderer ) {
+ return;
+ }
+
+ float *origin = this->Plane->GetOrigin();
+ float *normal = this->Plane->GetNormal();
+ float p2[3];
+
+ // Setup the plane normal
+ float d = this->Outline->GetOutput()->GetLength();
+
+ p2[0] = origin[0] + 0.30 * d * normal[0];
+ p2[1] = origin[1] + 0.30 * d * normal[1];
+ p2[2] = origin[2] + 0.30 * d * normal[2];
+
+ this->LineSource->SetPoint1(origin);
+ this->LineSource->SetPoint2(p2);
+ this->ConeSource->SetCenter(p2);
+ this->ConeSource->SetDirection(normal);
+
+ p2[0] = origin[0] - 0.30 * d * normal[0];
+ p2[1] = origin[1] - 0.30 * d * normal[1];
+ p2[2] = origin[2] - 0.30 * d * normal[2];
+
+ this->LineSource2->SetPoint1(origin);
+ this->LineSource2->SetPoint2(p2);
+ this->ConeSource2->SetCenter(p2);
+ this->ConeSource2->SetDirection(normal);
+
+ // Set up the position handle
+ this->Sphere->SetCenter(origin);
+
+ // Control the look of the edges
+ if ( this->Tubing ) {
+ this->EdgesMapper->SetInput(this->EdgesTuber->GetOutput());
+ }
+ else {
+ this->EdgesMapper->SetInput(this->Edges->GetOutput());
+ }
+}
+//==================================================================
+// function:SizeHandles
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::SizeHandles()
+{
+ float radius = this->vtk3DWidget::SizeHandles(1.35);
+
+ this->ConeSource->SetHeight(2.0*radius);
+ this->ConeSource->SetRadius(radius);
+ this->ConeSource2->SetHeight(2.0*radius);
+ this->ConeSource2->SetRadius(radius);
+
+ this->Sphere->SetRadius(radius);
+
+ this->EdgesTuber->SetRadius(0.25*radius);
+}
+//==================================================================
+// function:PrintSelf
+// purpose :
+//==================================================================
+void VISU_ImplicitFunctionWidget::PrintSelf(ostream& os, vtkIndent indent)
+{
+ this->Superclass::PrintSelf(os,indent);
+
+ if ( this->NormalProperty )
+ {
+ os << indent << "Normal Property: " << this->NormalProperty << "\n";
+ }
+ else
+ {
+ os << indent << "Normal Property: (none)\n";
+ }
+ if ( this->SelectedNormalProperty )
+ {
+ os << indent << "Selected Normal Property: "
+ << this->SelectedNormalProperty << "\n";
+ }
+ else
+ {
+ os << indent << "Selected Normal Property: (none)\n";
+ }
+
+ if ( this->PlaneProperty )
+ {
+ os << indent << "Plane Property: " << this->PlaneProperty << "\n";
+ }
+ else
+ {
+ os << indent << "Plane Property: (none)\n";
+ }
+ if ( this->SelectedPlaneProperty )
+ {
+ os << indent << "Selected Plane Property: "
+ << this->SelectedPlaneProperty << "\n";
+ }
+ else
+ {
+ os << indent << "Selected Plane Property: (none)\n";
+ }
+
+ if ( this->OutlineProperty )
+ {
+ os << indent << "Outline Property: " << this->OutlineProperty << "\n";
+ }
+ else
+ {
+ os << indent << "Outline Property: (none)\n";
+ }
+ if ( this->SelectedOutlineProperty )
+ {
+ os << indent << "Selected Outline Property: "
+ << this->SelectedOutlineProperty << "\n";
+ }
+ else
+ {
+ os << indent << "Selected Outline Property: (none)\n";
+ }
+
+ if ( this->EdgesProperty )
+ {
+ os << indent << "Edges Property: " << this->EdgesProperty << "\n";
+ }
+ else
+ {
+ os << indent << "Edges Property: (none)\n";
+ }
+
+ os << indent << "Normal To X Axis: "
+ << (this->NormalToXAxis ? "On" : "Off") << "\n";
+ os << indent << "Normal To Y Axis: "
+ << (this->NormalToYAxis ? "On" : "Off") << "\n";
+ os << indent << "Normal To Z Axis: "
+ << (this->NormalToZAxis ? "On" : "Off") << "\n";
+
+ os << indent << "Tubing: " << (this->Tubing ? "On" : "Off") << "\n";
+ os << indent << "Outline Translation: "
+ << (this->OutlineTranslation ? "On" : "Off") << "\n";
+ os << indent << "Draw Plane: " << (this->DrawPlane ? "On" : "Off") << "\n";
+}
+//==================================================================
+// function:DistanceToPlane
+// purpose :
+//==================================================================
+float DistanceToPlane(const float x[3],
+ const float n[3],
+ const float p0[3])
+{
+ return ((float) (n[0]*(x[0]-p0[0]) +
+ n[1]*(x[1]-p0[1]) +
+ n[2]*(x[2]-p0[2])));
+}
--- /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 : VISU_ImplicitFunctionWidget.h
+// Author : Peter KURNEV
+// Module : SALOME
+// $Header$
+
+#ifndef __VISU_ImplicitFunctionWidget_h
+#define __VISU_ImplicitFunctionWidget_h
+
+#include <vtkPolyDataSourceWidget.h>
+
+class vtkActor;
+class vtkPolyDataMapper;
+class vtkCellPicker;
+class vtkConeSource;
+class vtkLineSource;
+class vtkSphereSource;
+class vtkTubeFilter;
+class vtkPlane;
+class vtkCutter;
+class vtkProperty;
+class vtkImageData;
+class vtkOutlineFilter;
+class vtkFeatureEdges;
+class vtkPolyData;
+class vtkTransform;
+class vtkImplicitBoolean;
+class vtkImplicitFunction;
+
+class VISU_ImplicitFunctionWidget : public vtkPolyDataSourceWidget
+{
+public:
+ // Description:
+ // Instantiate the object.
+ static VISU_ImplicitFunctionWidget *New();
+
+ vtkTypeRevisionMacro(VISU_ImplicitFunctionWidget,vtkPolyDataSourceWidget);
+ void PrintSelf(ostream& os, vtkIndent indent);
+
+ void SetDistance (const float theDistance);
+ float Distance()const;
+ vtkImplicitFunction* ImplicitFunction();
+
+ // Description:
+ // Methods that satisfy the superclass' API.
+ virtual void SetEnabled(int);
+ virtual void PlaceWidget(float bounds[6]);
+ void PlaceWidget()
+ {this->Superclass::PlaceWidget();}
+
+ // Description:
+ // Get the origin of the plane.
+ void SetOrigin(float x, float y, float z);
+ void SetOrigin(float x[3]);
+ float* GetOrigin();
+ void GetOrigin(float xyz[3]);
+
+ // Description:
+ // Get the normal to the plane.
+ void SetNormal(float x, float y, float z);
+ void SetNormal(float x[3]);
+ float* GetNormal();
+ void GetNormal(float xyz[3]);
+
+ // Description:
+ // Force the plane widget to be aligned with one of the x-y-z axes.
+ // If one axis is set on, the other two will be set off.
+ // Remember that when the state changes, a ModifiedEvent is invoked.
+ // This can be used to snap the plane to the axes if it is orginally
+ // not aligned.
+ void SetNormalToXAxis(int);
+ vtkGetMacro(NormalToXAxis,int);
+ vtkBooleanMacro(NormalToXAxis,int);
+ void SetNormalToYAxis(int);
+ vtkGetMacro(NormalToYAxis,int);
+ vtkBooleanMacro(NormalToYAxis,int);
+ void SetNormalToZAxis(int);
+ vtkGetMacro(NormalToZAxis,int);
+ vtkBooleanMacro(NormalToZAxis,int);
+
+ // Description:
+ // Turn on/off tubing of the wire outline of the plane. The tube thickens
+ // the line by wrapping with a vtkTubeFilter.
+ vtkSetMacro(Tubing,int);
+ vtkGetMacro(Tubing,int);
+ vtkBooleanMacro(Tubing,int);
+
+ // Description:
+ // Enable/disable the drawing of the plane. In some cases the plane
+ // interferes with the object that it is operating on (i.e., the
+ // plane interferes with the cut surface it produces producing
+ // z-buffer artifacts.)
+ void SetDrawPlane(int plane);
+ vtkGetMacro(DrawPlane,int);
+ vtkBooleanMacro(DrawPlane,int);
+
+ // Description:
+ // Turn on/off the ability to translate the bounding box by grabbing it
+ // with the left mouse button.
+ vtkSetMacro(OutlineTranslation,int);
+ vtkGetMacro(OutlineTranslation,int);
+ vtkBooleanMacro(OutlineTranslation,int);
+
+ // Description:
+ // Grab the polydata that defines the plane. The polydata contains a single
+ // polygon that is clipped by the bounding box.
+ void GetPolyData(vtkPolyData *pd);
+
+ // Description:
+ // Satisfies superclass API. This returns a pointer to the underlying
+ // PolyData (which represents the plane).
+ vtkPolyDataSource* GetPolyDataSource();
+
+ // Description:
+ // Get the implicit function for the plane. The user must provide the
+ // instance of the class vtkPlane. Note that vtkPlane is a subclass of
+ // vtkImplicitFunction, meaning that it can be used by a variety of filters
+ // to perform clipping, cutting, and selection of data.
+ void GetPlane(vtkPlane *plane);
+
+ // Description:
+ // Satisfies the superclass API. This will change the state of the widget
+ // to match changes that have been made to the underlying PolyDataSource
+ void UpdatePlacement(void);
+
+ // Description:
+ // Get the properties on the normal (line and cone).
+ vtkGetObjectMacro(NormalProperty,vtkProperty);
+ vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
+
+ // Description:
+ // Get the plane properties. The properties of the plane when selected
+ // and unselected can be manipulated.
+ vtkGetObjectMacro(PlaneProperty,vtkProperty);
+ vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
+
+ // Description:
+ // Get the property of the outline.
+ vtkGetObjectMacro(OutlineProperty,vtkProperty);
+ vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
+
+ // Description:
+ // Get the property of the intersection edges. (This property also
+ // applies to the edges when tubed.)
+ vtkGetObjectMacro(EdgesProperty,vtkProperty);
+
+protected:
+ VISU_ImplicitFunctionWidget();
+ ~VISU_ImplicitFunctionWidget();
+
+//BTX - manage the state of the widget
+ int State;
+ enum WidgetState
+ {
+ Start=0,
+ MovingPlane,
+ MovingOutline,
+ MovingOrigin,
+ Scaling,
+ Pushing,
+ Rotating,
+ Outside,
+ ChangeDistance
+ };
+//ETX
+
+ //handles the events
+ static void ProcessEvents(vtkObject* object, unsigned long event,
+ void* clientdata, void* calldata);
+
+ // ProcessEvents() dispatches to these methods.
+ void OnLeftButtonDown();
+ void OnLeftButtonUp();
+ void OnMiddleButtonDown();
+ void OnMiddleButtonUp();
+ void OnRightButtonDown();
+ void OnRightButtonUp();
+ void OnMouseMove();
+
+ // Controlling ivars
+ int NormalToXAxis;
+ int NormalToYAxis;
+ int NormalToZAxis;
+ void UpdateRepresentation();
+
+ // The actual plane which is being manipulated
+ vtkPlane *Plane;
+ vtkPlane *myPlane2;
+ float myDistance;
+ vtkImplicitBoolean *myImplicitFunction;
+ // The bounding box is represented by a single voxel image data
+ vtkImageData *Box;
+ vtkOutlineFilter *Outline;
+ vtkPolyDataMapper *OutlineMapper;
+ vtkActor *OutlineActor;
+ void HighlightOutline(int highlight);
+ int OutlineTranslation; //whether the outline can be moved
+
+ // The cut plane is produced with a vtkCutter
+ vtkCutter *Cutter;
+ vtkPolyDataMapper *CutMapper;
+ vtkActor *CutActor;
+
+ vtkCutter *myCutter2;
+ vtkPolyDataMapper *myCutMapper2;
+ vtkActor *myCutActor2;
+
+ int DrawPlane;
+ void HighlightPlane(int highlight);
+
+ // Optional tubes are represented by extracting boundary edges and tubing
+ vtkFeatureEdges *Edges;
+ vtkTubeFilter *EdgesTuber;
+ vtkPolyDataMapper *EdgesMapper;
+ vtkActor *EdgesActor;
+ int Tubing; //control whether tubing is on
+
+ // The + normal cone
+ vtkConeSource *ConeSource;
+ vtkPolyDataMapper *ConeMapper;
+ vtkActor *ConeActor;
+ void HighlightNormal(int highlight);
+
+ // The + normal line
+ vtkLineSource *LineSource;
+ vtkPolyDataMapper *LineMapper;
+ vtkActor *LineActor;
+
+ // The - normal cone
+ vtkConeSource *ConeSource2;
+ vtkPolyDataMapper *ConeMapper2;
+ vtkActor *ConeActor2;
+
+ // The - normal line
+ vtkLineSource *LineSource2;
+ vtkPolyDataMapper *LineMapper2;
+ vtkActor *LineActor2;
+
+ // The origin positioning handle
+ vtkSphereSource *Sphere;
+ vtkPolyDataMapper *SphereMapper;
+ vtkActor *SphereActor;
+
+ // Do the picking
+ vtkCellPicker *Picker;
+
+ // Transform the normal (used for rotation)
+ vtkTransform *Transform;
+
+ // Methods to manipulate the plane
+ void ConstrainOrigin(float x[3]);
+ void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
+ void TranslatePlane(double *p1, double *p2);
+ void TranslateOutline(double *p1, double *p2);
+ void TranslateOrigin(double *p1, double *p2);
+ void Push(double *p1, double *p2);
+ void Scale(double *p1, double *p2, int X, int Y);
+ void PushDistance(double *p1, double *p2);
+
+ // Properties used to control the appearance of selected objects and
+ // the manipulator in general.
+ vtkProperty *NormalProperty;
+ vtkProperty *SelectedNormalProperty;
+ vtkProperty *PlaneProperty;
+ vtkProperty *SelectedPlaneProperty;
+ vtkProperty *OutlineProperty;
+ vtkProperty *SelectedOutlineProperty;
+ vtkProperty *EdgesProperty;
+
+ void CreateDefaultProperties();
+
+ void GeneratePlane();
+ virtual void SizeHandles();
+
+private:
+ VISU_ImplicitFunctionWidget(const VISU_ImplicitFunctionWidget&); //Not implemented
+ void operator=(const VISU_ImplicitFunctionWidget&); //Not implemented
+};
+
+#endif
}
VISU_LookupTable::VISU_LookupTable(int sze, int ext)
- : vtkLookupTable(sze, ext), myScale(1.0) {}
+ : vtkLookupTable(sze, ext), myScale(1.0), myBicolor(false) {}
int VISU_LookupTable::ComputeLogRange(float inRange[2], float outRange[2]){
if(inRange[0] >= inRange[1])
float aLowBound = log10(this->TableRange[0]);
v = pow(10.0f,aLowBound + (v - aLowBound)*myScale);
return vtkLookupTable::MapValue(v);
- }else{
+ } else if (!myBicolor) {
v = this->TableRange[0] + (v - this->TableRange[0])*myScale;
return vtkLookupTable::MapValue(v);
+ } else {
+ unsigned char* table = this->Table->GetPointer(0);
+ int index = v > 0 ? 4*static_cast<int>(this->GetNumberOfColors()-1) : 0;
+ return &table[index];
}
}
inline unsigned char *VISU_LinearLookup(float v,
unsigned char *table,
float maxIndex,
- float shift, float scale)
+ float shift, float scale,
+ bool bicolor)
{
- float findx = (v + shift)*scale;
- if (findx < 0)
- {
- findx = 0;
- }
- if (findx > maxIndex)
- {
- findx = maxIndex;
- }
- return &table[4*static_cast<int>(findx)];
- /* round
- return &table[4*(int)(findx + 0.5f)];
- */
+ if( !bicolor )
+ {
+ float findx = (v + shift)*scale;
+ if (findx < 0)
+ findx = 0;
+ if (findx > maxIndex)
+ findx = maxIndex;
+
+ return &table[4*static_cast<int>(findx)];
+ // round
+ //return &table[4*(int)(findx + 0.5f)];
+ }
+ else
+ {
+ int index = v > 0 ? 4*static_cast<int>(maxIndex) : 0;
+ return &table[index];
+ }
}
// accelerate the mapping by copying the data in 32-bit chunks instead
// of 8-bit chunks
template<class T>
void VISU_LookupTableMapData(vtkLookupTable *self, T *input,
- unsigned char *output, int length,
- int inIncr, int outFormat, float theMapScale)
+ unsigned char *output, int length,
+ int inIncr, int outFormat,
+ float theMapScale, bool bicolor)
{
int i = length;
float *range = self->GetTableRange();
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
*output++ = cptr[3];
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
input += inIncr;
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
*output++ = cptr[3];
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
input += inIncr;
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
*output++ = static_cast<unsigned char>(alpha*cptr[3]);
while (--i >= 0)
{
val = VISU_ApplyLogScale(*input, range, logRange);
- cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale);
+ cptr = VISU_LinearLookup(val, table, maxIndex, shift, scale*theMapScale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
input += inIncr;
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale, bicolor);
*output++ = *cptr++;
*output++ = *cptr++;
*output++ = *cptr++;
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
*output++ = static_cast<unsigned char>(cptr[3]*alpha);
{
while (--i >= 0)
{
- cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale);
+ cptr = VISU_LinearLookup(*input, table, maxIndex, shift, scale, bicolor);
*output++ = static_cast<unsigned char>(cptr[0]*0.30 + cptr[1]*0.59 +
cptr[2]*0.11 + 0.5);
input += inIncr;
template<class T>
void VISU_LookupTableMapMag(vtkLookupTable *self, T *input,
unsigned char *output, int length,
- int inIncr, int outFormat, float theMapScale)
+ int inIncr, int outFormat,
+ float theMapScale, bool bicolor)
{
double tmp, sum;
double *mag;
mag[i] = sqrt(sum);
}
- VISU_LookupTableMapData(self, mag, output, length, 1, outFormat, theMapScale);
+ VISU_LookupTableMapData(self, mag, output, length, 1, outFormat, theMapScale, bicolor);
delete [] mag;
}
break;
case VTK_CHAR:
VISU_LookupTableMapMag(this,static_cast<char *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_UNSIGNED_CHAR:
VISU_LookupTableMapMag(this,static_cast<unsigned char *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_SHORT:
VISU_LookupTableMapMag(this,static_cast<short *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_UNSIGNED_SHORT:
VISU_LookupTableMapMag(this,static_cast<unsigned short *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_INT:
VISU_LookupTableMapMag(this,static_cast<int *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_UNSIGNED_INT:
VISU_LookupTableMapMag(this,static_cast<unsigned int *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_LONG:
VISU_LookupTableMapMag(this,static_cast<long *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_UNSIGNED_LONG:
VISU_LookupTableMapMag(this,static_cast<unsigned long *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_FLOAT:
VISU_LookupTableMapMag(this,static_cast<float *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
case VTK_DOUBLE:
VISU_LookupTableMapMag(this,static_cast<double *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
return;
default:
vtkErrorMacro(<< "MapImageThroughTable: Unknown input ScalarType");
VISU_LookupTableMapData(this,
static_cast<unsigned char*>(newInput->GetPointer(0)),
output,numberOfValues,
- inputIncrement,outputFormat,myScale);
+ inputIncrement,outputFormat,myScale,myBicolor);
newInput->Delete();
bitArray->Delete();
}
case VTK_CHAR:
VISU_LookupTableMapData(this,static_cast<char *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_UNSIGNED_CHAR:
VISU_LookupTableMapData(this,static_cast<unsigned char *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_SHORT:
VISU_LookupTableMapData(this,static_cast<short *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_UNSIGNED_SHORT:
VISU_LookupTableMapData(this,static_cast<unsigned short *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_INT:
VISU_LookupTableMapData(this,static_cast<int *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_UNSIGNED_INT:
VISU_LookupTableMapData(this,static_cast<unsigned int *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_LONG:
VISU_LookupTableMapData(this,static_cast<long *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_UNSIGNED_LONG:
VISU_LookupTableMapData(this,static_cast<unsigned long *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_FLOAT:
VISU_LookupTableMapData(this,static_cast<float *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
case VTK_DOUBLE:
VISU_LookupTableMapData(this,static_cast<double *>(input),output,
- numberOfValues,inputIncrement,outputFormat,myScale);
+ numberOfValues,inputIncrement,outputFormat,myScale,myBicolor);
break;
default:
float GetMapScale() { return myScale; }
void SetMapScale(float theScale = 1.0) { myScale = theScale; Modified(); }
+ float GetBicolor() { return myBicolor; }
+ void SetBicolor( bool theBicolor ) { myBicolor = theBicolor; Modified(); }
+
static int ComputeLogRange(float inRange[2], float outRange[2]);
unsigned char *MapValue(float v);
~VISU_LookupTable() {};
float myScale;
+
+ bool myBicolor;
};
#endif // VISU_LookupTable_H
VISU_PipeLine::VISU_PipeLine()
{
if(MYDEBUG) MESSAGE("VISU_PipeLine - "<<this);
+ SetDebug(MYVTKDEBUG);
+
// Clipping planes
myExtractGeometry = SALOME_ExtractGeometry::New();
- //myExtractGeometry->SetReleaseDataFlag(true);
myExtractGeometry->Delete();
//myExtractGeometry->DebugOn();
+ myExtractGeometry->SetExtractInside(0);
+ //myExtractGeometry->SetReleaseDataFlag(true);
vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New();
- //myExtractGeometry->SetImplicitBoolean(anImplicitBoolean);
myExtractGeometry->SetImplicitFunction(anImplicitBoolean);
anImplicitBoolean->SetOperationTypeToIntersection();
anImplicitBoolean->Delete();
myIsShrinkable = false;
- SetDebug(MYVTKDEBUG);
}
VISU_PipeLine::~VISU_PipeLine()
{
SetIDMapper(thePipeLine->GetIDMapper());
myMapper->ShallowCopy(thePipeLine->GetMapper());
- //myExtractGeometry->SetImplicitBoolean(thePipeLine->myExtractGeometry->GetImplicitBoolean());
- myExtractGeometry->SetImplicitFunction(thePipeLine->myExtractGeometry->GetImplicitBoolean());
+ SetImplicitFunction(thePipeLine->GetImplicitFunction());
Build();
}
void VISU_PipeLine::SameAs(VISU_PipeLine *thePipeLine){
ShallowCopy(thePipeLine);
- //myExtractGeometry->SetImplicitBoolean(vtkImplicitBoolean::New());
- myExtractGeometry->SetImplicitFunction(vtkImplicitBoolean::New());
- myExtractGeometry->GetImplicitBoolean()->Delete();
+ vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New();
+ SetImplicitFunction(anImplicitBoolean);
+ anImplicitBoolean->Delete();
}
TInput* VISU_PipeLine::GetInput() const
{
return myIDMapper;
}
+
//=======================================================================
-void VISU_PipeLine::SetImplicitFunction(vtkImplicitFunction *theFunction)
+void
+VISU_PipeLine
+::SetImplicitFunction(vtkImplicitFunction *theFunction)
{
myExtractGeometry->SetImplicitFunction(theFunction);
}
-//=======================================================================
-vtkImplicitFunction * VISU_PipeLine::GetImplicitFunction()
+
+vtkImplicitFunction *
+VISU_PipeLine
+::GetImplicitFunction()
{
return myExtractGeometry->GetImplicitFunction();
}
-//=======================================================================
-void VISU_PipeLine::SetExtractInside(int theFlag)
+
+void
+VISU_PipeLine
+::SetExtractInside(int theFlag)
{
myExtractGeometry->SetExtractInside(theFlag);
}
msgid "VisuGUI_GaussPointsDlg::INCREMENT"
msgstr "Increment : "
+msgid "VisuGUI_GaussScalarBarPane::ACTIVE_BAR_GRP"
+msgstr "Active bar"
+
+msgid "VisuGUI_GaussScalarBarPane::LOCAL"
+msgstr "Local"
+
+msgid "VisuGUI_GaussScalarBarPane::GLOBAL"
+msgstr "Global"
+
+msgid "VisuGUI_GaussScalarBarPane::DISPLAYED"
+msgstr "Displayed"
+
+msgid "VisuGUI_GaussScalarBarPane::SCALAR_RANGE_GRP"
+msgstr "Scalar range"
+
+msgid "VisuGUI_GaussScalarBarPane::LOGARITHMIC_SCALING"
+msgstr "Logarithmic scaling"
+
+msgid "VisuGUI_GaussScalarBarPane::FIELD_RANGE_BTN"
+msgstr "Use field range"
+
+msgid "VisuGUI_GaussScalarBarPane::IMPOSED_RANGE_BTN"
+msgstr "Use imposed range"
+
+msgid "VisuGUI_GaussScalarBarPane::LBL_MIN"
+msgstr "Min:"
+
+msgid "VisuGUI_GaussScalarBarPane::LBL_MAX"
+msgstr "Max:"
+
+msgid "VisuGUI_GaussScalarBarPane::COLORS_LABELS_GRP"
+msgstr "Colors and labels"
+
+msgid "VisuGUI_GaussScalarBarPane::BICOLOR"
+msgstr "Bicolor"
+
+msgid "VisuGUI_GaussScalarBarPane::RAINBOW"
+msgstr "Rainbow"
+
+msgid "VisuGUI_GaussScalarBarPane::LBL_NB_COLORS"
+msgstr "Nb. of colors:"
+
+msgid "VisuGUI_GaussScalarBarPane::LBL_NB_LABELS"
+msgstr "Nb. of labels:"
+
+msgid "VisuGUI_GaussScalarBarPane::ORIENTATION_GRP"
+msgstr "Orientation"
+
+msgid "VisuGUI_GaussScalarBarPane::VERTICAL_BTN"
+msgstr "Vertical"
+
+msgid "VisuGUI_GaussScalarBarPane::HORIZONTAL_BTN"
+msgstr "Horizontal"
+
+msgid "VisuGUI_GaussScalarBarPane::ORIGIN_GRP"
+msgstr "Origin"
+
+msgid "VisuGUI_GaussScalarBarPane::LBL_X"
+msgstr "X:"
+
+msgid "VisuGUI_GaussScalarBarPane::LBL_Y"
+msgstr "Y:"
+
+msgid "VisuGUI_GaussScalarBarPane::DIMENSIONS_GRP"
+msgstr "Dimensions"
+
+msgid "VisuGUI_GaussScalarBarPane::LBL_WIDTH"
+msgstr "Width:"
+
+msgid "VisuGUI_GaussScalarBarPane::LBL_HEIGHT"
+msgstr "Height:"
+
+msgid "VisuGUI_GaussScalarBarPane::LBL_SPACING"
+msgstr "Spacing:"
+
+msgid "VisuGUI_GaussScalarBarPane::SAVE_DEFAULT_CHK"
+msgstr "Save as default values"
+
msgid "VVTK_ViewWindow::LBL_TOOLBAR_LABEL"
msgstr "GAUSS viewer tools"
#include "VisuGUI_GaussPointsDlg.h"
+#include "VISUConfig.hh"
+
+#include "VisuGUI_FontWg.h"
#include "VisuGUI_Tools.h"
#include "VISU_GaussPoints_i.hh"
+#include "VISU_GaussPointsPL.hxx"
+//#include "VISU_ScalarMap_i.hh"
+#include "VISU_ScalarMapPL.hxx"
+#include "VISU_Convertor.hxx"
+#include "SalomeApp_Application.h"
#include "SalomeApp_Module.h"
#include "SUIT_Desktop.h"
#include "SUIT_ResourceMgr.h"
#include "SUIT_Session.h"
-
-#include "QtxDblSpinBox.h"
+#include "SUIT_MessageBox.h"
#include <qlayout.h>
#include <qtabwidget.h>
#include <qbuttongroup.h>
#include <qradiobutton.h>
#include <qfiledialog.h>
+#include <qvalidator.h>
+#include <qcolordialog.h>
using namespace std;
+VisuGUI_GaussScalarBarPane::VisuGUI_GaussScalarBarPane (QWidget * parent, bool SetPref):
+ QVBox(parent)
+{
+ myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80;
+ myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12;
+ Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0;
+ myRangeMode = -1;
+
+ setSpacing(6);
+ //setMargin(11);
+
+ // Active bar ========================================================
+ QGroupBox* ActiveBarGroup = new QGroupBox (tr("ACTIVE_BAR_GRP"), this, "ActiveBarGroup");
+ ActiveBarGroup->setColumnLayout(0, Qt::Vertical );
+ ActiveBarGroup->layout()->setSpacing( 0 );
+ ActiveBarGroup->layout()->setMargin( 0 );
+ QGridLayout* ActiveBarGroupLayout = new QGridLayout( ActiveBarGroup->layout() );
+ ActiveBarGroupLayout->setAlignment( Qt::AlignTop );
+ ActiveBarGroupLayout->setSpacing( 6 );
+ ActiveBarGroupLayout->setMargin( 11 );
+
+ QButtonGroup* BarTypeGroup = new QButtonGroup( 2, Qt::Vertical, ActiveBarGroup, "BarTypeGroup" );
+ BarTypeGroup->setRadioButtonExclusive( true );
+ BarTypeGroup->setFrameStyle( QFrame::NoFrame );
+ BarTypeGroup->layout()->setMargin( 0 );
+
+ QRadioButton* LocalButton = new QRadioButton( tr( "LOCAL" ), BarTypeGroup );
+ LocalButton->setChecked( true );
+ QRadioButton* GlobalButton = new QRadioButton( tr( "GLOBAL" ), BarTypeGroup );
+
+ QCheckBox* DisplayedBox = new QCheckBox( tr( "DISPLAYED" ), ActiveBarGroup );
+ DisplayedBox->setChecked( true );
+ DisplayedBox->setEnabled( false );
+
+ ActiveBarGroupLayout->addMultiCellWidget( BarTypeGroup, 0, 1, 0, 0);
+ ActiveBarGroupLayout->addWidget( DisplayedBox, 1, 1);
+
+ // Range ============================================================
+ RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup");
+ RangeGroup->setColumnLayout(0, Qt::Vertical );
+ RangeGroup->layout()->setSpacing( 0 );
+ RangeGroup->layout()->setMargin( 0 );
+ QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
+ RangeGroupLayout->setAlignment( Qt::AlignTop );
+ RangeGroupLayout->setSpacing( 6 );
+ RangeGroupLayout->setMargin( 11 );
+
+ myModeLbl = new QLabel("Scalar Mode", RangeGroup);
+
+ myModeCombo = new QComboBox(RangeGroup);
+ myModeCombo->insertItem("Modulus");
+ myModeCombo->insertItem("Component 1");
+ myModeCombo->insertItem("Component 2");
+ myModeCombo->insertItem("Component 3");
+
+ RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
+ RangeGroupLayout->addWidget( myModeCombo, 0, 1 );
+
+ //TopLayout->addWidget( RangeGroup );
+
+ // Colors and Labels ========================================================
+ QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup");
+ ColLabGroup->setColumnLayout(0, Qt::Vertical );
+ ColLabGroup->layout()->setSpacing( 0 );
+ ColLabGroup->layout()->setMargin( 0 );
+ QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
+ ColLabGroupLayout->setAlignment( Qt::AlignTop );
+ ColLabGroupLayout->setSpacing( 6 );
+ ColLabGroupLayout->setMargin( 11 );
+
+ QButtonGroup* TypeGroup = new QButtonGroup( 2, Qt::Vertical, ColLabGroup, "TypeGroup" );
+ TypeGroup->setRadioButtonExclusive( true );
+ TypeGroup->setFrameStyle( QFrame::NoFrame );
+ TypeGroup->layout()->setMargin( 0 );
+
+ BicolorButton = new QRadioButton( tr( "BICOLOR" ), TypeGroup );
+ RainbowButton = new QRadioButton( tr( "RAINBOW" ), TypeGroup );
+
+ ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel");
+ ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
+ ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ ColorSpin->setMinimumWidth( 70 );
+ ColorSpin->setValue( 64 );
+
+ LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel");
+ LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
+ LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ LabelSpin->setMinimumWidth( 70 );
+ LabelSpin->setValue( 5 );
+
+ ColLabGroupLayout->addMultiCellWidget( TypeGroup, 0, 1, 0, 0);
+ ColLabGroupLayout->addWidget( ColorLabel, 1, 1);
+ ColLabGroupLayout->addWidget( ColorSpin, 1, 2);
+ ColLabGroupLayout->addWidget( LabelLabel, 1, 3);
+ ColLabGroupLayout->addWidget( LabelSpin, 1, 4);
+
+ //TopLayout->addWidget( ColLabGroup );
+
+ // Orientation ==========================================================
+ QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup");
+ OrientGroup->setColumnLayout(0, Qt::Vertical );
+ OrientGroup->layout()->setSpacing( 0 );
+ OrientGroup->layout()->setMargin( 0 );
+ QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
+ OrientGroupLayout->setAlignment( Qt::AlignTop );
+ OrientGroupLayout->setSpacing( 6 );
+ OrientGroupLayout->setMargin( 11 );
+
+ RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert");
+ RBvert->setChecked( true );
+ RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori");
+ OrientGroupLayout->addWidget( RBvert, 0, 0 );
+ OrientGroupLayout->addWidget( RBhori, 0, 1 );
+
+ // TopLayout->addWidget( OrientGroup );
+
+ // Origin ===============================================================
+ QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup");
+ OriginGroup->setColumnLayout(0, Qt::Vertical );
+ OriginGroup->layout()->setSpacing( 0 );
+ OriginGroup->layout()->setMargin( 0 );
+ QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
+ OriginGroupLayout->setAlignment( Qt::AlignTop );
+ OriginGroupLayout->setSpacing( 6 );
+ OriginGroupLayout->setMargin( 11 );
+
+ QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel");
+ XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
+ XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ XSpin->setMinimumWidth( 70 );
+ XSpin->setValue( 0.01 );
+
+ QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel");
+ YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
+ YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ YSpin->setMinimumWidth( 70 );
+ YSpin->setValue( 0.01 );
+
+ OriginGroupLayout->addWidget( XLabel, 0, 0);
+ OriginGroupLayout->addWidget( XSpin, 0, 1);
+ OriginGroupLayout->addWidget( YLabel, 0, 2);
+ OriginGroupLayout->addWidget( YSpin, 0, 3);
+
+ //TopLayout->addWidget( OriginGroup );
+
+ // Dimensions =========================================================
+ QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup");
+ DimGroup->setColumnLayout(0, Qt::Vertical );
+ DimGroup->layout()->setSpacing( 0 );
+ DimGroup->layout()->setMargin( 0 );
+ QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
+ DimGroupLayout->setAlignment( Qt::AlignTop );
+ DimGroupLayout->setSpacing( 6 );
+ DimGroupLayout->setMargin( 11 );
+
+ QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel");
+ WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
+ WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ WidthSpin->setMinimumWidth( 70 );
+ WidthSpin->setValue( 0.1 );
+
+ QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup, "HeightLabel");
+ HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
+ HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ HeightSpin->setMinimumWidth( 70 );
+ HeightSpin->setValue( 0.8 );
+
+ QLabel* SpacingLabel = new QLabel (tr("LBL_SPACING"), DimGroup, "SpacingLabel");
+ SpacingSpin = new QtxDblSpinBox( 0.0, 1.0, 0.01, DimGroup );
+ SpacingSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ SpacingSpin->setMinimumWidth( 70 );
+ SpacingSpin->setValue( 0.01 );
+
+ DimGroupLayout->addWidget( WidthLabel, 0, 0);
+ DimGroupLayout->addWidget( WidthSpin, 0, 1);
+ DimGroupLayout->addWidget( HeightLabel, 0, 2);
+ DimGroupLayout->addWidget( HeightSpin, 0, 3);
+ DimGroupLayout->addWidget( SpacingLabel, 0, 4);
+ DimGroupLayout->addWidget( SpacingSpin, 0, 5);
+
+ //TopLayout->addWidget( DimGroup );
+
+ // Save check box ===========================================================
+ QHBox* aSaveBox = new QHBox(this);
+ if (!SetPref) {
+ CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), aSaveBox, "CBSave");
+ //TopLayout->addWidget(CBSave);
+ }
+ else {
+ CBSave = 0;
+ }
+ myTextBtn = new QPushButton("Text properties...", aSaveBox);
+ myTextDlg = new VisuGUI_TextPrefDlg(this);
+ myTextDlg->setTitleVisible(!SetPref);
+
+ // signals and slots connections ===========================================
+ connect( GlobalButton, SIGNAL( toggled( bool ) ), DisplayedBox, SLOT( setEnabled( bool ) ) );
+ connect( RainbowButton, SIGNAL( toggled( bool ) ), ColorLabel, SLOT( setEnabled( bool ) ) );
+ connect( RainbowButton, SIGNAL( toggled( bool ) ), ColorSpin, SLOT( setEnabled( bool ) ) );
+ connect( RainbowButton, SIGNAL( toggled( bool ) ), LabelLabel, SLOT( setEnabled( bool ) ) );
+ connect( RainbowButton, SIGNAL( toggled( bool ) ), LabelSpin, SLOT( setEnabled( bool ) ) );
+ connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
+ connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
+ connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
+ connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
+
+ changeDefaults( 0 );
+ myIsStoreTextProp = false;
+}
+
+
+/**
+ * Initializes dialog box values from resources
+ */
+void VisuGUI_GaussScalarBarPane::initFromResources() {
+ int sbCol=64,sbLab=5,orient=0;
+ float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
+ float sbVmin=0., sbVmax=0.;
+ QString aString;
+
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+ int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
+ myModeCombo->setCurrentItem(aScalarMode);
+
+ orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", orient);
+ if(orient != 0){
+ orient=1;
+ sbX1=0.2;
+ sbY1=0.01;
+ sbW=0.6;
+ sbH=0.12;
+ }
+
+ QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
+
+ sbX1 = aResourceMgr->doubleValue("VISU", propertyName + "x", sbX1);
+ sbY1 = aResourceMgr->doubleValue("VISU", propertyName + "y", sbY1);
+
+ sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW);
+ sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH);
+
+ sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol);
+ sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab);
+
+ int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
+
+ if((sbX1 < 0.) || (sbY1 < 0.) ||
+ ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
+ if(orient == 0) {
+ sbX1=0.01;
+ sbY1=0.1;
+ sbW=0.1;
+ sbH=0.8;
+ } else {
+ sbX1=0.2;
+ sbY1=0.01;
+ sbW=0.6;
+ sbH=0.12;
+ }
+ }
+ if(sbCol < 2) sbCol=2;
+ if(sbCol > 64) sbCol=64;
+ if(sbLab < 2) sbLab=2;
+ if(sbLab > 65) sbLab=65;
+
+ if(sbVmin > sbVmax) {
+ sbVmin=0.;
+ sbVmax=0.;
+ }
+
+ setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 0);
+ setScalarBarData( sbCol, sbLab );
+
+ // "Title"
+ bool isBold = false, isItalic = false, isShadow = false;
+ int aFontFamily = VTK_ARIAL;
+
+ if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) )
+ {
+ QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
+
+ if ( f.family() == "Arial" )
+ aFontFamily = VTK_ARIAL;
+ else if ( f.family() == "Courier" )
+ aFontFamily = VTK_COURIER;
+ else if ( f.family() == "Times" )
+ aFontFamily = VTK_TIMES;
+
+ isBold = f.bold();
+ isItalic = f.italic();
+ isShadow = f.underline();
+ }
+
+ QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
+
+ myTextDlg->myTitleFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
+
+ // "Labels"
+ isBold = isItalic = isShadow = false;
+ aFontFamily = VTK_ARIAL;
+
+ if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) )
+ {
+ QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
+
+ if ( f.family() == "Arial" )
+ aFontFamily = VTK_ARIAL;
+ else if ( f.family() == "Courier" )
+ aFontFamily = VTK_COURIER;
+ else if ( f.family() == "Times" )
+ aFontFamily = VTK_TIMES;
+
+ isBold = f.bold();
+ isItalic = f.italic();
+ isShadow = f.underline();
+ }
+
+ aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
+
+ myTextDlg->myLabelFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
+}
+
+/**
+ * Stores dialog values to resources
+ */
+void VisuGUI_GaussScalarBarPane::storeToResources() {
+ int orient = (RBvert->isChecked())? 0 : 1;
+ float sbX1 = XSpin->value();
+ float sbY1 = YSpin->value();
+ float sbW = WidthSpin->value();
+ float sbH = HeightSpin->value();
+ int sbCol = ColorSpin->value();
+ int sbLab = LabelSpin->value();
+
+ if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
+ if(orient == 0) {
+ sbX1=0.01;
+ sbY1=0.1;
+ sbW=0.17;
+ sbH=0.8;
+ } else {
+ sbX1=0.2;
+ sbY1=0.01;
+ sbW=0.6;
+ sbH=0.12;
+ }
+ }
+
+ SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+ aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
+
+ QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
+
+ aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
+ aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
+ aResourceMgr->setValue("VISU", propertyName + "width", sbW);
+ aResourceMgr->setValue("VISU", propertyName + "height", sbH);
+
+ aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
+ aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
+
+ aResourceMgr->setValue("VISU", "scalar_range_type", 0);
+
+ ////
+
+ if (myIsStoreTextProp) {
+ // "Title"
+ QColor aTitleColor (255, 255, 255);
+ int aTitleFontFamily = VTK_ARIAL;
+ bool isTitleBold = false;
+ bool isTitleItalic = false;
+ bool isTitleShadow = false;
+
+ myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
+ isTitleBold, isTitleItalic, isTitleShadow);
+
+ QFont aTitleFont;
+
+ aTitleFont.setBold(isTitleBold);
+ aTitleFont.setItalic(isTitleItalic);
+ aTitleFont.setUnderline(isTitleShadow);
+
+ QString titleFontFamily;
+ switch (aTitleFontFamily) {
+ case VTK_ARIAL:
+ titleFontFamily = "Arial";
+ break;
+ case VTK_COURIER:
+ titleFontFamily = "Courier";
+ break;
+ case VTK_TIMES:
+ titleFontFamily = "Times";
+ break;
+ }
+ aTitleFont.setFamily(titleFontFamily);
+
+ aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
+
+ aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
+
+ // "Label"
+ QColor aLabelColor (255, 255, 255);
+ int aLabelFontFamily = VTK_ARIAL;
+ bool isLabelBold = false;
+ bool isLabelItalic = false;
+ bool isLabelShadow = false;
+
+ myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
+ isLabelBold, isLabelItalic, isLabelShadow);
+
+
+ QFont aLabelFont;
+
+ aLabelFont.setBold(isLabelBold);
+ aLabelFont.setItalic(isLabelItalic);
+ aLabelFont.setUnderline(isLabelShadow);
+
+ QString labelFontFamily;
+ switch (aLabelFontFamily) {
+ case VTK_ARIAL:
+ labelFontFamily = "Arial";
+ break;
+ case VTK_COURIER:
+ labelFontFamily = "Courier";
+ break;
+ case VTK_TIMES:
+ labelFontFamily = "Times";
+ break;
+ }
+
+ aLabelFont.setFamily(labelFontFamily);
+
+ aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
+
+ aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
+ }
+}
+
+/**
+ * Initialise dialog box from presentation object
+ */
+void VisuGUI_GaussScalarBarPane::initFromPrsObject(VISU::GaussPoints_i* thePrs) {
+ initFromResources();
+ myModeCombo->setCurrentItem(thePrs->GetScalarMode());
+ setPosAndSize( thePrs->GetPosX(),
+ thePrs->GetPosY(),
+ thePrs->GetWidth(),
+ thePrs->GetHeight(),
+ thePrs->GetBarOrientation());
+
+ bool bicolor = thePrs->GetGaussPointsPL()->GetBicolor();
+ BicolorButton->setChecked( bicolor );
+ RainbowButton->setChecked( !bicolor );
+ ColorLabel->setEnabled( !bicolor );
+ ColorSpin->setEnabled( !bicolor );
+ LabelLabel->setEnabled( !bicolor );
+ LabelSpin->setEnabled( !bicolor );
+
+
+ float aRange[2];
+ thePrs->GetGaussPointsPL()->GetSourceRange(aRange);
+ Rmin = aRange[0]; Rmax = aRange[1];
+ setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
+ bool isScalarMode = (thePrs->GetField()->myNbComp > 1);
+ myModeLbl->setEnabled(isScalarMode);
+ myModeCombo->setEnabled(isScalarMode);
+
+ // "Title"
+ myTextDlg->setTitleText(QString(thePrs->GetTitle()));
+
+ float R, G, B;
+ thePrs->GetTitleColor(&R, &G, &B);
+
+ myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
+ thePrs->GetTitFontType(),
+ thePrs->IsBoldTitle(),
+ thePrs->IsItalicTitle(),
+ thePrs->IsShadowTitle());
+
+ // "Labels"
+ thePrs->GetLabelColor(&R, &G, &B);
+
+ myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
+ thePrs->GetLblFontType(),
+ thePrs->IsBoldLabel(),
+ thePrs->IsItalicLabel(),
+ thePrs->IsShadowLabel());
+}
+
+/**
+ * Store values to presentation object
+ */
+int VisuGUI_GaussScalarBarPane::storeToPrsObject(VISU::GaussPoints_i* thePrs) {
+ thePrs->SetScalarMode(myModeCombo->currentItem());
+ thePrs->SetPosition(XSpin->value(), YSpin->value());
+ thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
+ thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
+
+ thePrs->SetSourceRange();
+ thePrs->SetNbColors(ColorSpin->value());
+ thePrs->SetLabels(LabelSpin->value());
+
+ thePrs->GetGaussPointsPL()->SetBicolor(BicolorButton->isChecked());
+
+ if (isToSave()) storeToResources();
+
+ if (myIsStoreTextProp) {
+ // "Title"
+ thePrs->SetTitle(myTextDlg->getTitleText().latin1());
+
+ QColor aTitColor (255, 255, 255);
+ int aTitleFontFamily = VTK_ARIAL;
+ bool isTitleBold = false;
+ bool isTitleItalic = false;
+ bool isTitleShadow = false;
+
+ myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
+ isTitleBold, isTitleItalic, isTitleShadow);
+
+ thePrs->SetBoldTitle(isTitleBold);
+ thePrs->SetItalicTitle(isTitleItalic);
+ thePrs->SetShadowTitle(isTitleShadow);
+ thePrs->SetTitFontType(aTitleFontFamily);
+ thePrs->SetTitleColor(aTitColor.red()/255.,
+ aTitColor.green()/255.,
+ aTitColor.blue()/255.);
+
+ // "Label"
+ QColor aLblColor (255, 255, 255);
+ int aLabelFontFamily = VTK_ARIAL;
+ bool isLabelBold = false;
+ bool isLabelItalic = false;
+ bool isLabelShadow = false;
+
+ myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
+ isLabelBold, isLabelItalic, isLabelShadow);
+
+ thePrs->SetBoldLabel(isLabelBold);
+ thePrs->SetItalicLabel(isLabelItalic);
+ thePrs->SetShadowLabel(isLabelShadow);
+ thePrs->SetLblFontType(aLabelFontFamily);
+ thePrs->SetLabelColor(aLblColor.red()/255.,
+ aLblColor.green()/255.,
+ aLblColor.blue()/255.);
+ }
+
+ return 1;
+}
+
+/*!
+ Called when orientation is changed
+*/
+void VisuGUI_GaussScalarBarPane::changeDefaults( int )
+{
+ if ( RBvert->isChecked() ) {
+ XSpin->setValue( myVerX );
+ YSpin->setValue( myVerY );
+ WidthSpin->setValue( myVerW );
+ HeightSpin->setValue( myVerH );
+ }
+ else {
+ XSpin->setValue( myHorX );
+ YSpin->setValue( myHorY );
+ WidthSpin->setValue( myHorW );
+ HeightSpin->setValue( myHorH );
+ }
+}
+
+/*!
+ Called when X,Y position is changed
+*/
+void VisuGUI_GaussScalarBarPane::XYChanged( double )
+{
+ QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
+ if ( snd == XSpin ) {
+ WidthSpin->setMaxValue( 1.0 - XSpin->value() );
+ }
+ if ( snd == YSpin ) {
+ HeightSpin->setMaxValue( 1.0 - YSpin->value() );
+ }
+}
+
+/*!
+ Sets size and position
+*/
+void VisuGUI_GaussScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
+{
+ if ( vert ) {
+ myVerX = x;
+ myVerY = y;
+ myVerW = w;
+ myVerH = h;
+ RBvert->setChecked( true );
+ }
+ else {
+ myHorX = x;
+ myHorY = y;
+ myHorW = w;
+ myHorH = h;
+ RBhori->setChecked( true );
+ }
+ changeDefaults( 0 );
+}
+
+/*!
+ Sets colors and labels number
+*/
+void VisuGUI_GaussScalarBarPane::setScalarBarData( int colors, int labels )
+{
+ ColorSpin->setValue( colors );
+ LabelSpin->setValue( labels );
+}
+
+/*!
+ Gets orientation
+*/
+int VisuGUI_GaussScalarBarPane::getOrientation()
+{
+ if (RBvert->isChecked() )
+ return 1;
+ else
+ return 0;
+}
+
+
+void VisuGUI_GaussScalarBarPane::onTextPref()
+{
+ myIsStoreTextProp = myTextDlg->exec();
+}
+
+
/*!
* Constructor
*/
QButtonGroup* aPrimitiveTypeGroup = new QButtonGroup( 3, Qt::Horizontal, TopGroup, "PrimitiveTypeGroup" );
aPrimitiveTypeGroup->setRadioButtonExclusive( true );
aPrimitiveTypeGroup->setFrameStyle( QFrame::NoFrame );
+ aPrimitiveTypeGroup->layout()->setMargin( 0 );
QRadioButton* aPointSpriteButton = new QRadioButton( tr( "POINT_SPRITE" ), aPrimitiveTypeGroup );
aPointSpriteButton->setChecked( true );
QRadioButton* anOpenGLPointButton = new QRadioButton( tr( "OPENGL_POINT" ), aPrimitiveTypeGroup );
+ anOpenGLPointButton->setEnabled( false );
+
QRadioButton* aGeometricalSphereButton = new QRadioButton( tr( "GEOMETRICAL_SPHERE" ), aPrimitiveTypeGroup );
+ aGeometricalSphereButton->setEnabled( false );
TopGroupLayout->addMultiCellWidget( aPrimitiveTypeGroup, 0, 0, 0, 2 );
- // Maximum Size
- QLabel* aMaximumSizeLabel = new QLabel( tr( "MAXIMUM_SIZE" ), TopGroup );
- QtxDblSpinBox* aMaximumSizeSpinBox = new QtxDblSpinBox( 1.0, 512.0, 1.0, TopGroup );
- aMaximumSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- aMaximumSizeSpinBox->setValue( 256.0 );
+ // Clamp
+ QLabel* aClampLabel = new QLabel( tr( "MAXIMUM_SIZE" ), TopGroup );
+ myClampSpinBox = new QtxDblSpinBox( 1.0, 512.0, 1.0, TopGroup );
+ myClampSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myClampSpinBox->setValue( 256.0 );
- TopGroupLayout->addWidget( aMaximumSizeLabel, 1, 0 );
- TopGroupLayout->addMultiCellWidget( aMaximumSizeSpinBox, 1, 1, 1, 2 );
+ TopGroupLayout->addWidget( aClampLabel, 1, 0 );
+ TopGroupLayout->addMultiCellWidget( myClampSpinBox, 1, 1, 1, 2 );
// Main Texture
QLabel* aMainTextureLabel = new QLabel( tr( "MAIN_TEXTURE" ), TopGroup );
// Min Size
QLabel* aMinSizeLabel = new QLabel( tr( "MIN_SIZE" ), BottomGroup );
- QtxDblSpinBox* aMinSizeSpinBox = new QtxDblSpinBox( 0, 100, 1, BottomGroup );
- aMinSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- aMinSizeSpinBox->setValue( 10 );
+ myMinSizeSpinBox = new QtxDblSpinBox( 0, 100, 1, BottomGroup );
+ myMinSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myMinSizeSpinBox->setValue( 10 );
BottomGroupLayout->addWidget( aMinSizeLabel, 0, 0 );
- BottomGroupLayout->addWidget( aMinSizeSpinBox, 0, 1 );
+ BottomGroupLayout->addWidget( myMinSizeSpinBox, 0, 1 );
// Max Size
QLabel* aMaxSizeLabel = new QLabel( tr( "MAX_SIZE" ), BottomGroup );
- QtxDblSpinBox* aMaxSizeSpinBox = new QtxDblSpinBox( 0, 100, 1, BottomGroup );
- aMaxSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- aMaxSizeSpinBox->setValue( 33 );
+ myMaxSizeSpinBox = new QtxDblSpinBox( 0, 100, 1, BottomGroup );
+ myMaxSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myMaxSizeSpinBox->setValue( 33 );
BottomGroupLayout->addWidget( aMaxSizeLabel, 0, 2 );
- BottomGroupLayout->addWidget( aMaxSizeSpinBox, 0, 3 );
+ BottomGroupLayout->addWidget( myMaxSizeSpinBox, 0, 3 );
// Magnification
QLabel* aMagnificationLabel = new QLabel( tr( "MAGNIFICATION" ), BottomGroup );
BottomGroupLayout->addWidget( aIncrementSpinBox, 1, 3 );
- myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
+ myScalarPane = new VisuGUI_GaussScalarBarPane(this, SetPref);
myScalarPane->setMargin(5);
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
}
-void VisuGUI_GaussPointsDlg::initFromPrsObject (VISU::GaussPoints_i* thePrs)
+void VisuGUI_GaussPointsDlg::initFromPrsObject( VISU::GaussPoints_i* thePrs )
{
myScalarPane->initFromPrsObject(thePrs);
}
-int VisuGUI_GaussPointsDlg::storeToPrsObject(VISU::GaussPoints_i* thePrs)
+int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::GaussPoints_i* thePrs )
{
+ //thePrs->GetGaussPointsPL()->SetRelativeMinSize( myMinSizeSpinBox->value() / 100.0 );
+ //thePrs->GetGaussPointsPL()->SetRelativeMaxSize( myMaxSizeSpinBox->value() / 100.0 );
+
return myScalarPane->storeToPrsObject(thePrs);
}
-void VisuGUI_GaussPointsDlg::accept() {
- if (myScalarPane->check()) QDialog::accept();
+void VisuGUI_GaussPointsDlg::accept()
+{
+ //if( myScalarPane->check() )
+ QDialog::accept();
}
void VisuGUI_GaussPointsDlg::onBrowseMainTexture()
#include "VisuGUI_ScalarBarDlg.h"
-
+#include <qvbox.h>
#include <qdialog.h>
#include <qgroupbox.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qlineedit.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+#include <qspinbox.h>
+#include <qcombobox.h>
+#include <qtoolbutton.h>
class SalomeApp_Module;
+class VisuGUI_TextPrefDlg;
namespace VISU
{
class GaussPoints_i;
}
+class VisuGUI_GaussScalarBarPane : public QVBox
+{
+ Q_OBJECT
+
+ public:
+ VisuGUI_GaussScalarBarPane(QWidget* parent, bool SetPref);
+ ~VisuGUI_GaussScalarBarPane() {};
+
+ int getOrientation();
+ void setPosAndSize( double x, double y, double w, double h, bool vert );
+ double getX() {return XSpin->value();}
+ double getY() {return YSpin->value();}
+ double getWidth() {return WidthSpin->value();}
+ double getHeight() {return HeightSpin->value();}
+ void setScalarBarData( int colors, int labels );
+ int getNbColors() {return ColorSpin->value();}
+ int getNbLabels() {return LabelSpin->value();}
+ bool isToSave() {return CBSave ? CBSave->isChecked() : false;}
+
+ void initFromResources();
+ void storeToResources();
+
+ void initFromPrsObject(VISU::GaussPoints_i* thePrs);
+ int storeToPrsObject(VISU::GaussPoints_i* thePrs);
+
+ protected:
+ QButtonGroup* RangeGroup;
+
+ QRadioButton* RBhori;
+ QRadioButton* RBvert;
+
+ QtxDblSpinBox* XSpin;
+ QtxDblSpinBox* YSpin;
+
+ QtxDblSpinBox* WidthSpin;
+ QtxDblSpinBox* HeightSpin;
+ QtxDblSpinBox* SpacingSpin;
+
+ QRadioButton* BicolorButton;
+ QRadioButton* RainbowButton;
+ QLabel* ColorLabel;
+ QSpinBox* ColorSpin;
+ QLabel* LabelLabel;
+ QSpinBox* LabelSpin;
+
+ QCheckBox* CBSave;
+ QLabel* myModeLbl;
+ QComboBox* myModeCombo;
+ QPushButton* myTextBtn;
+ VisuGUI_TextPrefDlg* myTextDlg;
+
+ double Imin, Imax, /* Fmin, Fmax,*/ Rmin, Rmax;
+ double myHorX, myHorY, myHorW, myHorH;
+ double myVerX, myVerY, myVerW, myVerH;
+ int myRangeMode;
+ bool myIsStoreTextProp;
+
+ private slots:
+ void changeDefaults( int );
+ void changeRange( int );
+ void XYChanged( double );
+ void onTextPref();
+};
+
class VisuGUI_GaussPointsDlg : public QDialog
{
Q_OBJECT
void onBrowseAlphaChannelTexture();
private:
- VisuGUI_ScalarBarPane* myScalarPane;
+ VisuGUI_GaussScalarBarPane* myScalarPane;
+
+ QtxDblSpinBox* myClampSpinBox;
+
+ QLineEdit* myMainTextureLineEdit;
+ QLineEdit* myAlphaChannelTextureLineEdit;
+
+ QtxDblSpinBox* myMinSizeSpinBox;
+ QtxDblSpinBox* myMaxSizeSpinBox;
- QLineEdit* myMainTextureLineEdit;
- QLineEdit* myAlphaChannelTextureLineEdit;
};
#endif // VISUGUI_GAUSSPOINTSDLS_H
//----------------------------------------------------------------------------
-void
-VISU::GaussPoints_i
-::RemoveAllClippingPlanes(VISU_Actor* theActor)
-{
- if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor))
- if(VISU_GaussPointsPL* aPipeLine = anActor->GetGaussPointsPL())
- aPipeLine->RemoveAllClippingPlanes();
-}
-
-bool
+void
VISU::GaussPoints_i
-::AddClippingPlane(VISU_Actor* theActor,
- vtkPlane* thePlane)
+::SetImplicitFunction(VISU_Actor* theActor,
+ vtkImplicitFunction* theImplicitFunction)
{
- if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor))
- if(VISU_GaussPointsPL* aPipeLine = anActor->GetGaussPointsPL())
- aPipeLine->AddClippingPlane(thePlane);
+ //VISU::ScalarMap_i::SetImplicitFunction(theActor,theImplicitFunction);
+ if(VISU_PipeLine* aPipeLine = theActor->GetPipeLine())
+ aPipeLine->SetImplicitFunction(theImplicitFunction);
}
-
typedef VISU::GaussPoints TInterface;
+ VISU_GaussPointsPL* GetGaussPointsPL(){ return myGaussPointsPL; }
+
protected:
virtual void DoSetInput(Result_i* theResult);
virtual void DoHook();
UpdateActor(VISU_Actor* theActor);
virtual
- void
- RemoveAllClippingPlanes(VISU_Actor* theActor);
-
- virtual
- bool
- AddClippingPlane(VISU_Actor* theActor,
- vtkPlane* thePlane);
+ void
+ SetImplicitFunction(VISU_Actor* theActor,
+ vtkImplicitFunction* theImplicitFunction);
};
}
static int MYDEBUG = 0;
#endif
+
+//----------------------------------------------------------------------------
VISU::Prs3d_i
::Prs3d_i(Result_i* theResult,
SALOMEDS::SObject_ptr theSObject) :
myResult->Destroy();
}
-void
-VISU::Prs3d_i
-::CreateActor(VISU_Actor* theActor, const Handle(SALOME_InteractiveObject)& theIO)
-{
- try{
- Update();
- Handle(SALOME_InteractiveObject) anIO = theIO;
- if(anIO.IsNull() && (!mySObject->_is_nil())){
- anIO = new SALOME_InteractiveObject(mySObject->GetID(),"VISU",GetName());
- theActor->setIO(anIO);
- }
- theActor->SetPipeLine(GetPipeLine());
- theActor->SetFactory(this);
- theActor->SetPrs3d(this);
- theActor->SetPosition(myOffset);
- }catch(std::bad_alloc& ex){
- throw std::runtime_error("CreateActor >> No enough memory");
- throw ex;
- } catch(std::exception& ex){
- throw ex;
- }catch(...) {
- throw std::runtime_error("CreateActor >> unexpected exception was caught!!!");
- }
-}
-
-void
-VISU::Prs3d_i
-::UpdateActor(VISU_Actor* theActor)
-{
- if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor() - this = "<<this);
- theActor->GetMapper()->ShallowCopy(myPipeLine->GetMapper());
- theActor->SetPosition(myOffset);
- theActor->Modified();
-}
+//----------------------------------------------------------------------------
VISU::Storable*
VISU::Prs3d_i
::Restore(const Storable::TRestoringMap& theMap)
Storable::DataToStream( theStr, "myOffset[2]", myOffset[2] );
}
+
+//----------------------------------------------------------------------------
+SALOMEDS::SObject_var
+VISU::Prs3d_i
+::GetSObject()
+{
+ if(CORBA::is_nil(mySObject.in())){
+ const SALOMEDS::Study_var& aStudy = myResult->GetStudyDocument();
+ CORBA::String_var anIOR = GetID();
+ mySObject = aStudy->FindObjectIOR(anIOR);
+ }
+ return mySObject;
+}
+
+Result_i*
+VISU::Prs3d_i
+::GetResult() const
+{
+ return myResult;
+}
+
+const std::string&
+VISU::Prs3d_i
+::GetMeshName() const
+{
+ return myMeshName;
+}
+
+
+//----------------------------------------------------------------------------
void
VISU::Prs3d_i
::Update()
}
-SALOMEDS::SObject_var
-VISU::Prs3d_i::GetSObject()
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::CreateActor(VISU_Actor* theActor, const Handle(SALOME_InteractiveObject)& theIO)
{
- if (CORBA::is_nil(mySObject.in())) {
- const SALOMEDS::Study_var& aStudy = myResult->GetStudyDocument();
- CORBA::String_var anIOR = GetID();
- mySObject = aStudy->FindObjectIOR(anIOR);
+ try{
+ Update();
+ Handle(SALOME_InteractiveObject) anIO = theIO;
+ if(anIO.IsNull() && (!mySObject->_is_nil())){
+ anIO = new SALOME_InteractiveObject(mySObject->GetID(),"VISU",GetName());
+ theActor->setIO(anIO);
+ }
+ theActor->SetPipeLine(GetPipeLine());
+ theActor->SetFactory(this);
+ theActor->SetPrs3d(this);
+ theActor->SetPosition(myOffset);
+ }catch(std::bad_alloc& ex){
+ throw std::runtime_error("CreateActor >> No enough memory");
+ throw ex;
+ } catch(std::exception& ex){
+ throw ex;
+ }catch(...) {
+ throw std::runtime_error("CreateActor >> unexpected exception was caught!!!");
}
- return mySObject;
}
void
VISU::Prs3d_i
-::GetBounds(float aBounds[6])
+::UpdateActor(VISU_Actor* theActor)
{
- myPipeLine->GetMapper()->GetBounds(aBounds);
+ if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor() - this = "<<this);
+ theActor->GetMapper()->ShallowCopy(myPipeLine->GetMapper());
+ theActor->SetPosition(myOffset);
+ theActor->Modified();
}
-// Clipping planes
-void
+//----------------------------------------------------------------------------
+void
VISU::Prs3d_i
-::RemoveAllClippingPlanes()
+::SetImplicitFunction(VISU_Actor* theActor,
+ vtkImplicitFunction* theImplicitFunction)
{
- myPipeLine->RemoveAllClippingPlanes();
+ myPipeLine->SetImplicitFunction(theImplicitFunction);
}
+// Clipping planes
void
VISU::Prs3d_i
-::RemoveAllClippingPlanes(VISU_Actor* theActor)
+::RemoveAllClippingPlanes()
{
- RemoveAllClippingPlanes();
+ myPipeLine->RemoveAllClippingPlanes();
}
bool
return myPipeLine->AddClippingPlane(thePlane);
}
-bool
-VISU::Prs3d_i
-::AddClippingPlane(VISU_Actor* theActor,
- vtkPlane* thePlane)
-{
- AddClippingPlane(thePlane);
-}
-
vtkIdType
VISU::Prs3d_i
::GetNumberOfClippingPlanes() const
myPipeLine->SetPlaneParam(theDir, theDist, thePlane);
}
-VISU::Result_i*
-VISU::GetResult(SALOMEDS::SObject_ptr theSObject)
+
+//----------------------------------------------------------------------------
+void
+VISU::Prs3d_i
+::GetBounds(float aBounds[6])
{
- VISU::Result_var aResult = FindResult(theSObject);
- if(!aResult->_is_nil())
- return dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
- return NULL;
+ myPipeLine->GetMapper()->GetBounds(aBounds);
}
void
theDy = myOffset[1];
theDz = myOffset[2];
}
+
+
+//----------------------------------------------------------------------------
+VISU::Result_i*
+VISU::GetResult(SALOMEDS::SObject_ptr theSObject)
+{
+ VISU::Result_var aResult = FindResult(theSObject);
+ if(!aResult->_is_nil())
+ return dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
+ return NULL;
+}
+
class vtkPlane;
class vtkUnstructuredGrid;
-namespace VISU{
+namespace VISU
+{
class Result_i;
+ //----------------------------------------------------------------------------
class Prs3d_i :
public virtual POA_VISU::Prs3d,
public virtual SALOME::GenericObj_i,
Prs3d_i(const Prs3d_i&);
public:
+ //----------------------------------------------------------------------------
explicit
Prs3d_i(Result_i* theResult,
bool theAddToStudy);
virtual
~Prs3d_i();
+ //----------------------------------------------------------------------------
+ virtual
+ const char*
+ GetComment() const = 0;
+
+ virtual
+ QString
+ GenerateName() = 0;
+
+ virtual
+ Storable*
+ Restore(const Storable::TRestoringMap& theMap);
+
+ virtual
+ void
+ ToStream(std::ostringstream& theStr);
+
+ //----------------------------------------------------------------------------
protected:
bool myAddToStudy;
float myOffset[3];
GetPipeLine();
public:
+ //----------------------------------------------------------------------------
+ Result_i*
+ GetResult() const;
+
+ virtual
+ SALOMEDS::SObject_var
+ GetSObject();
+
+ const std::string&
+ GetMeshName() const;
+
+ //----------------------------------------------------------------------------
virtual
void
Update();
vtkUnstructuredGrid*
GetInput();
- void
- GetBounds(float aBounds[6]);
-
- void
- SetOffset(const float* theOffsets);
-
- virtual
- void
- SetOffset(float theDx, float theDy, float theDz);
-
- void
- GetOffset(float* theOffsets);
-
- virtual
- void
- GetOffset(float& theDx, float& theDy, float& theDz);
-
- virtual
- const char*
- GetComment() const = 0;
-
- virtual
- QString
- GenerateName() = 0;
-
- virtual
- Storable*
- Restore(const Storable::TRestoringMap& theMap);
-
- virtual
- void
- ToStream(std::ostringstream& theStr);
-
+ //----------------------------------------------------------------------------
virtual
VISU_Actor*
CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL) = 0;
void
UpdateActor(VISU_Actor* theActor);
- Result_i*
- GetResult() const
- {
- return myResult;
- }
-
- virtual
- SALOMEDS::SObject_var
- GetSObject();
-
- const std::string&
- GetMeshName() const
- {
- return myMeshName;
- }
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ SetImplicitFunction(VISU_Actor* theActor,
+ vtkImplicitFunction* theImplicitFunction);
// Clipping planes
void
RemoveAllClippingPlanes();
- virtual
- void
- RemoveAllClippingPlanes(VISU_Actor* theActor);
-
bool
AddClippingPlane(vtkPlane* thePlane);
- virtual
- bool
- AddClippingPlane(VISU_Actor* theActor,
- vtkPlane* thePlane);
-
vtkIdType
GetNumberOfClippingPlanes() const;
void
SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane);
+
+ //----------------------------------------------------------------------------
+ void
+ GetBounds(float aBounds[6]);
+
+ void
+ SetOffset(const float* theOffsets);
+
+ virtual
+ void
+ SetOffset(float theDx, float theDy, float theDz);
+
+ void
+ GetOffset(float* theOffsets);
+
+ virtual
+ void
+ GetOffset(float& theDx, float& theDy, float& theDz);
};
+ //----------------------------------------------------------------------------
Result_i*
GetResult(SALOMEDS::SObject_ptr theSObject);
@COMMENCE@
# header files
-EXPORT_HEADERS= VVTK.h \
- VVTK_ViewManager.h \
- VVTK_ViewModel.h \
- VVTK_InteractorStyle.h \
- VVTK_ViewWindow.h \
- VVTK_View.h \
- VVTK_ImplicitFunctionWidget.h
+EXPORT_HEADERS = \
+ VVTK.h \
+ VVTK_ViewManager.h \
+ VVTK_ViewModel.h \
+ VVTK_InteractorStyle.h \
+ VVTK_ViewWindow.h \
+ VVTK_View.h
# Libraries targets
LIB = libVVTK.la
-LIB_SRC= VVTK_ViewManager.cxx \
- VVTK_ViewModel.cxx \
- VVTK_InteractorStyle.cxx \
- VVTK_ViewWindow.cxx \
- VVTK_Renderer.cxx \
- VVTK_View.cxx \
- VVTK_ImplicitFunctionWidget.cxx
-
-LIB_MOC = VVTK_ViewWindow.h \
- VVTK_ViewModel.h \
- VVTK_ViewManager.h \
- VVTK_View.h
-
-CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) \
- -I$(KERNEL_ROOT_DIR)/include/salome \
- -I$(GUI_ROOT_DIR)/include/salome
-
-LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) \
- -L$(KERNEL_ROOT_DIR)/lib/salome \
- -L$(GUI_ROOT_DIR)/lib/salome
+LIB_SRC = \
+ VVTK_ViewManager.cxx \
+ VVTK_ViewModel.cxx \
+ VVTK_InteractorStyle.cxx \
+ VVTK_ViewWindow.cxx \
+ VVTK_Renderer.cxx \
+ VVTK_View.cxx
+
+LIB_MOC = \
+ VVTK_ViewWindow.h \
+ VVTK_ViewModel.h \
+ VVTK_ViewManager.h \
+ VVTK_View.h
+
+CPPFLAGS += \
+ $(QT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) \
+ -I$(KERNEL_ROOT_DIR)/include/salome \
+ -I$(GUI_ROOT_DIR)/include/salome
+
+LDFLAGS += \
+ $(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) \
+ -L$(KERNEL_ROOT_DIR)/lib/salome \
+ -L$(GUI_ROOT_DIR)/lib/salome
LIBS+= -lsuit -lCAM -lSalomeObject -lSVTK -lOpUtil
#include "VVTK_Renderer.h"
#include "VISU_GaussPtsAct.h"
+#include "VISU_ImplicitFunctionWidget.h"
#include <vtkObjectFactory.h>
-#include <vtkImplicitPlaneWidget.h>
#include <vtkProperty.h>
#include <vtkRenderWindowInteractor.h>
//----------------------------------------------------------------------------
VVTK_Renderer1
::VVTK_Renderer1():
- myImplicitPlaneWidget(vtkImplicitPlaneWidget::New())
+ myImplicitFunctionWidget(VISU_ImplicitFunctionWidget::New())
{
if(MYDEBUG) INFOS("VVTK_Renderer1() - "<<this);
- myImplicitPlaneWidget->SetPlaceFactor(1.0);
- myImplicitPlaneWidget->SetOutlineTranslation(false);
- vtkProperty* aSelectedPlaneProperty = myImplicitPlaneWidget->GetSelectedPlaneProperty();
- vtkProperty* aPlaneProperty = myImplicitPlaneWidget->GetPlaneProperty();
- aPlaneProperty->SetOpacity(aSelectedPlaneProperty->GetOpacity()*1.5);
+ myImplicitFunctionWidget->SetPlaceFactor(1.0);
+ myImplicitFunctionWidget->SetOutlineTranslation(false);
+ //vtkProperty* aSelectedPlaneProperty = myImplicitFunctionWidget->GetSelectedPlaneProperty();
+ //vtkProperty* aPlaneProperty = myImplicitFunctionWidget->GetPlaneProperty();
+ //aPlaneProperty->SetOpacity(aSelectedPlaneProperty->GetOpacity()*1.5);
- myImplicitPlaneWidget->Delete();
+ myImplicitFunctionWidget->Delete();
}
VVTK_Renderer1
::~VVTK_Renderer1()
{
if(MYDEBUG) INFOS("~VVTK_Renderer1() - "<<this);
- myImplicitPlaneWidget->SetInteractor(NULL);
+ myImplicitFunctionWidget->SetInteractor(NULL);
}
//----------------------------------------------------------------------------
::SetInteractor(vtkRenderWindowInteractor* theInteractor)
{
SVTK_Renderer::SetInteractor(theInteractor);
- myImplicitPlaneWidget->SetInteractor(theInteractor);
+ myImplicitFunctionWidget->SetInteractor(theInteractor);
}
//----------------------------------------------------------------------------
-vtkImplicitPlaneWidget*
+VISU_ImplicitFunctionWidget*
VVTK_Renderer1
-::GetImplicitPlaneWidget()
+::GetImplicitFunctionWidget()
{
- return myImplicitPlaneWidget.GetPointer();
+ return myImplicitFunctionWidget.GetPointer();
}
//----------------------------------------------------------------------------
::OnAdjustActors()
{
if(SVTK_Renderer::OnAdjustActors()){
- myImplicitPlaneWidget->PlaceWidget(myBndBox);
- myImplicitPlaneWidget->SetOrigin((myBndBox[1] + myBndBox[0]) / 2.0,
- (myBndBox[3] + myBndBox[2]) / 2.0,
- (myBndBox[5] + myBndBox[4]) / 2.0);
- myImplicitPlaneWidget->SetHandleSize(myImplicitPlaneWidget->GetHandleSize());
+ myImplicitFunctionWidget->PlaceWidget(myBndBox);
+ myImplicitFunctionWidget->SetOrigin((myBndBox[1] + myBndBox[0]) / 2.0,
+ (myBndBox[3] + myBndBox[2]) / 2.0,
+ (myBndBox[5] + myBndBox[4]) / 2.0);
+ myImplicitFunctionWidget->SetHandleSize(myImplicitFunctionWidget->GetHandleSize());
return true;
}
return false;
//----------------------------------------------------------------------------
VVTK_Renderer2
::VVTK_Renderer2():
- myEventCallbackCommand(vtkCallbackCommand::New()),
- myFunction(vtkPlane::New())
+ myEventCallbackCommand(vtkCallbackCommand::New())
{
if(MYDEBUG) INFOS("VVTK_Renderer2() - "<<this);
myEventCallbackCommand->Delete();
- myFunction->Delete();
myPriority = 0.0;
myEventCallbackCommand->SetClientData(this);
::SetRenderer1(VVTK_Renderer1* theRenderer)
{
myRenderer1 = theRenderer;
- myImplicitPlaneWidget1 = myRenderer1->GetImplicitPlaneWidget();
- myImplicitPlaneWidget1->AddObserver(vtkCommand::EndInteractionEvent,
- myEventCallbackCommand.GetPointer(),
- myPriority);
-
+ myImplicitFunctionWidget1 = myRenderer1->GetImplicitFunctionWidget();
+ myImplicitFunctionWidget1->AddObserver(vtkCommand::EndInteractionEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+ myImplicitFunction = myImplicitFunctionWidget1->ImplicitFunction();
}
void
VVTK_Renderer2
::OnEndInteractionEvent()
{
- myImplicitPlaneWidget1->GetPlane(myFunction.GetPointer());
myInteractor->Render();
}
{
SVTK_Renderer::AddActor(theActor);
if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(theActor))
- if(VISU::TActorFactory* aFactory = anActor->GetFactory())
- aFactory->AddClippingPlane(anActor,myFunction.GetPointer());
+ if(VISU::TActorFactory* aFactory = anActor->GetFactory()){
+ aFactory->SetImplicitFunction(anActor,myImplicitFunction.GetPointer());
+ }
}
//----------------------------------------------------------------------------
VVTK_Renderer2
::RemoveActor(VTKViewer_Actor* theActor)
{
- SVTK_Renderer::RemoveActor(theActor);
if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(theActor))
if(VISU::TActorFactory* aFactory = anActor->GetFactory())
- aFactory->RemoveAllClippingPlanes(anActor);
+ aFactory->SetImplicitFunction(anActor,NULL);
+ SVTK_Renderer::RemoveActor(theActor);
}
#include "SVTK_Renderer.h"
-class vtkImplicitPlaneWidget;
-class vtkPlane;
+class VISU_ImplicitFunctionWidget;
+class vtkImplicitFunction;
//----------------------------------------------------------------------------
class VVTK_EXPORT VVTK_Renderer1 : public SVTK_Renderer
void
SetInteractor(vtkRenderWindowInteractor* theInteractor);
- vtkImplicitPlaneWidget*
- GetImplicitPlaneWidget();
+ VISU_ImplicitFunctionWidget*
+ GetImplicitFunctionWidget();
protected:
VVTK_Renderer1();
bool
OnAdjustActors();
- vtkSmartPointer<vtkImplicitPlaneWidget> myImplicitPlaneWidget;
+ vtkSmartPointer<VISU_ImplicitFunctionWidget> myImplicitFunctionWidget;
};
// Priority at which events are processed
float myPriority;
- vtkSmartPointer<vtkImplicitPlaneWidget> myImplicitPlaneWidget1;
- vtkSmartPointer<vtkPlane> myFunction;
+ vtkSmartPointer<VISU_ImplicitFunctionWidget> myImplicitFunctionWidget1;
+ vtkSmartPointer<vtkImplicitFunction> myImplicitFunction;
VVTK_Renderer1* myRenderer1;
};
#include "VVTK_View.h"
#include "VVTK_InteractorStyle.h"
+#include "VISU_ImplicitFunctionWidget.h"
#include "SVTK_RenderWindowInteractor.h"
#include "VVTK_Renderer.h"
#include "QtxAction.h"
#include <qtoolbar.h>
-#include <vtkImplicitPlaneWidget.h>
+#include <qsplitter.h>
//----------------------------------------------------------------------------
VVTK_MainWindowBase
//----------------------------------------------------------------------------
VVTK_MainWindow1
-::VVTK_MainWindow1(QWidget* theParent,
+::VVTK_MainWindow1(QSplitter* theParent,
const char* theName,
SUIT_ResourceMgr* theResourceMgr):
- VVTK_MainWindowBase(theParent,theName,theResourceMgr)
+ VVTK_MainWindowBase(theParent,theName,theResourceMgr),
+ mySplitter(theParent)
{
QPixmap aPixmap;
QtxAction* anAction;
VVTK_MainWindow1
::OnPlaneSegmentationSwitch(bool theIsPlaneSegmentationOn)
{
- myRenderer->GetImplicitPlaneWidget()->SetEnabled(theIsPlaneSegmentationOn);
+ myRenderer->GetImplicitFunctionWidget()->SetEnabled(theIsPlaneSegmentationOn);
+ mySplitter->setCollapsible(this,!theIsPlaneSegmentationOn);
}
class VVTK_Renderer1;
class VVTK_Renderer2;
+class QSplitter;
+
//----------------------------------------------------------------------------
class VVTK_EXPORT VVTK_MainWindowBase: public SVTK_MainWindow
Q_OBJECT;
public:
- VVTK_MainWindow1(QWidget* theParent,
+ VVTK_MainWindow1(QSplitter* theParent,
const char* theName,
SUIT_ResourceMgr* theResourceMgr);
virtual
protected:
VVTK_Renderer1* myRenderer;
+ QSplitter* mySplitter;
};
QBoxLayout* aLayout = new QVBoxLayout(aWidget);
aLayout->setAutoAdd(true);
QSplitter* aSplitter = new QSplitter(Qt::Vertical,aWidget);
+ aSplitter->setChildrenCollapsible(true);
myMainWindow1 = new VVTK_MainWindow1(aSplitter,
"VVTK_MainWindow",