Add template based SelectionSingleton::countObjectsOfType
Also convert code to use this new method
This commit is contained in:
@@ -1698,7 +1698,7 @@ bool StdCmdAlignment::isActive()
|
||||
{
|
||||
if (ManualAlignment::hasInstance())
|
||||
return false;
|
||||
return Gui::Selection().countObjectsOfType(App::GeoFeature::getClassTypeId()) == 2;
|
||||
return Gui::Selection().countObjectsOfType<App::GeoFeature>() == 2;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -392,6 +392,13 @@ public:
|
||||
unsigned int countObjectsOfType(const Base::Type& typeId=App::DocumentObject::getClassTypeId(),
|
||||
const char* pDocName=nullptr, ResolveMode resolve = ResolveMode::OldStyleElement) const;
|
||||
|
||||
/**
|
||||
* A convenience template-based method that returns the number of objects of the given type.
|
||||
* \a T must be based on Base::BaseClass, otherwise 0 is returned.
|
||||
*/
|
||||
template<typename T> inline unsigned int countObjectsOfType(
|
||||
const char* pDocName=nullptr, ResolveMode resolve = ResolveMode::OldStyleElement) const;
|
||||
|
||||
/**
|
||||
* Does basically the same as the method above unless that it accepts a string literal as first argument.
|
||||
* \a typeName must be a registered type, otherwise 0 is returned.
|
||||
@@ -724,6 +731,15 @@ protected:
|
||||
SelectionStyle selectionStyle;
|
||||
};
|
||||
|
||||
/**
|
||||
* A convenience template-based method that returns the number of objects of the given type.
|
||||
*/
|
||||
template<typename T>
|
||||
inline unsigned int SelectionSingleton::countObjectsOfType(const char* pDocName, ResolveMode resolve) const {
|
||||
static_assert(std::is_base_of<App::DocumentObject, T>::value, "Template parameter T must be derived from App::DocumentObject");
|
||||
return this->countObjectsOfType(T::getClassTypeId(), pDocName, resolve);
|
||||
}
|
||||
|
||||
/**
|
||||
* A convenience template-based method that returns an array with the correct types already.
|
||||
*/
|
||||
|
||||
@@ -594,7 +594,7 @@ void StdWorkbench::setupContextMenu(const char* recipient, MenuItem* item) const
|
||||
<< StdViews << "Separator"
|
||||
<< "Std_ViewDockUndockFullscreen";
|
||||
|
||||
if (Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0) {
|
||||
if (Gui::Selection().countObjectsOfType<App::DocumentObject>() > 0) {
|
||||
*item << "Separator" << "Std_ToggleVisibility"
|
||||
<< "Std_ToggleSelectability" << "Std_TreeSelection"
|
||||
<< "Std_RandomColor" << "Std_ToggleTransparency" << "Separator" << "Std_Delete"
|
||||
@@ -603,7 +603,7 @@ void StdWorkbench::setupContextMenu(const char* recipient, MenuItem* item) const
|
||||
}
|
||||
else if (strcmp(recipient,"Tree") == 0)
|
||||
{
|
||||
if (Gui::Selection().countObjectsOfType(App::DocumentObject::getClassTypeId()) > 0) {
|
||||
if (Gui::Selection().countObjectsOfType<App::DocumentObject>() > 0) {
|
||||
*item << "Std_ToggleFreeze" << "Separator"
|
||||
<< "Std_Placement" << "Std_ToggleVisibility" << "Std_ShowSelection" << "Std_HideSelection"
|
||||
<< "Std_ToggleSelectability" << "Std_TreeSelectAllInstances" << "Separator"
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1209,7 +1201,7 @@ void CmdMeshRemeshGmsh::activated(int)
|
||||
|
||||
bool CmdMeshRemeshGmsh::isActive()
|
||||
{
|
||||
return getSelection().countObjectsOfType(Mesh::Feature::getClassTypeId()) == 1;
|
||||
return getSelection().countObjectsOfType<Mesh::Feature>() == 1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
@@ -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"
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
@@ -1360,7 +1355,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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -132,11 +132,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"
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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)
|
||||
@@ -843,7 +843,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 +970,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 +1059,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:
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +317,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)
|
||||
|
||||
Reference in New Issue
Block a user