INCLUDE(FindPython)
INCLUDE(FindSalome)
INCLUDE(FindSolveSpace)
+INCLUDE(FindCAS)
IF(UNIX)
IF(CMAKE_COMPILER_IS_GNUCC)
INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events)
SET(PROJECT_HEADERS
- Config.h
+ Config_def.h
Config_FeatureMessage.h
Config_XMLReader.h
Config_ModuleReader.h
+++ /dev/null
-#ifndef CONFIG_H
-#define CONFIG_H
-
-#if defined CONFIG_EXPORTS
-#if defined WIN32
-#define CONFIG_EXPORT __declspec( dllexport )
-#else
-#define CONFIG_EXPORT
-#endif
-#else
-#if defined WIN32
-#define CONFIG_EXPORT __declspec( dllimport )
-#else
-#define CONFIG_EXPORT
-#endif
-#endif
-
-#endif //CONFIG_H
#ifndef Config_Common_H_
#define Config_Common_H_
-#include "Config.h"
+#include "Config_def.h"
#include <string>
#include <stdarg.h>
#ifndef CONFIG_MESSAGE_H\r
#define CONFIG_MESSAGE_H\r
\r
-#include <Config.h>\r
+#include <Config_def.h>\r
#include <Events_Message.h>\r
\r
#include <string>\r
#ifndef CONFIG_FEATUREREADER_H_
#define CONFIG_FEATUREREADER_H_
-#include <Config.h>
+#include <Config_def.h>
#include <Config_XMLReader.h>
#include <string>
#ifndef CONFIG_MODULEREADER_H_
#define CONFIG_MODULEREADER_H_
-#include <Config.h>
+#include <Config_def.h>
#include <Config_XMLReader.h>
#include <map>
#ifndef PARTSET_MESSAGE_H_
#define PARTSET_MESSAGE_H_
-#include <Config.h>
+#include <Config_def.h>
#include <Events_Message.h>
/*
return myCurrentNode != NULL;
}
-std::string Config_WidgetAPI::widgetType()
+std::string Config_WidgetAPI::widgetType() const
{
std::string result = "";
if(myCurrentNode) {
return result;
}
-bool Config_WidgetAPI::isContainerWidget()
+bool Config_WidgetAPI::isContainerWidget() const
{
return isNode(myCurrentNode, WDG_GROUP, WDG_CHECK_GROUP,
NULL);
}
-bool Config_WidgetAPI::isPagedWidget()
+bool Config_WidgetAPI::isPagedWidget() const
{
return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH,
NULL);
}
-std::string Config_WidgetAPI::getProperty(const char* thePropName)
+std::string Config_WidgetAPI::getProperty(const char* thePropName) const
{
std::string result = "";
char* aPropChars = (char*) xmlGetProp(myCurrentNode, BAD_CAST thePropName);
return result;
}
-std::string Config_WidgetAPI::widgetId()
+std::string Config_WidgetAPI::widgetId() const
{
return getProperty("id");
}
-std::string Config_WidgetAPI::widgetTooltip()
+std::string Config_WidgetAPI::widgetTooltip() const
{
return getProperty("tooltip");
}
-std::string Config_WidgetAPI::widgetIcon()
+std::string Config_WidgetAPI::widgetIcon() const
{
return getProperty("icon");
}
-std::string Config_WidgetAPI::widgetLabel()
+std::string Config_WidgetAPI::widgetLabel() const
{
return getProperty("label");
}
#ifndef CONFIG_WIDGETAPI_H_
#define CONFIG_WIDGETAPI_H_
-#include <Config.h>
+#include <Config_def.h>
#include <cstdarg>
#include <string>
bool toChildWidget();
bool toParentWidget();
- std::string widgetType();
- bool isContainerWidget();
- bool isPagedWidget();
+ std::string widgetType() const;
+ bool isContainerWidget() const;
+ bool isPagedWidget() const;
- std::string widgetId();
- std::string widgetIcon();
- std::string widgetLabel();
- std::string widgetTooltip();
+ std::string widgetId() const;
+ std::string widgetIcon() const;
+ std::string widgetLabel() const;
+ std::string widgetTooltip() const;
- std::string getProperty(const char* thePropName);
+ std::string getProperty(const char* thePropName) const;
private:
xmlDocPtr myDoc;
#ifndef CONFIG_WIDGETREADER_H_
#define CONFIG_WIDGETREADER_H_
-#include <Config.h>
+#include <Config_def.h>
#include <Config_XMLReader.h>
#include <map>
#ifndef CONFIG_XMLREADER_H_
#define CONFIG_XMLREADER_H_
-#include <Config.h>
+#include <Config_def.h>
#include <cstdarg>
#include <string>
--- /dev/null
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#if defined CONFIG_EXPORTS
+#if defined WIN32
+#define CONFIG_EXPORT __declspec( dllexport )
+#else
+#define CONFIG_EXPORT
+#endif
+#else
+#if defined WIN32
+#define CONFIG_EXPORT __declspec( dllimport )
+#else
+#define CONFIG_EXPORT
+#endif
+#endif
+
+#endif //CONFIG_H
ADD_DEFINITIONS(-DCONSTRUCTIONPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
ADD_LIBRARY(ConstructionPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-TARGET_LINK_LIBRARIES(ConstructionPlugin ${PROJECT_LIBRARIES} ModelAPI)
+TARGET_LINK_LIBRARIES(ConstructionPlugin ${PROJECT_LIBRARIES} ModelAPI GeomAPI GeomAlgoAPI)
INCLUDE_DIRECTORIES(
../ModelAPI
+ ../GeomAPI
+ ../GeomAlgoAPI
)
SET(XML_RESOURCES
#include "ModelAPI_Document.h"
#include "ModelAPI_Data.h"
#include "ModelAPI_AttributeDouble.h"
+#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAPI_Pnt.h>
using namespace std;
data()->addAttribute(POINT_ATTR_Z, ModelAPI_AttributeDouble::type());
}
-// this is for debug only
-#include <iostream>
void ConstructionPlugin_Point::execute()
{
- // TODO: create a real shape for the point using OCC layer
- cout<<"X="<<data()->real(POINT_ATTR_X)->value()<<" Y="<<data()->real(POINT_ATTR_Y)->value()
- <<" Z="<<data()->real(POINT_ATTR_Z)->value()<<endl;
+ boost::shared_ptr<GeomAPI_Pnt> aPnt(new GeomAPI_Pnt(
+ data()->real(POINT_ATTR_X)->value(), data()->real(POINT_ATTR_Y)->value(), data()->real(POINT_ATTR_Z)->value()));
+
+ data()->store(GeomAlgoAPI_PointBuilder::point(aPnt));
}
label="Select a face"
icon=":icons/sketch.png"
tooltip="Select a face for extrusion"
+ activate="true"
/>
<doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="10" icon=":icons/dimension_v.png" tooltip="Set size of extrusion"/>
<boolvalue id="extrusion_reverse" label="Reverse" default="false" tooltip="Reverse default direction"/>
FIND_PACKAGE(SWIG REQUIRED)
-INCLUDE(FindCAS)
INCLUDE(${SWIG_USE_FILE})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
FIND_PACKAGE(SWIG REQUIRED)
-INCLUDE(FindCAS)
INCLUDE(${SWIG_USE_FILE})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
GeomAlgoAPI_CompoundBuilder.h
GeomAlgoAPI_FaceBuilder.h
GeomAlgoAPI_EdgeBuilder.h
+ GeomAlgoAPI_PointBuilder.h
)
SET(PROJECT_SOURCES
GeomAlgoAPI_CompoundBuilder.cpp
GeomAlgoAPI_FaceBuilder.cpp
GeomAlgoAPI_EdgeBuilder.cpp
+ GeomAlgoAPI_PointBuilder.cpp
)
ADD_DEFINITIONS(-DGEOMALGOAPI_EXPORTS ${CAS_DEFINITIONS})
#include "memory"
#include "GeomAlgoAPI.h"
#include "GeomAlgoAPI_FaceBuilder.h"
+ #include "GeomAlgoAPI_EdgeBuilder.h"
+ #include "GeomAlgoAPI_PointBuilder.h"
%}
// to avoid error on this
// all supported interfaces
%include "GeomAlgoAPI_FaceBuilder.h"
+%include "GeomAlgoAPI_EdgeBuilder.h"
+%include "GeomAlgoAPI_PointBuilder.h"
--- /dev/null
+// File: GeomAlgoAPI_PointBuilder.cpp
+// Created: 02 Jun 2014
+// Author: Mikhail PONIKAROV
+
+
+
+#include <GeomAlgoAPI_PointBuilder.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Shape.h>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <TopoDS_Vertex.hxx>
+
+boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_PointBuilder::point(
+ boost::shared_ptr<GeomAPI_Pnt> thePoint)
+{
+ const gp_Pnt& aPnt = thePoint->impl<gp_Pnt>();
+ BRepBuilderAPI_MakeVertex aMaker(aPnt);
+ TopoDS_Vertex aVertex = aMaker.Vertex();
+ boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+ aRes->setImpl(new TopoDS_Shape(aVertex));
+ return aRes;
+}
--- /dev/null
+// File: GeomAlgoAPI_PointBuilder.h
+// Created: 02 Jun 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef GeomAlgoAPI_PointBuilder_HeaderFile
+#define GeomAlgoAPI_PointBuilder_HeaderFile
+
+#include <GeomAlgoAPI.h>
+#include <boost/shared_ptr.hpp>
+
+class GeomAPI_Shape;
+class GeomAPI_Pnt;
+
+/**\class GeomAlgoAPI_PointBuilder
+ * \ingroup DataAlgo
+ * \brief Allows to create face-shapes by different parameters
+ */
+
+class GEOMALGOAPI_EXPORT GeomAlgoAPI_PointBuilder
+{
+public:
+ /// Creates linear edge by two points
+ static boost::shared_ptr<GeomAPI_Shape> point(
+ boost::shared_ptr<GeomAPI_Pnt> thePoint);
+};
+
+#endif
INCLUDE(Common)
-INCLUDE(FindCAS)
SET(PROJECT_HEADERS
GeomData.h
INCLUDE(Common)
-INCLUDE(FindCAS)
SET(PROJECT_HEADERS
Model.h
Events
Config
GeomData
+ GeomAPI
${CAS_OCAF}
+ ${CAS_TKCAF}
)
../Config
../GeomData
../GeomDataAPI
+ ../GeomAPI
${CAS_INCLUDE_DIRS}
)
void Model_AttributeBoolean::setValue(bool theValue)
{
- if (myBool->Get() != theValue) {
- myBool->Set(theValue? 1 : 0);
+ Standard_Boolean aValue = theValue ? Standard_True : Standard_False;
+ if (myBool->Get() != aValue) {
+ myBool->Set(aValue);
static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
Events_Loop::loop()->send(aMsg);
bool Model_AttributeBoolean::value()
{
- return (myBool->Get() == 1)? true : false;
+ return myBool->Get() == Standard_True;
}
Model_AttributeBoolean::Model_AttributeBoolean(TDF_Label& theLabel)
{
return !myLab.IsNull() && myLab.HasAttribute();
}
+
+#include <TNaming_Builder.hxx>
+#include <TNaming_NamedShape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <GeomAPI_Shape.h>
+
+void Model_Data::store(const boost::shared_ptr<GeomAPI_Shape>& theShape)
+{
+ // the simplest way is to keep this attribute here, on Data
+ // TODO: add naming structure in separated document for shape storage
+ TNaming_Builder aBuilder(myLab);
+ if (!theShape) return; // bad shape
+ TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
+ if (aShape.IsNull()) return; // null shape inside
+
+ aBuilder.Generated(aShape);
+}
+
+boost::shared_ptr<GeomAPI_Shape> Model_Data::shape()
+{
+ Handle(TNaming_NamedShape) aName;
+ if (myLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) {
+ TopoDS_Shape aShape = aName->Get();
+ if (!aShape.IsNull()) {
+ boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+ aRes->setImpl(new TopoDS_Shape(aShape));
+ return aRes;
+ }
+ }
+ return boost::shared_ptr<GeomAPI_Shape>();
+}
/// Returns true if it is correctly connected t othe data model
MODEL_EXPORT virtual bool isValid();
+ /// Stores the shape (called by the execution method).
+ MODEL_EXPORT virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape);
+ /// Returns the shape-result produced by this feature
+ MODEL_EXPORT virtual boost::shared_ptr<GeomAPI_Shape> shape();
+
/// Initializes object by the attributes: must be called just after the object is created
/// for each attribute of the object
/// \param theID identifier of the attribute that can be referenced by this ID later
class ModelAPI_AttributeRefList;
class ModelAPI_Document;
class ModelAPI_Attribute;
+class GeomAPI_Shape;
/**\class ModelAPI_Data
* \ingroup DataModel
/// Returns true if it is correctly connected t othe data model
virtual bool isValid() = 0;
+ /// Stores the shape (called by the execution method).
+ virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape) = 0;
+ /// Returns the shape-result produced by this feature
+ virtual boost::shared_ptr<GeomAPI_Shape> shape() = 0;
+
/// Initializes object by the attributes: must be called just after the object is created
/// for each attribute of the object
/// \param theID identifier of the attribute that can be referenced by this ID later
/// Returns true if feature refers to the same model data instance
MODELAPI_EXPORT virtual bool isSame(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
- {return true;}
+ {return theFeature.get() == this;}
/// To virtually destroy the fields of successors
virtual ~ModelAPI_Feature() {}
ModuleBase_WidgetPoint2D.h
ModuleBase_WidgetSwitch.h
ModuleBase_MetaWidget.h
+ ModuleBase_SelectorWidget.h
+ ModuleBase_IWorkshop.h
)
SET(PROJECT_SOURCES
ModuleBase_WidgetPoint2D.cpp
ModuleBase_WidgetSwitch.cpp
ModuleBase_MetaWidget.cpp
+ ModuleBase_SelectorWidget.cpp
)
SET(PROJECT_LIBRARIES
Config
ModelAPI
${QT_LIBRARIES}
+ ${CAS_VIEWER}
+ ${CAS_KERNEL}
)
SET(PROJECT_AUTOMOC
#SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES})
INCLUDE_DIRECTORIES(
- ${PROJECT_SOURCE_DIR}/src/Config
+ ${CAS_INCLUDE_DIRS}
+ ${CMAKE_SOURCE_DIR}/src/Config
${CMAKE_SOURCE_DIR}/src/Events
${CMAKE_SOURCE_DIR}/src/Model
${CMAKE_SOURCE_DIR}/src/ModelAPI
${CMAKE_SOURCE_DIR}/src/GeomDataAPI
)
-ADD_DEFINITIONS(-DMODULEBASE_EXPORTS)
+ADD_DEFINITIONS(-DMODULEBASE_EXPORTS ${CAS_DEFINITIONS})
ADD_LIBRARY(ModuleBase SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
TARGET_LINK_LIBRARIES(ModuleBase ${PROJECT_LIBRARIES})
--- /dev/null
+// File: ModuleBase_IWorkshop.h
+// Created: 2 June 2014
+// Author: Vitaly Smetannikov
+
+#ifndef ModuleBase_IWorkshop_H
+#define ModuleBase_IWorkshop_H
+
+#include "ModuleBase.h"
+
+#include <ModelAPI_Feature.h>
+
+#include <AIS_InteractiveContext.hxx>
+
+#include <QObject>
+
+/**
+* Class which provides access to Workshop object serveces
+*/
+class MODULEBASE_EXPORT ModuleBase_IWorkshop: public QObject
+{
+Q_OBJECT
+public:
+ ModuleBase_IWorkshop(QObject* theParent):QObject(theParent) {}
+
+ virtual ~ModuleBase_IWorkshop() {};
+
+ //! Returns AIS_InteractiveContext from current OCCViewer
+ virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
+
+ //! Returns list of currently selected data objects
+ virtual QList<FeaturePtr> selectedFeatures() const = 0;
+
+signals:
+ void selectionChanged();
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+// File: ModuleBase_SelectorWidget.h
+// Created: 2 June 2014
+// Author: Vitaly Smetannikov
+
+
+#include "ModuleBase_SelectorWidget.h"
+#include "ModuleBase_IWorkshop.h"
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_AttributeReference.h>
+#include <Config_WidgetAPI.h>
+
+#include <QWidget>
+#include <QLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QToolButton>
+#include <QString>
+#include <QEvent>
+
+
+ModuleBase_SelectorWidget::ModuleBase_SelectorWidget(QWidget* theParent,
+ ModuleBase_IWorkshop* theWorkshop,
+ const Config_WidgetAPI* theData)
+: ModuleBase_ModelWidget(theParent), myWorkshop(theWorkshop), myActivateOnStart(false)
+{
+ myFeatureAttributeID = theData->widgetId();
+
+ myContainer = new QWidget(theParent);
+ QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
+
+ aLayout->setContentsMargins(0, 0, 0, 0);
+ QString aLabelText = QString::fromStdString(theData->widgetLabel());
+ QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
+ myLabel = new QLabel(aLabelText, myContainer);
+ myLabel->setPixmap(QPixmap(aLabelIcon));
+
+ aLayout->addWidget(myLabel);
+
+ QString aToolTip = QString::fromStdString(theData->widgetTooltip());
+ myTextLine = new QLineEdit(myContainer);
+ myTextLine->setReadOnly(true);
+ myTextLine->setToolTip(aToolTip);
+ myTextLine->installEventFilter(this);
+
+ aLayout->addWidget(myTextLine);
+
+ myActivateBtn = new QToolButton(myContainer);
+ myActivateBtn->setIcon(QIcon(":icons/hand_point.png"));
+ myActivateBtn->setCheckable(true);
+ myActivateBtn->setToolTip(tr("Activate/Deactivate selection"));
+ connect(myActivateBtn, SIGNAL(toggled(bool)), this, SLOT(activateSelection(bool)));
+
+ aLayout->addWidget(myActivateBtn);
+
+ QString aActivateTxt = QString::fromStdString(theData->getProperty("activate"));
+ if (!aActivateTxt.isNull()) {
+ myActivateOnStart = (aActivateTxt == "true");
+ }
+}
+
+//********************************************************************
+ModuleBase_SelectorWidget::~ModuleBase_SelectorWidget()
+{
+}
+
+//********************************************************************
+bool ModuleBase_SelectorWidget::storeValue(FeaturePtr theFeature)
+{
+ DataPtr aData = theFeature->data();
+ boost::shared_ptr<ModelAPI_AttributeReference> aRef =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(myFeatureAttributeID));
+
+ aRef->setFeature(mySelectedFeature);
+
+ return true;
+}
+
+//********************************************************************
+bool ModuleBase_SelectorWidget::restoreValue(FeaturePtr theFeature)
+{
+ DataPtr aData = theFeature->data();
+ boost::shared_ptr<ModelAPI_AttributeReference> aRef =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(myFeatureAttributeID));
+
+ mySelectedFeature = aRef->value();
+ updateSelectionName();
+ return true;
+}
+
+//********************************************************************
+bool ModuleBase_SelectorWidget::canFocusTo(const std::string& theAttributeName)
+{
+ return false;
+}
+
+//********************************************************************
+void ModuleBase_SelectorWidget::focusTo()
+{
+}
+
+//********************************************************************
+QList<QWidget*> ModuleBase_SelectorWidget::getControls() const
+{
+ QList<QWidget*> aControls;
+ aControls.append(myLabel);
+ aControls.append(myTextLine);
+ aControls.append(myActivateBtn);
+ return aControls;
+}
+
+//********************************************************************
+void ModuleBase_SelectorWidget::onSelectionChanged()
+{
+ QList<FeaturePtr> aFeatures = myWorkshop->selectedFeatures();
+ if (aFeatures.size() > 0) {
+ FeaturePtr aFeature = aFeatures.first();
+ if ((!mySelectedFeature) && (!aFeature))
+ return;
+ if (mySelectedFeature && aFeature && mySelectedFeature->isSame(aFeature))
+ return;
+
+ // TODO: Check that the selection corresponds to selection type
+ mySelectedFeature = aFeature;
+ if (mySelectedFeature) {
+ updateSelectionName();
+ activateSelection(false);
+ } else {
+ myTextLine->setText("");
+ }
+ emit valuesChanged();
+ }
+}
+
+//********************************************************************
+void ModuleBase_SelectorWidget::updateSelectionName()
+{
+ if (mySelectedFeature) {
+ std::string aName;
+ if (mySelectedFeature->data())
+ aName = mySelectedFeature->data()->getName();
+ else
+ aName = boost::dynamic_pointer_cast<ModelAPI_Object>(mySelectedFeature)->getName();
+
+ myTextLine->setText(QString::fromStdString(aName));
+ } else
+ myTextLine->setText("");
+}
+
+//********************************************************************
+bool ModuleBase_SelectorWidget::eventFilter(QObject* theObj, QEvent* theEvent)
+{
+ if (theObj == myTextLine) {
+ if (theEvent->type() == QEvent::Polish) {
+ activateSelection(myActivateOnStart);
+ onSelectionChanged();
+ }
+ }
+ return ModuleBase_ModelWidget::eventFilter(theObj, theEvent);
+}
+
+//********************************************************************
+void ModuleBase_SelectorWidget::enableOthersControls(bool toEnable)
+{
+ QWidget* aParent = myContainer->parentWidget();
+ QList<QWidget*> aChldList = aParent->findChildren<QWidget*>();
+ foreach(QWidget* aWgt, aChldList) {
+ if ((aWgt != myLabel) && (aWgt != myActivateBtn) && (aWgt != myTextLine) && (aWgt != myContainer))
+ aWgt->setEnabled(toEnable);
+ }
+}
+
+//********************************************************************
+void ModuleBase_SelectorWidget::activateSelection(bool toActivate)
+{
+ enableOthersControls(!toActivate);
+ myTextLine->setEnabled(toActivate);
+
+ if (toActivate)
+ connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+ else
+ disconnect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+
+ myActivateBtn->setDown(toActivate);
+}
\ No newline at end of file
--- /dev/null
+// File: ModuleBase_SelectorWidget.h
+// Created: 2 June 2014
+// Author: Vitaly Smetannikov
+
+#ifndef ModuleBase_SelectorWidget_H
+#define ModuleBase_SelectorWidget_H
+
+#include "ModuleBase.h"
+#include "ModuleBase_ModelWidget.h"
+
+#include <ModelAPI_Feature.h>
+
+
+class Config_WidgetAPI;
+class QWidget;
+class QLabel;
+class QLineEdit;
+class QToolButton;
+class ModuleBase_IWorkshop;
+
+class MODULEBASE_EXPORT ModuleBase_SelectorWidget: public ModuleBase_ModelWidget
+{
+ Q_OBJECT
+public:
+ ModuleBase_SelectorWidget(QWidget* theParent,
+ ModuleBase_IWorkshop* theWorkshop,
+ const Config_WidgetAPI* theData);
+
+ virtual ~ModuleBase_SelectorWidget();
+
+ /// Saves the internal parameters to the given feature
+ /// \param theFeature a model feature to be changed
+ virtual bool storeValue(FeaturePtr theFeature);
+
+ virtual bool restoreValue(FeaturePtr theFeature);
+
+ /// Returns whether the widget can accept focus, or if it corresponds to the given attribute
+ /// \param theAttribute name
+ virtual bool canFocusTo(const std::string& theAttributeName);
+
+ /// Set focus to the current widget if it corresponds to the given attribute
+ virtual void focusTo();
+
+ /// Returns the internal parent wiget control, that can be shown anywhere
+ /// \returns the widget
+ QWidget* getControl() const { return myContainer; }
+
+ /// Returns list of widget controls
+ /// \return a control list
+ virtual QList<QWidget*> getControls() const;
+
+ void setActivationOnStart(bool toActivate) { myActivateOnStart = toActivate; }
+ bool activateOnStart() const { return myActivateOnStart; }
+
+ FeaturePtr selectedFeature() const { return mySelectedFeature; }
+
+public slots:
+
+ /// Activate or deactivate selection
+ void activateSelection(bool toActivate);
+
+protected:
+ bool eventFilter(QObject* theObj, QEvent* theEvent);
+
+private slots:
+ void onSelectionChanged();
+
+private:
+ void enableOthersControls(bool toEnable);
+ void updateSelectionName();
+
+ std::string myFeatureAttributeID;
+
+ QWidget* myContainer;
+ QLabel* myLabel;
+ QLineEdit* myTextLine;
+ QToolButton* myActivateBtn;
+
+ ModuleBase_IWorkshop* myWorkshop;
+
+ bool myActivateOnStart;
+
+ FeaturePtr mySelectedFeature;
+};
+
+#endif
\ No newline at end of file
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_WidgetPoint2D.h>
#include <ModuleBase_WidgetSwitch.h>
+#include <ModuleBase_SelectorWidget.h>
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
#include <QPixmap>
#include <QGroupBox>
#include <QToolBox>
-#include <QLineEdit>
-#include <QToolButton>
#include <QCheckBox>
#ifdef _DEBUG
#include <cfloat>
#include <climits>
-ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(ModuleBase_Operation* theOperation)
- : myOperation(theOperation)
+ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(ModuleBase_Operation* theOperation, ModuleBase_IWorkshop* theWorkshop)
+ : myOperation(theOperation), myWorkshop(theWorkshop)
{
QString aXml = myOperation->getDescription()->xmlRepresentation();
myWidgetApi = new Config_WidgetAPI(aXml.toStdString());
QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent)
{
- QWidget* aRes = new QWidget();
- QHBoxLayout* aLayout = new QHBoxLayout(aRes);
+ ModuleBase_SelectorWidget* aSelector = new ModuleBase_SelectorWidget(theParent, myWorkshop, myWidgetApi);
+
+ QObject::connect(aSelector, SIGNAL(valuesChanged()), myOperation, SLOT(storeCustomValue()));
- aLayout->setContentsMargins(0, 0, 0, 0);
- QString aLabelText = qs(myWidgetApi->widgetLabel());
- QString aLabelIcon = qs(myWidgetApi->widgetIcon());
- QLabel* aLabel = new QLabel(aLabelText, aRes);
- aLabel->setPixmap(QPixmap(aLabelIcon));
-
- aLayout->addWidget(aLabel);
-
- QLineEdit* aTextLine = new QLineEdit(aRes);
- aTextLine->setReadOnly(true);
-
- aLayout->addWidget(aTextLine);
-
- QToolButton* aActivateBtn = new QToolButton(aRes);
- aActivateBtn->setIcon(QIcon(":icons/hand_point.png"));
- aActivateBtn->setCheckable(true);
-
- aLayout->addWidget(aActivateBtn);
-
- return aRes;
+ myModelWidgets.append(aSelector);
+ return aSelector->getControl();
}
#ifndef ModuleBase_WidgetFactory_H_
#define ModuleBase_WidgetFactory_H_
-#include <ModuleBase.h>
-#include <ModuleBase_ModelWidget.h>
+#include "ModuleBase.h"
+#include "ModuleBase_ModelWidget.h"
#include <QString>
#include <QList>
class QWidget;
class Config_WidgetAPI;
class ModuleBase_Operation;
+class ModuleBase_IWorkshop;
class MODULEBASE_EXPORT ModuleBase_WidgetFactory
{
public:
- ModuleBase_WidgetFactory(ModuleBase_Operation*);
+ ModuleBase_WidgetFactory(ModuleBase_Operation* theOperation, ModuleBase_IWorkshop* theWorkshop);
virtual ~ModuleBase_WidgetFactory();
void createWidget(QWidget* theParent);
private:
Config_WidgetAPI* myWidgetApi;
ModuleBase_Operation* myOperation;
+ ModuleBase_IWorkshop* myWorkshop;
QList<ModuleBase_ModelWidget*> myModelWidgets;
};
-INCLUDE(FindCAS)
-
SET(CMAKE_AUTOMOC ON)
SET(PROJECT_HEADERS
INCLUDE(Common)
-INCLUDE(FindCAS)
SET(CMAKE_AUTOMOC ON)
std::string aDescription = aWdgReader.featureDescription(aStdCmdId);
// create the operation
- ModuleBase_Operation* anOperation;
+ ModuleBase_Operation* anOperation = 0;
if (theCmdId == PartSet_OperationSketch::Type()) {
anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
}
-INCLUDE(FindCAS)
SET(CMAKE_AUTOMOC ON)
XGUI_ViewerPrs.h
XGUI_PropertyPanel.h
XGUI_ContextMenuMgr.h
+ XGUI_ModuleConnector.h
)
SET(PROJECT_AUTOMOC
XGUI_ViewerPrs.cpp
XGUI_PropertyPanel.cpp
XGUI_ContextMenuMgr.cpp
+ XGUI_ModuleConnector.cpp
)
SET(PROJECT_RESOURCES
--- /dev/null
+// File: XGUI_ModuleConnector.cpp
+// Created: 3 June 2014
+// Author: Vitaly Smetannikov
+
+
+#include "XGUI_ModuleConnector.h"
+#include "XGUI_Workshop.h"
+#include "XGUI_ViewerProxy.h"
+#include "XGUI_SelectionMgr.h"
+
+
+
+XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
+: ModuleBase_IWorkshop(theWorkshop), myWorkshop(theWorkshop)
+{
+ XGUI_SelectionMgr* aSelector = myWorkshop->selector();
+ connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
+}
+
+XGUI_ModuleConnector::~XGUI_ModuleConnector()
+{
+}
+
+Handle(AIS_InteractiveContext) XGUI_ModuleConnector::AISContext() const
+{
+ return myWorkshop->viewer()->AISContext();
+}
+
+
+QFeatureList XGUI_ModuleConnector::selectedFeatures() const
+{
+ return myWorkshop->selector()->selectedFeatures();
+}
\ No newline at end of file
--- /dev/null
+// File: XGUI_ModuleConnector.h
+// Created: 3 June 2014
+// Author: Vitaly Smetannikov
+
+#ifndef XGUI_ModuleConnector_H
+#define XGUI_ModuleConnector_H
+
+
+#include "XGUI.h"
+#include "XGUI_Constants.h"
+
+#include <ModuleBase_IWorkshop.h>
+
+class Handle_AIS_InteractiveContext;
+class XGUI_Workshop;
+
+/**
+* Implementation of IWorkshop interface which provides access to Workshop sevices at module level
+*/
+class XGUI_EXPORT XGUI_ModuleConnector: public ModuleBase_IWorkshop
+{
+ Q_OBJECT
+public:
+ XGUI_ModuleConnector(XGUI_Workshop* theWorkshop);
+
+ virtual ~XGUI_ModuleConnector();
+
+ //! Returns AIS_InteractiveContext from current OCCViewer
+ virtual Handle(AIS_InteractiveContext) AISContext() const;
+
+ //! Returns list of currently selected data objects
+ QFeatureList selectedFeatures() const;
+
+private:
+ XGUI_Workshop* myWorkshop;
+};
+
+#endif
\ No newline at end of file
aLabelWgt->setFrameShape(myTreeView->frameShape());
aLabelWgt->setFrameShadow(myTreeView->frameShadow());
- connect(myTreeView, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
+ connect(myTreeView, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(onActivePartChanged(FeaturePtr)));
connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SIGNAL(activePartChanged(FeaturePtr)));
myActiveDocLbl->setProperty("OldText", myActiveDocLbl->text());
}
}
+}
+
+//***************************************************
+void XGUI_ObjectsBrowser::onSelectionChanged()
+{
+ myFeaturesList = myTreeView->selectedFeatures();
+ emit selectionChanged();
}
\ No newline at end of file
//! Called on Edit command request
void onEditItem();
+ void onSelectionChanged();
+
private:
void closeDocNameEditing(bool toSave);
XGUI_Workshop* myWorkshop;
};
-#endif
\ No newline at end of file
+#endif
#include "XGUI_ViewerProxy.h"
#include "XGUI_PropertyPanel.h"
#include "XGUI_ContextMenuMgr.h"
+#include "XGUI_ModuleConnector.h"
#include <Model_Events.h>
#include <ModelAPI_PluginManager.h>
this, SLOT(onContextMenuCommand(const QString&, bool)));
myViewerProxy = new XGUI_ViewerProxy(this);
+
+ myModuleConnector = new XGUI_ModuleConnector(this);
connect(myOperationMgr, SIGNAL(operationStarted()), SLOT(onOperationStarted()));
connect(myOperationMgr, SIGNAL(operationResumed()), SLOT(onOperationStarted()));
showPropertyPanel();
- ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation);
+ ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation, myModuleConnector);
QWidget* aContent = myPropertyPanel->contentWidget();
qDeleteAll(aContent->children());
aFactory.createWidget(aContent);
class XGUI_ViewerProxy;
class XGUI_PropertyPanel;
class XGUI_ContextMenuMgr;
+class XGUI_ModuleConnector;
class ModuleBase_Operation;
XGUI_ErrorDialog* myErrorDlg;
XGUI_ViewerProxy* myViewerProxy;
XGUI_ContextMenuMgr* myContextMenuMgr;
+ XGUI_ModuleConnector* myModuleConnector;
QString myCurrentDir;
static QMap<QString, QString> myIcons;