ADD_SUBDIRECTORY (src/PartSet)
ADD_SUBDIRECTORY (src/XGUI)
ADD_SUBDIRECTORY (src/GeomApp)
+ADD_SUBDIRECTORY (src/ExchangePlugin)
IF(${HAVE_SALOME})
ADD_SUBDIRECTORY (src/NewGeom)
@SET PATH=%ROOT_DIR%\install\plugins;%ROOT_DIR%\install\bin;%PATH%
@SET PYTHONPATH=%ROOT_DIR%\install\swig;%PYTHONPATH%
+@REM -------------------------
+@REM PTHREAD
+@SET PATH=%PDIR%\pthreads-2.9.1\lib;%PATH%
+@REM -------------------------
+
+
@REM -------------------------
@REM SUIT
@SET SUIT_DIR=%PDIR%\suit
\r
public:\r
//const Events_ID theID, const void* theSender = 0\r
- CONFIG_EXPORT Config_FeatureMessage(const Events_ID theId, const void* theParent = 0);CONFIG_EXPORT virtual ~Config_FeatureMessage();\r
+ CONFIG_EXPORT Config_FeatureMessage(const Events_ID theId, const void* theParent = 0);\r
+ CONFIG_EXPORT virtual ~Config_FeatureMessage();\r
\r
//Auto-generated getters/setters\r
- CONFIG_EXPORT const std::string& icon() const;CONFIG_EXPORT const std::string& id() const;CONFIG_EXPORT const std::string& keysequence() const;CONFIG_EXPORT const std::string& text() const;CONFIG_EXPORT const std::string& tooltip() const;\r
+ CONFIG_EXPORT const std::string& icon() const;\r
+ CONFIG_EXPORT const std::string& id() const;\r
+ CONFIG_EXPORT const std::string& keysequence() const;\r
+ CONFIG_EXPORT const std::string& text() const;\r
+ CONFIG_EXPORT const std::string& tooltip() const;\r
+ CONFIG_EXPORT const std::string& groupId() const;\r
+ CONFIG_EXPORT const std::string& workbenchId() const;\r
+ CONFIG_EXPORT const std::string& pluginLibrary() const;\r
+ CONFIG_EXPORT const std::string& nestedFeatures() const;\r
+ CONFIG_EXPORT bool isUseInput() const;\r
+ CONFIG_EXPORT bool isInternal() const;\r
\r
- CONFIG_EXPORT const std::string& groupId() const;CONFIG_EXPORT const std::string& workbenchId() const;CONFIG_EXPORT const std::string& pluginLibrary() const;CONFIG_EXPORT const std::string& nestedFeatures() const;CONFIG_EXPORT bool isUseInput() const;CONFIG_EXPORT bool isInternal() const;\r
-\r
- CONFIG_EXPORT void setIcon(const std::string& icon);CONFIG_EXPORT void setId(\r
- const std::string& id);CONFIG_EXPORT void setKeysequence(const std::string& keysequence);CONFIG_EXPORT void setText(\r
- const std::string& text);CONFIG_EXPORT void setTooltip(const std::string& tooltip);CONFIG_EXPORT void setGroupId(\r
- const std::string& groupId);CONFIG_EXPORT void setWorkbenchId(const std::string& workbenchId);CONFIG_EXPORT void setPluginLibrary(\r
- const std::string& thePluginLibrary);CONFIG_EXPORT void setNestedFeatures(\r
- const std::string& theNestedFeatures);CONFIG_EXPORT void setUseInput(bool isUseInput);CONFIG_EXPORT void setInternal(\r
- bool isInternal);\r
+ CONFIG_EXPORT void setIcon(const std::string& icon);\r
+ CONFIG_EXPORT void setId(const std::string& id);\r
+ CONFIG_EXPORT void setKeysequence(const std::string& keysequence);\r
+ CONFIG_EXPORT void setText(const std::string& text);\r
+ CONFIG_EXPORT void setTooltip(const std::string& tooltip);\r
+ CONFIG_EXPORT void setGroupId(const std::string& groupId);\r
+ CONFIG_EXPORT void setWorkbenchId(const std::string& workbenchId);\r
+ CONFIG_EXPORT void setPluginLibrary(const std::string& thePluginLibrary);\r
+ CONFIG_EXPORT void setNestedFeatures(const std::string& theNestedFeatures);\r
+ CONFIG_EXPORT void setUseInput(bool isUseInput);\r
+ CONFIG_EXPORT void setInternal(bool isInternal);\r
};\r
\r
#endif // CONFIG_MESSAGE_H\r
const static char* WDG_SWITCH_CASE = "case";
const static char* WDG_SELECTOR = "selector";
-//Specific widget containers
+//Specific widgets
const static char* WDG_POINT_SELECTOR = "point_selector";
const static char* WDG_POINT2D_DISTANCE = "point2ddistance";
-
const static char* WDG_FEATURE_SELECTOR = "feature_selector";
const static char* WDG_FEATURE_OR_ATTRIBUTE_SELECTOR = "feature_or_attribute_selector";
const static char* WDG_DOUBLEVALUE_EDITOR = "doublevalue_editor";
+const static char* WDG_FILE_SELECTOR= "file_selector";
+
//Common Widget's or Feature's Properties
const static char* _ID = "id";
Config_WidgetAPI(std::string theRawXml);
virtual ~Config_WidgetAPI();
+ //TODO(sbh): Make these fields protected, accessible only for WidgetFactory
bool toNextWidget();
bool toChildWidget();
bool toParentWidget();
<plugin library="SketchPlugin" configuration="plugin-Sketch.xml"/>
<plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
<plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
+ <plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
<plugin library="SketchSolver"/>
<plugin library="DFBrowser"/>
</plugins>
--- /dev/null
+INCLUDE(Common)
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events
+ ${PROJECT_SOURCE_DIR}/src/Config
+ ${PROJECT_SOURCE_DIR}/src/ModelAPI
+ ${PROJECT_SOURCE_DIR}/src/GeomAPI
+ ${CAS_INCLUDE_DIRS}
+)
+
+SET(PROJECT_HEADERS
+ ExchangePlugin.h
+ ExchangePlugin_Plugin.h
+ ExchangePlugin_ImportFeature.h
+ ExchangePlugin_Validators.h
+)
+
+SET(PROJECT_SOURCES
+ ExchangePlugin_Plugin.cpp
+ ExchangePlugin_ImportFeature.cpp
+ ExchangePlugin_Validators.cpp
+)
+
+SET(XML_RESOURCES
+ plugin-Exchange.xml
+)
+
+SET(PROJECT_LIBRARIES
+ Events
+ ModelAPI
+ Config
+ GeomAPI
+ ${CAS_OCAF}
+ ${CAS_TKCAF}
+)
+
+ADD_DEFINITIONS(-DEXCHANGEPLUGIN_EXPORTS ${CAS_DEFINITIONS})
+ADD_LIBRARY(ExchangePlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES})
+
+TARGET_LINK_LIBRARIES(ExchangePlugin ${PROJECT_LIBRARIES})
+
+INSTALL(TARGETS ExchangePlugin DESTINATION plugins)
+INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
--- /dev/null
+#ifndef EXCHANGEPLUGIN_H
+#define EXCHANGEPLUGIN_H
+
+#if defined EXCHANGEPLUGIN_EXPORTS
+#if defined WIN32
+#define EXCHANGEPLUGIN_EXPORT __declspec( dllexport )
+#else
+#define EXCHANGEPLUGIN_EXPORT
+#endif
+#else
+#if defined WIN32
+#define EXCHANGEPLUGIN_EXPORT __declspec( dllimport )
+#else
+#define EXCHANGEPLUGIN_EXPORT
+#endif
+#endif
+
+#endif
--- /dev/null
+/*
+ * ExchangePlugin_ImportFeature.cpp
+ *
+ * Created on: Aug 28, 2014
+ * Author: sbh
+ */
+
+#include <ExchangePlugin_ImportFeature.h>
+
+#include <GeomAPI_Shape.h>
+#include <Config_Common.h>
+#include <Events_Error.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_ResultBody.h>
+
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Label.hxx>
+#include <TopoDS_Shape.hxx>
+#include <OSD_Path.hxx>
+
+#include <algorithm>
+#include <string>
+#ifdef _DEBUG
+#include <iostream>
+#include <ostream>
+#endif
+
+#ifdef WIN32
+# define _separator_ '\\'
+#else
+# define _separator_ '/'
+#endif
+
+typedef TopoDS_Shape (*importFunctionPointer)(const TCollection_AsciiString&,
+ const TCollection_AsciiString&,
+ TCollection_AsciiString&,
+ const TDF_Label&);
+
+ExchangePlugin_ImportFeature::ExchangePlugin_ImportFeature()
+{
+}
+
+ExchangePlugin_ImportFeature::~ExchangePlugin_ImportFeature()
+{
+ // TODO Auto-generated destructor stub
+}
+
+/*
+ * Returns the unique kind of a feature
+ */
+const std::string& ExchangePlugin_ImportFeature::getKind()
+{
+ return ExchangePlugin_ImportFeature::ID();
+}
+
+/*
+ * Request for initialization of data model of the feature: adding all attributes
+ */
+void ExchangePlugin_ImportFeature::initAttributes()
+{
+ data()->addAttribute(ExchangePlugin_ImportFeature::FILE_PATH_ID(), ModelAPI_AttributeString::type());
+}
+
+/*
+ * Computes or recomputes the results
+ */
+void ExchangePlugin_ImportFeature::execute()
+{
+ AttributeStringPtr aFilePathAttr = boost::dynamic_pointer_cast<ModelAPI_AttributeString>(
+ data()->attribute(ExchangePlugin_ImportFeature::FILE_PATH_ID()));
+ std::string aFilePath = aFilePathAttr->value();
+ if(aFilePath.empty())
+ return;
+ importFile(aFilePath);
+}
+
+bool ExchangePlugin_ImportFeature::importFile(const std::string& theFileName)
+{
+ // retrieve the file and plugin library names
+ TCollection_AsciiString aFileName (theFileName.c_str());
+ OSD_Path aPath(aFileName);
+ TCollection_AsciiString aFormatName = aPath.Extension();
+ // ".brep" -> "BREP". TCollection_AsciiString are numbered from 1
+ aFormatName = aFormatName.SubString(2, aFormatName.Length());
+ aFormatName.UpperCase();
+
+ // Load plugin library and get the "Import" method
+ LibHandle anImportLib = loadImportPlugin(std::string(aFormatName.ToCString()));
+ if(!anImportLib)
+ return false;
+ importFunctionPointer fp = (importFunctionPointer) GetProc(anImportLib, "Import");
+ // Perform the import
+ TCollection_AsciiString anError;
+ TDF_Label anUnknownLabel = TDF_Label();
+ TopoDS_Shape aShape = fp(aFileName,
+ aFormatName,
+ anError,
+ anUnknownLabel);
+ // Check if shape is valid
+ if ( aShape.IsNull() ) {
+ std::string aShapeError = "An error occurred while importing " + theFileName + ": ";
+ aShapeError = aShapeError + std::string(anError.ToCString());
+ Events_Error::send(aShapeError, this);
+ #ifdef _DEBUG
+ std::cerr << aShapeError << std::endl;
+ #endif
+ return false;
+ }
+ // Pass the results into the model
+ std::string anObjectName = aPath.Name().ToCString();
+ data()->setName(anObjectName);
+ boost::shared_ptr<ModelAPI_ResultBody> aResult = document()->createBody(data());
+ boost::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
+ aGeomShape->setImpl(new TopoDS_Shape(aShape));
+ aResult->store(aGeomShape);
+ setResult(aResult);
+
+ return true;
+}
+
+LibHandle ExchangePlugin_ImportFeature::loadImportPlugin(const std::string& theFormatName)
+{
+ std::string aLibName = library(theFormatName + ID());
+ LibHandle anImportLib = LoadLib(aLibName.c_str());
+ std::string anImportError = "Failed to load " + aLibName + ": ";
+ if(!anImportLib) {
+#ifdef WIN32
+ LPVOID lpMsgBuf;
+ ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ 0, ::GetLastError(), 0, (LPTSTR) &lpMsgBuf, 0, 0);
+ anImportError = anImportError + std::string((char*) lpMsgBuf);
+ ::LocalFree(lpMsgBuf);
+#else
+ anImportError = anImportError + std::string(dlerror());
+#endif
+ Events_Error::send(anImportError, this);
+#ifdef _DEBUG
+ std::cerr << anImportError << std::endl;
+#endif
+ return false;
+ }
+ // Test loaded plugin for existence of valid "Import" function:
+ importFunctionPointer fp = (importFunctionPointer) GetProc(anImportLib, "Import");
+ if (!fp) {
+ std::string aFunctionError = "No valid \"Import\" function was found in the " + aLibName;
+ Events_Error::send(aFunctionError, this);
+#ifdef _DEBUG
+ std::cerr << aFunctionError << std::endl;
+#endif
+ UnLoadLib(anImportLib)
+ return NULL;
+ }
+ return anImportLib;
+}
--- /dev/null
+/*
+ * ExchangePlugin_ImportFeature.h
+ *
+ * Created on: Aug 28, 2014
+ * Author: sbh
+ */
+
+#ifndef EXCHANGEPLUGIN_IMPORTFEATURE_H_
+#define EXCHANGEPLUGIN_IMPORTFEATURE_H_
+
+#include <ExchangePlugin.h>
+#include <ModelAPI_Feature.h>
+
+#include <map>
+
+#ifdef WIN32
+#include <windows.h>
+#define LibHandle HMODULE
+#define LoadLib( name ) LoadLibrary( name )
+#define GetProc GetProcAddress
+#define UnLoadLib( handle ) FreeLibrary( handle );
+#else
+#include <dlfcn.h>
+#define LibHandle void*
+#define LoadLib( name ) dlopen( name, RTLD_LAZY | RTLD_GLOBAL)
+#define GetProc dlsym
+#define UnLoadLib( handle ) dlclose( handle );
+#endif
+
+class EXCHANGEPLUGIN_EXPORT ExchangePlugin_ImportFeature : public ModelAPI_Feature
+{
+ public:
+ /// Extrusion kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_IMPORT_ID("Import");
+ return MY_IMPORT_ID;
+ }
+ /// attribute name of referenced face
+ inline static const std::string& FILE_PATH_ID()
+ {
+ static const std::string MY_FILE_PATH_ID("import_file_selector");
+ return MY_FILE_PATH_ID;
+ }
+
+ ExchangePlugin_ImportFeature();
+ virtual ~ExchangePlugin_ImportFeature();
+
+ /// Returns the unique kind of a feature
+ virtual const std::string& getKind();
+
+ /// Request for initialization of data model of the feature: adding all attributes
+ virtual void initAttributes();
+
+ /// Computes or recomputes the results
+ virtual void execute();
+
+ virtual bool isInHistory()
+ {
+ return false;
+ }
+
+ protected:
+ bool importFile(const std::string& theFileName);
+ LibHandle loadImportPlugin(const std::string& theFormatName);
+
+};
+
+#endif /* IMPORT_IMPORTFEATURE_H_ */
--- /dev/null
+/*
+ *
+ */
+
+#include <ExchangePlugin_Plugin.h>
+#include <ExchangePlugin_ImportFeature.h>
+
+#include <ModelAPI_PluginManager.h>
+
+#include <boost/smart_ptr/shared_ptr.hpp>
+
+using namespace std;
+
+// the only created instance of this plugin
+static ExchangePlugin_Plugin* MY_INSTANCE = new ExchangePlugin_Plugin();
+
+ExchangePlugin_Plugin::ExchangePlugin_Plugin()
+{
+ // register this plugin
+ ModelAPI_PluginManager::get()->registerPlugin(this);
+}
+
+FeaturePtr ExchangePlugin_Plugin::createFeature(string theFeatureID)
+{
+ if (theFeatureID == ExchangePlugin_ImportFeature::ID()) {
+ return FeaturePtr(new ExchangePlugin_ImportFeature);
+ }
+ // feature of such kind is not found
+ return FeaturePtr();
+}
--- /dev/null
+// File: ExchangePlugin_Plugin.hxx
+// Created: 07 July 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef EXCHANGEPLUGIN_PLUGIN_H_
+#define EXCHANGEPLUGIN_PLUGIN_H_
+
+#include <ExchangePlugin.h>
+#include <ModelAPI_Plugin.h>
+#include <ModelAPI_Feature.h>
+
+class EXCHANGEPLUGIN_EXPORT ExchangePlugin_Plugin : public ModelAPI_Plugin
+{
+ public:
+ /// Creates the feature object of this plugin by the feature string ID
+ virtual FeaturePtr createFeature(std::string theFeatureID);
+
+ public:
+ /// Is needed for python wrapping by swig
+ ExchangePlugin_Plugin();
+};
+
+#endif
--- /dev/null
+// File: SketchPlugin_Validators.cpp
+// Created: 01 Aug 2014
+// Author: Vitaly SMETANNIKOV
+
+#include <ExchangePlugin_Validators.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_PluginManager.h>
+
+#include <list>
+#include <string>
+
+
+bool ExchangePlugin_ImportFormatValidator::isValid(const FeaturePtr& theFeature,
+ const std::list<std::string>& theArguments,
+ const ObjectPtr& theObject) const
+{
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+ return false;
+}
+
--- /dev/null
+// File: SketchPlugin_Validators.h
+// Created: 01 Aug 2014
+// Author: Vitaly SMETANNIKOV
+
+#ifndef EXCHANGEPLUGIN_VALIDATORS_H
+#define EXCHANGEPLUGIN_VALIDATORS_H
+
+#include "ExchangePlugin.h"
+#include <ModelAPI_AttributeValidator.h>
+
+class ExchangePlugin_ImportFormatValidator : public ModelAPI_AttributeValidator
+{
+ public:
+ virtual bool isValid(const FeaturePtr& theFeature,
+ const std::list<std::string>& theArguments,
+ const ObjectPtr& theObject) const;
+
+};
+
+#endif
--- /dev/null
+<plugin>
+ <workbench id="Features">
+ <group id="Exchange">
+ <feature
+ id="Import"
+ title="Import"
+ tooltip="Import a mesh"
+ icon=":icons/import.png">
+ <file_selector
+ id="import_file_selector"
+ title="Import file"
+ path="D:\NewGEOM\data\brep-step"
+ formats="BREP,STEP" />
+ <!-- TODO: pass formats as validator
+ <validator id="Format" parameters="BREP:BREPImport,STEP:STEPImport" />
+ -->
+ </feature>
+ </group>
+ </workbench>
+</plugin>
\ No newline at end of file
Model_AttributeRefAttr.h
Model_AttributeRefList.h
Model_AttributeBoolean.h
+ Model_AttributeString.h
Model_Events.h
Model_Update.h
Model_Validator.h
Model_AttributeRefAttr.cpp
Model_AttributeRefList.cpp
Model_AttributeBoolean.cpp
+ Model_AttributeString.cpp
Model_Events.cpp
Model_Update.cpp
Model_Validator.cpp
#include <TDataStd_Integer.hxx>
#include <TDF_Label.hxx>
-/**\class Model_AttributeDouble
+/**\class Model_AttributeBoolean
* \ingroup DataModel
* \brief Attribute that contains real value with double precision.
*/
--- /dev/null
+// File: Model_AttributeString.cpp
+// Created: 2 june 2014
+// Author: Vitaly Smetannikov
+
+#include <Model_AttributeString.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Attribute.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Object.h>
+
+#include <Standard_TypeDef.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_Name.hxx>
+
+#include <string>
+
+void Model_AttributeString::setValue(const std::string& theValue)
+{
+ TCollection_ExtendedString aValue(theValue.c_str());
+ if (!myIsInitialized || myString->Get() != aValue) {
+ myString->Set(aValue);
+ owner()->data()->sendAttributeUpdated(this);
+ }
+}
+
+std::string Model_AttributeString::value()
+{
+ return TCollection_AsciiString(myString->Get()).ToCString();
+}
+
+Model_AttributeString::Model_AttributeString(TDF_Label& theLabel)
+{
+ // check the attribute could be already presented in this doc (after load document)
+ myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myString) == Standard_True;
+ if (!myIsInitialized) {
+ // create attribute: not initialized by value yet, just empty string
+ myString = TDataStd_Name::Set(theLabel, TCollection_ExtendedString());
+ }
+}
--- /dev/null
+// File: Model_AttributeString.h
+// Created: 2 june 2014
+// Author: Vitaly Smetannikov
+
+#ifndef Model_AttributeString_H_
+#define Model_AttributeString_H_
+
+#include <Model.h>
+#include <ModelAPI_AttributeString.h>
+
+#include <TDF_Label.hxx>
+#include <Handle_TDataStd_Name.hxx>
+
+#include <string>
+
+/**\class Model_AttributeString
+ * \ingroup DataModel
+ * \brief Attribute that contains std (null terminated) string.
+ */
+
+class Model_AttributeString : public ModelAPI_AttributeString
+{
+ Handle_TDataStd_Name myString; ///< double is Real attribute
+ public:
+ /// Defines the double value
+ MODEL_EXPORT virtual void setValue(const std::string& theValue);
+
+ /// Returns the double value
+ MODEL_EXPORT virtual std::string value();
+
+ protected:
+ /// Initializes attibutes
+ Model_AttributeString(TDF_Label& theLabel);
+
+ friend class Model_Data;
+};
+
+#endif
#include <Model_AttributeRefAttr.h>
#include <Model_AttributeRefList.h>
#include <Model_AttributeBoolean.h>
+#include <Model_AttributeString.h>
+#include <Model_Events.h>
+
#include <GeomData_Point.h>
#include <GeomData_Point2D.h>
#include <GeomData_Dir.h>
-#include <TDataStd_Name.hxx>
-#include "Model_Events.h"
#include <Events_Loop.h>
#include <Events_Error.h>
-using namespace std;
+#include <TDataStd_Name.hxx>
Model_Data::Model_Data()
{
myLab = theLab;
}
-string Model_Data::name()
+std::string Model_Data::name()
{
Handle(TDataStd_Name) aName;
if (myLab.FindAttribute(TDataStd_Name::GetID(), aName))
- return string(TCollection_AsciiString(aName->Get()).ToCString());
+ return std::string(TCollection_AsciiString(aName->Get()).ToCString());
return ""; // not defined
}
-void Model_Data::setName(const string& theName)
+void Model_Data::setName(const std::string& theName)
{
bool isModified = false;
Handle(TDataStd_Name) aName;
}*/
}
-void Model_Data::addAttribute(const string& theID, const string theAttrType)
+void Model_Data::addAttribute(const std::string& theID, const std::string theAttrType)
{
TDF_Label anAttrLab = myLab.FindChild(myAttrs.size() + 1);
ModelAPI_Attribute* anAttr = 0;
- if (theAttrType == ModelAPI_AttributeDocRef::type())
+ if (theAttrType == ModelAPI_AttributeDocRef::type()) {
anAttr = new Model_AttributeDocRef(anAttrLab);
- else if (theAttrType == ModelAPI_AttributeDouble::type())
+ } else if (theAttrType == ModelAPI_AttributeDouble::type()) {
anAttr = new Model_AttributeDouble(anAttrLab);
- else if (theAttrType == ModelAPI_AttributeReference::type())
+ } else if (theAttrType == ModelAPI_AttributeReference::type()) {
anAttr = new Model_AttributeReference(anAttrLab);
- else if (theAttrType == ModelAPI_AttributeRefAttr::type())
+ } else if (theAttrType == ModelAPI_AttributeRefAttr::type()) {
anAttr = new Model_AttributeRefAttr(anAttrLab);
- else if (theAttrType == ModelAPI_AttributeRefList::type())
+ } else if (theAttrType == ModelAPI_AttributeRefList::type()) {
anAttr = new Model_AttributeRefList(anAttrLab);
- else if (theAttrType == GeomData_Point::type())
+ } else if (theAttrType == GeomData_Point::type()) {
anAttr = new GeomData_Point(anAttrLab);
- else if (theAttrType == GeomData_Dir::type())
+ } else if (theAttrType == GeomData_Dir::type()) {
anAttr = new GeomData_Dir(anAttrLab);
- else if (theAttrType == GeomData_Point2D::type())
+ } else if (theAttrType == GeomData_Point2D::type()) {
anAttr = new GeomData_Point2D(anAttrLab);
- else if (theAttrType == Model_AttributeBoolean::type())
+ } else if (theAttrType == Model_AttributeBoolean::type()) {
anAttr = new Model_AttributeBoolean(anAttrLab);
-
+ } else if (theAttrType == Model_AttributeString::type()) {
+ anAttr = new Model_AttributeString(anAttrLab);
+ }
if (anAttr) {
myAttrs[theID] = boost::shared_ptr<ModelAPI_Attribute>(anAttr);
anAttr->setObject(myObject);
}
}
-boost::shared_ptr<ModelAPI_AttributeDocRef> Model_Data::docRef(const string& theID)
+boost::shared_ptr<ModelAPI_AttributeDocRef> Model_Data::docRef(const std::string& theID)
{
- map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeDocRef>();
return aRes;
}
-boost::shared_ptr<ModelAPI_AttributeDouble> Model_Data::real(const string& theID)
+boost::shared_ptr<ModelAPI_AttributeDouble> Model_Data::real(const std::string& theID)
{
- map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeDouble>();
boost::shared_ptr<ModelAPI_AttributeBoolean> Model_Data::boolean(const std::string& theID)
{
- map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeBoolean>();
return aRes;
}
-boost::shared_ptr<ModelAPI_AttributeReference> Model_Data::reference(const string& theID)
+boost::shared_ptr<ModelAPI_AttributeString> Model_Data::string(const std::string& theID)
+{
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ if (aFound == myAttrs.end()) {
+ // TODO: generate error on unknown attribute request and/or add mechanism for customization
+ return boost::shared_ptr<ModelAPI_AttributeString>();
+ }
+ boost::shared_ptr<ModelAPI_AttributeString> aRes =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeString>(aFound->second);
+ if (!aRes) {
+ // TODO: generate error on invalid attribute type request
+ }
+ return aRes;
+
+}
+
+boost::shared_ptr<ModelAPI_AttributeReference> Model_Data::reference(const std::string& theID)
{
- map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeReference>();
return aRes;
}
-boost::shared_ptr<ModelAPI_AttributeRefAttr> Model_Data::refattr(const string& theID)
+boost::shared_ptr<ModelAPI_AttributeRefAttr> Model_Data::refattr(const std::string& theID)
{
- map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeRefAttr>();
return aRes;
}
-boost::shared_ptr<ModelAPI_AttributeRefList> Model_Data::reflist(const string& theID)
+boost::shared_ptr<ModelAPI_AttributeRefList> Model_Data::reflist(const std::string& theID)
{
- map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
if (aFound == myAttrs.end()) {
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeRefList>();
return myAttrs[theID];
}
-const string& Model_Data::id(const boost::shared_ptr<ModelAPI_Attribute>& theAttr)
+const std::string& Model_Data::id(const boost::shared_ptr<ModelAPI_Attribute>& theAttr)
{
- map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = myAttrs.begin();
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttr = myAttrs.begin();
for (; anAttr != myAttrs.end(); anAttr++) {
if (anAttr->second == theAttr)
return anAttr->first;
}
// not found
- static string anEmpty;
+ static std::string anEmpty;
return anEmpty;
}
return !myLab.IsNull() && myLab.HasAttribute();
}
-list<boost::shared_ptr<ModelAPI_Attribute> > Model_Data::attributes(const string& theType)
+std::list<boost::shared_ptr<ModelAPI_Attribute> > Model_Data::attributes(const std::string& theType)
{
- list<boost::shared_ptr<ModelAPI_Attribute> > aResult;
- map<string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttrsIter = myAttrs.begin();
+ std::list<boost::shared_ptr<ModelAPI_Attribute> > aResult;
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttrsIter = myAttrs.begin();
for (; anAttrsIter != myAttrs.end(); anAttrsIter++) {
if (theType.empty() || anAttrsIter->second->attributeType() == theType) {
aResult.push_back(anAttrsIter->second);
#ifndef Model_Data_H_
#define Model_Data_H_
-#include "Model.h"
+#include <Model.h>
+#include <ModelAPI_Attribute.h>
+#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeDocRef.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_AttributeString.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Feature.h>
+#include <ModelAPI_Object.h>
+
#include <TDF_Label.hxx>
+#include <boost/smart_ptr/shared_ptr.hpp>
+
#include <map>
+#include <list>
+#include <string>
class ModelAPI_Attribute;
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string& theID);
/// Returns the attribute that contains reference to a feature
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeReference>
- reference(const std::string& theID);
+ reference(const std::string& theID);
/// Returns the attribute that contains reference to an attribute of a feature
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeRefAttr>
- refattr(const std::string& theID);
+ refattr(const std::string& theID);
/// Returns the attribute that contains list of references to features
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeRefList>
- reflist(const std::string& theID);
+ reflist(const std::string& theID);
/// Returns the attribute that contains boolean value
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeBoolean>
- boolean(const std::string& theID);
+ boolean(const std::string& theID);
+ /// Returns the attribute that contains real value with double precision
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeString>
+ string(const std::string& theID);
/// Returns the generic attribute by identifier
/// \param theID identifier of the attribute
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID);
/// Returns all attributes ofthe feature of the given type
/// or all attributes if "theType" is empty
MODEL_EXPORT virtual std::list<boost::shared_ptr<ModelAPI_Attribute> >
- attributes(const std::string& theType);
+ attributes(const std::string& theType);
/// Identifier by the id (not fast, iteration by map)
/// \param theAttr attribute already created in this data
#include <list>
#include <boost/shared_ptr.hpp>
-bool Model_FeatureValidator::isValid(const boost::shared_ptr<ModelAPI_Feature>& theFeature
-/*, const std::string theAttr*/
-/*, std::list<std::string> theArguments*/) const
+bool Model_FeatureValidator::isValid(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const
{
boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
if (!aData->isValid())
}
}
}
+ addDefaultValidators(theResult);
}
void Model_ValidatorsFactory::validators(const std::string& theFeatureID,
}
return NULL;
}
+
+void Model_ValidatorsFactory::addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators) const
+{
+ std::string anId = "Model_FeatureValidator";
+ std::map<std::string, ModelAPI_Validator*>::const_iterator it = myIDs.find(anId);
+ if(it == myIDs.end())
+ return;
+ theValidators.push_back(it->second);
+}
// const boost::shared_ptr<ModelAPI_Feature>& theFeature, const std::string& theAttrID) const;
protected:
+ void addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators) const;
/// Get instance from PluginManager
Model_ValidatorsFactory();
ModelAPI_AttributeRefAttr.h
ModelAPI_AttributeRefList.h
ModelAPI_AttributeBoolean.h
+ ModelAPI_AttributeString.h
ModelAPI_Events.h
ModelAPI_Validator.h
ModelAPI_FeatureValidator.h
#include "ModelAPI_Attribute.h"
#include "ModelAPI_AttributeDocRef.h"
#include "ModelAPI_AttributeDouble.h"
+ #include "ModelAPI_AttributeString.h"
#include "ModelAPI_AttributeReference.h"
#include "ModelAPI_AttributeRefAttr.h"
#include "ModelAPI_Validator.h"
%shared_ptr(ModelAPI_Attribute)
%shared_ptr(ModelAPI_AttributeDocRef)
%shared_ptr(ModelAPI_AttributeDouble)
+%shared_ptr(ModelAPI_AttributeString)
%shared_ptr(ModelAPI_AttributeReference)
%shared_ptr(ModelAPI_AttributeRefAttr)
%shared_ptr(ModelAPI_AttributeRefList)
%include "ModelAPI_Attribute.h"
%include "ModelAPI_AttributeDocRef.h"
%include "ModelAPI_AttributeDouble.h"
+%include "ModelAPI_AttributeString.h"
%include "ModelAPI_AttributeReference.h"
%include "ModelAPI_AttributeRefAttr.h"
%include "ModelAPI_Validator.h"
// Created: 2 june 2014
// Author: Vitaly Smetannikov
-#ifndef ModelAPI_AttributeBoolean_H_
-#define ModelAPI_AttributeBoolean_H_
+#ifndef MODELAPI_ATTRIBUTEBOOLEAN_H_
+#define MODELAPI_ATTRIBUTEBOOLEAN_H_
#include "ModelAPI_Attribute.h"
--- /dev/null
+// File: ModelAPI_AttributeString.h
+// Created: 2 Apr 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef MODELAPI_ATTRIBUTESTRING_H_
+#define MODELAPI_ATTRIBUTESTRING_H_
+
+#include "ModelAPI_Attribute.h"
+
+#include <string>
+
+/**\class ModelAPI_AttributeString
+ * \ingroup DataModel
+ * \brief API for the attribute that contains std (null terminated) string.
+ */
+
+class ModelAPI_AttributeString : public ModelAPI_Attribute
+{
+ public:
+ /// Defines the double value
+ MODELAPI_EXPORT virtual void setValue(const std::string& theValue) = 0;
+
+ /// Returns the double value
+ MODELAPI_EXPORT virtual std::string value() = 0;
+
+ /// Returns the type of this class of attributes
+ MODELAPI_EXPORT static std::string type()
+ {
+ return "String";
+ }
+
+ /// Returns the type of this class of attributes, not static method
+ MODELAPI_EXPORT virtual std::string attributeType()
+ {
+ return type();
+ }
+
+ /// To virtually destroy the fields of successors
+ MODELAPI_EXPORT virtual ~ModelAPI_AttributeString()
+ {
+ }
+
+ protected:
+ /// Objects are created for features automatically
+ MODELAPI_EXPORT ModelAPI_AttributeString()
+ {
+ }
+};
+
+//! Pointer on double attribute
+typedef boost::shared_ptr<ModelAPI_AttributeString> AttributeStringPtr;
+
+#endif
class ModelAPI_AttributeRefAttr;
class ModelAPI_AttributeRefList;
class ModelAPI_AttributeBoolean;
+class ModelAPI_AttributeString;
class ModelAPI_Document;
class ModelAPI_Attribute;
class GeomAPI_Shape;
virtual boost::shared_ptr<ModelAPI_AttributeRefList> reflist(const std::string& theID) = 0;
/// Returns the attribute that contains boolean value
virtual boost::shared_ptr<ModelAPI_AttributeBoolean> boolean(const std::string& theID) = 0;
+ /// Returns the attribute that contains boolean value
+ virtual boost::shared_ptr<ModelAPI_AttributeString> string(const std::string& theID) = 0;
/// Returns the generic attribute by identifier
/// \param theID identifier of the attribute
#include <ModelAPI_AttributeDocRef.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeString.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeRefAttr.h>
#include <ModelAPI_AttributeRefList.h>
virtual ~ModelAPI_Validator()
{
}
- ;
/// Returns true if feature and/or attributes are valid
/// \param theFeature the validated feature
ModuleBase_SelectionValidator.h
ModuleBase_ISelection.h
ModuleBase_ViewerPrs.h
+ ModuleBase_WidgetFileSelector.h
)
SET(PROJECT_SOURCES
ModuleBase_WidgetPoint2dDistance.cpp
ModuleBase_WidgetValue.cpp
ModuleBase_WidgetValueFeature.cpp
+ ModuleBase_WidgetFileSelector.cpp
)
SET(PROJECT_LIBRARIES
virtual ~ModuleBase_ModelWidget()
{
}
- ;
/// Set the given wrapped value to the current widget
/// This value should be processed in the widget according to the needs
{
return false;
}
- ;
/// Returns the state whether the attribute of the feature is initialized
/// \param theObject a model feature to be checked
void ModuleBase_Operation::commitOperation()
{
- if (myFeature)
- myFeature->execute();
}
void ModuleBase_Operation::afterCommitOperation()
myFeature = aDoc->addFeature(getDescription()->operationId().toStdString());
if (myFeature) { // TODO: generate an error if feature was not created
myIsModified = true;
- myFeature->execute();
+ // Model update should call "execute" of a feature.
+ //myFeature->execute();
// Init default values
/*QList<ModuleBase_ModelWidget*> aWidgets = getDescription()->modelWidgets();
QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
#include <ModuleBase_WidgetDoubleValue.h>
#include <ModuleBase_WidgetBoolValue.h>
#include <ModuleBase_WidgetPoint2dDistance.h>
+#include <ModuleBase_WidgetFileSelector.h>
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_IModule.h>
} else if (theType == WDG_POINT2D_DISTANCE) {
result = point2dDistanceControl(theParent);
-
+ } else if (theType == WDG_FILE_SELECTOR) {
+ result = fileSelectorControl(theParent);
} else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
result = createContainer(theType, theParent);
} else {
return aDistWgt->getControl();
}
+
+QWidget* ModuleBase_WidgetFactory::fileSelectorControl(QWidget* theParent)
+{
+ ModuleBase_WidgetFileSelector* aFileSelectorWgt =
+ new ModuleBase_WidgetFileSelector(theParent, myWidgetApi, myParentId);
+ myModelWidgets.append(aFileSelectorWgt);
+
+ return aFileSelectorWgt->getControl();
+}
QWidget* selectorControl(QWidget* theParent);
QWidget* booleanControl(QWidget* theParent);
QWidget* point2dDistanceControl(QWidget* theParent);
+ QWidget* fileSelectorControl(QWidget* theParent);
/// Check whether the XML definition for the given type contains internal property
/// \param theType the widget type
--- /dev/null
+/*
+ * ModuleBase_WidgetFileSelector.cpp
+ *
+ * Created on: Aug 28, 2014
+ * Author: sbh
+ */
+
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Object.h>
+#include <ModuleBase_WidgetFileSelector.h>
+
+#include <Config_WidgetAPI.h>
+
+#include <QGridLayout>
+#include <QFileDialog>
+#include <QLineEdit>
+#include <QList>
+#include <QObject>
+#include <QPushButton>
+#include <QString>
+#include <QLabel>
+
+#include <boost/smart_ptr/shared_ptr.hpp>
+#include <string>
+
+ModuleBase_WidgetFileSelector::ModuleBase_WidgetFileSelector(QWidget* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+ : ModuleBase_ModelWidget(theParent, theData, theParentId)
+{
+ myHasDefaultValue = false;
+
+ myTitle = QString::fromStdString(theData->getProperty("title"));
+ //TODO(sbh): Get them from the feature
+ myFormats = getSupportedFormats(theData);
+ myDefaultPath = QString::fromStdString(theData->getProperty("path"));
+
+ myMainWidget = new QWidget(theParent);
+ QGridLayout* aMainLay = new QGridLayout(myMainWidget);
+ aMainLay->setContentsMargins(0, 0, 0, 0);
+ QLabel* aTitleLabel = new QLabel(myTitle, myMainWidget);
+ aTitleLabel->setIndent(1);
+ aMainLay->addWidget(aTitleLabel, 0, 0);
+ myPathField = new QLineEdit(myMainWidget);
+ aMainLay->addWidget(myPathField, 1, 0);
+ QPushButton* aSelectPathBtn = new QPushButton("...", myMainWidget);
+ aSelectPathBtn->setMaximumWidth(20);
+ aSelectPathBtn->setMaximumHeight(20);
+ aMainLay->addWidget(aSelectPathBtn, 1, 1);
+ aMainLay->setColumnStretch(0, 1);
+ myPathField->setMinimumHeight(20);
+ aMainLay->setHorizontalSpacing(1);
+ myMainWidget->setLayout(aMainLay);
+
+ connect(myPathField, SIGNAL(textChanged(const QString&)),
+ this, SLOT(onPathChanged()));
+ connect(aSelectPathBtn, SIGNAL(clicked()),
+ this, SLOT(onPathSelectionBtn()));
+}
+
+ModuleBase_WidgetFileSelector::~ModuleBase_WidgetFileSelector()
+{
+}
+
+bool ModuleBase_WidgetFileSelector::storeValue() const
+{
+ DataPtr aData = myFeature->data();
+ AttributeStringPtr aStringAttr = aData->string(attributeID());
+ QString aModelValue = QString::fromStdString(aStringAttr->value());
+ QString aWidgetValue = myPathField->text();
+ if(aModelValue != aWidgetValue) {
+ aStringAttr->setValue(aWidgetValue.toStdString());
+ updateObject(myFeature);
+ }
+ return true;
+}
+
+bool ModuleBase_WidgetFileSelector::restoreValue()
+{
+ DataPtr aData = myFeature->data();
+ AttributeStringPtr aStringAttr = aData->string(attributeID());
+
+ bool isBlocked = myPathField->blockSignals(true);
+ myPathField->setText(QString::fromStdString(aStringAttr->value()));
+ myPathField->blockSignals(isBlocked);
+
+ return true;
+}
+
+QWidget* ModuleBase_WidgetFileSelector::getControl() const
+{
+ return myMainWidget;
+}
+
+QList<QWidget*> ModuleBase_WidgetFileSelector::getControls() const
+{
+ QList<QWidget*> result;
+ QPushButton * aButton = myMainWidget->findChild<QPushButton *>();
+ result << aButton;
+ result << myPathField;
+ return result;
+}
+
+bool ModuleBase_WidgetFileSelector::isCurrentPathValid()
+{
+ QFileInfo aFile (myPathField->text());
+ return aFile.exists() && myFormats.contains(aFile.suffix(), Qt::CaseInsensitive);
+}
+
+
+void ModuleBase_WidgetFileSelector::onPathSelectionBtn()
+{
+ QString aFilter = formatsString(myFormats);
+ QString aFileName = QFileDialog::getOpenFileName(myMainWidget, myTitle, myDefaultPath, aFilter);
+ if (!aFileName.isEmpty()) {
+ myPathField->setText(aFileName);
+ }
+}
+
+void ModuleBase_WidgetFileSelector::onPathChanged()
+{
+ if(!isCurrentPathValid())
+ return;
+ storeValue();
+ emit valuesChanged();
+}
+
+QStringList ModuleBase_WidgetFileSelector::getSupportedFormats(const Config_WidgetAPI* theData) const
+{
+ QString aXMLFormat = QString::fromStdString(theData->getProperty("formats"));
+ aXMLFormat = aXMLFormat.toUpper();
+ const QChar kSep = ',';
+ return aXMLFormat.split(kSep, QString::SkipEmptyParts);
+}
+
+QString ModuleBase_WidgetFileSelector::formatsString(const QStringList theFormats) const
+{
+ QStringList aResult;
+ foreach(QString eachFormat, theFormats) {
+ aResult << QString("%1 files (*.%1)").arg(eachFormat);
+ }
+ return aResult.join(";;");
+}
+
--- /dev/null
+/*
+ * ModuleBase_WidgetFileSelector.h
+ *
+ * Created on: Aug 28, 2014
+ * Author: sbh
+ */
+
+#ifndef MODULEBASE_WIDGETFILESELECTOR_H_
+#define MODULEBASE_WIDGETFILESELECTOR_H_
+
+#include <ModuleBase.h>
+#include <ModuleBase_ModelWidget.h>
+
+#include <QList>
+#include <QString>
+#include <QStringList>
+
+class QWidget;
+class QLineEdit;
+
+class MODULEBASE_EXPORT ModuleBase_WidgetFileSelector : public ModuleBase_ModelWidget
+{
+ Q_OBJECT
+ public:
+ ModuleBase_WidgetFileSelector(QWidget* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId);
+ virtual ~ModuleBase_WidgetFileSelector();
+
+ /// Saves the internal parameters to the given feature
+ /// \param theObject a model feature to be changed
+ virtual bool storeValue() const;
+
+ virtual bool restoreValue();
+
+ /// Returns the internal parent wiget control, that can be shown anywhere
+ /// \returns the widget
+ QWidget* getControl() const;
+
+ /// Returns list of widget controls
+ /// \return a control list
+ virtual QList<QWidget*> getControls() const;
+
+ /// Returns true if a file on the current path in the line edit
+ /// exists and has supported format
+ bool isCurrentPathValid();
+
+ public slots:
+ void onPathSelectionBtn();
+ void onPathChanged();
+
+ protected:
+ QStringList getSupportedFormats(const Config_WidgetAPI* theData) const;
+ QString formatsString(const QStringList theFormats) const;
+
+ private:
+ QLineEdit* myPathField;
+ QWidget* myMainWidget;
+ QStringList myFormats;
+
+ QString myTitle;
+ QString myDefaultPath;
+};
+
+#endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */
<feature id="SketchLine" title="Line" tooltip="Create a new line" icon=":icons/line.png">
<point_selector id="StartPoint" title="Start point" tooltip="Start point of the line" previous_feature_param="EndPoint"/>
<point_selector id="EndPoint" title="End point" tooltip="End point of the line"/>
- <validator id="Model_FeatureValidator" />
</feature>
<feature id="SketchCircle" title="Circle" tooltip="Create a new circle" icon=":icons/circle.png">
<point_selector id="CircleCenter" title="Center" tooltip="Center of the circle"/>