class QAction;
class XGUI_Workshop;
+class Config_WidgetAPI;
+class ModuleBase_ModelWidget;
/**
* Interface to a module
/// Called when it is necessary to update a command state (enable or disable it)
virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;
+ /// Creates custom widgets for property panel
+ virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
+ Config_WidgetAPI* theWidgetApi, QList<ModuleBase_ModelWidget*>& theModelWidgets)
+ {
+ return 0;
+ }
+
virtual ~ModuleBase_IModule() {};
};
#include <QObject>
+class ModuleBase_IModule;
+
/**
* Class which provides access to Workshop object serveces
*/
//! Returns list of currently selected data objects
virtual QList<FeaturePtr> selectedFeatures() const = 0;
+ //! Returns instance of loaded module
+ virtual ModuleBase_IModule* module() const = 0;
+
signals:
void selectionChanged();
};
#include <ModuleBase_WidgetDoubleValue.h>
#include <ModuleBase_WidgetBoolValue.h>
#include <ModuleBase_WidgetPoint2dDistance.h>
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_IModule.h>
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
}
else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
result = createContainer(theType, theParent);
- }
+ } else {
+ result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi, myModelWidgets);
#ifdef _DEBUG
- else { qDebug() << "ModuleBase_WidgetFactory::fillWidget: find bad widget type"; }
+ if (!result) { qDebug("ModuleBase_WidgetFactory::fillWidget: find bad widget type"); }
#endif
+ }
return result;
}
PartSet_OperationSketch.h
PartSet_TestOCC.h
PartSet_Tools.h
+ PartSet_WidgetSketchLabel.h
)
SET(PROJECT_SOURCES
PartSet_OperationSketch.cpp
PartSet_TestOCC.cpp
PartSet_Tools.cpp
+ PartSet_WidgetSketchLabel.cpp
)
SET(PROJECT_RESOURCES
#include <ModuleBase_WidgetFactory.h>
#include <PartSet_Listener.h>
#include <PartSet_TestOCC.h>
+#include <PartSet_WidgetSketchLabel.h>
#include <ModuleBase_Operation.h>
#include <ModelAPI_Object.h>
QStringList aList = aActMgr->nestedCommands(aOperation->id());
return aList.contains(theCmdId);
}
+
+QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent,
+ Config_WidgetAPI* theWidgetApi, QList<ModuleBase_ModelWidget*>& theModelWidgets)
+{
+ if (theType == "sketch-start-label") {
+ PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi);
+ aWgt->setOperationsMgr(myWorkshop->operationMgr());
+ theModelWidgets.append(aWgt);
+ return aWgt->getControl();
+ } else
+ return 0;
+}
/// \param theCmdId the operation name
void updateCurrentPreview(const std::string& theCmdId);
+ /// Creates custom widgets for property panel
+ virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
+ Config_WidgetAPI* theWidgetApi, QList<ModuleBase_ModelWidget*>& theModelWidgets);
+
+
public slots:
void onFeatureTriggered();
/// SLOT, that is called after the operation is started. Connect on the focus activated signal
/// \return enabled state
virtual bool isNestedOperationsEnabled() const;
+ /// Returns whether the sketch plane is set
+ /// \return the boolean value whether the sketch is set
+ bool hasSketchPlane() const;
+
signals:
/// signal about the sketch plane is selected
/// \param theX the value in the X direction of the plane
/// Default impl calls corresponding slot and commits immediately.
virtual void startOperation();
- /// Returns whether the sketch plane is set
- /// \return the boolean value whether the sketch is set
- bool hasSketchPlane() const;
-
/// Set the plane to the current sketch
/// \param theShape the shape
void setSketchPlane(const TopoDS_Shape& theShape);
--- /dev/null
+// File: PartSet_WidgetSketchLabel.cpp
+// Created: 07 July 2014
+// Author: Vitaly SMETANNIKOV
+
+#include "PartSet_WidgetSketchLabel.h"
+#include "PartSet_OperationSketch.h"
+
+#include <ModuleBase_Operation.h>
+#include <XGUI_OperationMgr.h>
+
+#include <Config_WidgetAPI.h>
+
+#include <QLabel>
+
+PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
+ const Config_WidgetAPI* theData)
+: ModuleBase_ModelWidget(theParent, theData)
+{
+ myText = QString::fromStdString(theData->getProperty("title"));
+ myLabel = new QLabel(myText, theParent);
+ myLabel->setWordWrap(true);
+ myTooltip = QString::fromStdString(theData->getProperty("tooltip"));
+ myLabel->setToolTip(myTooltip);
+}
+
+QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
+{
+ QList<QWidget*> aLst;
+ aLst<<myLabel;
+ return aLst;
+}
+
+QWidget* PartSet_WidgetSketchLabel::getControl() const
+{
+ return myLabel;
+}
+
+
+
+void PartSet_WidgetSketchLabel::setOperationsMgr(XGUI_OperationMgr* theMgr)
+{
+ ModuleBase_Operation* aOperation = theMgr->currentOperation();
+ if (aOperation->inherits("PartSet_OperationSketch")) {
+ PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(aOperation);
+ connect(aSketchOpe, SIGNAL(planeSelected(double, double, double)),
+ this, SLOT(onPlaneSelected()));
+ }
+}
+
+void PartSet_WidgetSketchLabel::onPlaneSelected()
+{
+ PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(sender());
+ if (aSketchOpe->hasSketchPlane()) {
+ myLabel->setText("");
+ myLabel->setToolTip("");
+ } else {
+ myLabel->setText(myText);
+ myLabel->setToolTip(myTooltip);
+ }
+}
--- /dev/null
+// File: PartSet_WidgetSketchLabel.h
+// Created: 07 July 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef PartSet_WidgetSketchLabel_H
+#define PartSet_WidgetSketchLabel_H
+
+#include "PartSet.h"
+
+#include <ModuleBase_ModelWidget.h>
+
+class QLabel;
+class XGUI_OperationMgr;
+
+class PARTSET_EXPORT PartSet_WidgetSketchLabel : public ModuleBase_ModelWidget
+{
+ Q_OBJECT
+public:
+ PartSet_WidgetSketchLabel(QWidget* theParent, const Config_WidgetAPI* theData);
+
+ virtual ~PartSet_WidgetSketchLabel() {};
+
+ /// Saves the internal parameters to the given feature
+ /// \param theFeature a model feature to be changed
+ virtual bool storeValue(FeaturePtr theFeature) const { return true;}
+
+ virtual bool restoreValue(FeaturePtr theFeature) { return true;}
+
+ /// Returns list of widget controls
+ /// \return a control list
+ virtual QList<QWidget*> getControls() const;
+
+ QWidget* getControl() const;
+
+ void setOperationsMgr(XGUI_OperationMgr* theMgr);
+
+private slots:
+ void onPlaneSelected();
+
+private:
+ QLabel* myLabel;
+ QString myText;
+ QString myTooltip;
+};
+
+#endif
\ No newline at end of file
<workbench id="Sketch">
<group id="Basic">
<feature id="Sketch" nested="SketchPoint SketchLine SketchCircle SketchArc SketchConstraintLength SketchConstraintRadius SketchConstraintDistance SketchConstraintParallel SketchConstraintPerpendicular" title="Sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png">
- <label title="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch"/>
+ <sketch-start-label title="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch"/>
<!--icon=":pictures/x_point.png"-->
</feature>
<feature id="SketchPoint" title="Point" tooltip="Create a new point" icon=":icons/point.png">
return myWorkshop->selector()->selectedFeatures();
}
+ModuleBase_IModule* XGUI_ModuleConnector::module() const
+{
+ return myWorkshop->module();
+}
\ No newline at end of file
//! Returns list of currently selected data objects
virtual QFeatureList selectedFeatures() const;
+ //! Returns instance of loaded module
+ virtual ModuleBase_IModule* module() const;
+
private:
XGUI_Workshop* myWorkshop;
};
XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
: QObject(),
myCurrentDir(QString()),
- myPartSetModule(NULL),
+ myModule(NULL),
mySalomeConnector(theConnector),
myPropertyPanel(0),
myObjectBrowser(0),
QKeySequence(), isUsePropPanel);
salomeConnector()->setNestedActions(aId, aNestedFeatures.split(" "));
myActionsMgr->addCommand(aAction);
- myPartSetModule->featureCreated(aAction);
+ myModule->featureCreated(aAction);
} else {
XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
QKeySequence(), isUsePropPanel);
aCommand->setNestedCommands(aNestedFeatures.split(" ", QString::SkipEmptyParts));
myActionsMgr->addCommand(aCommand);
- myPartSetModule->featureCreated(aCommand);
+ myModule->featureCreated(aCommand);
}
}
{
Config_ModuleReader aModuleReader;
QString moduleName = QString::fromStdString(aModuleReader.getModuleName());
- myPartSetModule = loadModule(moduleName);
- if (!myPartSetModule)
+ myModule = loadModule(moduleName);
+ if (!myModule)
return false;
- myPartSetModule->createFeatures();
+ myModule->createFeatures();
myActionsMgr->update();
return true;
}
}
}
foreach(QAction* aCmd, aCommands) {
- aCmd->setEnabled(myPartSetModule->isFeatureEnabled(aCmd->data().toString()));
+ aCmd->setEnabled(myModule->isFeatureEnabled(aCmd->data().toString()));
}
}
if (aCmd) {
QString aId = salomeConnector()->commandId(aCmd);
if (!aId.isNull())
- myPartSetModule->launchOperation(aId);
+ myModule->launchOperation(aId);
}
}
//! Show the given features in 3d Viewer
void showFeatures(QFeatureList theList, bool isVisible);
+ ModuleBase_IModule* module() const { return myModule; }
+
signals:
void salomeViewerSelection();
void errorOccurred(const QString&);
void createDockWidgets();
XGUI_MainWindow* myMainWindow;
- ModuleBase_IModule* myPartSetModule;
+ ModuleBase_IModule* myModule;
XGUI_ObjectsBrowser* myObjectBrowser;
XGUI_PropertyPanel* myPropertyPanel;
XGUI_SelectionMgr* mySelector;