for (; anIt != aLast; anIt++) {
ObjectPtr anObject = (*anIt).object();
if (anObject.get() != NULL && !anExistedObjects.contains(anObject)) {
- theValuesTo.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));
+ theValuesTo.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL));
}
}
{
GeomShapePtr aShape;
- const TopoDS_Shape& aTDSShape = thePrs.shape();
+ const GeomShapePtr& aPrsShape = thePrs.shape();
// if only result is selected, an empty shape is set to the model
- if (aTDSShape.IsNull()) {
+ if (!aPrsShape.get() || aPrsShape->isNull()) {
}
else {
- aShape = GeomShapePtr(new GeomAPI_Shape());
- aShape->setImpl(new TopoDS_Shape(aTDSShape));
+ aShape = aPrsShape;
// If the result object is built on the same shape, the result shape here is empty one
ResultPtr aResult = getResult(thePrs);
if (aResult.get() && aShape->isEqual(aResult->shape()))
for (; anIt != aLast; anIt++) {
ObjectPtr anObject = *anIt;
if (anObject.get() != NULL) {
- aSelectedPrs.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));
+ aSelectedPrs.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL));
}
}
return aSelectedPrs;
}
ModuleBase_ViewerPrs::ModuleBase_ViewerPrs(ObjectPtr theResult,
- const TopoDS_Shape& theShape,
+ const GeomShapePtr& theShape,
Handle_SelectMgr_EntityOwner theOwner)
: myResult(theResult),
myShape(theShape),
bool ModuleBase_ViewerPrs::operator==(const ModuleBase_ViewerPrs& thePrs)
{
bool isEqualResult = (myResult.get() == thePrs.object().get());
- bool isEqualShape = myShape.IsEqual(thePrs.shape()) == Standard_True;
+ bool isEqualShape = (!myShape.get() && !thePrs.shape().get()) ||
+ (myShape.get() && myShape->isEqual(thePrs.shape()));
bool isEqualIO = (myInteractive == thePrs.interactive()) == Standard_True;
bool isEqualOwner = (myOwner.Access() == thePrs.owner().Access());
#include "ModuleBase.h"
#include <memory>
-#include <TopoDS_Shape.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <AIS_InteractiveObject.hxx>
#include <ModelAPI_Result.h>
+#include <GeomAPI_Shape.h>
/**\class ModuleBase_ViewerPrs
* \ingroup GUI
/// \param theResult an object
/// \param theShape a viewer shape
/// \param theOwner a selection owner
- MODULEBASE_EXPORT ModuleBase_ViewerPrs(ObjectPtr theResult, const TopoDS_Shape& theShape,
+ MODULEBASE_EXPORT ModuleBase_ViewerPrs(ObjectPtr theResult, const GeomShapePtr& theShape,
Handle_SelectMgr_EntityOwner theOwner);
/// Destructor
/// Sets the shape
/// \param theShape a shape instance
- MODULEBASE_EXPORT void setShape(const TopoDS_Shape& theShape)
+ MODULEBASE_EXPORT void setShape(const GeomShapePtr& theShape)
{
myShape = theShape;
}
/// Returns the shape
/// \return a shape instance
- MODULEBASE_EXPORT const TopoDS_Shape& shape() const
+ MODULEBASE_EXPORT const GeomShapePtr& shape() const
{
return myShape;
}
/// \return boolean value
MODULEBASE_EXPORT bool isEmpty() const
{
- return myShape.IsNull() &&
+ return (!myShape.get() || myShape->isNull()) &&
myOwner.IsNull() && !myResult.get();
}
private:
ObjectPtr myResult; /// the feature
Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner
- TopoDS_Shape myShape; /// the shape
+ GeomShapePtr myShape; /// the shape
Handle(AIS_InteractiveObject) myInteractive; /// interactive object
};
continue;
AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
ResultPtr anObject = anAttr->context();
- if (anObject.get()) {
- TopoDS_Shape aShape;
- std::shared_ptr<GeomAPI_Shape> aShapePtr = anAttr->value();
- if (aShapePtr.get()) {
- aShape = aShapePtr->impl<TopoDS_Shape>();
- }
- theValues.append(ModuleBase_ViewerPrs(anObject, aShape, NULL));
- }
+ if (anObject.get())
+ theValues.append(ModuleBase_ViewerPrs(anObject, anAttr->value(), NULL));
}
}
else if (aType == ModelAPI_AttributeRefList::typeId()) {
continue;
ObjectPtr anObject = aRefListAttr->object(i);
if (anObject.get()) {
- theValues.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));
+ theValues.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL));
}
}
}
AttributePtr anAttribute = aRefAttrListAttr->attribute(i);
if (anAttribute.get()) {
GeomShapePtr aGeomShape = myWorkshop->module()->findShape(anAttribute);
- if (aGeomShape.get()) {
- aShape = aGeomShape->impl<TopoDS_Shape>();
- }
- theValues.append(ModuleBase_ViewerPrs(anObject, aShape, NULL));
+ theValues.append(ModuleBase_ViewerPrs(anObject, aGeomShape, NULL));
}
}
}
AttributePtr anAttribute = myFeature->attribute(attributeID());
ObjectPtr anObject = ModuleBase_Tools::getObject(anAttribute);
- TopoDS_Shape aShape;
std::shared_ptr<GeomAPI_Shape> aShapePtr = getShape();
- if (aShapePtr.get()) {
- aShape = aShapePtr->impl<TopoDS_Shape>();
- }
- ModuleBase_ViewerPrs aPrs(anObject, aShape, NULL);
+ ModuleBase_ViewerPrs aPrs(anObject, aShapePtr, NULL);
aSelected.append(aPrs);
}
return aSelected;
bool hasFeature = false;
QList<ModuleBase_ViewerPrs> aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer);
- TopoDS_Shape aShape;
ResultPtr aResult;
FeaturePtr aFeature;
foreach(ModuleBase_ViewerPrs aPrs, aPrsList) {
aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs.object());
if (aResult.get() != NULL) {
- aShape = aPrs.shape();
- if (aShape.IsEqual(aResult->shape()->impl<TopoDS_Shape>()))
+ const GeomShapePtr& aShape = aPrs.shape();
+ if (aShape.get() && aShape->isEqual(aResult->shape()))
hasFeature = true;
else
hasAttribute = true;
}
if (aPrsList.size() == 1) {
- TopoDS_Shape aShape = aPrsList.first().shape();
- if ((!aShape.IsNull()) && aShape.ShapeType() == TopAbs_VERTEX) {
+ const GeomShapePtr& aShape = aPrsList.first().shape();
+ if (aShape.get() && !aShape->isNull() && aShape->shapeType() == GeomAPI_Shape::VERTEX) {
// Find 2d coordinates
FeaturePtr aSketchFea = myModule->sketchMgr()->activeSketch();
if (aSketchFea->getKind() == SketchPlugin_Sketch::ID()) {
- gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
+ const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+ gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aTDShape));
std::shared_ptr<GeomAPI_Pnt> aPnt3d(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z()));
std::shared_ptr<GeomAPI_Pnt2d> aSelPnt = PartSet_Tools::convertTo2D(aSketchFea, aPnt3d);
FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
FeaturePtr anOpFeature = aFOperation->feature();
- TopoDS_Shape aShape = aSelectedPrs.shape();
+ GeomShapePtr aShape = aSelectedPrs.shape();
// click on the digit of dimension constrain comes here with an empty shape, so we need the check
- if (aFeature == anOpFeature && !aShape.IsNull()) {
- AttributePtr anAttribute = PartSet_Tools::findAttributeBy2dPoint(anObject, aShape,
+ if (aFeature == anOpFeature && aShape.get() && !aShape->isNull()) {
+ const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+ AttributePtr anAttribute = PartSet_Tools::findAttributeBy2dPoint(anObject, aTDShape,
mySketchMgr->activeSketch());
if (anAttribute.get()) {
QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
// appendShapeIfVisible() on the step of filling myFeatureShapes list
// the reason is to avoid empty AIS object visualized in the viewer
//if (!aGeomShape.get()) continue;
- TopoDS_Shape aShape = aGeomShape->impl<TopoDS_Shape>();
+ TopoDS_Shape aShape = aGeomShape.get() ? aGeomShape->impl<TopoDS_Shape>() : TopoDS_Shape();
// change deviation coefficient to provide more precise circle
ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer);
ModuleBase_ViewerPrs aPrs = *anIIt;
ObjectPtr anObject = aPrs.object();
- GeomShapePtr aGeomShape;
-
- TopoDS_Shape aShape = aPrs.shape();
- if (!aShape.IsNull()) {
- aGeomShape = GeomShapePtr(new GeomAPI_Shape());
- aGeomShape->setImpl(new TopoDS_Shape(aShape));
- }
- else {
+ GeomShapePtr aGeomShape = aPrs.shape();
+ if (!aGeomShape.get() || aGeomShape->isNull()) {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get()) {
aGeomShape = aResult->shape();
PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(anActiveWidget);
if (aPoint2DWdg) { // line, start point should be equal last point of the last feature line
QList<ModuleBase_ViewerPrs> aSelection;
- aSelection.append(ModuleBase_ViewerPrs(aLastFeature, TopoDS_Shape(), NULL));
+ aSelection.append(ModuleBase_ViewerPrs(aLastFeature, GeomShapePtr(), NULL));
aWidgetIsFilled = aPoint2DWdg->setSelection(aSelection, true);
}
}
{
bool aHasVertex = false;
- const TopoDS_Shape& aShape = thePrs.shape();
- if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX)
+ const GeomShapePtr& aShape = thePrs.shape();
+ if (aShape.get() && !aShape->isNull() && aShape->shapeType() == GeomAPI_Shape::VERTEX)
{
- const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
+ const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+ const TopoDS_Vertex& aVertex = TopoDS::Vertex(aTDShape);
if (!aVertex.IsNull())
{
gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
int aCount = 0;
foreach (ModuleBase_ViewerPrs aPrs, aList) {
- const TopoDS_Shape& aShape = aPrs.shape();
- if (!aShape.IsNull()) {
- if (aShape.ShapeType() == TopAbs_VERTEX)
+ const GeomShapePtr& aShape = aPrs.shape();
+ if (aShape.get() && !aShape->isNull()) {
+ if (aShape->shapeType() == GeomAPI_Shape::VERTEX)
aCount++;
}
}
QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
int aCount = 0;
foreach(ModuleBase_ViewerPrs aPrs, aList) {
- const TopoDS_Shape& aShape = aPrs.shape();
- if (!aShape.IsNull()) {
- if (aShape.ShapeType() == TopAbs_EDGE) {
- TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+ const GeomShapePtr& aShape = aPrs.shape();
+ if (aShape.get() && !aShape->isNull()) {
+ if (aShape->shapeType() == GeomAPI_Shape::EDGE) {
+ const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+ TopoDS_Edge aEdge = TopoDS::Edge(aTDShape);
Standard_Real aStart, aEnd;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
GeomAdaptor_Curve aAdaptor(aCurve);
ModuleBase_ViewerPrs aPrs;
int aCount = 0;
foreach (ModuleBase_ViewerPrs aPrs, aList) {
- const TopoDS_Shape& aShape = aPrs.shape();
- if (!aShape.IsNull()) {
- if (aShape.ShapeType() == TopAbs_EDGE) {
- TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+ const GeomShapePtr& aShape = aPrs.shape();
+ if (aShape.get() && !aShape->isNull()) {
+ if (aShape->shapeType() == GeomAPI_Shape::EDGE) {
+ const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+ TopoDS_Edge aEdge = TopoDS::Edge(aTDShape);
Standard_Real aStart, aEnd;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
GeomAdaptor_Curve aAdaptor(aCurve);
return false;
ModuleBase_ViewerPrs aPrs = aList.first();
- const TopoDS_Shape& aShape = aPrs.shape();
- if (aShape.IsNull())
+ const GeomShapePtr& aShape = aPrs.shape();
+ if (!aShape.get() || aShape->isNull() || aShape->shapeType() != GeomAPI_Shape::EDGE)
return false;
-
- if (aShape.ShapeType() != TopAbs_EDGE)
- return false;
-
- std::shared_ptr<GeomAPI_Shape> aShapePtr(new GeomAPI_Shape);
- aShapePtr->setImpl(new TopoDS_Shape(aShape));
- GeomAPI_Edge aEdge1(aShapePtr);
+ GeomAPI_Edge aEdge1(aShape);
if (aEdge1.isLine() || aEdge1.isArc()) {
if (aList.size() == 2) {
// Check second selection
aPrs = aList.last();
- const TopoDS_Shape& aShape2 = aPrs.shape();
- if (aShape2.IsNull())
- return false;
-
- if (aShape2.ShapeType() != TopAbs_EDGE)
+ const GeomShapePtr& aShape2 = aPrs.shape();
+ if (!aShape2.get() || aShape2->isNull() || aShape2->shapeType() != GeomAPI_Shape::EDGE)
return false;
+ GeomAPI_Edge aEdge2(aShape2);
- std::shared_ptr<GeomAPI_Shape> aShapePtr2(new GeomAPI_Shape);
- aShapePtr2->setImpl(new TopoDS_Shape(aShape2));
- GeomAPI_Edge aEdge2(aShapePtr2);
if (aEdge1.isLine() && aEdge2.isArc())
return true;
else if (aEdge1.isArc() && aEdge2.isLine())
int aCount = 0;
int aType = 0;
foreach (ModuleBase_ViewerPrs aPrs, aList) {
- std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
- aShape->setImpl(new TopoDS_Shape(aPrs.shape()));
- if (aShape->isEdge()) {
+ GeomShapePtr aShape = aPrs.shape();
+ if (aShape.get() && aShape->isEdge()) {
aCount++;
GeomAPI_Edge aEdge(aShape);
if (aEdge.isLine()) {
return isDone;
ModuleBase_ViewerPrs aValue = theValues.takeFirst();
- TopoDS_Shape aShape = aValue.shape();
- if (!aShape.IsNull()) {
+ GeomShapePtr aShape = aValue.shape();
+ if (aShape.get() && !aShape->isNull()) {
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
double aX, aY;
- if (getPoint2d(aView, aShape, aX, aY)) {
+ const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+ if (getPoint2d(aView, aTDShape, aX, aY)) {
isDone = setPoint(aX, aY);
PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY);
}
// 1. hide main planes if they have been displayed
erasePreviewPlanes();
// 2. if the planes were displayed, change the view projection
- TopoDS_Shape aShape = thePrs.shape();
+ const GeomShapePtr& aShape = thePrs.shape();
std::shared_ptr<GeomAPI_Shape> aGShape;
std::shared_ptr<GeomAPI_Shape> aBaseShape;
(aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
// selection happens in OCC viewer
- if (!aShape.IsNull()) {
- aGShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
- aGShape->setImpl(new TopoDS_Shape(aShape));
+ if (aShape.get() && !aShape->isNull()) {
+ aGShape = aShape;
if (aSelAttr && aSelAttr->context()) {
aBaseShape = aSelAttr->context()->shape();
{
bool isOwnerSet = false;
- const TopoDS_Shape& aShape = thePrs.shape();
+ const GeomShapePtr& aShape = thePrs.shape();
std::shared_ptr<GeomAPI_Dir> aDir;
if (thePrs.object() && (feature() != thePrs.object())) {
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
if (aRes) {
GeomShapePtr aShapePtr(new GeomAPI_Shape());
- if (aShape.IsNull()) { // selection happens in the OCC viewer
+ if (!aShape.get() || aShape->isNull()) { // selection happens in the OCC viewer
aShapePtr = ModelAPI_Tools::shape(aRes);
}
else { // selection happens in OB browser
- aShapePtr->setImpl(new TopoDS_Shape(aShape));
+ aShapePtr = aShape;
}
if (aShapePtr.get() != NULL) {
aSelAttr->setValue(aRes, aShapePtr);
}
}
}
- else if (!aShape.IsNull()) {
- aDir = setSketchPlane(aShape);
+ else if (aShape.get() && !aShape->isNull()) {
+ const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+ aDir = setSketchPlane(aTDShape);
isOwnerSet = aDir.get();
}
return isOwnerSet;
aContext->UnhilightSelected(false);
aContext->ClearSelected(false);
foreach (ModuleBase_ViewerPrs aPrs, theValues) {
- const TopoDS_Shape& aShape = aPrs.shape();
- if (!aShape.IsNull()) {
+ const GeomShapePtr& aGeomShape = aPrs.shape();
+ if (aGeomShape.get() && !aGeomShape->isNull()) {
+ const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
aContext->AddOrRemoveSelected(aShape, false);
} else {
ObjectPtr anObject = aPrs.object();
for (; anIt != aLast; anIt++) {
ObjectPtr anObject = *anIt;
if (anObject.get() != NULL && !aPresentationObjects.contains(anObject)) {
- thePresentations.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));
+ thePresentations.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL));
}
}
}
if (aShape.IsNull())
aShape = findAxisShape(anIO);
#endif
- if (!aShape.IsNull())
- thePrs.setShape(aShape);
+ if (!aShape.IsNull()) {
+ std::shared_ptr<GeomAPI_Shape> aGeomShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+ aGeomShape->setImpl(new TopoDS_Shape(aShape));
+ thePrs.setShape(aGeomShape);
+ }
} else {
#ifdef DEBUG_DELIVERY
// Fill by trihedron shapes
BRep_Builder aBuilder;
TopoDS_Edge aEdge;
aBuilder.MakeEdge(aEdge, aTLine, Precision::Confusion());
- if (!aEdge.IsNull())
- thePrs.setShape(aEdge);
+ if (!aEdge.IsNull()) {
+ std::shared_ptr<GeomAPI_Shape> aGeomShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+ aGeomShape->setImpl(new TopoDS_Shape(aEdge));
+ thePrs.setShape(aGeomShape);
+ }
} else {
Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast(anIO);
if (!aPoint.IsNull()) {
BRep_Builder aBuilder;
TopoDS_Vertex aVertex;
aBuilder.MakeVertex(aVertex, aPnt->Pnt(), Precision::Confusion());
- if (!aVertex.IsNull())
- thePrs.setShape(aVertex);
+ if (!aVertex.IsNull()) {
+ std::shared_ptr<GeomAPI_Shape> aGeomShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+ aGeomShape->setImpl(new TopoDS_Shape(aVertex));
+ thePrs.setShape(aGeomShape);
+ }
}
}
#endif
if (aResult.get()) {
ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(aResult);
if (aCompSolid.get()) {
- GeomShapePtr aShapePtr = aCompSolid->shape();
- if (aShapePtr.get()) {
- TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
- if (aShape.IsEqual(thePrs.shape())) {
- thePrs.setObject(aCompSolid);
- return;
- }
+ GeomShapePtr aShape = aCompSolid->shape();
+ if (aShape.get() && aShape->isEqual(thePrs.shape())) {
+ thePrs.setObject(aCompSolid);
+ return;
}
}
}
aPrs.setObject(aResult);
if (aContext->HasOpenedContext()) {
TopoDS_Shape aShape = aContext->DetectedShape();
- if (!aShape.IsNull())
- aPrs.setShape(aShape);
+ if (!aShape.IsNull()) {
+ std::shared_ptr<GeomAPI_Shape> aGeomShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+ aGeomShape->setImpl(new TopoDS_Shape(aShape));
+ aPrs.setShape(aGeomShape);
+ }
}
aPresentations.push_back(aPrs);
}