Merge pull request #19019 from hyarion/refactor/countObjectsOfType

Refactor countObjectsOfType in selection and document
This commit is contained in:
Chris Hennes
2025-01-14 16:05:12 -06:00
committed by GitHub
31 changed files with 194 additions and 222 deletions

View File

@@ -479,7 +479,7 @@ CmdDrawingOpenBrowserView::CmdDrawingOpenBrowserView()
void CmdDrawingOpenBrowserView::activated(int iMsg)
{
Q_UNUSED(iMsg);
unsigned int n = getSelection().countObjectsOfType(Drawing::FeaturePage::getClassTypeId());
unsigned int n = getSelection().countObjectsOfType<Drawing::FeaturePage>();
if (n != 1) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
@@ -691,7 +691,7 @@ CmdDrawingExportPage::CmdDrawingExportPage()
void CmdDrawingExportPage::activated(int iMsg)
{
Q_UNUSED(iMsg);
unsigned int n = getSelection().countObjectsOfType(Drawing::FeaturePage::getClassTypeId());
unsigned int n = getSelection().countObjectsOfType<Drawing::FeaturePage>();
if (n != 1) {
QMessageBox::warning(Gui::getMainWindow(),
QObject::tr("Wrong selection"),
@@ -757,7 +757,7 @@ void CmdDrawingProjectShape::activated(int iMsg)
bool CmdDrawingProjectShape::isActive(void)
{
int ct = Gui::Selection().countObjectsOfType(Part::Feature::getClassTypeId());
int ct = Gui::Selection().countObjectsOfType<Part::Feature>();
return (ct > 0 && !Gui::Control().activeDialog());
}

View File

@@ -223,8 +223,7 @@ bool CmdFemAddPart::isActive(void)
{
if (Gui::Control().activeDialog())
return false;
Base::Type type = Base::Type::fromName("Part::Feature");
return Gui::Selection().countObjectsOfType(type) > 0;
return Gui::Selection().countObjectsOfType<Part::Feature>(type) > 0;
}
*/
@@ -1165,7 +1164,7 @@ void CmdFemDefineNodesSet::activated(int)
bool CmdFemDefineNodesSet::isActive()
{
// Check for the selected mesh feature (all Mesh types)
if (getSelection().countObjectsOfType(Fem::FemMeshObject::getClassTypeId()) != 1) {
if (getSelection().countObjectsOfType<Fem::FemMeshObject>() != 1) {
return false;
}
@@ -1314,7 +1313,7 @@ void CmdFemDefineElementsSet::activated(int)
bool CmdFemDefineElementsSet::isActive()
{
// Check for the selected mesh feature (all Mesh types)
if (getSelection().countObjectsOfType(Fem::FemMeshObject::getClassTypeId()) != 1) {
if (getSelection().countObjectsOfType<Fem::FemMeshObject>() != 1) {
return false;
}
@@ -2028,25 +2027,25 @@ bool CmdFemPostClipFilter::isActive()
return false;
}
// only activate if a result is either a post pipeline or a possible filter
if (getSelection().getObjectsOfType<Fem::FemPostPipeline>().size() == 1) {
if (getSelection().countObjectsOfType<Fem::FemPostPipeline>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostClipFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostClipFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostDataAlongLineFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostDataAlongLineFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostScalarClipFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostScalarClipFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostContoursFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostContoursFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostCutFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostCutFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostWarpVectorFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostWarpVectorFilter>() == 1) {
return true;
}
return false;
@@ -2080,25 +2079,25 @@ bool CmdFemPostCutFilter::isActive()
return false;
}
// only activate if a result is either a post pipeline or a possible filter
if (getSelection().getObjectsOfType<Fem::FemPostPipeline>().size() == 1) {
if (getSelection().countObjectsOfType<Fem::FemPostPipeline>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostClipFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostClipFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostContoursFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostContoursFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostCutFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostCutFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostScalarClipFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostScalarClipFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostDataAlongLineFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostDataAlongLineFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostWarpVectorFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostWarpVectorFilter>() == 1) {
return true;
}
return false;
@@ -2132,22 +2131,22 @@ bool CmdFemPostDataAlongLineFilter::isActive()
return false;
}
// only activate if a result is either a post pipeline or a possible filter
if (getSelection().getObjectsOfType<Fem::FemPostPipeline>().size() == 1) {
if (getSelection().countObjectsOfType<Fem::FemPostPipeline>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostClipFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostClipFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostContoursFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostContoursFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostCutFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostCutFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostScalarClipFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostScalarClipFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostWarpVectorFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostWarpVectorFilter>() == 1) {
return true;
}
return false;
@@ -2182,22 +2181,22 @@ bool CmdFemPostDataAtPointFilter::isActive()
return false;
}
// only activate if a result is either a post pipeline or a possible filter
if (getSelection().getObjectsOfType<Fem::FemPostPipeline>().size() == 1) {
if (getSelection().countObjectsOfType<Fem::FemPostPipeline>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostClipFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostClipFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostCutFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostCutFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostDataAlongLineFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostDataAlongLineFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostScalarClipFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostScalarClipFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostWarpVectorFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostWarpVectorFilter>() == 1) {
return true;
}
return false;
@@ -2307,22 +2306,22 @@ bool CmdFemPostScalarClipFilter::isActive()
return false;
}
// only activate if a result is either a post pipeline or a possible other filter
if (getSelection().getObjectsOfType<Fem::FemPostPipeline>().size() == 1) {
if (getSelection().countObjectsOfType<Fem::FemPostPipeline>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostClipFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostClipFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostContoursFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostContoursFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostCutFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostCutFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostDataAlongLineFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostDataAlongLineFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostWarpVectorFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostWarpVectorFilter>() == 1) {
return true;
}
return false;
@@ -2356,22 +2355,22 @@ bool CmdFemPostWarpVectorFilter::isActive()
return false;
}
// only activate if a result is either a post pipeline or a possible other filter
if (getSelection().getObjectsOfType<Fem::FemPostPipeline>().size() == 1) {
if (getSelection().countObjectsOfType<Fem::FemPostPipeline>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostClipFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostClipFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostCutFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostCutFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostContoursFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostContoursFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostDataAlongLineFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostDataAlongLineFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostScalarClipFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostScalarClipFilter>() == 1) {
return true;
}
return false;
@@ -2405,22 +2404,22 @@ bool CmdFemPostContoursFilter::isActive()
return false;
}
// only activate if a result is either a post pipeline or a possible other filter
if (getSelection().getObjectsOfType<Fem::FemPostPipeline>().size() == 1) {
if (getSelection().countObjectsOfType<Fem::FemPostPipeline>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostClipFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostClipFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostCutFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostCutFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostDataAlongLineFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostDataAlongLineFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostScalarClipFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostScalarClipFilter>() == 1) {
return true;
}
else if (getSelection().getObjectsOfType<Fem::FemPostWarpVectorFilter>().size() == 1) {
else if (getSelection().countObjectsOfType<Fem::FemPostWarpVectorFilter>() == 1) {
return true;
}
return false;

View File

@@ -99,7 +99,7 @@ void CmdInspectElement::activated(int)
bool CmdInspectElement::isActive()
{
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc || doc->countObjectsOfType(Inspection::Feature::getClassTypeId()) == 0) {
if (!doc || doc->countObjectsOfType<Inspection::Feature>() == 0) {
return false;
}

View File

@@ -64,7 +64,7 @@ void StdCmdMeasure::activated(int iMsg)
bool StdCmdMeasure::isActive()
{
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc || doc->countObjectsOfType(App::GeoFeature::getClassTypeId()) == 0) {
if (!doc || doc->countObjectsOfType<App::GeoFeature>() == 0) {
return false;
}

View File

@@ -151,7 +151,7 @@ void CmdMeshUnion::activated(int)
bool CmdMeshUnion::isActive()
{
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 2;
return getSelection().countObjectsOfType<Mesh::Feature>() == 2;
}
//--------------------------------------------------------------------------------------
@@ -230,7 +230,7 @@ void CmdMeshDifference::activated(int)
bool CmdMeshDifference::isActive()
{
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 2;
return getSelection().countObjectsOfType<Mesh::Feature>() == 2;
}
//--------------------------------------------------------------------------------------
@@ -309,7 +309,7 @@ void CmdMeshIntersection::activated(int)
bool CmdMeshIntersection::isActive()
{
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 2;
return getSelection().countObjectsOfType<Mesh::Feature>() == 2;
}
//--------------------------------------------------------------------------------------
@@ -445,7 +445,7 @@ void CmdMeshExport::activated(int)
bool CmdMeshExport::isActive()
{
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 1;
return getSelection().countObjectsOfType<Mesh::Feature>() == 1;
}
//--------------------------------------------------------------------------------------
@@ -516,7 +516,7 @@ bool CmdMeshFromGeometry::isActive()
if (!doc) {
return false;
}
return getSelection().countObjectsOfType(App::GeoFeature::getClassTypeId()) >= 1;
return getSelection().countObjectsOfType<App::GeoFeature>() >= 1;
}
//===========================================================================
@@ -598,7 +598,7 @@ void CmdMeshVertexCurvature::activated(int)
bool CmdMeshVertexCurvature::isActive()
{
// Check for the selected mesh feature (all Mesh types)
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0;
return getSelection().countObjectsOfType<Mesh::Feature>() > 0;
}
//--------------------------------------------------------------------------------------
@@ -636,7 +636,7 @@ void CmdMeshVertexCurvatureInfo::activated(int)
bool CmdMeshVertexCurvatureInfo::isActive()
{
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc || doc->countObjectsOfType(Mesh::Curvature::getClassTypeId()) == 0) {
if (!doc || doc->countObjectsOfType<Mesh::Curvature>() == 0) {
return false;
}
@@ -696,7 +696,7 @@ void CmdMeshPolySegm::activated(int)
bool CmdMeshPolySegm::isActive()
{
// Check for the selected mesh feature (all Mesh types)
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 0) {
if (getSelection().countObjectsOfType<Mesh::Feature>() == 0) {
return false;
}
@@ -744,7 +744,7 @@ void CmdMeshAddFacet::activated(int)
bool CmdMeshAddFacet::isActive()
{
// Check for the selected mesh feature (all Mesh types)
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) != 1) {
if (getSelection().countObjectsOfType<Mesh::Feature>() != 1) {
return false;
}
@@ -809,7 +809,7 @@ void CmdMeshPolyCut::activated(int)
bool CmdMeshPolyCut::isActive()
{
// Check for the selected mesh feature (all Mesh types)
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 0) {
if (getSelection().countObjectsOfType<Mesh::Feature>() == 0) {
return false;
}
@@ -874,7 +874,7 @@ void CmdMeshPolyTrim::activated(int)
bool CmdMeshPolyTrim::isActive()
{
// Check for the selected mesh feature (all Mesh types)
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 0) {
if (getSelection().countObjectsOfType<Mesh::Feature>() == 0) {
return false;
}
@@ -913,11 +913,7 @@ void CmdMeshTrimByPlane::activated(int)
bool CmdMeshTrimByPlane::isActive()
{
// Check for the selected mesh feature (all Mesh types)
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) != 1) {
return false;
}
return true;
return getSelection().countObjectsOfType<Mesh::Feature>() == 1;
}
//--------------------------------------------------------------------------------------
@@ -946,11 +942,7 @@ void CmdMeshSectionByPlane::activated(int)
bool CmdMeshSectionByPlane::isActive()
{
// Check for the selected mesh feature (all Mesh types)
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) != 1) {
return false;
}
return true;
return getSelection().countObjectsOfType<Mesh::Feature>() == 1;
}
//--------------------------------------------------------------------------------------
@@ -978,7 +970,7 @@ void CmdMeshCrossSections::activated(int)
bool CmdMeshCrossSections::isActive()
{
return (Gui::Selection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0
return (Gui::Selection().countObjectsOfType<Mesh::Feature>() > 0
&& !Gui::Control().activeDialog());
}
@@ -1026,7 +1018,7 @@ void CmdMeshPolySplit::activated(int)
bool CmdMeshPolySplit::isActive()
{
// Check for the selected mesh feature (all Mesh types)
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 0) {
if (getSelection().countObjectsOfType<Mesh::Feature>() == 0) {
return false;
}
@@ -1078,7 +1070,7 @@ void CmdMeshEvaluation::activated(int)
bool CmdMeshEvaluation::isActive()
{
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc || doc->countObjectsOfType(Mesh::Feature::getClassTypeId()) == 0) {
if (!doc || doc->countObjectsOfType<Mesh::Feature>() == 0) {
return false;
}
return true;
@@ -1117,7 +1109,7 @@ void CmdMeshEvaluateFacet::activated(int)
bool CmdMeshEvaluateFacet::isActive()
{
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc || doc->countObjectsOfType(Mesh::Feature::getClassTypeId()) == 0) {
if (!doc || doc->countObjectsOfType<Mesh::Feature>() == 0) {
return false;
}
@@ -1160,7 +1152,7 @@ bool CmdMeshRemoveComponents::isActive()
{
// Check for the selected mesh feature (all Mesh types)
App::Document* doc = getDocument();
if (!(doc && doc->countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0)) {
if (!(doc && doc->countObjectsOfType<Mesh::Feature>() > 0)) {
return false;
}
Gui::Document* viewDoc = Gui::Application::Instance->getDocument(doc);
@@ -1209,7 +1201,7 @@ void CmdMeshRemeshGmsh::activated(int)
bool CmdMeshRemeshGmsh::isActive()
{
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 1;
return getSelection().countObjectsOfType<Mesh::Feature>() == 1;
}
//--------------------------------------------------------------------------------------
@@ -1245,7 +1237,7 @@ void CmdMeshRemoveCompByHand::activated(int)
bool CmdMeshRemoveCompByHand::isActive()
{
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc || doc->countObjectsOfType(Mesh::Feature::getClassTypeId()) == 0) {
if (!doc || doc->countObjectsOfType<Mesh::Feature>() == 0) {
return false;
}
@@ -1297,7 +1289,7 @@ void CmdMeshEvaluateSolid::activated(int)
bool CmdMeshEvaluateSolid::isActive()
{
// Check for the selected mesh feature (all Mesh types)
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 1;
return getSelection().countObjectsOfType<Mesh::Feature>() == 1;
}
//--------------------------------------------------------------------------------------
@@ -1326,7 +1318,7 @@ bool CmdMeshSmoothing::isActive()
if (Gui::Control().activeDialog()) {
return false;
}
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0;
return getSelection().countObjectsOfType<Mesh::Feature>() > 0;
}
//--------------------------------------------------------------------------------------
@@ -1358,7 +1350,7 @@ bool CmdMeshDecimating::isActive()
}
#endif
// Check for the selected mesh feature (all Mesh types)
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0;
return getSelection().countObjectsOfType<Mesh::Feature>() > 0;
}
//--------------------------------------------------------------------------------------
@@ -1394,7 +1386,7 @@ void CmdMeshHarmonizeNormals::activated(int)
bool CmdMeshHarmonizeNormals::isActive()
{
// Check for the selected mesh feature (all Mesh types)
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0;
return getSelection().countObjectsOfType<Mesh::Feature>() > 0;
}
//--------------------------------------------------------------------------------------
@@ -1430,7 +1422,7 @@ void CmdMeshFlipNormals::activated(int)
bool CmdMeshFlipNormals::isActive()
{
// Check for the selected mesh feature (all Mesh types)
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0;
return getSelection().countObjectsOfType<Mesh::Feature>() > 0;
}
//--------------------------------------------------------------------------------------
@@ -1482,7 +1474,7 @@ void CmdMeshBoundingBox::activated(int)
bool CmdMeshBoundingBox::isActive()
{
// Check for the selected mesh feature (all Mesh types)
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 1;
return getSelection().countObjectsOfType<Mesh::Feature>() == 1;
}
//--------------------------------------------------------------------------------------
@@ -1565,7 +1557,7 @@ void CmdMeshFillupHoles::activated(int)
bool CmdMeshFillupHoles::isActive()
{
// Check for the selected mesh feature (all Mesh types)
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0;
return getSelection().countObjectsOfType<Mesh::Feature>() > 0;
}
//--------------------------------------------------------------------------------------
@@ -1604,7 +1596,7 @@ void CmdMeshFillInteractiveHole::activated(int)
bool CmdMeshFillInteractiveHole::isActive()
{
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc || doc->countObjectsOfType(Mesh::Feature::getClassTypeId()) == 0) {
if (!doc || doc->countObjectsOfType<Mesh::Feature>() == 0) {
return false;
}
@@ -1648,7 +1640,7 @@ bool CmdMeshSegmentation::isActive()
if (Gui::Control().activeDialog()) {
return false;
}
return Gui::Selection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 1;
return Gui::Selection().countObjectsOfType<Mesh::Feature>() == 1;
}
//--------------------------------------------------------------------------------------
@@ -1684,7 +1676,7 @@ bool CmdMeshSegmentationBestFit::isActive()
if (Gui::Control().activeDialog()) {
return false;
}
return Gui::Selection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 1;
return Gui::Selection().countObjectsOfType<Mesh::Feature>() == 1;
}
//--------------------------------------------------------------------------------------
@@ -1730,7 +1722,7 @@ void CmdMeshMerge::activated(int)
bool CmdMeshMerge::isActive()
{
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) >= 2;
return getSelection().countObjectsOfType<Mesh::Feature>() >= 2;
}
//--------------------------------------------------------------------------------------
@@ -1779,7 +1771,7 @@ void CmdMeshSplitComponents::activated(int)
bool CmdMeshSplitComponents::isActive()
{
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 1;
return getSelection().countObjectsOfType<Mesh::Feature>() == 1;
}
//--------------------------------------------------------------------------------------
@@ -1837,7 +1829,7 @@ void CmdMeshScale::activated(int)
bool CmdMeshScale::isActive()
{
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0;
return getSelection().countObjectsOfType<Mesh::Feature>() > 0;
}

View File

@@ -158,7 +158,7 @@ void Workbench::deactivated()
void Workbench::setupContextMenu(const char* recipient, Gui::MenuItem* item) const
{
StdWorkbench::setupContextMenu(recipient, item);
if (Gui::Selection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0) {
if (Gui::Selection().countObjectsOfType<Mesh::Feature>() > 0) {
*item << "Separator"
<< "Mesh_Import"
<< "Mesh_Export"

View File

@@ -173,11 +173,7 @@ void CmdMeshPartTrimByPlane::activated(int)
bool CmdMeshPartTrimByPlane::isActive()
{
// Check for the selected mesh feature (all Mesh types)
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) != 1) {
return false;
}
return true;
return getSelection().countObjectsOfType<Mesh::Feature>() == 1;
}
//===========================================================================
@@ -262,11 +258,7 @@ void CmdMeshPartSection::activated(int)
bool CmdMeshPartSection::isActive()
{
// Check for the selected mesh feature (all Mesh types)
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) != 1) {
return false;
}
return true;
return getSelection().countObjectsOfType<Mesh::Feature>() == 1;
}
//===========================================================================
@@ -304,7 +296,7 @@ void CmdMeshPartCrossSections::activated(int iMsg)
bool CmdMeshPartCrossSections::isActive()
{
return (Gui::Selection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0
return (Gui::Selection().countObjectsOfType<Mesh::Feature>() > 0
&& !Gui::Control().activeDialog());
}
@@ -343,11 +335,7 @@ bool CmdMeshPartCurveOnMesh::isActive()
// Check for the selected mesh feature (all Mesh types)
App::Document* doc = App::GetApplication().getActiveDocument();
if (doc && doc->countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0) {
return true;
}
return false;
return doc && doc->countObjectsOfType<Mesh::Feature>() > 0;
}

View File

@@ -31,7 +31,7 @@
namespace Part
{
class Mirroring : public Part::Feature
class PartExport Mirroring : public Part::Feature
{
PROPERTY_HEADER_WITH_OVERRIDE(Part::Mirroring);

View File

@@ -344,8 +344,7 @@ void CmdPartCut::activated(int iMsg)
bool CmdPartCut::isActive()
{
return getSelection().countObjectsOfType(
App::DocumentObject::getClassTypeId(), nullptr, Gui::ResolveMode::FollowLink)==2;
return getSelection().countObjectsOfType<App::DocumentObject>(nullptr, Gui::ResolveMode::FollowLink) == 2;
}
//===========================================================================
@@ -404,8 +403,7 @@ void CmdPartCommon::activated(int iMsg)
bool CmdPartCommon::isActive()
{
return getSelection().countObjectsOfType(
App::DocumentObject::getClassTypeId(), nullptr, Gui::ResolveMode::FollowLink) >= 1;
return getSelection().countObjectsOfType<App::DocumentObject>(nullptr, Gui::ResolveMode::FollowLink) >= 1;
}
//===========================================================================
@@ -483,8 +481,7 @@ void CmdPartFuse::activated(int iMsg)
bool CmdPartFuse::isActive()
{
return getSelection().countObjectsOfType(
App::DocumentObject::getClassTypeId(), nullptr, Gui::ResolveMode::FollowLink) >= 1;
return getSelection().countObjectsOfType<App::DocumentObject>(nullptr, Gui::ResolveMode::FollowLink) >= 1;
}
//===========================================================================
@@ -839,8 +836,7 @@ CmdPartCompound::CmdPartCompound()
void CmdPartCompound::activated(int iMsg)
{
Q_UNUSED(iMsg);
unsigned int n = getSelection().countObjectsOfType(
App::DocumentObject::getClassTypeId(), nullptr, Gui::ResolveMode::FollowLink);
unsigned int n = getSelection().countObjectsOfType<App::DocumentObject>(nullptr, Gui::ResolveMode::FollowLink);
if (n < 1) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select one shape or more, please."));
@@ -872,8 +868,7 @@ void CmdPartCompound::activated(int iMsg)
bool CmdPartCompound::isActive()
{
return getSelection().countObjectsOfType(
App::DocumentObject::getClassTypeId(), nullptr, Gui::ResolveMode::FollowLink) >= 1;
return getSelection().countObjectsOfType<App::DocumentObject>(nullptr, Gui::ResolveMode::FollowLink) >= 1;
}
//===========================================================================
@@ -921,7 +916,7 @@ void CmdPartSection::activated(int iMsg)
bool CmdPartSection::isActive()
{
return getSelection().countObjectsOfType(App::DocumentObject::getClassTypeId(), nullptr, Gui::ResolveMode::FollowLink) == 2;
return getSelection().countObjectsOfType<App::DocumentObject>(nullptr, Gui::ResolveMode::FollowLink) == 2;
}
//===========================================================================
@@ -1032,7 +1027,7 @@ void CmdPartExport::activated(int iMsg)
bool CmdPartExport::isActive()
{
return Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId(), nullptr, Gui::ResolveMode::FollowLink) > 0;
return Gui::Selection().countObjectsOfType<App::DocumentObject>(nullptr, Gui::ResolveMode::FollowLink) > 0;
}
//===========================================================================
@@ -1158,8 +1153,7 @@ void CmdPartMakeSolid::activated(int iMsg)
bool CmdPartMakeSolid::isActive()
{
return Gui::Selection().countObjectsOfType
(App::DocumentObject::getClassTypeId(), nullptr, Gui::ResolveMode::FollowLink) > 0;
return Gui::Selection().countObjectsOfType<App::DocumentObject>(nullptr, Gui::ResolveMode::FollowLink) > 0;
}
//===========================================================================
@@ -1360,7 +1354,7 @@ void CmdPartMakeFace::activated(int iMsg)
bool CmdPartMakeFace::isActive()
{
return (Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId(), nullptr, Gui::ResolveMode::FollowLink) > 0 &&
return (Gui::Selection().countObjectsOfType<App::DocumentObject>(nullptr, Gui::ResolveMode::FollowLink) > 0 &&
!Gui::Control().activeDialog());
}
@@ -1892,8 +1886,7 @@ void CmdPartThickness::activated(int iMsg)
bool CmdPartThickness::isActive()
{
Base::Type partid = Base::Type::fromName("Part::Feature");
bool objectsSelected = Gui::Selection().countObjectsOfType(partid, nullptr, Gui::ResolveMode::FollowLink) > 0;
bool objectsSelected = Gui::Selection().countObjectsOfType<Part::Feature>(nullptr, Gui::ResolveMode::FollowLink) > 0;
return (objectsSelected && !Gui::Control().activeDialog());
}
@@ -1923,7 +1916,7 @@ void CmdShapeInfo::activated(int iMsg)
bool CmdShapeInfo::isActive()
{
App::Document* doc = App::GetApplication().getActiveDocument();
if (!doc || doc->countObjectsOfType(Part::Feature::getClassTypeId()) == 0)
if (!doc || doc->countObjectsOfType<Part::Feature>() == 0)
return false;
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
@@ -2107,8 +2100,7 @@ void CmdColorPerFace::activated(int iMsg)
bool CmdColorPerFace::isActive()
{
Base::Type partid = Base::Type::fromName("Part::Feature");
bool objectSelected = Gui::Selection().countObjectsOfType(partid) == 1;
bool objectSelected = Gui::Selection().countObjectsOfType<Part::Feature>() == 1;
return (hasActiveDocument() && !Gui::Control().activeDialog() && objectSelected);
}

View File

@@ -119,8 +119,7 @@ void CmdPartShapeFromMesh::activated(int iMsg)
bool CmdPartShapeFromMesh::isActive()
{
Base::Type meshid = Base::Type::fromName("Mesh::Feature");
return Gui::Selection().countObjectsOfType(meshid) > 0;
return Gui::Selection().countObjectsOfType("Mesh::Feature") > 0;
}
//===========================================================================
// Part_PointsFromMesh
@@ -205,8 +204,7 @@ void CmdPartPointsFromMesh::activated(int iMsg)
bool CmdPartPointsFromMesh::isActive()
{
Base::Type meshid = Base::Type::fromName("App::GeoFeature");
return Gui::Selection().countObjectsOfType(meshid) > 0;
return Gui::Selection().countObjectsOfType<App::GeoFeature>() > 0;
}
//===========================================================================

View File

@@ -64,6 +64,7 @@
#include <Mod/Part/App/PartFeature.h>
#include <Mod/Part/App/PrimitiveFeature.h>
#include <Mod/Part/App/DatumFeature.h>
#include <Mod/Part/App/FeatureMirroring.h>
#include <App/Datums.h>
#include "Mirroring.h"
@@ -289,7 +290,7 @@ bool Mirroring::accept()
}
Gui::WaitCursor wc;
unsigned int count = activeDoc->countObjectsOfType(Base::Type::fromName("Part::Mirroring"));
unsigned int count = activeDoc->countObjectsOfType<Part::Mirroring>();
activeDoc->openTransaction("Mirroring");
QString shape, label, selectionString;

View File

@@ -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;
}
//===========================================================================

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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"

View File

@@ -188,7 +188,7 @@ void CmdPointsExport::activated(int iMsg)
bool CmdPointsExport::isActive()
{
return getSelection().countObjectsOfType(Points::Feature::getClassTypeId()) > 0;
return getSelection().countObjectsOfType<Points::Feature>() > 0;
}
DEF_STD_CMD_A(CmdPointsTransform)
@@ -227,7 +227,7 @@ void CmdPointsTransform::activated(int iMsg)
bool CmdPointsTransform::isActive()
{
return getSelection().countObjectsOfType(Points::Feature::getClassTypeId()) > 0;
return getSelection().countObjectsOfType<Points::Feature>() > 0;
}
DEF_STD_CMD_A(CmdPointsConvert)
@@ -315,7 +315,7 @@ void CmdPointsConvert::activated(int iMsg)
bool CmdPointsConvert::isActive()
{
return getSelection().countObjectsOfType(Base::Type::fromName("App::GeoFeature")) > 0;
return getSelection().countObjectsOfType<App::GeoFeature>() > 0;
}
DEF_STD_CMD_A(CmdPointsPolyCut)
@@ -363,7 +363,7 @@ void CmdPointsPolyCut::activated(int iMsg)
bool CmdPointsPolyCut::isActive()
{
// Check for the selected mesh feature (all Mesh types)
return getSelection().countObjectsOfType(Points::Feature::getClassTypeId()) > 0;
return getSelection().countObjectsOfType<Points::Feature>() > 0;
}
DEF_STD_CMD_A(CmdPointsMerge)
@@ -426,7 +426,7 @@ void CmdPointsMerge::activated(int iMsg)
bool CmdPointsMerge::isActive()
{
return getSelection().countObjectsOfType(Points::Feature::getClassTypeId()) > 1;
return getSelection().countObjectsOfType<Points::Feature>() > 1;
}
DEF_STD_CMD_A(CmdPointsStructure)
@@ -537,7 +537,7 @@ void CmdPointsStructure::activated(int iMsg)
bool CmdPointsStructure::isActive()
{
return getSelection().countObjectsOfType(Points::Feature::getClassTypeId()) == 1;
return getSelection().countObjectsOfType<Points::Feature>() == 1;
}
void CreatePointsCommands()

View File

@@ -233,7 +233,7 @@ void CmdApproxPlane::activated(int)
bool CmdApproxPlane::isActive()
{
if (getSelection().countObjectsOfType(App::GeoFeature::getClassTypeId()) > 0) {
if (getSelection().countObjectsOfType<App::GeoFeature>() > 0) {
return true;
}
return false;
@@ -301,7 +301,7 @@ void CmdApproxCylinder::activated(int)
bool CmdApproxCylinder::isActive()
{
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0) {
if (getSelection().countObjectsOfType<Mesh::Feature>() > 0) {
return true;
}
return false;
@@ -349,7 +349,7 @@ void CmdApproxSphere::activated(int)
bool CmdApproxSphere::isActive()
{
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0) {
if (getSelection().countObjectsOfType<Mesh::Feature>() > 0) {
return true;
}
return false;
@@ -407,7 +407,7 @@ void CmdApproxPolynomial::activated(int)
bool CmdApproxPolynomial::isActive()
{
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0) {
if (getSelection().countObjectsOfType<Mesh::Feature>() > 0) {
return true;
}
return false;
@@ -442,7 +442,7 @@ bool CmdSegmentation::isActive()
if (Gui::Control().activeDialog()) {
return false;
}
return Gui::Selection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 1;
return Gui::Selection().countObjectsOfType<Mesh::Feature>() == 1;
}
DEF_STD_CMD_A(CmdSegmentationManual)
@@ -521,7 +521,7 @@ void CmdSegmentationFromComponents::activated(int)
bool CmdSegmentationFromComponents::isActive()
{
if (getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0) {
if (getSelection().countObjectsOfType<Mesh::Feature>() > 0) {
return true;
}
return false;
@@ -591,7 +591,7 @@ void CmdMeshBoundary::activated(int)
bool CmdMeshBoundary::isActive()
{
return Gui::Selection().countObjectsOfType(Mesh::Feature::getClassTypeId()) > 0;
return Gui::Selection().countObjectsOfType<Mesh::Feature>() > 0;
}
DEF_STD_CMD_A(CmdPoissonReconstruction)
@@ -676,7 +676,7 @@ void CmdViewTriangulation::activated(int)
bool CmdViewTriangulation::isActive()
{
return (Gui::Selection().countObjectsOfType(Points::Structured::getClassTypeId()) > 0);
return (Gui::Selection().countObjectsOfType<Points::Structured>() > 0);
}
void CreateReverseEngineeringCommands()

View File

@@ -54,8 +54,8 @@ CmdRobotExportKukaCompact::CmdRobotExportKukaCompact()
void CmdRobotExportKukaCompact::activated(int)
{
unsigned int n1 = getSelection().countObjectsOfType(Robot::RobotObject::getClassTypeId());
unsigned int n2 = getSelection().countObjectsOfType(Robot::TrajectoryObject::getClassTypeId());
unsigned int n1 = getSelection().countObjectsOfType<Robot::RobotObject>();
unsigned int n2 = getSelection().countObjectsOfType<Robot::TrajectoryObject>();
if (n1 != 1 || n2 != 1) {
QMessageBox::warning(Gui::getMainWindow(),
@@ -129,8 +129,8 @@ CmdRobotExportKukaFull::CmdRobotExportKukaFull()
void CmdRobotExportKukaFull::activated(int)
{
unsigned int n1 = getSelection().countObjectsOfType(Robot::RobotObject::getClassTypeId());
unsigned int n2 = getSelection().countObjectsOfType(Robot::TrajectoryObject::getClassTypeId());
unsigned int n1 = getSelection().countObjectsOfType<Robot::RobotObject>();
unsigned int n2 = getSelection().countObjectsOfType<Robot::TrajectoryObject>();
if (n1 != 1 || n2 != 1) {
QMessageBox::warning(Gui::getMainWindow(),

View File

@@ -98,8 +98,8 @@ CmdRobotInsertWaypoint::CmdRobotInsertWaypoint()
void CmdRobotInsertWaypoint::activated(int)
{
unsigned int n1 = getSelection().countObjectsOfType(Robot::RobotObject::getClassTypeId());
unsigned int n2 = getSelection().countObjectsOfType(Robot::TrajectoryObject::getClassTypeId());
unsigned int n1 = getSelection().countObjectsOfType<Robot::RobotObject>();
unsigned int n2 = getSelection().countObjectsOfType<Robot::TrajectoryObject>();
if (n1 != 1 || n2 != 1) {
QMessageBox::warning(Gui::getMainWindow(),

View File

@@ -328,7 +328,7 @@ void CmdSketcherEditSketch::activated(int iMsg)
bool CmdSketcherEditSketch::isActive()
{
return Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) == 1;
return Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() == 1;
}
DEF_STD_CMD_A(CmdSketcherLeaveSketch)
@@ -539,7 +539,7 @@ void CmdSketcherReorientSketch::activated(int iMsg)
bool CmdSketcherReorientSketch::isActive()
{
return Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) == 1;
return Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() == 1;
}
DEF_STD_CMD_A(CmdSketcherMapSketch)
@@ -763,12 +763,8 @@ void CmdSketcherMapSketch::activated(int iMsg)
bool CmdSketcherMapSketch::isActive()
{
App::Document* doc = App::GetApplication().getActiveDocument();
Base::Type sketch_type = Base::Type::fromName("Part::Part2DObject");
std::vector<Gui::SelectionObject> selobjs = Gui::Selection().getSelectionEx();
if (doc && doc->countObjectsOfType(sketch_type) > 0 && !selobjs.empty())
return true;
return false;
return doc && doc->countObjectsOfType<Part::Part2DObject>() > 0 && !selobjs.empty();
}
DEF_STD_CMD_A(CmdSketcherViewSketch)
@@ -843,7 +839,7 @@ bool CmdSketcherValidateSketch::isActive()
{
if (Gui::Control().activeDialog())
return false;
return Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) == 1;
return Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() == 1;
}
DEF_STD_CMD_A(CmdSketcherMirrorSketch)
@@ -970,7 +966,7 @@ void CmdSketcherMirrorSketch::activated(int iMsg)
bool CmdSketcherMirrorSketch::isActive()
{
return Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) > 0;
return Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() > 0;
}
DEF_STD_CMD_A(CmdSketcherMergeSketches)
@@ -1059,7 +1055,7 @@ void CmdSketcherMergeSketches::activated(int iMsg)
bool CmdSketcherMergeSketches::isActive()
{
return Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) > 1;
return Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() > 1;
}
// Acknowledgement of idea and original python macro goes to SpritKopf:

View File

@@ -141,7 +141,7 @@ void CmdSketcherToggleConstruction::activated(int iMsg)
{
Q_UNUSED(iMsg);
// Option A: nothing is selected change creation mode from/to construction
if (Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) == 0) {
if (Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() == 0) {
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();

View File

@@ -81,7 +81,7 @@ bool isCreateConstraintActive(Gui::Document* doc)
&& doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) {
if (static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit())->getSketchMode()
== ViewProviderSketch::STATUS_NONE) {
if (Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId())
if (Gui::Selection().countObjectsOfType<Sketcher::SketchObject>()
> 0) {
return true;
}
@@ -10013,7 +10013,7 @@ void CmdSketcherToggleDrivingConstraint::activated(int iMsg)
std::vector<Gui::SelectionObject> selection;
if (Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) > 0) {
if (Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() > 0) {
// Now we check whether we have a constraint selected or not.
// get the selection
@@ -10137,7 +10137,7 @@ void CmdSketcherToggleActiveConstraint::activated(int iMsg)
std::vector<Gui::SelectionObject> selection;
if (Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) > 0) {
if (Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() > 0) {
// Now we check whether we have a constraint selected or not.
// get the selection

View File

@@ -61,9 +61,7 @@ bool isSketcherVirtualSpaceActive(Gui::Document* doc, bool actsOnSelection)
if (!actsOnSelection) {
return true;
}
else if (Gui::Selection().countObjectsOfType(
Sketcher::SketchObject::getClassTypeId())
> 0) {
else if (Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() > 0) {
return true;
}
}
@@ -111,7 +109,7 @@ void CmdSketcherSwitchVirtualSpace::activated(int iMsg)
std::vector<Gui::SelectionObject> selection;
if (Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId()) > 0) {
if (Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() > 0) {
// Now we check whether we have a constraint selected or not.
selection = getSelection().getSelectionEx();

View File

@@ -510,10 +510,7 @@ bool SketcherGui::isCommandActive(Gui::Document* doc, bool actsOnSelection)
if (!actsOnSelection) {
return true;
}
else if (Gui::Selection().countObjectsOfType(Sketcher::SketchObject::getClassTypeId())
> 0) {
return true;
}
return Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() > 0;
}
}
@@ -531,11 +528,7 @@ bool SketcherGui::isSketcherBSplineActive(Gui::Document* doc, bool actsOnSelecti
if (!actsOnSelection) {
return true;
}
else if (Gui::Selection().countObjectsOfType(
Sketcher::SketchObject::getClassTypeId())
> 0) {
return true;
}
return Gui::Selection().countObjectsOfType<Sketcher::SketchObject>() > 0;
}
}
}

View File

@@ -201,13 +201,9 @@ bool CmdSurfaceCurveOnMesh::isActive()
}
// Check for the selected mesh feature (all Mesh types)
Base::Type meshType = Base::Type::fromName("Mesh::Feature");
App::Document* doc = App::GetApplication().getActiveDocument();
if (doc && doc->countObjectsOfType(meshType) > 0) {
return true;
}
return false;
// Use string based check to avoid linking to Mesh module
return doc && doc->countObjectsOfType("Mesh::Feature") > 0;
}
//===========================================================================
@@ -317,7 +313,7 @@ void CmdSurfaceExtendFace::activated(int)
bool CmdSurfaceExtendFace::isActive()
{
return Gui::Selection().countObjectsOfType(Part::Feature::getClassTypeId()) == 1;
return Gui::Selection().countObjectsOfType<Part::Feature>() == 1;
}
DEF_STD_CMD_A(CmdSurfaceSections)