#include <QString>\r
#include <QObject>\r
#include <QMap>\r
+#include <QList>\r
\r
#include <string>\r
#include <vector>\r
/// It is called as on clearing of property panel as on filling with new widgets\r
virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}\r
\r
+ /// Have an opportunity to create widgets for the current operation instead of standard creation in workshop\r
+ /// \param theOperation a started operation\r
+ /// \param theWidgets a list of created widgets\r
+ /// \return boolean result, false by default\r
+ virtual bool createWidgets(ModuleBase_Operation* theOperation,\r
+ QList<ModuleBase_ModelWidget*>& theWidgets) const { return false; }\r
+\r
//! Returns True if there are available Undos and there is not an active operation\r
virtual bool canUndo() const;\r
\r
virtual AttributePtr findAttribute(const ObjectPtr& theObject,\r
const GeomShapePtr& theGeomShape) = 0;\r
\r
- /// Returns color of the object\r
- /// \param theObject a result of a feature object\r
- /// \param theColor a vector of three values in [0, 255] range\r
- virtual void getColor(const ObjectPtr& theObject, std::vector<int>& theColor) {}\r
-\r
/// Returns XML information by the feature index\r
/// \param theFeatureId a feature id\r
/// \param theXmlCfg XML configuration\r
thePage->alignToTop();
}
+void ModuleBase_WidgetFactory::createWidget(ModuleBase_PageBase* thePage,
+ const std::string& theWidgetId)
+{
+ bool aFound = false;
+ moveToWidgetId(theWidgetId, aFound);
+ if (aFound) {
+ std::string aWdgType = myWidgetApi->widgetType();
+
+ // Create a ModelWidget
+ ModuleBase_ModelWidget* aWidget = createWidgetByType(aWdgType, thePage->pageWidget());
+ if (aWidget) {
+ if (!myWidgetApi->getBooleanAttribute(ATTR_INTERNAL, false)) {
+ thePage->addModelWidget(aWidget);
+ }
+ else {
+ aWidget->setVisible(false);
+ }
+ }
+ }
+ thePage->alignToTop();
+}
+
void ModuleBase_WidgetFactory::getAttributeTitle(const std::string& theFeatureKind,
const std::string& theAttributeId,
std::string& theTitle)
{
- if (!theTitle.empty())
+ bool aFound = false;
+ moveToWidgetId(theAttributeId, aFound);
+ if (aFound) {
+ theTitle = QString::fromStdString(myWidgetApi->widgetLabel()).toStdString().c_str();
+ if (theTitle.empty())
+ theTitle = QString::fromStdString(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)).toStdString().c_str();
+ }
+}
+
+void ModuleBase_WidgetFactory::moveToWidgetId(const std::string& theWidgetId, bool& theFound)
+{
+ if (theFound)
return;
myParentId = myWidgetApi->widgetId();
std::string aWdgType = myWidgetApi->widgetType();
// Find title under PageGroup
if (myWidgetApi->isGroupBoxWidget() ||
- ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) {
-
- getAttributeTitle(theFeatureKind, theAttributeId, theTitle);
- } else {
+ ModuleBase_WidgetCreatorFactory::get()->hasPageWidget(aWdgType)) {
+ moveToWidgetId(theWidgetId, theFound);
+ }
+ else {
// Find title here
std::string anAttributeId = myWidgetApi->widgetId();
- if (anAttributeId == theAttributeId) {
- theTitle = QString::fromStdString(myWidgetApi->widgetLabel()).toStdString().c_str();
- if (theTitle.empty())
- theTitle = QString::fromStdString(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)).toStdString().c_str();
-
- }
- if (myWidgetApi->isPagedWidget()) {
+ theFound = anAttributeId == theWidgetId;
+ if (!theFound && myWidgetApi->isPagedWidget()) {
//If current widget is toolbox or switch-casebox then fetch all
//it's pages recursively and setup into the widget.
myWidgetApi->toChildWidget();
do {
- getAttributeTitle(theFeatureKind, theAttributeId, theTitle);
- } while (myWidgetApi->toNextWidget() && theTitle.empty());
+ moveToWidgetId(theWidgetId, theFound);
+ } while (!theFound && myWidgetApi->toNextWidget());
}
}
- } while (myWidgetApi->toNextWidget() && theTitle.empty());
+ } while (!theFound && myWidgetApi->toNextWidget());
}
ModuleBase_PageBase* ModuleBase_WidgetFactory::createPageByType(const std::string& theType,
virtual ~ModuleBase_WidgetFactory();
/// Creates content widget for property panel
- /// \param theParent a parent widget
- void createWidget(ModuleBase_PageBase* theParent);
+ /// \param thePage a parent page
+ void createWidget(ModuleBase_PageBase* thePage);
+ /// Creates one widget for property panel for the widget with given index
+ /// \param theParent a parent widget
+ /// \param theWidgetId a widget index
+ void createWidget(ModuleBase_PageBase* thePage,
+ const std::string& theWidgetId);
/// Returns list of model widgets
QList<ModuleBase_ModelWidget*> getModelWidgets() const
/// \param theStdString is STD string
static QString qs(const std::string& theStdString);
+ /// It updates internal config api to point in the structure to given id of widget
+ /// The method is recusive and it stops when the found flag is true
+ /// \param theWidgetId a widget id key value
+ /// \param theFound a flag about found windget and recursive search should be stopped
+ void moveToWidgetId(const std::string& theWidgetId, bool& theFound);
+
private:
/// API object for XML reading
Config_WidgetAPI* myWidgetApi;
#include <ModuleBase_FilterFactory.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_OperationFeature.h>
+#include <ModuleBase_WidgetFactory.h>
+#include <ModuleBase_OperationDescription.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Events.h>
#include <QMessageBox>
#include <QMainWindow>
#include <QLineEdit>
+#include <QString>
#include <GeomAlgoAPI_FaceBuilder.h>
#include <GeomDataAPI_Dir.h>
// the selection is cleared after commit the create operation
// in order to do not use the same selected objects in the restarted operation
// for common behaviour, the selection is cleared even if the operation is not restarted
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
- XGUI_Workshop* aWorkshop = aConnector->workshop();
- aWorkshop->selector()->clearSelection();
+ getWorkshop()->selector()->clearSelection();
}
}
}
myMenuMgr->grantedOperationIds(theOperation, theIds);
if (PartSet_SketcherMgr::isSketchOperation(theOperation)) {
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
- XGUI_Workshop* aWorkshop = aConnector->workshop();
-
+ XGUI_Workshop* aWorkshop = getWorkshop();
theIds.append(aWorkshop->contextMenuMgr()->action("DELETE_CMD")->text());
}
}
{
myCustomPrs->clearPrs();
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
- XGUI_Workshop* aWorkshop = aConnector->workshop();
+ XGUI_Workshop* aWorkshop = getWorkshop();
XGUI_Displayer* aDisplayer = aWorkshop->displayer();
aDisplayer->deactivateSelectionFilters();
}
aPanel->activateWidget(aPanel->modelWidgets().first());
}
+bool PartSet_Module::createWidgets(ModuleBase_Operation* theOperation,
+ QList<ModuleBase_ModelWidget*>& theWidgets) const
+{
+ bool aProcessed = false;
+
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
+ XGUI_Workshop* aWorkshop = getWorkshop();
+ XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
+ if (mySketchMgr->activeSketch().get() && aFOperation && aPropertyPanel) {
+ ModuleBase_ISelection* aSelection = workshop()->selection();
+ // click on a point in sketch leads here with the point is highlighted, not yet selected
+ QList<ModuleBase_ViewerPrs> aPreselection = aSelection->getHighlighted();
+ if (aPreselection.size() == 1) {
+ ModuleBase_ViewerPrs aSelectedPrs = aPreselection[0];
+ ObjectPtr anObject = aSelectedPrs.object();
+
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+ FeaturePtr anOpFeature = aFOperation->feature();
+ TopoDS_Shape aShape = aSelectedPrs.shape();
+ // click on the digit of dimension constrain comes here with an empty shape, so we need the check
+ if (aFeature == anOpFeature && !aShape.IsNull()) {
+ AttributePtr anAttribute = PartSet_Tools::findAttributeBy2dPoint(anObject, aShape,
+ mySketchMgr->activeSketch());
+ if (anAttribute.get()) {
+ QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+ ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), workshop());
+
+ const std::string anAttributeId = anAttribute->id();
+ aFactory.createWidget(aPropertyPanel->contentWidget(), anAttributeId);
+
+ theWidgets = aFactory.getModelWidgets();
+ aProcessed = true;
+ }
+ }
+ }
+ }
+ return aProcessed;
+}
void PartSet_Module::onSelectionChanged()
{
Config_WidgetAPI* theWidgetApi, std::string theParentId)
{
ModuleBase_IWorkshop* aWorkshop = workshop();
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
- XGUI_Workshop* aXUIWorkshop = aConnector->workshop();
+ XGUI_Workshop* aXUIWorkshop = getWorkshop();
ModuleBase_ModelWidget* aWgt = NULL;
if (theType == "sketch-start-label") {
PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, aWorkshop,
{
bool isProcessed = false;
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
- XGUI_Workshop* aWorkshop = aConnector->workshop();
+ XGUI_Workshop* aWorkshop = getWorkshop();
XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr();
//SessionPtr aMgr = ModelAPI_Session::get();
//Handle(V3d_View) aView = aViewer->activeView();
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
- XGUI_Workshop* aWorkshop = aConnector->workshop();
+ XGUI_Workshop* aWorkshop = getWorkshop();
XGUI_Displayer* aDisplayer = aWorkshop->displayer();
Handle(V3d_Viewer) aV3dViewer = aContext->CurrentViewer();
Handle(V3d_View) aView;
if (theResult.get())
return aCustomized;
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
- XGUI_Workshop* aWorkshop = aConnector->workshop();
+ XGUI_Workshop* aWorkshop = getWorkshop();
XGUI_Displayer* aDisplayer = aWorkshop->displayer();
ObjectPtr anObject = aDisplayer->getObject(thePrs);
if (anObject.get()) {
SessionPtr aMgr = ModelAPI_Session::get();
QAction* aActivatePartAction = myMenuMgr->action("ACTIVATE_PARTSET_CMD");
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
- XGUI_Workshop* aWorkshop = aConnector->workshop();
+ XGUI_Workshop* aWorkshop = getWorkshop();
QLabel* aHeader = aWorkshop->objectBrowser()->activeDocLabel();
aActivatePartAction->setEnabled((aMgr->activeDocument() != aMgr->moduleDocument()));
if (myWorkshop->currentOperation() &&
(!aAllowActivationList.contains(myWorkshop->currentOperation()->id())))
return;
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
- XGUI_Workshop* aWorkshop = aConnector->workshop();
+ XGUI_Workshop* aWorkshop = getWorkshop();
XGUI_DataTree* aTreeView = aWorkshop->objectBrowser()->treeView();
QLabel* aLabel = aWorkshop->objectBrowser()->activeDocLabel();
QPalette aPalet = aLabel->palette();
if (theIndex.column() != 0) // Use only first column
return;
- XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
- XGUI_Workshop* aWorkshop = aConnector->workshop();
+ XGUI_Workshop* aWorkshop = getWorkshop();
XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
// De not use non editable Indexes
if ((aDataModel->flags(theIndex) & Qt::ItemIsSelectable) == 0)
return anAttribute;
}
-//******************************************************
-void PartSet_Module::getColor(const ObjectPtr& theObject, std::vector<int>& theColor)
-{
- if (myOverconstraintListener->isConflictingObject(theObject)) {
- myOverconstraintListener->getConflictingColor(theColor);
- }
-}
-
//******************************************************
void PartSet_Module::onBooleanOperationChange(int theOperation)
{
break;
}
}
+
+//******************************************************
+XGUI_Workshop* PartSet_Module::getWorkshop() const
+{
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+ return aConnector->workshop();
+}
class ModuleBase_Operation;
class ModuleBase_IViewWindow;
+class XGUI_Workshop;
class PartSet_MenuMgr;
class PartSet_CustomPrs;
class PartSet_SketcherMgr;
/// Call back forlast tuning of property panel before operation performance
virtual void propertyPanelDefined(ModuleBase_Operation* theOperation);
+ /// If there is found selected attribute, widgets are created and contains only a widget for the attribute
+ /// It is important for Property Panel filling by sketch point attribute
+ /// \param theOperation a started operation
+ /// \param theWidgets a list of created widgets
+ /// \return boolean result, false by default
+ virtual bool createWidgets(ModuleBase_Operation* theOperation,
+ QList<ModuleBase_ModelWidget*>& theWidgets) const;
+
/// Creates an operation and send it to loop
/// \param theCmdId the operation name
virtual void launchOperation(const QString& theCmdId);
/// \return theAttribute
virtual AttributePtr findAttribute(const ObjectPtr& theObject, const GeomShapePtr& theGeomShape);
- /// Returns color of the object
- /// \param theObject a result of a feature object
- /// \param theColor a vector of three values in [0, 255] range
- virtual void getColor(const ObjectPtr& theObject, std::vector<int>& theColor);
-
public slots:
/// Redefines the parent method in order to customize the next case:
/// If the sketch nested operation is active and the presentation is not visualized in the viewer,
//! Delete features
virtual bool deleteObjects();
+ /// Returns the workshop
+ XGUI_Workshop* getWorkshop() const;
+
private:
SelectMgr_ListOfFilter mySelectionFilters;
#define SKETCH_ENTITY_COLOR "225,0,0"
#define SKETCH_EXTERNAL_COLOR "170,0,225"
#define SKETCH_AUXILIARY_COLOR "0,85,0"
-#define SKETCH_OVERCONSTRAINT_COLOR "255,0,0"
+#define SKETCH_OVERCONSTRAINT_COLOR "0,0,0"
/**\class SketchPlugin_SketchEntity
* \ingroup Plugins
return;
showPropertyPanel();
- QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
- ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myModuleConnector);
-
myPropertyPanel->cleanContent();
- aFactory.createWidget(myPropertyPanel->contentWidget());
- QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
+ QList<ModuleBase_ModelWidget*> aWidgets;
+ if (!module()->createWidgets(theOperation, aWidgets)) {
+ QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+ ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myModuleConnector);
+ aFactory.createWidget(myPropertyPanel->contentWidget());
+ aWidgets = aFactory.getModelWidgets();
+ }
// check compatibility of feature and widgets
FeaturePtr aFeature = aFOperation->feature();