It provides an infinite state for plane/axis shapes.
std::shared_ptr<GeomAPI_Pnt> aStart = GeomAlgoAPI_PointBuilder::point(aShape1);
std::shared_ptr<GeomAPI_Pnt> anEnd = GeomAlgoAPI_PointBuilder::point(aShape2);
if (aStart->distance(anEnd) > ConstructionPlugin_Axis::MINIMAL_LENGTH()) {
- std::shared_ptr<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd);
+ std::shared_ptr<GeomAPI_Edge> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd, true);
ResultConstructionPtr aConstr = document()->createConstruction(data());
aConstr->setShape(anEdge);
isCustomized = thePrs->setLineStyle(3) || isCustomized;
isCustomized = thePrs->setWidth(2) || isCustomized;
- thePrs->setInfiniteState(true);
-
return isCustomized;
}
return isChanged;
}
-bool GeomAPI_AISObject::setInfiniteState(const bool theState)
-{
- bool isChanged = false;
- Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
- if (!anAIS.IsNull() && anAIS->IsInfinite() != theState) {
- anAIS->SetInfiniteState(theState);
- isChanged = true;
-
- bool isInfinite = anAIS->IsInfinite();
- int aValue = 9;
- }
- return isChanged;
-}
-
-
bool GeomAPI_AISObject::setTransparensy(double theVal)
{
bool isChanged = false;
/// \returns true if the object value differs from the current
bool setLineStyle(int theStyle);
- //! Sets the infinite state flag aFlage.
- //! considered as infinite, i.e. its graphic presentations
- //! are not taken in account for View FitAll...
- //! \param theState a state
- /// \returns true if the object value differs from the current
- bool setInfiniteState(const bool theState);
-
/// Set transparency of the presentation (theVal = 0 ... 1)
/// \returns true if the object value differs from the current
bool setTransparensy(double theVal);
#include <gp_Circ.hxx>
std::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::line(
- std::shared_ptr<GeomAPI_Pnt> theStart, std::shared_ptr<GeomAPI_Pnt> theEnd)
+ std::shared_ptr<GeomAPI_Pnt> theStart, std::shared_ptr<GeomAPI_Pnt> theEnd,
+ const bool theInfinite)
{
const gp_Pnt& aStart = theStart->impl<gp_Pnt>();
const gp_Pnt& anEnd = theEnd->impl<gp_Pnt>();
BRepBuilderAPI_MakeEdge anEdgeBuilder(aStart, anEnd);
std::shared_ptr<GeomAPI_Edge> aRes(new GeomAPI_Edge);
TopoDS_Edge anEdge = anEdgeBuilder.Edge();
+ if (theInfinite)
+ anEdge.Infinite(Standard_True);
aRes->setImpl(new TopoDS_Shape(anEdge));
return aRes;
}
BRepBuilderAPI_MakeEdge anEdgeBuilder(aStart, anEnd);
std::shared_ptr<GeomAPI_Edge> aRes(new GeomAPI_Edge);
TopoDS_Edge anEdge = anEdgeBuilder.Edge();
+ // an axis is an infinite object
+ anEdge.Infinite(Standard_True);
aRes->setImpl(new TopoDS_Shape(anEdge));
return aRes;
}
class GEOMALGOAPI_EXPORT GeomAlgoAPI_EdgeBuilder
{
public:
- /// Creates linear edge by two points
+ /// Creates linear edge by two points.
+ /// \param theStart a first point of an edge
+ /// \param theEnd an end point of an edge
+ /// \param theInfinite if true, the shape of the edge is infinite. It is used for axis edge.
static std::shared_ptr<GeomAPI_Edge> line(std::shared_ptr<GeomAPI_Pnt> theStart,
- std::shared_ptr<GeomAPI_Pnt> theEnd);
- /// Creates edge - axis of the given cylindrical face
+ std::shared_ptr<GeomAPI_Pnt> theEnd,
+ const bool theInfinite = false);
+ /// Creates edge - axis of the given cylindrical face. The result axis edge is infinite
static std::shared_ptr<GeomAPI_Edge> cylinderAxis(
std::shared_ptr<GeomAPI_Shape> theCylindricalFace);
std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
std::shared_ptr<GeomAPI_Pln> thePlane,
- const double theSize)
+ const double theSize,
+ const bool theInfinite)
{
// half of the size in each direction from the center
BRepBuilderAPI_MakeFace aFaceBuilder(thePlane->impl<gp_Pln>(),
-theSize / 2., theSize / 2.,
-theSize / 2., theSize / 2.);
std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
- aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
+ TopoDS_Shape aFace = aFaceBuilder.Face();
+ if (theInfinite)
+ aFace.Infinite(Standard_True);
+ aRes->setImpl(new TopoDS_Shape(aFace/*aFaceBuilder.Face()*/));
return aRes;
}
/// Creates square planar face by given point of the center,
/// normal to the plane and size of square
static std::shared_ptr<GeomAPI_Shape> square(std::shared_ptr<GeomAPI_Pln> thePlane,
- const double theSize);
+ const double theSize,
+ const bool theInfinite = false);
/// Returns the plane of the planar face. If it is not planar, returns empty ptr.
static std::shared_ptr<GeomAPI_Pln> plane(std::shared_ptr<GeomAPI_Shape> theFace);
#include "PartSet_FilterInfinite.h"
#include <AIS_InteractiveObject.hxx>
+#include <AIS_Shape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <StdSelect_BRepOwner.hxx>
IMPLEMENT_STANDARD_HANDLE(PartSet_FilterInfinite, SelectMgr_Filter);
IMPLEMENT_STANDARD_RTTIEXT(PartSet_FilterInfinite, SelectMgr_Filter);
Standard_Boolean PartSet_FilterInfinite::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
{
+ Standard_Boolean aValid = Standard_True;
Handle(AIS_InteractiveObject) anAISObj =
Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
- if (!anAISObj.IsNull() && anAISObj->IsInfinite()) {
- return Standard_False;
+ if (!anAISObj.IsNull()) {
+ Handle(AIS_InteractiveObject) anObj =
+ Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+ Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(anObj);
+ if (!aAISShape.IsNull()) {
+ TopoDS_Shape anAISShape = aAISShape->Shape();
+ if (!anAISShape.IsNull() && anAISShape.Infinite()) {
+ aValid = Standard_False;
+ // for infinite object, the selection is possible only for shapes of owners, which are coincide
+ // to the shape of corresponded AIS object. In other words, for axis, only edge can be selected
+ // (vertices are not selectable), for planes, only faces can be selected (not edges or vertices)
+ TopoDS_Shape anOwnerShape;
+ Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
+ if( !aBRO.IsNull() ) {
+ anOwnerShape = aBRO->Shape();
+ if (!anOwnerShape.IsNull()) {
+ aValid = anAISShape.ShapeType() == anOwnerShape.ShapeType();
+ }
+ }
+ }
+ }
}
- return Standard_True;
+ return aValid;
}
Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
+
+ if (myFilterInfinite.IsNull())
+ myFilterInfinite = new PartSet_FilterInfinite();
+ myWorkshop->viewer()->addSelectionFilter(myFilterInfinite);
}
PartSet_Module::~PartSet_Module()
{
if (!myDocumentShapeFilter.IsNull())
myDocumentShapeFilter.Nullify();
+ if (!myFilterInfinite.IsNull())
+ myFilterInfinite.Nullify();
}
void PartSet_Module::registerValidators()
#include "PartSet.h"
#include "PartSet_Filters.h"
#include "PartSet_DocumentDataModel.h"
+#include "PartSet_FilterInfinite.h"
#include <ModuleBase_IModule.h>
#include <ModuleBase_Definitions.h>
/// A filter which provides selection within a current document or whole PartSet
Handle(PartSet_GlobalFilter) myDocumentShapeFilter;
+ Handle(PartSet_FilterInfinite) myFilterInfinite;
PartSet_SketcherMgr* mySketchMgr;
{
if (!myPlaneFilter.IsNull())
myPlaneFilter.Nullify();
- if (!myFilterInfinite.IsNull())
- myFilterInfinite.Nullify();
-
}
void PartSet_SketcherMgr::onEnterViewPort()
if (myPlaneFilter.IsNull())
myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
- if (myFilterInfinite.IsNull())
- myFilterInfinite = new PartSet_FilterInfinite();
-
myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
- myModule->workshop()->viewer()->addSelectionFilter(myFilterInfinite);
bool aHasPlane = false;
if (theOperation->isEditOperation()) {
// The sketch was aborted
myCurrentSketch = CompositeFeaturePtr();
myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
- myModule->workshop()->viewer()->removeSelectionFilter(myFilterInfinite);
// Erase all sketcher objects
QStringList aSketchIds = sketchOperationIdList();
myCurrentSketch = CompositeFeaturePtr();
myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
- myModule->workshop()->viewer()->removeSelectionFilter(myFilterInfinite);
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
}
#include "PartSet.h"
-#include "PartSet_FilterInfinite.h"
-
#include <ModelAPI_Feature.h>
#include <ModelAPI_Attribute.h>
#include <ModelAPI_CompositeFeature.h>
CompositeFeaturePtr myCurrentSketch;
Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
- Handle(PartSet_FilterInfinite) myFilterInfinite;
FeatureToSelectionMap myCurrentSelection;
bool myPreviousUpdateViewerEnabled;