1. Using AttributeSelection instead of AttrRef for external line to use result+shape
2. switch off plane filter when the corresponded control is active
3. correction: propety panel is empty if the constraint is selected as point attribute does not present in XML
virtual bool isViewerSelector() { return true; }
/// Activate or deactivate selection and selection filters
- void activateSelectionAndFilters(bool toActivate);
+ virtual void activateSelectionAndFilters(bool toActivate);
/// Checks the widget validity. By default, it returns true.
/// \param thePrs a selected presentation in the view
aFactory.createWidget(aPropertyPanel->contentWidget(), anAttributeId);
theWidgets = aFactory.getModelWidgets();
- aProcessed = true;
+ // it is possible that the point does not present in XML definition,
+ // in this case, we assume that it is not processed by this module
+ // e.g. "Intersection point" feature
+ aProcessed = !theWidgets.isEmpty();
}
}
}
#include <SketchPlugin_ConstraintMiddle.h>
#include <SketchPlugin_MultiRotation.h>
#include <SketchPlugin_MultiTranslation.h>
+#include <SketchPlugin_IntersectionPoint.h>
#include <SketcherPrs_Tools.h>
//#define DEBUG_CURSOR
-//#define DEBUG_INTERSECTION_POINT
-
/// Returns list of unique objects by sum of objects from List1 and List2
/*QList<ModuleBase_ViewerPrs> getSumList(const QList<ModuleBase_ViewerPrs>& theList1,
const QList<ModuleBase_ViewerPrs>& theList2)
aIds << SketchPlugin_Arc::ID().c_str();
aIds << SketchPlugin_Circle::ID().c_str();
aIds << SketchPlugin_ConstraintFillet::ID().c_str();
- aIds << SketchPlugin_Circle::ID().c_str();
+ aIds << SketchPlugin_IntersectionPoint::ID().c_str();
// TODO
// SketchRectangle is a python feature, so its ID is passed just as a string
aIds << "SketchRectangle";
if (myPlaneFilter.IsNull())
myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
-#ifndef DEBUG_INTERSECTION_POINT
myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
-#endif
bool aHasPlane = false;
std::shared_ptr<GeomAPI_Pln> aPln;
if (aFOperation->isEditOperation()) {
}
}
+void PartSet_SketcherMgr::activatePlaneFilter(const bool& toActivate)
+{
+ if (toActivate)
+ myModule->workshop()->viewer()->addSelectionFilter(myPlaneFilter);
+ else
+ myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
+}
+
void PartSet_SketcherMgr::operationActivatedByPreselection()
{
ModuleBase_Operation* anOperation = getCurrentOperation();
/// \param theOperation a committed operation
void commitNestedSketch(ModuleBase_Operation* theOperation);
+ /// Append the sketch plane filter into the current viewer
+ /// \param toActivate state whether the filter should be activated/deactivated
+ void activatePlaneFilter(const bool& toActivate);
+
/// Commit the operation if it is possible. If the operation is dimention constraint,
/// it gives widget editor to input dimention value
void operationActivatedByPreselection();
// Author: Vitaly Smetannikov
#include "PartSet_WidgetShapeSelector.h"
+#include "PartSet_Module.h"
+#include "PartSet_SketcherMgr.h"
#include <ModelAPI_AttributeRefAttr.h>
#include <ModelAPI_Session.h>
#include <XGUI_Displayer.h>
#include <XGUI_SelectionMgr.h>
#include <XGUI_Selection.h>
+#include <XGUI_Tools.h>
PartSet_WidgetShapeSelector::PartSet_WidgetShapeSelector(QWidget* theParent,
ModuleBase_IWorkshop* theWorkshop,
const std::string& theParentId)
: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData, theParentId)
{
+ myUseSketchPlane = theData->getBooleanAttribute("use_sketch_plane", true);
myExternalObjectMgr = new PartSet_ExternalObjectsMgr(theData->getProperty("use_external"), true);
}
delete myExternalObjectMgr;
}
+//********************************************************************
+void PartSet_WidgetShapeSelector::activateSelectionAndFilters(bool toActivate)
+{
+ ModuleBase_WidgetShapeSelector::activateSelectionAndFilters(toActivate);
+ if (!myUseSketchPlane) {
+ XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(aWorkshop->module());
+ aModule->sketchMgr()->activatePlaneFilter(false);
+ }
+}
+
//********************************************************************
bool PartSet_WidgetShapeSelector::isValidSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
{
/// Retrurns installed sketcher
CompositeFeaturePtr sketch() const { return mySketch; }
+ /// Activate or deactivate selection and selection filters
+ /// \param toActivate boolean state whether it should be activated/deactivated
+ virtual void activateSelectionAndFilters(bool toActivate);
+
protected:
/// Checks the widget validity. By default, it returns true.
/// \param thePrs a selected presentation in the view
/// Pointer to a sketch
CompositeFeaturePtr mySketch;
+
+ bool myUseSketchPlane; /// state whether the sketch plane filter should be switched on
};
#endif
\ No newline at end of file
{
AttributeSelectionPtr aLineAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(attribute(EXTERNAL_LINE_ID()));
- ResultPtr aLineResult = std::dynamic_pointer_cast<ModelAPI_Result>(aLineAttr->context());
- if (!aLineResult)
+
+ std::shared_ptr<GeomAPI_Edge> anEdge;
+ if(aLineAttr && aLineAttr->value() && aLineAttr->value()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aLineAttr->value()));
+ } else if(aLineAttr->context() && aLineAttr->context()->shape() && aLineAttr->context()->shape()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aLineAttr->context()->shape()));
+ }
+ if(!anEdge.get())
return;
- std::shared_ptr<GeomAPI_Edge> aLinearEdge =
- std::dynamic_pointer_cast<GeomAPI_Edge>(aLineResult->shape());
- std::shared_ptr<GeomAPI_Lin> aLine = aLinearEdge->line();
+ std::shared_ptr<GeomAPI_Lin> aLine = anEdge->line();
std::shared_ptr<GeomAPI_Pln> aSketchPlane = sketch()->plane();
std::shared_ptr<GeomAPI_Pnt> anIntersection = aSketchPlane->intersect(aLine);
theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
return false;
}
- AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
- ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anAttr->context());
- if (!aResult) {
- theError = "The attribute " + theAttribute->id() + " should be an object";
- return false;
+ AttributeSelectionPtr aLineAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+ std::shared_ptr<GeomAPI_Edge> anEdge;
+ if(aLineAttr && aLineAttr->value() && aLineAttr->value()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aLineAttr->value()));
+ } else if(aLineAttr->context() && aLineAttr->context()->shape() && aLineAttr->context()->shape()->isEdge()) {
+ anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aLineAttr->context()->shape()));
}
- std::shared_ptr<GeomAPI_Edge> anEdge = std::dynamic_pointer_cast<GeomAPI_Edge>(aResult->shape());
if (!anEdge || !anEdge->isLine()) {
theError = "The attribute " + theAttribute->id() + " should be a line";
return false;
// find a sketch
std::shared_ptr<SketchPlugin_Sketch> aSketch;
- std::set<AttributePtr> aRefs = anAttr->owner()->data()->refsToMe();
+ std::set<AttributePtr> aRefs = aLineAttr->owner()->data()->refsToMe();
std::set<AttributePtr>::const_iterator anIt = aRefs.begin();
for (; anIt != aRefs.end(); ++anIt) {
CompositeFeaturePtr aComp =
std::shared_ptr<GeomAPI_Pln> aPlane = aSketch->plane();
std::shared_ptr<GeomAPI_Dir> aNormal = aPlane->direction();
- return true;//fabs(aNormal->dot(aLineDir)) > tolerance * tolerance;
+ return fabs(aNormal->dot(aLineDir)) > tolerance * tolerance;
}
id="ExternalLine"
label="Edge"
tooltip="Select external line."
- shape_types="edge">
+ shape_types="edge"
+ use_external="false"
+ use_sketch_plane="false">
<validator id="GeomValidators_ShapeType" parameters="line"/>
<validator id="SketchPlugin_IntersectionValidator"/>
</sketch_shape_selector>
#include "XGUI_Tools.h"
+#include "XGUI_ModuleConnector.h"
+#include "XGUI_Workshop.h"
+
+#include "ModuleBase_IWorkshop.h"
+
#include <TopoDS_Shape.hxx>
#include <ModelAPI_Object.h>
#include <ModelAPI_Result.h>
}
}
+XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop)
+{
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(theWorkshop);
+ return aConnector->workshop();
+}
+
}
#include <memory>
class QWidget;
+class XGUI_Workshop;
+class ModuleBase_IWorkshop;
/*!
\ingroup GUI
* \returns boolean value
*/
bool XGUI_EXPORT isSubOfComposite(const ObjectPtr& theObject);
+
+/*!
+ Returns converted workshop
+ \param theWorkshop an interface workshop
+ \return XGUI workshop instance
+*/
+XGUI_EXPORT XGUI_Workshop* workshop(ModuleBase_IWorkshop* theWorkshop);
+
};
#endif