Superclass::ShallowCopyPL(thePipeLine);
UpdateInsideCursorSettings();
+
+ Highlight(isHighlighted());
}
SetMapper(myMapper.GetPointer());
}
+
+//----------------------------------------------------------------------------
+namespace
+{
+ inline
+ float
+ GetRadius(vtkIdType theVTKID,
+ vtkDataArray *theScalarArray,
+ VISU_GaussPointsPL* theGaussPointsPL)
+ {
+ float aRadius = 0.5;
+ if(theGaussPointsPL->GetPSMapper()->GetPointSpriteMode() == 1) // Geometry mode
+ aRadius *= theGaussPointsPL->GetSize() * theGaussPointsPL->GetAverageCellSize();
+ else if(theGaussPointsPL->GetBicolor()){
+ float aVal = theScalarArray->GetTuple1(theVTKID);
+ if(aVal >= 0)
+ aRadius *= theGaussPointsPL->GetMaxSize();
+ else
+ aRadius *= theGaussPointsPL->GetMinSize();
+ aRadius *= theGaussPointsPL->GetAverageCellSize();
+ }else
+ aRadius *= theGaussPointsPL->GetPointSize(theVTKID,theScalarArray);
+
+ return aRadius;
+ }
+}
+
+float
+VISU_GaussPtsAct
+::GetRadius(vtkIdType theVTKID,
+ vtkDataArray *theScalarArray)
+{
+ return ::GetRadius(theVTKID,theScalarArray,myDeviceActor->GetPipeLine());
+}
+
+//----------------------------------------------------------------------------
+float
+VISU_GaussPtsAct
+::GetMagnification(vtkIdType theObjID)
+{
+ return GetGaussPointsPL()->GetMagnification();
+}
+
+
+//----------------------------------------------------------------------------
+namespace
+{
+ inline
+ float
+ GetClamp(VISU_GaussPointsPL* theGaussPointsPL)
+ {
+ float aClamp = theGaussPointsPL->GetClamp();
+ if(theGaussPointsPL->GetPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere)
+ return -aClamp;
+ return aClamp;
+ }
+}
+
+float
+VISU_GaussPtsAct
+::GetClamp(vtkIdType theObjID)
+{
+ return ::GetClamp(GetGaussPointsPL());
+}
+
+
+//----------------------------------------------------------------------------
void
VISU_GaussPtsAct
::SetFactory(VISU::TActorFactory* theActorFactory)
vtkDataSet* aDataSet = GetInput();
vtkCellData* aCellData = aDataSet->GetCellData();
if(vtkDataArray *aScalarArray = aCellData->GetScalars()){
- float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray) / 2.;
float aPyramidHeight = myPickingSettings->GetPyramidHeight();
aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
//float aColor[3] = myPreHighlightActor->GetProperty()->GetColor();
aColor[1] = 1. - aColor[1];
aColor[2] = 1. - aColor[2];
myCursorPyramid->Init(aPyramidHeight,
- aRadius,
+ GetRadius(aVtkId,aScalarArray),
+ GetMagnification(aVtkId),
+ GetClamp(anObjId),
aNodeCoord,
aColor);
}
SVTK_SelectionEvent* theSelectionEvent,
bool theIsHighlight)
{
+ myIsHighlighted = false;
Handle(SALOME_InteractiveObject) anIO = getIO();
int anInitialHasIndex = mySelector->HasIndex(anIO);
if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) && hasIO()) {
vtkIdType anObjId = GetNodeObjId( aVtkId );
if(anObjId >= 0){
+ myIsHighlighted = true;
// Update the Selector
if(mySelector->IsSelected(myIO))
mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
VISU_GaussPtsAct
::Highlight(bool theIsHighlight)
{
+ if(!mySelector.GetPointer())
+ return;
+
myOutlineActor->SetVisibility(false);
myTextActor->SetVisibility(0);
myCursorPyramidSelected->SetVisibility(0);
//
vtkIdType aVtkId = GetNodeVTKID(anObjId);
if(aVtkId >= 0){
- float *aNodeCoord, aVal, aRadius;
- //
- aNodeCoord = GetNodeCoord(anObjId);
+ float *aNodeCoord = GetNodeCoord(anObjId);
float aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.};
//
vtkDataSet* aDataSet = GetInput();
vtkCellData* aDataSetAttributes = aDataSet->GetCellData();
//
if(vtkDataArray* aScalarArray = aDataSetAttributes->GetScalars()){
- aVal = aScalarArray->GetTuple1(aVtkId);
- aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray) / 2.;
+ float aVal = aScalarArray->GetTuple1(aVtkId);
//
GetScalarBarCtrl()->SetIsMarked(true);
GetScalarBarCtrl()->SetMarkValue(aVal);
float aPyramidHeight = myPickingSettings->GetPyramidHeight();
aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
myCursorPyramidSelected->Init(aPyramidHeight,
- aRadius,
+ GetRadius(aVtkId,aScalarArray),
+ GetMagnification(aVtkId),
+ GetClamp(anObjId),
aNodeCoord,
myHighlightActor->GetProperty()->GetColor());
myCursorPyramidSelected->SetVisibility(anIsVisible && theIsHighlight);
aPipeline->Update();
+ Highlight(isHighlighted());
+
Update();
}
}
+//----------------------------------------------------------------------------
+float
+VISU_GaussPtsAct1
+::GetRadius(vtkIdType theVTKID,
+ vtkDataArray *theScalarArray)
+{
+ VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
+ if(myWidgetCtrl && myWidgetCtrl->GetEnabled()){
+ if(myInsideDeviceActor->GetPipeLine()->GetElemObjID(theVTKID) < 0)
+ aPipeLine = myOutsideDeviceActor->GetPipeLine();
+ else
+ aPipeLine = myInsideDeviceActor->GetPipeLine();
+ }
+ return ::GetRadius(theVTKID,theScalarArray,aPipeLine);
+}
+
+
+//----------------------------------------------------------------------------
+float
+VISU_GaussPtsAct1
+::GetMagnification(vtkIdType theObjID)
+{
+ VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
+ if(myWidgetCtrl && myWidgetCtrl->GetEnabled()){
+ if(myInsideDeviceActor->GetPipeLine()->GetElemVTKID(theObjID) < 0)
+ aPipeLine = myOutsideDeviceActor->GetPipeLine();
+ else
+ aPipeLine = myInsideDeviceActor->GetPipeLine();
+ }
+ return aPipeLine->GetMagnification();
+}
+
+
+//----------------------------------------------------------------------------
+float
+VISU_GaussPtsAct1
+::GetClamp(vtkIdType theObjID)
+{
+ if(myWidgetCtrl && myWidgetCtrl->GetEnabled()){
+ if(myInsideDeviceActor->GetPipeLine()->GetElemVTKID(theObjID) < 0)
+ return ::GetClamp(myOutsideDeviceActor->GetPipeLine());
+ else
+ return ::GetClamp(myInsideDeviceActor->GetPipeLine());
+ }
+ return Superclass::GetClamp(theObjID);
+}
+
+
//----------------------------------------------------------------
void
VISU_GaussPtsAct1
aPipeline->Update();
+ Highlight(isHighlighted());
+
Update();
}
::VISU_CursorPyramid():
myHeight(10.0),
myRadius(5.0),
+ myMagnification(1.0),
+ myClamp(256.0),
myNbCones(6),
myAppendFilter(vtkAppendPolyData::New()),
myMapper(vtkPolyDataMapper::New())
VISU_CursorPyramid
::Render(vtkRenderer *ren, vtkMapper *vtkNotUsed(m))
{
+ if (ren == NULL)
+ {
+ vtkErrorMacro("No mapper for actor.");
+ return;
+ }
+
+ this->SetScale(1.0);
+ float aMRadius = myRadius*myMagnification;
+ Init(myHeight,aMRadius);
+
+ if(myClamp > 0.0f){
+ float aPoint1[3] = {0.0, 0.0, 0.0};
+ ren->SetDisplayPoint(aPoint1);
+ ren->DisplayToWorld();
+ ren->GetWorldPoint(aPoint1);
+
+ float aPoint2[3] = {0.0, myClamp, 0.0};
+ ren->SetDisplayPoint(aPoint2);
+ ren->DisplayToWorld();
+ ren->GetWorldPoint(aPoint2);
+
+ float aWorldClamp =
+ (aPoint2[0] - aPoint1[0])*(aPoint2[0] - aPoint1[0]) +
+ (aPoint2[1] - aPoint1[1])*(aPoint2[1] - aPoint1[1]) +
+ (aPoint2[2] - aPoint1[2])*(aPoint2[2] - aPoint1[2]);
+
+ aWorldClamp = sqrt(aWorldClamp);
+ float aMDiameter = 2.0 * aMRadius;
+ float aCoeff = aWorldClamp / aMDiameter;
+ float aMagnification = aWorldClamp / 2.0 / myRadius;
+ /*
+ cout<<"aMDiameter = "<<aMDiameter<<"; aCoeff = "<<aCoeff<<
+ "; myMagnification = "<<myMagnification<<"; aMagnification = "<<aMagnification<<endl;
+ */
+ if(aCoeff < 1.0){
+ this->SetScale(aCoeff);
+ if(aMagnification > myMagnification)
+ Init(myHeight/aCoeff,aMRadius);
+ }
+ }
+
if (this->Mapper == NULL)
{
vtkErrorMacro("No mapper for actor.");
VISU_CursorPyramid
::SetHeight(float theHeight)
{
- Init(theHeight, myRadius, GetPosition(), GetProperty()->GetColor());
+ Init(theHeight, myRadius, myMagnification, myClamp, GetPosition(), GetProperty()->GetColor());
}
//----------------------------------------------------------------------------
VISU_CursorPyramid
::Init(float theHeight,
float theRadius,
+ float theMagnification,
+ float theClamp,
float thePos[3],
float theColor[3])
{
+ Init(theHeight,theRadius*theMagnification);
SetPosition(thePos[0],thePos[1],thePos[2]);
GetProperty()->SetColor(theColor);
SetMapper(myMapper.GetPointer());
myHeight = theHeight;
myRadius = theRadius;
+ myMagnification = theMagnification;
+ myClamp = theClamp;
+}
+
+void
+VISU_CursorPyramid
+::Init(float theHeight,
+ float theRadius)
+{
for(int i = 0; i < myNbCones; ++i){
vtkConeSource* aSource = mySources[i].GetPointer();
aSource->SetHeight(theHeight);