-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is 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.
+// 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
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// VISU OBJECT : interactive object for VISU entities implementation
-// File :
-// Author :
+// File :
+// Author :
// Module : VISU
-
+//
#include "VISU_Actor.h"
+#include "VISU_ActorFactory.h"
#include "VISU_PickingSettings.h"
#include "VISU_GaussPtsDeviceActor.h"
+#include "VISU_SelectVisiblePoints.h"
#include "VISU_PipeLine.hxx"
+#include "VISU_UsedPointsFilter.hxx"
#include "SVTK_Actor.h"
#include "SVTK_Event.h"
+#include "VTKViewer_CellCenters.h"
#include "VTKViewer_FramedTextActor.h"
#include "VTKViewer_ShrinkFilter.h"
#include "VTKViewer_GeometryFilter.h"
-#include "VISU_ActorFactory.h"
+
#include "SALOME_InteractiveObject.hxx"
-
+
+#include "SUIT_Session.h"
+#include "SUIT_ResourceMgr.h"
+
#include <stdexcept>
#include <sstream>
+#include <cmath> // to use std::abs( int )
// VTK Includes
#include <vtkProperty.h>
#include <vtkTextActor.h>
#include <vtkProperty2D.h>
#include <vtkRenderer.h>
+#include <vtkRenderWindow.h>
#include <vtkCellPicker.h>
#include <vtkCell.h>
#include <vtkPointPicker.h>
#include <vtkActor2D.h>
#include <vtkMaskPoints.h>
#include <vtkLabeledDataMapper.h>
-#include <vtkSelectVisiblePoints.h>
#include <vtkTextProperty.h>
#include <vtkProperty2D.h>
myIsShrinkable(false),
myShrinkFilter(VTKViewer_ShrinkFilter::New()),
myAnnotationMapper(vtkTextMapper::New()),
+#if (VTK_XVERSION < 0x050100)
myAnnotationActor(vtkTextActor::New()),
+#else
+ myAnnotationActor(vtkActor2D::New()),
+#endif
myTextActor(VTKViewer_FramedTextActor::New()),
myIsFeatureEdgesAllowed(false),
myIsFeatureEdgesEnabled(false),
myFeatureEdges->Delete();
myEventCallbackCommand->Delete();
- myEventCallbackCommand->SetClientData(this);
+ myEventCallbackCommand->SetClientData(this);
myEventCallbackCommand->SetCallback(VISU_Actor::ProcessEvents);
if( VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get() )
- aPickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent,
- myEventCallbackCommand.GetPointer(),
- myPriority);
-
+ aPickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+
//Definition of values labeling pipeline
myValLblDataSet = vtkUnstructuredGrid::New();
- myValCellCenters = vtkCellCenters::New();
+ myValCellCenters = VTKViewer_CellCenters::New();
myValCellCenters->SetInput(myValLblDataSet);
+ myValUsedPoints = VISU_UsedPointsFilter::New();
+ myValUsedPoints->SetInput(myValLblDataSet);
+
myValMaskPoints = vtkMaskPoints::New();
myValMaskPoints->SetInput(myValCellCenters->GetOutput());
myValMaskPoints->SetOnRatio(1);
-
- myValSelectVisiblePoints = vtkSelectVisiblePoints::New();
+
+ myValSelectVisiblePoints = VISU_SelectVisiblePoints::New();
myValSelectVisiblePoints->SetInput(myValMaskPoints->GetOutput());
myValSelectVisiblePoints->SelectInvisibleOff();
myValSelectVisiblePoints->SetTolerance(0.1);
-
+
+ char aFormat[16] = "%g";
+ SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+ if (aResourceMgr) {
+ // san: precision can be negative - this is used by double spin boxes
+ int aFloatingPrec = std::abs( aResourceMgr->integerValue("VISU", "visual_data_precision", 6) );
+ sprintf(aFormat, "%%.%dg", aFloatingPrec);
+ //cout << "$$$ aFormat = " << aFormat << endl;
+ }
+
myValLabeledDataMapper = vtkLabeledDataMapper::New();
myValLabeledDataMapper->SetInput(myValSelectVisiblePoints->GetOutput());
- myValLabeledDataMapper->SetLabelFormat("%g");
+ //myValLabeledDataMapper->SetLabelFormat("%g");
+ //myValLabeledDataMapper->SetLabelFormat("%.20g");
+ myValLabeledDataMapper->SetLabelFormat(aFormat);
myValLabeledDataMapper->SetLabelModeToLabelScalars();
-
+
vtkTextProperty* aClsTextProp = vtkTextProperty::New();
aClsTextProp->SetFontFamilyToTimes();
static int aCellsFontSize = 12;
aClsTextProp->SetShadow(0);
myValLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
aClsTextProp->Delete();
-
+
myIsValLabeled = false;
myValLabels = vtkActor2D::New();
myValLabels->SetMapper(myValLabeledDataMapper);
myValLabels->GetProperty()->SetColor(0,1,0);
myValLabels->SetVisibility( myIsValLabeled );
+
+ // to allow modification of the reference coordinate in redefined SetPosition() methods
+ vtkCoordinate* aValLabelsCoordinate = vtkCoordinate::New();
+ myValLabels->GetPositionCoordinate()->SetReferenceCoordinate( aValLabelsCoordinate );
+ aValLabelsCoordinate->Delete();
}
//----------------------------------------------------------------------------
myValLabeledDataMapper->Delete();
myValSelectVisiblePoints->Delete();
myValMaskPoints->Delete();
+ myValUsedPoints->Delete();
myValCellCenters->Delete();
myValLabels->Delete();
}
//----------------------------------------------------------------------------
-void
+void
VISU_Actor
::setIO(const Handle(SALOME_InteractiveObject)& theIO)
{
- Superclass::setIO(theIO);
- myName = theIO->getName();
+ Superclass::setIO(theIO);
+ myName = theIO->getName();
}
//----------------------------------------------------------------------------
-void
+void
VISU_Actor
::SetPrs3d(VISU::Prs3d_i* thePrs3d)
-{
+{
myPrs3d = thePrs3d;
}
-VISU::Prs3d_i*
+VISU::Prs3d_i*
VISU_Actor
::GetPrs3d()
-{
+{
return myPrs3d;
}
//----------------------------------------------------------------------------
void
VISU_Actor
-::SetPipeLine(VISU_PipeLine* thePipeLine)
+::SetPipeLine(VISU_PipeLine* thePipeLine)
{
myPipeLine = thePipeLine;
if(thePipeLine){
if(vtkMapper *aMapper = myPipeLine->GetMapper()){
if(vtkDataSet *aDataSet = aMapper->GetInput()){
- SetShrinkable(thePipeLine->IsShrinkable());
- SetFeatureEdgesAllowed(thePipeLine->IsFeatureEdgesAllowed());
- SetMapperInput(aDataSet);
+ SetShrinkable(thePipeLine->IsShrinkable());
+ SetFeatureEdgesAllowed(thePipeLine->IsFeatureEdgesAllowed());
+ SetMapperInput(aDataSet);
}
}
}
this->Modified();
}
-VISU_PipeLine*
+VISU_PipeLine*
VISU_Actor
-::GetPipeLine()
-{
+::GetPipeLine()
+{
return myPipeLine.GetPointer();
}
-VISU_PipeLine*
+VISU_PipeLine*
VISU_Actor
-::GetCurrentPL()
-{
+::GetCurrentPL()
+{
return GetPipeLine();
}
//----------------------------------------------------------------------------
void
VISU_Actor
-::SetRepresentation(int theMode)
-{
+::SetRepresentation(int theMode)
+{
Superclass::SetRepresentation(theMode);
if(myRepresentation == VTK_POINTS)
{
UnShrink();
}
- SetFeatureEdgesEnabled( theMode == SVTK::Representation::FeatureEdges );
+ SetFeatureEdgesEnabled( theMode == VTKViewer::Representation::FeatureEdges );
}
VISU_Actor
::SetShrink()
{
- if(!myIsShrinkable)
+ if(!myIsShrinkable)
return;
if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
myShrinkFilter->SetInput(aDataSet);
VISU_Actor
::UnShrink()
{
- if(!myIsShrunk)
+ if(!myIsShrunk)
return;
if(vtkDataSet* aDataSet = myPassFilter[0]->GetOutput()){
myPassFilter[1]->SetInput(aDataSet);
bool
VISU_Actor
-::IsShrunkable()
-{
+::IsShrunkable()
+{
return myIsShrinkable;
}
//----------------------------------------------------------------------------
bool
VISU_Actor
-::IsFeatureEdgesAllowed()
-{
+::IsFeatureEdgesAllowed()
+{
return myIsFeatureEdgesAllowed;
}
VISU_Actor
::SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled)
{
- if ( !myIsFeatureEdgesAllowed || myIsFeatureEdgesEnabled == theIsFeatureEdgesEnabled )
+ if ( !myIsFeatureEdgesAllowed || myIsFeatureEdgesEnabled == theIsFeatureEdgesEnabled )
return;
if ( vtkPolyData* aPolyData = myPassFilter[ 2 ]->GetPolyDataOutput() )
void
VISU_Actor
::GetFeatureEdgesFlags(bool& theIsFeatureEdges,
- bool& theIsBoundaryEdges,
- bool& theIsManifoldEdges,
- bool& theIsNonManifoldEdges)
+ bool& theIsBoundaryEdges,
+ bool& theIsManifoldEdges,
+ bool& theIsNonManifoldEdges)
{
theIsFeatureEdges = myFeatureEdges->GetFeatureEdges();
theIsBoundaryEdges = myFeatureEdges->GetBoundaryEdges();
void
VISU_Actor
::SetFeatureEdgesFlags(bool theIsFeatureEdges,
- bool theIsBoundaryEdges,
- bool theIsManifoldEdges,
- bool theIsNonManifoldEdges)
+ bool theIsBoundaryEdges,
+ bool theIsManifoldEdges,
+ bool theIsNonManifoldEdges)
{
myFeatureEdges->SetFeatureEdges(theIsFeatureEdges);
myFeatureEdges->SetBoundaryEdges(theIsBoundaryEdges);
vtkFloatingPointType
VISU_Actor
::GetOpacity()
-{
+{
return GetProperty()->GetOpacity();
}
theRenderer->RemoveActor(myAnnotationActor.GetPointer());
theRenderer->RemoveActor(myTextActor.GetPointer());
theRenderer->RemoveActor(myValLabels);
- Superclass::RemoveFromRender(theRenderer);
+ Superclass::RemoveFromRender(theRenderer);
myDestroySignal(this);
}
//----------------------------------------------------------------------------
-void
+void
VISU_Actor
::SetVisibility(int theMode)
{
{
return GetFactory()->GetActiveState();
}
+
+//----------------------------------------------------------------------------
+void
+VISU_Actor
+::SetPosition( double thePosition[3] )
+{
+ Superclass::SetPosition( thePosition );
+ if( vtkCoordinate* aCoord = myValLabels->GetPositionCoordinate()->GetReferenceCoordinate() )
+ aCoord->SetValue( thePosition );
+ myValSelectVisiblePoints->SetOffset( thePosition );
+}
+
//----------------------------------------------------------------------------
-void
+void
+VISU_Actor
+::SetPosition( double theX, double theY, double theZ )
+{
+ Superclass::SetPosition( theX, theY, theZ );
+ if( vtkCoordinate* aCoord = myValLabels->GetPositionCoordinate()->GetReferenceCoordinate() )
+ aCoord->SetValue( theX, theY, theZ );
+ myValSelectVisiblePoints->SetOffset( theX, theY, theZ );
+}
+
+//----------------------------------------------------------------------------
+void
VISU_Actor
::SetVTKMapping(bool theIsVTKMapping)
{
myIsVTKMapping = theIsVTKMapping;
}
-bool
+bool
VISU_Actor
::IsVTKMapping() const
{
}
//----------------------------------------------------------------------------
-vtkDataSet*
+vtkDataSet*
VISU_Actor
::GetInput()
{
return VISU::GetElemVTKID(GetMapper()->GetInput(), theID);
}
-vtkCell*
+vtkCell*
VISU_Actor
::GetElemCell(vtkIdType theObjID)
{
//----------------------------------------------------------------------------
bool
VISU_Actor
-::isSubElementsHighlighted()
-{
- return myIsSubElementsHighlighted;
+::isSubElementsHighlighted()
+{
+ return myIsSubElementsHighlighted;
}
inline
void
ChangeZoom(vtkFloatingPointType theZoomFactor,
- vtkRenderer* theRenderer,
- vtkIdType theInitialHasIndex,
- vtkIdType theCurrentHasIndex)
+ vtkRenderer* theRenderer,
+ vtkIdType theInitialHasIndex,
+ vtkIdType theCurrentHasIndex)
{
//printf( "VISU_Actor::ChangeZoom( %d, %d )", theInitialHasIndex, theCurrentHasIndex );
if(theInitialHasIndex + theCurrentHasIndex == 1){
}
/*!
- Updates visibility of the highlight devices
+ Updates visibility of the highlight devices
*/
void
VISU_Actor
{
if( mySelectionMode == ActorSelection )
ResetTextActor();
- else
- aShowTextActor = false;
myLastSelectionMode = mySelectionMode;
}
- myTextActor->SetVisibility( GetVisibility() && theIsHighlight && aShowTextActor );
+ myTextActor->SetVisibility( GetVisibility() && theIsHighlight && aShowTextActor &&
+ ( mySelectionMode == ActorSelection || isSubElementsHighlighted() ) );
bool anInitialHasIndex = isHighlighted();
bool aCurrentHasIndex = theIsHighlight;
{
vtkFloatingPointType aZoomFactor = aPickingSettings->GetZoomFactor();
ChangeZoom(aZoomFactor,
- GetRenderer(),
- anInitialHasIndex,
- aCurrentHasIndex);
+ GetRenderer(),
+ anInitialHasIndex,
+ aCurrentHasIndex);
}
}
*/
bool
VISU_Actor
-::PreHighlight(vtkInteractorStyle* theInteractorStyle,
- SVTK_SelectionEvent* theSelectionEvent,
- bool theIsHighlight)
+::PreHighlight(vtkInteractorStyle* theInteractorStyle,
+ SVTK_SelectionEvent* theSelectionEvent,
+ bool theIsHighlight)
{
bool aRet = Superclass::PreHighlight(theInteractorStyle,
- theSelectionEvent,
- theIsHighlight);
+ theSelectionEvent,
+ theIsHighlight);
#ifndef ENABLE_ANNOTATION
return aRet;
-#endif
+#endif
//
myAnnotationActor->SetVisibility(0);
if(theIsHighlight){
switch(mySelectionMode){
- case CellSelection:{
+ case CellSelection:{
vtkRenderer* aRenderer = theInteractorStyle->GetCurrentRenderer();
- myCellPicker->Pick(theSelectionEvent->myX,
- theSelectionEvent->myY,
- 0.0,
- aRenderer);
+ myCellPicker->Pick(theSelectionEvent->myX,
+ theSelectionEvent->myY,
+ 0.0,
+ aRenderer);
if(myCellPicker->GetActor() != this)
- return false;
+ return false;
vtkIdType aVTKId = myCellPicker->GetCellId();
if(aVTKId >= 0 && mySelector->IsValid(this,aVTKId,true) && hasIO()){
- vtkIdType anObjId = GetElemObjId(aVTKId);
- if(vtkCell* aCell = GetElemCell(anObjId)){
- vtkPoints* aPts = aCell->GetPoints();
- if(int aNbPts = aCell->GetNumberOfPoints()){
- vtkFloatingPointType aCoord[3] = {0.0, 0.0, 0.0};
- for(int i = 0; i < aNbPts; i++){
- vtkFloatingPointType *aPntCoord = aPts->GetPoint(i);
- aCoord[0] += aPntCoord[0];
- aCoord[1] += aPntCoord[1];
- aCoord[2] += aPntCoord[2];
- }
- // Display coordinates
- vtkFloatingPointType aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0};
- aRenderer->SetWorldPoint(aWorldCoord);
- aRenderer->WorldToDisplay();
- vtkFloatingPointType aSelectionPoint[3];
- aRenderer->GetDisplayPoint(aSelectionPoint);
- myAnnotationActor->SetPosition(aSelectionPoint);
- //
- // To prepare the annotation text
- std::ostringstream aStr;
- aStr<<"Cell ID: "<< anObjId;
- std::string aString = aStr.str();
- myAnnotationMapper->SetInput(aString.c_str());
-
- myAnnotationActor->SetVisibility(1);
- return true;
- }
- }
+ vtkIdType anObjId = GetElemObjId(aVTKId);
+ if(vtkCell* aCell = GetElemCell(anObjId)){
+ vtkPoints* aPts = aCell->GetPoints();
+ if(int aNbPts = aCell->GetNumberOfPoints()){
+ vtkFloatingPointType aCoord[3] = {0.0, 0.0, 0.0};
+ for(int i = 0; i < aNbPts; i++){
+ vtkFloatingPointType *aPntCoord = aPts->GetPoint(i);
+ aCoord[0] += aPntCoord[0];
+ aCoord[1] += aPntCoord[1];
+ aCoord[2] += aPntCoord[2];
+ }
+ // Display coordinates
+ vtkFloatingPointType aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0};
+ aRenderer->SetWorldPoint(aWorldCoord);
+ aRenderer->WorldToDisplay();
+ vtkFloatingPointType aSelectionPoint[3];
+ aRenderer->GetDisplayPoint(aSelectionPoint);
+ myAnnotationActor->SetPosition(aSelectionPoint);
+ //
+ // To prepare the annotation text
+ std::ostringstream aStr;
+ aStr<<"Cell ID: "<< anObjId;
+ std::string aString = aStr.str();
+ myAnnotationMapper->SetInput(aString.c_str());
+
+ myAnnotationActor->SetVisibility(1);
+ return true;
+ }
+ }
}
break;
}
- case NodeSelection:{
+ case NodeSelection:{
vtkRenderer* aRenderer = theInteractorStyle->GetCurrentRenderer();
- myPointPicker->Pick(theSelectionEvent->myX,
- theSelectionEvent->myY,
- 0.0,
- aRenderer);
+ myPointPicker->Pick(theSelectionEvent->myX,
+ theSelectionEvent->myY,
+ 0.0,
+ aRenderer);
if(myPointPicker->GetActor() != this)
- return false;
+ return false;
vtkIdType aVtkId = myPointPicker->GetPointId();
if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){
- vtkIdType anObjId = GetNodeObjId( aVtkId );
- if(vtkFloatingPointType* aCoord = GetNodeCoord(anObjId)){
- // Display coordinates
- vtkFloatingPointType aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0};
- aRenderer->SetWorldPoint(aWorldCoord);
- aRenderer->WorldToDisplay();
- vtkFloatingPointType aSelectionPoint[3];
- aRenderer->GetDisplayPoint(aSelectionPoint);
- myAnnotationActor->SetPosition(aSelectionPoint);
- //
- // To prepare the annotation text
- std::ostringstream aStr;
- aStr<<"Node ID: "<< anObjId;
- std::string aString = aStr.str();
- myAnnotationMapper->SetInput(aString.c_str());
-
- myAnnotationActor->SetVisibility(1);
- return true;
- }
+ vtkIdType anObjId = GetNodeObjId( aVtkId );
+ if(vtkFloatingPointType* aCoord = GetNodeCoord(anObjId)){
+ // Display coordinates
+ vtkFloatingPointType aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0};
+ aRenderer->SetWorldPoint(aWorldCoord);
+ aRenderer->WorldToDisplay();
+ vtkFloatingPointType aSelectionPoint[3];
+ aRenderer->GetDisplayPoint(aSelectionPoint);
+ myAnnotationActor->SetPosition(aSelectionPoint);
+ //
+ // To prepare the annotation text
+ std::ostringstream aStr;
+ aStr<<"Node ID: "<< anObjId;
+ std::string aString = aStr.str();
+ myAnnotationMapper->SetInput(aString.c_str());
+
+ myAnnotationActor->SetVisibility(1);
+ return true;
+ }
}
break;
}
*/
bool
VISU_Actor
-::Highlight(vtkInteractorStyle* theInteractorStyle,
- SVTK_SelectionEvent* theSelectionEvent,
- bool theIsHighlight)
+::Highlight(vtkInteractorStyle* theInteractorStyle,
+ SVTK_SelectionEvent* theSelectionEvent,
+ bool theIsHighlight)
{
return Superclass::Highlight(theInteractorStyle,
- theSelectionEvent,
- theIsHighlight);
+ theSelectionEvent,
+ theIsHighlight);
}
//-------------------------------------------------------------------------
VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
bool anInitialHasIndex = isSubElementsHighlighted() && mySelectionMode != ActorSelection;
-
+
TColStd_IndexedMapOfInteger aMapIndex;
mySelector->GetIndex( getIO(), aMapIndex );
bool aCurrentHasIndex = aMapIndex.Extent() == 1;
{
case ActorSelection:
{
- ResetTextActor();
- break;
+ ResetTextActor();
+ break;
}
case CellSelection:
{
- if( !aCurrentHasIndex )
- {
- myTextActor->SetVisibility(false);
- break;
- }
-
- int anObjId = aMapIndex(1);
- vtkCellData* aCellData = aDataSet->GetCellData();
- if(vtkCell* aCell = GetElemCell(anObjId)){
- vtkPoints* aPts = aCell->GetPoints();
- if(int aNbPts = aCell->GetNumberOfPoints()){
- vtkFloatingPointType aCoord[3] = {0.0, 0.0, 0.0};
- for(int i = 0; i < aNbPts; i++){
- vtkFloatingPointType *aPntCoord = aPts->GetPoint(i);
- aCoord[0] += aPntCoord[0];
- aCoord[1] += aPntCoord[1];
- aCoord[2] += aPntCoord[2];
- }
-
- aFlyTo = true;
- aFlyToCoord[0] = aCoord[0] / aNbPts;
- aFlyToCoord[1] = aCoord[1] / aNbPts;
- aFlyToCoord[2] = aCoord[2] / aNbPts;
-
- vtkFloatingPointType aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0};
- aRenderer->SetWorldPoint(aWorldCoord);
- aRenderer->WorldToDisplay();
- vtkFloatingPointType aSelectionPoint[3];
- aRenderer->GetDisplayPoint(aSelectionPoint);
- myTextActor->SetPosition(aSelectionPoint);
- myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
- myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
- myTextActor->SetWorldPoint(aWorldCoord);
-
- std::ostringstream aStr;
- aStr << "Cell ID: " << anObjId;
-
- vtkCell* aCell = GetElemCell(anObjId);
- int aVTKID = GetElemVTKID(anObjId);
- if (aCell) {
- int aNbOfPoints = aCell->GetNumberOfPoints();
- if ( aNbOfPoints > 0 ) {
- aStr << getScalar(aCellData, aVTKID);
- aStr << getVector(aCellData, aVTKID);
- }
- }
-
- std::string aString = aStr.str();
- myTextActor->SetText(aString.c_str());
- }
- }
- break;
+ if( !aCurrentHasIndex )
+ {
+ myTextActor->SetVisibility(false);
+ break;
+ }
+
+ int anObjId = aMapIndex(1);
+ vtkCellData* aCellData = aDataSet->GetCellData();
+ if(vtkCell* aCell = GetElemCell(anObjId)){
+ vtkPoints* aPts = aCell->GetPoints();
+ if(int aNbPts = aCell->GetNumberOfPoints()){
+ vtkFloatingPointType aCoord[3] = {0.0, 0.0, 0.0};
+ for(int i = 0; i < aNbPts; i++){
+ vtkFloatingPointType *aPntCoord = aPts->GetPoint(i);
+ aCoord[0] += aPntCoord[0];
+ aCoord[1] += aPntCoord[1];
+ aCoord[2] += aPntCoord[2];
+ }
+
+ aFlyTo = true;
+ aFlyToCoord[0] = aCoord[0] / aNbPts;
+ aFlyToCoord[1] = aCoord[1] / aNbPts;
+ aFlyToCoord[2] = aCoord[2] / aNbPts;
+
+ vtkFloatingPointType aWorldCoord[4] = {aCoord[0]/aNbPts, aCoord[1]/aNbPts, aCoord[2]/aNbPts, 1.0};
+ aRenderer->SetWorldPoint(aWorldCoord);
+ aRenderer->WorldToDisplay();
+ vtkFloatingPointType aSelectionPoint[3];
+ aRenderer->GetDisplayPoint(aSelectionPoint);
+ myTextActor->SetPosition(aSelectionPoint);
+ myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
+ myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
+ myTextActor->SetWorldPoint(aWorldCoord);
+
+ std::ostringstream aStr;
+ aStr << "Cell ID: " << anObjId;
+
+ vtkCell* aCell = GetElemCell(anObjId);
+ int aVTKID = GetElemVTKID(anObjId);
+ if (aCell) {
+ int aNbOfPoints = aCell->GetNumberOfPoints();
+ if ( aNbOfPoints > 0 ) {
+ aStr << getScalar(aCellData, aVTKID);
+ aStr << getVector(aCellData, aVTKID);
+ }
+ }
+
+ std::string aString = aStr.str();
+ myTextActor->SetText(aString.c_str());
+ }
+ }
+ break;
}
case NodeSelection:
- {
- if( !aCurrentHasIndex )
- {
- myTextActor->SetVisibility(false);
- break;
- }
-
- int anObjId = aMapIndex(1);
- vtkPointData* aPntData = aDataSet->GetPointData();
- if(vtkFloatingPointType* aCoord = GetNodeCoord(anObjId)){
- aFlyTo = true;
- aFlyToCoord[0] = aCoord[0];
- aFlyToCoord[1] = aCoord[1];
- aFlyToCoord[2] = aCoord[2];
-
- vtkFloatingPointType aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0};
- aRenderer->SetWorldPoint(aWorldCoord);
- aRenderer->WorldToDisplay();
- vtkFloatingPointType aSelectionPoint[3];
- aRenderer->GetDisplayPoint(aSelectionPoint);
- myTextActor->SetPosition(aSelectionPoint);
- myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
- myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
- myTextActor->SetWorldPoint(aWorldCoord);
-
- std::ostringstream aStr;
- aStr << "Point ID: " << anObjId;
-
- int aVTKID = GetNodeVTKID(anObjId);
- if(aVTKID >= 0) {
- aStr << getScalar(aPntData, aVTKID);
- aStr << getVector(aPntData, aVTKID);
- }
-
- const VISU::PIDMapper& aMapper = GetPipeLine()->GetIDMapper();
- //VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(anObjId);
- VISU::TStructuredId aVec = aMapper->GetIndexesOfNode(anObjId);
-
- aStr << "\nCoordinates: " << "[";
- aStr << aCoord[0];
- //if( aVec.size() > 0 )
- if (aVec[0] != -1)
- aStr << " (" << aVec[0] << ")";
- aStr << "; ";
-
- aStr << aCoord[1];
- //if( aVec.size() > 1 )
- if (aVec[1] != -1)
- aStr << " (" << aVec[1] << ")";
- aStr << "; ";
-
- aStr << aCoord[2];
- //if( aVec.size() > 2 )
- if (aVec[2] != -1)
- aStr << " (" << aVec[2] << ")";
- aStr << "]";
-
- std::string aString = aStr.str();
- myTextActor->SetText(aString.c_str());
- }
- break;
+ {
+ if( !aCurrentHasIndex )
+ {
+ myTextActor->SetVisibility(false);
+ break;
+ }
+
+ int anObjId = aMapIndex(1);
+ vtkPointData* aPntData = aDataSet->GetPointData();
+ if(vtkFloatingPointType* aCoord = GetNodeCoord(anObjId)){
+ aFlyTo = true;
+ aFlyToCoord[0] = aCoord[0];
+ aFlyToCoord[1] = aCoord[1];
+ aFlyToCoord[2] = aCoord[2];
+
+ vtkFloatingPointType aWorldCoord[4] = {aCoord[0], aCoord[1], aCoord[2], 1.0};
+ aRenderer->SetWorldPoint(aWorldCoord);
+ aRenderer->WorldToDisplay();
+ vtkFloatingPointType aSelectionPoint[3];
+ aRenderer->GetDisplayPoint(aSelectionPoint);
+ myTextActor->SetPosition(aSelectionPoint);
+ myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
+ myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
+ myTextActor->SetWorldPoint(aWorldCoord);
+
+ std::ostringstream aStr;
+ aStr << "Point ID: " << anObjId;
+
+ int aVTKID = GetNodeVTKID(anObjId);
+ if(aVTKID >= 0) {
+ aStr << getScalar(aPntData, aVTKID);
+ aStr << getVector(aPntData, aVTKID);
+ }
+
+ const VISU::PIDMapper& aMapper = GetPipeLine()->GetIDMapper();
+ //VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(anObjId);
+ VISU::TStructuredId aVec = aMapper->GetIndexesOfNode(anObjId);
+
+ aStr << "\nCoordinates: " << "[";
+ aStr << aCoord[0];
+ //if( aVec.size() > 0 )
+ if (aVec[0] != -1)
+ aStr << " (" << aVec[0] << ")";
+ aStr << "; ";
+
+ aStr << aCoord[1];
+ //if( aVec.size() > 1 )
+ if (aVec[1] != -1)
+ aStr << " (" << aVec[1] << ")";
+ aStr << "; ";
+
+ aStr << aCoord[2];
+ //if( aVec.size() > 2 )
+ if (aVec[2] != -1)
+ aStr << " (" << aVec[2] << ")";
+ aStr << "]";
+
+ std::string aString = aStr.str();
+ myTextActor->SetText(aString.c_str());
+ }
+ break;
}
case EdgeOfCellSelection:
- break;
+ break;
default:
- break;
+ break;
}
}
{
vtkFloatingPointType aZoomFactor = aPickingSettings->GetZoomFactor();
ChangeZoom(aZoomFactor,
- GetRenderer(),
- anInitialHasIndex,
- aCurrentHasIndex);
+ GetRenderer(),
+ anInitialHasIndex,
+ aCurrentHasIndex);
}
// FlyTo
vtkRenderWindowInteractor* anInteractor = myInteractor;
vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
-
+
double aPosition[3];
GetPosition( aPosition );
for( int i = 0; i < 3; i++ )
GetBounds(aCoord);
vtkFloatingPointType aWorldCoord[4] = { ( aCoord[0] + aCoord[1] ) / 2,
- ( aCoord[2] + aCoord[3] ) / 2,
- ( aCoord[4] + aCoord[5] ) / 2, 1.0};
+ ( aCoord[2] + aCoord[3] ) / 2,
+ ( aCoord[4] + aCoord[5] ) / 2, 1.0};
vtkRenderer* aRenderer = GetRenderer();
aRenderer->SetWorldPoint(aWorldCoord);
aRenderer->WorldToDisplay();
}
//-------------------------------------------------------------------------
-void
+void
VISU_Actor
-::ProcessEvents(vtkObject* vtkNotUsed(theObject),
- unsigned long theEvent,
- void* theClientData,
- void* vtkNotUsed(theCallData))
+::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* vtkNotUsed(theCallData))
{
if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
if(VISU_Actor* self = dynamic_cast<VISU_Actor*>(anObject)) {
if(theEvent == VISU::UpdatePickingSettingsEvent)
- self->UpdatePickingSettings();
+ self->UpdatePickingSettings();
}
}
vtkDataSet* aGrid = GetValLabelsInput();
if ( !aGrid )
return;
-
+
bool isOnPnt = VISU::IsDataOnPoints( aGrid );
bool isOnCell = VISU::IsDataOnCells( aGrid );
if ( !isOnPnt && !isOnCell )
return;
}
}
-
+
myIsValLabeled = theIsValLabeled;
if ( myIsValLabeled )
myValMaskPoints->SetInput( myValCellCenters->GetOutput() );
}
else if ( isOnPnt )
- myValMaskPoints->SetInput( aDataSet );
+ {
+ myValUsedPoints->SetInput( aDataSet );
+ myValMaskPoints->SetInput( myValUsedPoints->GetOutput() );
+ }
myValLabels->SetVisibility( GetVisibility() );
}
else
myValLabels->SetVisibility( false );
-
+
Modified();
}
vtkTextProperty* VISU_Actor::GetsValLabelsProps() const
{
- return myValLabeledDataMapper->GetLabelTextProperty();
+ return myValLabeledDataMapper->GetLabelTextProperty();
}
//----------------------------------------------------------------------------
}
-
-VISU_Actor::EQuadratic2DRepresentation
+VISU_Actor::EQuadratic2DRepresentation
VISU_Actor::GetQuadratic2DRepresentation() const
{
if(Superclass::GetQuadraticArcMode()){