mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
connect(aLabelWgt, SIGNAL(showConstraintToggled(int, bool)),
mySketchMgr, SLOT(onShowConstraintsToggle(int, bool)));
+ connect(aLabelWgt, SIGNAL(showFreePoints(bool)), mySketchMgr, SLOT(onShowPoints(bool)));
+ aLabelWgt->setShowPointsState(mySketchMgr->isShowFreePointsShown());
aWgt = aLabelWgt;
} else if (theType == "sketch-2dpoint_selector") {
PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, aWorkshop,
#include <GeomDataAPI_Point2D.h>
+#include <GeomAPI_Shape.h>
+
#include <Events_Loop.h>
#include <SketchPlugin_Line.h>
delete myExternalPointsMgr;
myExternalPointsMgr = 0;
}
+ onShowPoints(false);
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
}
if (isClearSelectionPossible)
workshop()->selector()->clearSelection();
+ if (myPointsHighlight.size())
+ onShowPoints(true);
}
void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
return workshop()->operationMgr();
}
+void PartSet_SketcherMgr::onShowPoints(bool toShow)
+{
+ if (!myCurrentSketch.get())
+ return;
+ ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ ModuleBase_IViewer* aViewer = aWorkshop->viewer();
+ Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
+
+ bool aToUpdate = false;
+ if (toShow) {
+ std::list<ResultPtr> aFreePoints = SketcherPrs_Tools::getFreePoints(myCurrentSketch);
+
+ // Delete obsolete presentations
+ std::list<ResultPtr> aDelList;
+ foreach(ResultPtr aObj, myPointsHighlight.keys()) {
+ bool aFound = (std::find(aFreePoints.begin(), aFreePoints.end(), aObj) != aFreePoints.end());
+ if (!aFound)
+ aDelList.push_back(aObj);
+ }
+ foreach(ResultPtr aObj, aDelList) {
+ aContext->Remove(myPointsHighlight[aObj], false);
+ aToUpdate = true;
+ myPointsHighlight.remove(aObj);
+ }
+
+ // Display new objects
+ QList<ResultPtr> aKeysList = myPointsHighlight.keys();
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aFreePoints.cbegin(); aIt != aFreePoints.cend(); aIt++) {
+ if (!aKeysList.contains(*aIt)) {
+ GeomShapePtr aShapePtr = (*aIt)->shape();
+ TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
+ Handle(AIS_Shape) aShapePrs = new AIS_Shape(aShape);
+ aShapePrs->SetColor(Quantity_NOC_BLUE1);
+ aShapePrs->SetZLayer(Graphic3d_ZLayerId_Top);
+ Handle(Prs3d_Drawer) aDrawer = aShapePrs->Attributes();
+ if (aDrawer->HasOwnPointAspect()) {
+ aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_O_STAR);
+ aDrawer->PointAspect()->SetColor(Quantity_NOC_BLUE1);
+ aDrawer->PointAspect()->SetScale(2);
+ }
+ else
+ aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_O_STAR, Quantity_NOC_BLUE1, 2));
+ aContext->Display(aShapePrs, false);
+ aContext->Deactivate(aShapePrs);
+ myPointsHighlight[*aIt] = aShapePrs;
+ aToUpdate = true;
+ }
+ }
+ }
+ else {
+ foreach(Handle(AIS_Shape) aPrs, myPointsHighlight.values()) {
+ aContext->Remove(aPrs, false);
+ aToUpdate = true;
+ }
+ myPointsHighlight.clear();
+ }
+ if (aToUpdate)
+ aViewer->update();
+}
#include <TopoDS_Shape.hxx>
#include <TopTools_MapOfShape.hxx>
+#include <AIS_Shape.hxx>
#include <QObject>
#include <QList>
void updateBySketchParameters(const PartSet_Tools::ConstraintVisibleState& theType,
bool theState);
+ bool isShowFreePointsShown() const {
+ return myPointsHighlight.size() > 0;
+ }
+
public slots:
/// Process sketch plane selected event
void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
+ void onShowPoints(bool toShow);
+
private slots:
/// Toggle show constraints
void onShowConstraintsToggle(int theType, bool theState);
QMap<PartSet_Tools::ConstraintVisibleState, bool> myIsConstraintsShown;
PartSet_ExternalPointsMgr* myExternalPointsMgr;
+
+ QMap<ResultPtr, Handle(AIS_Shape)> myPointsHighlight;
};
if (toShowConstraints.contains(aState))
aShowConstraints->setChecked(toShowConstraints[aState]);
}
-
+ myShowPoints = new QCheckBox(tr("Show free points"), this);
+ connect(myShowPoints, SIGNAL(toggled(bool)), this, SIGNAL(showFreePoints(bool)));
+ aLayout->addWidget(myShowPoints);
QPushButton* aPlaneBtn = new QPushButton(tr("Change sketch plane"), aSecondWgt);
connect(aPlaneBtn, SIGNAL(clicked(bool)), SLOT(onChangePlane()));
aMgr->startOperation();
myOpenTransaction = true;
}
-}
\ No newline at end of file
+}
+
+void PartSet_WidgetSketchLabel::setShowPointsState(bool theState)
+{
+ bool aBlock = myShowPoints->blockSignals(true);
+ myShowPoints->setChecked(theState);
+ myShowPoints->blockSignals(aBlock);
+}
virtual void setHighlighted(bool) { /*do nothing*/ };
virtual void enableFocusProcessing();
+ /// Set current state of show free points
+ /// \param theState a state of the corresponded check box
+ void setShowPointsState(bool theState);
+
/// Returns True if the selected presentation can be used for plane definition
/// \param thePrs a presentation
static bool canFillSketch(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
/// \param theState a state of the check box
void showConstraintToggled(int theType, bool theState);
+ void showFreePoints(bool toShow);
+
protected:
/// Creates a backup of the current values of the attribute
/// It should be realized in the specific widget because of different
QCheckBox* myViewInverted;
QCheckBox* myRemoveExternal;
+ QCheckBox* myShowPoints;
QMap<PartSet_Tools::ConstraintVisibleState, QCheckBox*> myShowConstraints;