Merge pull request #19019 from hyarion/refactor/countObjectsOfType
Refactor countObjectsOfType in selection and document
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user