Sketcher: Refactor miscelaneous command isActive()
This commit is contained in:
committed by
abdullahtahiriyo
parent
fbbadde9fe
commit
fe405fcefb
@@ -315,22 +315,28 @@ void SketcherGui::ActivateHandler(Gui::Document* doc, DrawSketchHandler* handler
|
||||
}
|
||||
}
|
||||
|
||||
bool SketcherGui::isCommandActive(Gui::Document* doc, bool actsOnSelection)
|
||||
{
|
||||
bool SketcherGui::isSketchInEdit(Gui::Document* doc) {
|
||||
if (doc) {
|
||||
// checks if a Sketch Viewprovider is in Edit and is in no special mode
|
||||
if (doc->getInEdit()
|
||||
&& doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) {
|
||||
auto mode =
|
||||
static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit())->getSketchMode();
|
||||
if (mode == ViewProviderSketch::STATUS_NONE
|
||||
|| mode == ViewProviderSketch::STATUS_SKETCH_UseHandler) {
|
||||
if (!actsOnSelection)
|
||||
return true;
|
||||
else if (Gui::Selection().countObjectsOfType(
|
||||
Sketcher::SketchObject::getClassTypeId())
|
||||
> 0)
|
||||
return true;
|
||||
auto* vp = dynamic_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
|
||||
return (vp != nullptr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SketcherGui::isCommandActive(Gui::Document* doc, bool actsOnSelection)
|
||||
{
|
||||
if(isSketchInEdit(doc)) {
|
||||
auto mode = static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit())->getSketchMode();
|
||||
|
||||
if (mode == ViewProviderSketch::STATUS_NONE ||
|
||||
mode == ViewProviderSketch::STATUS_SKETCH_UseHandler) {
|
||||
|
||||
if (!actsOnSelection) {
|
||||
return true;
|
||||
}
|
||||
else if (Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user