#include "ModuleBase_Tools.h"
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Document.h>
namespace ModuleBase_Tools
{
return boost::shared_ptr<GeomAPI_Shape>();
}
+//******************************************************************
+FeaturePtr feature(ObjectPtr theObject)
+{
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+ if (!aFeature) {
+ ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult) {
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ DocumentPtr aDoc = aMgr->rootDocument();
+ return aDoc->feature(aResult);
+ }
+ }
+ return aFeature;
+}
+
}
\ No newline at end of file
#include <PartSet_OperationFeatureCreate.h>
#include <PartSet_OperationFeatureEditMulti.h>
#include <PartSet_OperationFeatureEdit.h>
-#include <ModuleBase_Operation.h>
-#include <ModuleBase_OperationDescription.h>
-#include <ModuleBase_WidgetFactory.h>
#include <PartSet_Listener.h>
#include <PartSet_TestOCC.h>
#include <PartSet_WidgetSketchLabel.h>
#include <PartSet_Validators.h>
+#include <PartSet_Tools.h>
#include <ModuleBase_Operation.h>
+#include <ModuleBase_OperationDescription.h>
+#include <ModuleBase_WidgetFactory.h>
+#include <ModuleBase_Operation.h>
+#include <ModuleBase_Tools.h>
+
#include <ModelAPI_Object.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_Validator.h>
-
#include <ModelAPI_Data.h>
+
#include <GeomDataAPI_Point2D.h>
-#include <PartSet_Tools.h>
#include <XGUI_MainWindow.h>
#include <XGUI_Displayer.h>
void PartSet_Module::onLaunchOperation(std::string theName, ObjectPtr theObject)
{
- FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+ FeaturePtr aFeature = ModuleBase_Tools::feature(theObject);
if (!aFeature) {
- ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
- if (aResult) {
- PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
- DocumentPtr aDoc = aMgr->rootDocument();
- aFeature = aDoc->feature(aResult);
- } else {
- qDebug("Warning! Restart operation without feature!");
- return;
- }
+ qDebug("Warning! Restart operation without feature!");
+ return;
}
ModuleBase_Operation* anOperation = createOperation(theName.c_str(),
aFeature ? aFeature->getKind() : "");
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_WidgetEditor.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
#include <ModelAPI_Events.h>
const std::list<ModuleBase_ViewerPrs>& theSelected,
const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
- ObjectPtr aFeature;
+ ObjectPtr aObject;
if (!theHighlighted.empty())
- aFeature = theHighlighted.front().object();
- if (!aFeature && !theSelected.empty()) // changed for a constrain
- aFeature = theSelected.front().object();
+ aObject = theHighlighted.front().object();
+ if (!aObject && !theSelected.empty()) // changed for a constrain
+ aObject = theSelected.front().object();
+
+ FeaturePtr aFeature = ModuleBase_Tools::feature(aObject);
if (!aFeature || aFeature != feature()) {
commit();
emit featureConstructed(feature(), FM_Deactivation);