[Sketcher] Disable constraints selection when geometry/constraint handler is active
This commit is contained in:
committed by
abdullahtahiriyo
parent
3b16914a9c
commit
a12f5f2691
@@ -61,6 +61,11 @@ using namespace Sketcher;
|
||||
|
||||
/************************************ Attorney *******************************************/
|
||||
|
||||
inline void ViewProviderSketchDrawSketchHandlerAttorney::setConstraintSelectability(ViewProviderSketch &vp, bool enabled /*= true*/)
|
||||
{
|
||||
vp.setConstraintSelectability(enabled);
|
||||
}
|
||||
|
||||
inline void ViewProviderSketchDrawSketchHandlerAttorney::setPositionText(ViewProviderSketch &vp, const Base::Vector2d &Pos, const SbString &txt)
|
||||
{
|
||||
vp.setPositionText(Pos,txt);
|
||||
@@ -116,6 +121,16 @@ DrawSketchHandler::DrawSketchHandler() : sketchgui(0) {}
|
||||
|
||||
DrawSketchHandler::~DrawSketchHandler() {}
|
||||
|
||||
void DrawSketchHandler::preActivated(ViewProviderSketch* vp)
|
||||
{
|
||||
ViewProviderSketchDrawSketchHandlerAttorney::setConstraintSelectability(*vp, false);
|
||||
}
|
||||
|
||||
void DrawSketchHandler::postDeactivatedAlwaysRun(ViewProviderSketch* vp)
|
||||
{
|
||||
ViewProviderSketchDrawSketchHandlerAttorney::setConstraintSelectability(*vp, true);
|
||||
}
|
||||
|
||||
void DrawSketchHandler::quit(void)
|
||||
{
|
||||
assert(sketchgui);
|
||||
|
||||
@@ -46,6 +46,7 @@ class ViewProviderSketch;
|
||||
*/
|
||||
class ViewProviderSketchDrawSketchHandlerAttorney {
|
||||
private:
|
||||
static inline void setConstraintSelectability(ViewProviderSketch &vp, bool enabled = true);
|
||||
static inline void setPositionText(ViewProviderSketch &vp, const Base::Vector2d &Pos, const SbString &txt);
|
||||
static inline void setPositionText(ViewProviderSketch &vp, const Base::Vector2d &Pos);
|
||||
static inline void resetPositionText(ViewProviderSketch &vp);
|
||||
@@ -96,8 +97,11 @@ public:
|
||||
DrawSketchHandler();
|
||||
virtual ~DrawSketchHandler();
|
||||
|
||||
virtual void preActivated(ViewProviderSketch *);
|
||||
virtual void activated(ViewProviderSketch *){}
|
||||
virtual void deactivated(ViewProviderSketch *){}
|
||||
virtual void postDeactivated(ViewProviderSketch *){}
|
||||
static void postDeactivatedAlwaysRun(ViewProviderSketch *);
|
||||
virtual void mouseMove(Base::Vector2d onSketchPos)=0;
|
||||
virtual bool pressButton(Base::Vector2d onSketchPos)=0;
|
||||
virtual bool releaseButton(Base::Vector2d onSketchPos)=0;
|
||||
|
||||
@@ -627,6 +627,11 @@ void EditModeCoinManager::updateColor(const GeoListFacade & geolistfacade)
|
||||
pEditModeConstraintCoinManager->updateConstraintColor(constraints);
|
||||
}
|
||||
|
||||
void EditModeCoinManager::setConstraintSelectability(bool enabled /* = true */)
|
||||
{
|
||||
pEditModeConstraintCoinManager->setConstraintSelectability(enabled);
|
||||
}
|
||||
|
||||
void EditModeCoinManager::createEditModeInventorNodes()
|
||||
{
|
||||
// 1 - Create the edit root node
|
||||
|
||||
@@ -233,6 +233,11 @@ public:
|
||||
void updateGridExtent();
|
||||
//@}
|
||||
|
||||
/** @name change constraints selectability*/
|
||||
//@{
|
||||
void setConstraintSelectability(bool enabled = true);
|
||||
//@}
|
||||
|
||||
private:
|
||||
// This function populates the coin nodes with the information of the current geometry
|
||||
void processGeometry(const GeoListFacade & geolistfacade);
|
||||
|
||||
@@ -345,6 +345,7 @@ struct EditModeScenegraphNodes {
|
||||
/** @name Constraint nodes*/
|
||||
//@{
|
||||
SmSwitchboard *constrGroup;
|
||||
SoPickStyle *constrGrpSelect;
|
||||
SoDrawStyle *ConstraintDrawStyle;
|
||||
//@}
|
||||
|
||||
|
||||
@@ -1401,6 +1401,16 @@ void EditModeConstraintCoinManager::rebuildConstraintNodes(void)
|
||||
rebuildConstraintNodes(geolistfacade);
|
||||
}
|
||||
|
||||
void EditModeConstraintCoinManager::setConstraintSelectability(bool enabled /* = true */)
|
||||
{
|
||||
if (enabled) {
|
||||
editModeScenegraphNodes.constrGrpSelect->style.setValue(SoPickStyle::SHAPE);
|
||||
}
|
||||
else {
|
||||
editModeScenegraphNodes.constrGrpSelect->style.setValue(SoPickStyle::UNPICKABLE);
|
||||
}
|
||||
}
|
||||
|
||||
void EditModeConstraintCoinManager::rebuildConstraintNodes(const GeoListFacade & geolistfacade)
|
||||
{
|
||||
const std::vector<Sketcher::Constraint *> &constrlist = ViewProviderSketchCoinAttorney::getConstraints(viewProvider);
|
||||
@@ -2399,7 +2409,16 @@ void EditModeConstraintCoinManager::createEditModeInventorNodes()
|
||||
editModeScenegraphNodes.EditRoot->addChild(editModeScenegraphNodes.ConstraintDrawStyle);
|
||||
|
||||
// add the group where all the constraints has its SoSeparator
|
||||
editModeScenegraphNodes.constrGrpSelect = new SoPickStyle(); // used to toggle constraints selectability
|
||||
editModeScenegraphNodes.constrGrpSelect->style.setValue(SoPickStyle::SHAPE);
|
||||
editModeScenegraphNodes.EditRoot->addChild(editModeScenegraphNodes.constrGrpSelect);
|
||||
setConstraintSelectability(); // Ensure default value;
|
||||
|
||||
editModeScenegraphNodes.constrGroup = new SmSwitchboard();
|
||||
editModeScenegraphNodes.constrGroup->setName("ConstraintGroup");
|
||||
editModeScenegraphNodes.EditRoot->addChild(editModeScenegraphNodes.constrGroup);
|
||||
|
||||
SoPickStyle *ps = new SoPickStyle(); // used to following nodes aren't impacted
|
||||
ps->style.setValue(SoPickStyle::SHAPE);
|
||||
editModeScenegraphNodes.EditRoot->addChild(ps);
|
||||
}
|
||||
|
||||
@@ -115,6 +115,11 @@ public:
|
||||
void rebuildConstraintNodes(void);
|
||||
//@}
|
||||
|
||||
/** @name change constraints selectability*/
|
||||
//@{
|
||||
void setConstraintSelectability(bool enabled = true);
|
||||
//@}
|
||||
|
||||
std::set<int> detectPreselectionConstr( const SoPickedPoint *Point,
|
||||
const SbVec2s &cursorPos);
|
||||
|
||||
|
||||
@@ -364,6 +364,7 @@ void ViewProviderSketch::activateHandler(DrawSketchHandler *newHandler)
|
||||
sketchHandler = std::unique_ptr<DrawSketchHandler>(newHandler);
|
||||
Mode = STATUS_SKETCH_UseHandler;
|
||||
sketchHandler->sketchgui = this;
|
||||
sketchHandler->preActivated(this);
|
||||
sketchHandler->activated(this);
|
||||
|
||||
// make sure receiver has focus so immediately pressing Escape will be handled by
|
||||
@@ -382,10 +383,11 @@ void ViewProviderSketch::deactivateHandler()
|
||||
drawEdit(editCurve); // erase any line
|
||||
resetPositionText();
|
||||
sketchHandler->deactivated(this);
|
||||
sketchHandler->postDeactivated(this);
|
||||
sketchHandler->unsetCursor();
|
||||
sketchHandler = nullptr;
|
||||
}
|
||||
|
||||
DrawSketchHandler::postDeactivatedAlwaysRun(this);
|
||||
Mode = STATUS_NONE;
|
||||
}
|
||||
|
||||
@@ -3289,6 +3291,11 @@ QIcon ViewProviderSketch::mergeColorfulOverlayIcons (const QIcon & orig) const
|
||||
|
||||
/*************************** functions ViewProviderSketch offers to friends such as DrawHandlerSketch ************************/
|
||||
|
||||
void ViewProviderSketch::setConstraintSelectability(bool enabled /*= true*/)
|
||||
{
|
||||
editCoinManager->setConstraintSelectability(enabled);
|
||||
}
|
||||
|
||||
void ViewProviderSketch::setPositionText(const Base::Vector2d &Pos, const SbString &text)
|
||||
{
|
||||
editCoinManager->setPositionText(Pos,text);
|
||||
|
||||
@@ -698,6 +698,7 @@ private:
|
||||
void deleteSelected();
|
||||
|
||||
//********* ViewProviderSketchDrawSketchHandlerAttorney **********//
|
||||
void setConstraintSelectability(bool enabled = true);
|
||||
void setPositionText(const Base::Vector2d &Pos, const SbString &txt);
|
||||
void setPositionText(const Base::Vector2d &Pos);
|
||||
void resetPositionText(void);
|
||||
|
||||
Reference in New Issue
Block a user