Merge pull request #19019 from hyarion/refactor/countObjectsOfType
Refactor countObjectsOfType in selection and document
This commit is contained in:
@@ -486,7 +486,7 @@ void CmdPartDesignClone::activated(int iMsg)
|
||||
|
||||
bool CmdPartDesignClone::isActive()
|
||||
{
|
||||
return getSelection().countObjectsOfType(Part::Feature::getClassTypeId()) == 1;
|
||||
return getSelection().countObjectsOfType<Part::Feature>() == 1;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -707,7 +707,7 @@ std::tuple<bool, PartDesign::Body*> SketchWorkflow::shouldCreateBody()
|
||||
pdBody->Placement.setValue(xLink->Placement.getValue());
|
||||
}
|
||||
if (!pdBody) {
|
||||
if (appdocument->countObjectsOfType(PartDesign::Body::getClassTypeId()) == 0) {
|
||||
if (appdocument->countObjectsOfType<PartDesign::Body>() == 0) {
|
||||
shouldMakeBody = true;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -121,7 +121,7 @@ PartDesign::Body *getBody(bool messageIfNot, bool autoActivate, bool assertModer
|
||||
|
||||
if (activeView) {
|
||||
auto doc = activeView->getAppDocument();
|
||||
bool singleBodyDocument = doc->countObjectsOfType(PartDesign::Body::getClassTypeId()) == 1;
|
||||
bool singleBodyDocument = doc->countObjectsOfType<PartDesign::Body>() == 1;
|
||||
if (assertModern) {
|
||||
activeBody = activeView->getActiveObject<PartDesign::Body*>(PDBODYKEY,topParent,subname);
|
||||
|
||||
|
||||
@@ -101,13 +101,10 @@ void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) con
|
||||
*item << "Std_ToggleFreeze";
|
||||
}
|
||||
|
||||
bool docHaveBodies = activeView->getAppDocument()->countObjectsOfType (
|
||||
PartDesign::Body::getClassTypeId () ) > 0;
|
||||
|
||||
if ( docHaveBodies ) {
|
||||
if (activeView->getAppDocument()->countObjectsOfType<PartDesign::Body>() > 0) {
|
||||
bool addMoveFeature = true;
|
||||
bool addMoveFeatureInTree = (body != nullptr);
|
||||
for (auto sel: selection) {
|
||||
for (auto sel : selection) {
|
||||
// if at least one selected feature cannot be moved to a body
|
||||
// disable the entry
|
||||
if ( addMoveFeature && !PartDesign::Body::isAllowed ( sel.pObject ) ) {
|
||||
@@ -132,11 +129,11 @@ void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) con
|
||||
}
|
||||
}
|
||||
|
||||
if (Gui::Selection().countObjectsOfType(PartDesign::Transformed::getClassTypeId()) -
|
||||
Gui::Selection().countObjectsOfType(PartDesign::MultiTransform::getClassTypeId()) == 1 )
|
||||
if (Gui::Selection().countObjectsOfType<PartDesign::Transformed>() -
|
||||
Gui::Selection().countObjectsOfType<PartDesign::MultiTransform>() == 1 )
|
||||
*item << "PartDesign_MultiTransform";
|
||||
|
||||
if (Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0) {
|
||||
if (Gui::Selection().countObjectsOfType<App::DocumentObject>() > 0) {
|
||||
*item << "Std_Placement"
|
||||
<< "Std_ToggleVisibility"
|
||||
<< "Std_ShowSelection"
|
||||
|
||||
Reference in New Issue
Block a user