-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 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
#include "GEOM_WireframeFace.h"
#include "GEOM_ShadingFace.h"
#include "GEOM_PainterPolyDataMapper.h"
+#include "GEOMUtils.hxx"
#include "SVTK_Actor.h"
#include <OCC2VTK_Tools.h>
+#include <GEOMUtils.hxx>
#include <vtkObjectFactory.h>
#include <vtkRenderer.h>
+#include <vtkTextActor.h>
+#include <vtkTextProperty.h>
#include <vtkProperty.h>
#include <vtkPointPicker.h>
#include <vtkCellPicker.h>
myIsSelected(false),
myVectorMode(false),
myVerticesMode(false),
+ myNameMode(false),
myVertexActor(GEOM_DeviceActor::New(),true),
myVertexSource(GEOM_VertexSource::New(),true),
myShadingFaceSource(GEOM_ShadingFace::New(),true),
myHighlightActor(GEOM_DeviceActor::New(),true),
+
+ myTextActor( vtkTextActor::New() ),
+
+ myHighlightProp(vtkProperty::New()),
+ myPreHighlightProp(vtkProperty::New()),
+ myShadingFaceProp(vtkProperty::New()),
+ myShadingBackFaceProp(vtkProperty::New()),
+
myAppendFilter(vtkAppendPolyData::New(),true),
// Use mapper as an instance of GEOM_PainterPolyDataMapper class
// to prevent drawing of mappers' content (due to an empty definition
// of GEOM_PainterPolyDataMapper::RenderPiece(...)).
// !!! Presentation of GEOM_Actor is drawing only with help of actors
// defined in this class !!!
- myPolyDataMapper(GEOM_PainterPolyDataMapper::New(),true),
-
- myHighlightProp(vtkProperty::New()),
- myPreHighlightProp(vtkProperty::New()),
- myShadingFaceProp(vtkProperty::New()),
- myShadingBackFaceProp(vtkProperty::New())
+ myPolyDataMapper(GEOM_PainterPolyDataMapper::New(),true)
{
#ifdef MYDEBUG
MESSAGE (this<< " GEOM_Actor::GEOM_Actor");
setDisplayMode(0); // WIRE FRAME
SetVectorMode(0); //
SetVerticesMode(0); //
+ SetNameMode(0);
}
#ifdef MYDEBUG
MESSAGE (this<< " ~GEOM_Actor::GEOM_Actor");
#endif
+ myTextActor->Delete();
myHighlightProp->Delete();
myPreHighlightProp->Delete();
myShadingFaceProp->Delete();
this->mySharedEdgeSource->Modified();
this->myWireframeFaceSource->Modified();
this->myShadingFaceSource->Modified();
+ this->myTextActor->Modified();
}
void
myVertexActor->AddToRender(theRenderer);
myStandaloneVertexActor->AddToRender(theRenderer);
+
+ theRenderer->AddActor( myTextActor );
}
void
myVertexActor->RemoveFromRender(theRenderer);
myStandaloneVertexActor->RemoveFromRender(theRenderer);
+ theRenderer->RemoveActor( myTextActor );
SetSelected(false);
SetVisibility(false);
myIsolatedEdgeActor->GetProperty()->SetColor(myIsolatedEdgeColor[0],
myIsolatedEdgeColor[1],
myIsolatedEdgeColor[2]);
- mySharedEdgeActor->GetProperty()->SetColor(myIsolatedEdgeColor[0],
- myIsolatedEdgeColor[1],
- myIsolatedEdgeColor[2]);
+ mySharedEdgeActor->GetProperty()->SetColor(mySharedEdgeColor[0],
+ mySharedEdgeColor[1],
+ mySharedEdgeColor[2]);
myOneFaceEdgeActor->GetProperty()->SetColor(myOneFaceEdgeColor[0],
myOneFaceEdgeColor[1],
myOneFaceEdgeColor[2]);
myVertexActor->SetVisibility(theVisibility && (isOnlyVertex || (myVerticesMode && (!myIsSelected && !myIsPreselected))));// must be added new mode points
myStandaloneVertexActor->SetVisibility(theVisibility);
+
+ myTextActor->SetVisibility( theVisibility && myNameMode );
}
return myVerticesMode;
}
+void
+GEOM_Actor
+::SetShapeName()
+{
+ if( !getIO() || myShape.IsNull() )
+ return;
+
+ gp_Ax3 anAx3 = GEOMUtils::GetPosition(myShape);
+ double center[3] = { anAx3.Location().X(),
+ anAx3.Location().Y(),
+ anAx3.Location().Z() };
+ double* pos = center;
+ myTextActor->GetTextProperty()->SetFontSize( 16 );
+ myTextActor->GetTextProperty()->ShadowOn();
+ myTextActor->GetPositionCoordinate()->SetCoordinateSystemToWorld();
+ myTextActor->GetPositionCoordinate()->SetValue(pos);
+ myTextActor->SetInput( getIO()->getName() );
+}
+
+void
+GEOM_Actor
+::SetNameMode(bool theMode)
+{
+ myNameMode = theMode;
+ myTextActor->SetVisibility(theMode);
+ SetModified();
+}
+
+bool
+GEOM_Actor
+::GetNameMode()
+{
+ return myNameMode;
+}
+
void
GEOM_Actor::
-SetDeflection(float theDeflection)
+SetDeflection(double theDeflection)
{
- if( myDeflection == theDeflection )
- return;
-
- myDeflection = theDeflection;
-
- GEOM::MeshShape(myShape,myDeflection);
-
- SetModified();
+ double aDeflection = ( theDeflection <= 0 ) ? GEOMUtils::DefaultDeflection() : theDeflection;
+
+ if ( myDeflection != aDeflection ) {
+ myDeflection = aDeflection;
+ GEOMUtils::MeshShape( myShape, myDeflection );
+ SetModified();
+ }
}
void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
- float theDeflection,
+ double theDeflection,
bool theIsVector)
{
myShape = theShape;
TopTools_IndexedDataMapOfShapeListOfShape anEdgeMap;
TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,anEdgeMap);
- GEOM::SetShape(theShape,anEdgeMap,theIsVector,
- myStandaloneVertexSource.Get(),
- myIsolatedEdgeSource.Get(),
- myOneFaceEdgeSource.Get(),
- mySharedEdgeSource.Get(),
- myWireframeFaceSource.Get(),
- myShadingFaceSource.Get());
+ GEOM::ShapeToVTK(theShape,anEdgeMap,theIsVector,
+ myStandaloneVertexSource.Get(),
+ myIsolatedEdgeSource.Get(),
+ myOneFaceEdgeSource.Get(),
+ mySharedEdgeSource.Get(),
+ myWireframeFaceSource.Get(),
+ myShadingFaceSource.Get());
isOnlyVertex =
myIsolatedEdgeSource->IsEmpty() &&
myOneFaceEdgeSource->IsEmpty() &&
myHighlightActor->GetDeviceActor()->SetInfinitive(true);
}
+ SetShapeName();
+
// 0051777: TC7.2.0: Element could not be selected in Hypothesis Construction
myAppendFilter->Update();
}
-// OLD METHODS
-void GEOM_Actor::setDeflection(double adef) {
-#ifdef MYDEBUG
- MESSAGE ( "GEOM_Actor::setDeflection" );
-#endif
- SetDeflection((float)adef);
-}
-
-
// warning! must be checked!
// SetHighlightProperty
// SetWireframeProperty
#endif
}
-double GEOM_Actor::getDeflection()
-{
-#ifdef MYDEBUG
- MESSAGE ( "GEOM_Actor::getDeflection" );
-#endif
- return (double) GetDeflection();
-}
-
-
double GEOM_Actor::isVector()
{
#ifdef MYDEBUG
myWireframeFaceActor->GetProperty()->SetColor(r, g, b);
}
+/*!
+ \brief Set color of labels
+ This actor is shown only if 'Show name' is switched-on, see SetVisibility()
+*/
+void GEOM_Actor::SetLabelColor(double r, double g, double b)
+{
+ myTextActor->GetTextProperty()->SetColor(r, g, b);
+}
+
void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
{
// we set material properties as back and front material