-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
IF(WIN32)
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
IF(WIN32)
SET(QT_USE_QTMAIN ON)
ENDIF()
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
SET(LIBXMLDIR $ENV{LIBXML2_ROOT_DIR})
-INCLUDE_DIRECTORIES(${LIBXMLDIR}/include/libxml2)
+
+IF(WIN32)
+ INCLUDE_DIRECTORIES(${LIBXMLDIR}/include)
+ELSE()
+ INCLUDE_DIRECTORIES(${LIBXMLDIR}/include/libxml2)
+ENDIF(WIN32)
+
LINK_DIRECTORIES (${LIBXMLDIR}/lib)
IF(WIN32)
SET(LIBXML2_LIBRARIES ${LIBXMLDIR}/lib/libxml2.lib)
+++ /dev/null
-#------ Setting products installation directory ------
-export INST_ROOT=/misc/dn21/hdfeditor/sbh/NewGeom/products
-
-#------ Python ------
-export PYTHON_ROOT_DIR=${INST_ROOT}/Python-2.7.3
-export PYTHONHOME=${PYTHON_ROOT_DIR}
-export PYTHON_INCLUDE=${PYTHON_ROOT_DIR}/include/python2.7
-export PYTHON_VERSION=2.7
-export PATH=${PYTHON_ROOT_DIR}/bin:${PATH}
-export LD_LIBRARY_PATH=${PYTHON_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-export PYTHONPATH=${PYTHON_ROOT_DIR}/lib/python2.7
-#For cmake
-export PYTHON_LIB_DIR=${PYTHON_ROOT_DIR}/lib
-export PYTHON_INC_DIR=${PYTHON_INCLUDE}
-##
-#------ Qt ------
-export QT4_ROOT_DIR=${INST_ROOT}/qt-4.8.4
-export QT_PLUGIN_PATH=${QT4_ROOT_DIR}/plugins
-export PATH=${QT4_ROOT_DIR}/bin:${PATH}
-export LD_LIBRARY_PATH=${QT4_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-##
-#------ boost ------
-#export BOOST_ROOT_DIR=${INST_ROOT}/boost-1.52.0
-#export LD_LIBRARY_PATH ${BOOST_ROOT_DIR}/lib
-##
-#------ swig ------
-export SWIG_ROOT_DIR=${INST_ROOT}/swig-2.0.8
-export SWIG_LIB=${SWIG_ROOT_DIR}/share/swig/2.0.8
-export PATH=${SWIG_ROOT_DIR}/bin:${PATH}
-##
-#------ cmake ------
-export CMAKE_ROOT_DIR=${INST_ROOT}/cmake-2.8.10.2
-export PATH=${CMAKE_ROOT_DIR}/bin:${PATH}
-##
-#------ freetype ------
-export FREETYPE_ROOT_DIR=${INST_ROOT}/freetype-2.4.11
-export LD_LIBRARY_PATH=${FREETYPE_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-##
-#------ freeimage ------
-export FREEIMAGE_ROOT_DIR=${INST_ROOT}/freeimage-3.15.4
-export PATH=${FREEIMAGE_ROOT_DIR}/bin:${PATH}
-export LD_LIBRARY_PATH=${FREEIMAGE_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-##
-#------ gl2ps ------
-export GL2PS_ROOT_DIR=${INST_ROOT}/gl2ps-1.3.8
-export PATH=${GL2PS_ROOT_DIR}/bin:${PATH}
-export LD_LIBRARY_PATH=${GL2PS_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-##
-#------ tbb ------
-export TBB_ROOT_DIR=${INST_ROOT}/tbb-30_018oss
-export PATH=${TBB_ROOT_DIR}/bin/intel64/cc4.1.0_libc2.4_kernel2.6.16.21:${PATH}
-export LD_LIBRARY_PATH=${TBB_ROOT_DIR}/lib/intel64/cc4.1.0_libc2.4_kernel2.6.16.21:${LD_LIBRARY_PATH}
-##
-#------ libxml2 ------
-export LIBXML2_ROOT_DIR=${INST_ROOT}/libxml2-2.9.0
-export PATH=${LIBXML2_ROOT_DIR}/bin:${PATH}
-export LD_LIBRARY_PATH=${LIBXML2_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-# DO NOT rename following 3 variables, \r
-# they are required by CMake "find(Libxml2)" procedure\r
-export LIBXML2_INCLUDE_DIR=${LIBXML2_ROOT_DIR}/include/libxml2\r
-export LIBXML2_LIB_DIR=${LIBXML2_ROOT_DIR}/lib\r
-export LIBXML2_BIN_DIR=${LIBXML2_ROOT_DIR}/bin
-##
-#------ OCCT ------
-export CAS_ROOT_DIR=${INST_ROOT}/OCCT-6.7.0
-
-export PATH=${CAS_ROOT_DIR}:${CAS_ROOT_DIR}/bin:${PATH}
-export LD_LIBRARY_PATH=${CAS_ROOT_DIR}:${CAS_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
-# Variable for Foundation Classes :
-export CSF_UnitsLexicon=${CAS_ROOT_DIR}/src/UnitsAPI/Lexi_Expr.dat
-export CSF_UnitsDefinition=${CAS_ROOT_DIR}/src/UnitsAPI/Units.dat
-# Variable for DataExchange :
-export CSF_SHMessage=${CAS_ROOT_DIR}/src/SHMessage
-export CSF_XSMessage=${CAS_ROOT_DIR}/src/XSMessage
-# Variable for Font :
-export CSF_MDTVFontDirectory=${CAS_ROOT_DIR}/src/FontMFT
-export CSF_MDTVTexturesDirectory=${CAS_ROOT_DIR}/src/Textures
-# Activation of OCCT Kernel multithreading :
-export MMGT_REENTRANT=1
-# this variable only needed for DRAWEXE
-export CASROOT=${CAS_ROOT_DIR}
-##
-export LIB=${LD_LIBRARY_PATH}
-
-
SRC_DIR=${ROOT_DIR}/sources
-source ${SRC_DIR}/centos6_env.sh
+source ${SRC_DIR}/linux_env.sh
mkdir -p ${ROOT_DIR}/build
cd ${ROOT_DIR}/build
--- /dev/null
+#------ Setting products installation directory ------
+export INST_ROOT=/misc/dn21/hdfeditor/sbh/NewGeom/products
+
+#------ Python ------
+export PYTHON_ROOT_DIR=${INST_ROOT}/Python-2.7.3
+export PYTHONHOME=${PYTHON_ROOT_DIR}
+export PYTHON_INCLUDE=${PYTHON_ROOT_DIR}/include/python2.7
+export PYTHON_VERSION=2.7
+export PATH=${PYTHON_ROOT_DIR}/bin:${PATH}
+export LD_LIBRARY_PATH=${PYTHON_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+export PYTHONPATH=${PYTHON_ROOT_DIR}/lib/python2.7
+#For cmake
+export PYTHON_LIB_DIR=${PYTHON_ROOT_DIR}/lib
+export PYTHON_INC_DIR=${PYTHON_INCLUDE}
+##
+#------ Qt ------
+export QT4_ROOT_DIR=${INST_ROOT}/qt-4.8.4
+export QT_PLUGIN_PATH=${QT4_ROOT_DIR}/plugins
+export PATH=${QT4_ROOT_DIR}/bin:${PATH}
+export LD_LIBRARY_PATH=${QT4_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+##
+#------ boost ------
+#export BOOST_ROOT_DIR=${INST_ROOT}/boost-1.52.0
+#export LD_LIBRARY_PATH ${BOOST_ROOT_DIR}/lib
+##
+#------ swig ------
+export SWIG_ROOT_DIR=${INST_ROOT}/swig-2.0.8
+export SWIG_LIB=${SWIG_ROOT_DIR}/share/swig/2.0.8
+export PATH=${SWIG_ROOT_DIR}/bin:${PATH}
+##
+#------ cmake ------
+export CMAKE_ROOT_DIR=${INST_ROOT}/cmake-2.8.10.2
+export PATH=${CMAKE_ROOT_DIR}/bin:${PATH}
+##
+#------ freetype ------
+export FREETYPE_ROOT_DIR=${INST_ROOT}/freetype-2.4.11
+export LD_LIBRARY_PATH=${FREETYPE_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+##
+#------ freeimage ------
+export FREEIMAGE_ROOT_DIR=${INST_ROOT}/freeimage-3.15.4
+export PATH=${FREEIMAGE_ROOT_DIR}/bin:${PATH}
+export LD_LIBRARY_PATH=${FREEIMAGE_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+##
+#------ gl2ps ------
+export GL2PS_ROOT_DIR=${INST_ROOT}/gl2ps-1.3.8
+export PATH=${GL2PS_ROOT_DIR}/bin:${PATH}
+export LD_LIBRARY_PATH=${GL2PS_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+##
+#------ tbb ------
+export TBB_ROOT_DIR=${INST_ROOT}/tbb-30_018oss
+export PATH=${TBB_ROOT_DIR}/bin/intel64/cc4.1.0_libc2.4_kernel2.6.16.21:${PATH}
+export LD_LIBRARY_PATH=${TBB_ROOT_DIR}/lib/intel64/cc4.1.0_libc2.4_kernel2.6.16.21:${LD_LIBRARY_PATH}
+##
+#------ libxml2 ------
+export LIBXML2_ROOT_DIR=${INST_ROOT}/libxml2-2.9.0
+export PATH=${LIBXML2_ROOT_DIR}/bin:${PATH}
+export LD_LIBRARY_PATH=${LIBXML2_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+# DO NOT rename following 3 variables,
+# they are required by CMake "find(Libxml2)" procedure
+export LIBXML2_INCLUDE_DIR=${LIBXML2_ROOT_DIR}/include/libxml2
+export LIBXML2_LIB_DIR=${LIBXML2_ROOT_DIR}/lib
+export LIBXML2_BIN_DIR=${LIBXML2_ROOT_DIR}/bin
+##
+#------ OCCT ------
+export CAS_ROOT_DIR=${INST_ROOT}/OCCT-6.7.0
+
+export PATH=${CAS_ROOT_DIR}:${CAS_ROOT_DIR}/bin:${PATH}
+export LD_LIBRARY_PATH=${CAS_ROOT_DIR}:${CAS_ROOT_DIR}/lib:${LD_LIBRARY_PATH}
+# Variable for Foundation Classes :
+export CSF_UnitsLexicon=${CAS_ROOT_DIR}/src/UnitsAPI/Lexi_Expr.dat
+export CSF_UnitsDefinition=${CAS_ROOT_DIR}/src/UnitsAPI/Units.dat
+# Variable for DataExchange :
+export CSF_SHMessage=${CAS_ROOT_DIR}/src/SHMessage
+export CSF_XSMessage=${CAS_ROOT_DIR}/src/XSMessage
+# Variable for Font :
+export CSF_MDTVFontDirectory=${CAS_ROOT_DIR}/src/FontMFT
+export CSF_MDTVTexturesDirectory=${CAS_ROOT_DIR}/src/Textures
+# Activation of OCCT Kernel multithreading :
+export MMGT_REENTRANT=1
+# this variable only needed for DRAWEXE
+export CASROOT=${CAS_ROOT_DIR}
+##
+export LIB=${LD_LIBRARY_PATH}
+
+
rem --------------- cmake 2.8.7 --------------
if "%CMAKEDIR%" == "" (
- set CMAKEDIR=%PDIR%\cmake-2.8.12.1
+ set CMAKEDIR=%PDIR%\cmake-2.8.10.2
)
set PATH=%CMAKEDIR%\bin;%PATH%
@REM -------------------------
@REM CASCADE
-@SET PATH=%CASROOT%;%CASROOT%\win32\bind;%PATH%
-@SET LIB=%CASROOT%\win32\libd;%LIB%
-@set CSF_GraphicShr=%CASROOT%\win32\bind\TKOpenGl.dll
+@SET PATH=%CASROOT%;%CASROOT%\win32\bin%OCC_LIB_PREFIX%;%PATH%
+@SET LIB=%CASROOT%\win32\lib%OCC_LIB_PREFIX%;%LIB%
+@set CSF_GraphicShr=%CASROOT%\win32\bin%OCC_LIB_PREFIX%\TKOpenGl.dll
@set CSF_MDTVFontDirectory=%CASROOT%\src\FontMFT
@set CSF_LANGUAGE=us
@set MMGT_CLEAR=1
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
INCLUDE(Common)
INCLUDE(XMLProcessing)
Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile,
- const std::string& theLibraryName)
+ const std::string& theLibraryName,
+ const char* theEventGenerated)
: Config_XMLReader(theXmlFile),
- myLibraryName(theLibraryName)
+ myLibraryName(theLibraryName),
+ myEventGenerated(theEventGenerated ? theEventGenerated : "FeatureEvent")
{
}
void Config_FeatureReader::processNode(xmlNodePtr theNode)
{
- static Event_ID aMenuItemEvent = Event_Loop::eventByName("FeatureEvent");
+ Event_ID aMenuItemEvent = Event_Loop::eventByName(myEventGenerated);
if (isNode(theNode, NODE_FEATURE, NULL)) {
Event_Loop* aEvLoop = Event_Loop::loop();
Config_FeatureMessage aMessage(aMenuItemEvent, this);
{
public:
Config_FeatureReader(const std::string& theXmlFile,
- const std::string& theLibraryName = "");
+ const std::string& theLibraryName = "",
+ const char* theEventGenerated = 0);
virtual ~Config_FeatureReader();
protected:
std::string myLastWorkbench;
std::string myLastGroup;
std::string myLibraryName;
+ /// event generated on feature data sending, by default it is "FeatureEvent"
+ const char* myEventGenerated;
};
#endif /* CONFIG_FEATUREREADER_H_ */
-Config_ModuleReader::Config_ModuleReader()
- : Config_XMLReader("plugins.xml"), myIsAutoImport(false)
+Config_ModuleReader::Config_ModuleReader(const char* theEventGenerated)
+ : Config_XMLReader("plugins.xml"), myIsAutoImport(false), myEventGenerated(theEventGenerated)
{
}
if(thePluginLibrary.empty()) {
aReader = new Config_FeatureReader(thePluginName);
} else {
- aReader = new Config_FeatureReader(thePluginName, thePluginLibrary);
+ aReader = new Config_FeatureReader(thePluginName, thePluginLibrary, myEventGenerated);
}
aReader->readAll();
}
{
public:
- CONFIG_EXPORT Config_ModuleReader();
+ CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0);
CONFIG_EXPORT virtual ~Config_ModuleReader();
CONFIG_EXPORT void setAutoImport(bool enabled);
private:
bool myIsAutoImport;
std::map<std::string, std::string> myPluginsMap;
-
+ const char* myEventGenerated;
};
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
INCLUDE(Common)
SET(PROJECT_HEADERS
const Event_ID& eventID() const {return myEventId;}
//! Returns sender of the message or NULL if it is anonymous message
- void* sender() {return mySender;}
+ void* sender() const {return mySender;}
};
#endif
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
INCLUDE(Common)
INCLUDE(FindCAS)
static Handle_Model_Application TheApplication = new Model_Application;
-//=======================================================================
-//function : getApplication
-//purpose :
//=======================================================================
Handle(Model_Application) Model_Application::getApplication()
{
return TheApplication;
}
-//=======================================================================
-//function : getDocument
-//purpose :
//=======================================================================
const std::shared_ptr<Model_Document>& Model_Application::getDocument(string theDocID)
{
}
//=======================================================================
-//function : OCAFApp_Application
-//purpose :
+bool Model_Application::hasDocument(std::string theDocID)
+{
+ return myDocs.find(theDocID) != myDocs.end();
+}
+
//=======================================================================
Model_Application::Model_Application()
{
TheKeepHandle = this;
}
-//=======================================================================
-//function : Formats
-//purpose :
//=======================================================================
void Model_Application::Formats(TColStd_SequenceOfExtendedString& theFormats)
{
theFormats.Append(TCollection_ExtendedString("BinOcaf")); // standard binary schema
}
-//=======================================================================
-//function : ResourcesName
-//purpose :
//=======================================================================
Standard_CString Model_Application::ResourcesName()
{
MODEL_EXPORT static Handle_Model_Application getApplication();
//! Returns the main document (on first call creates it) by the string identifier
MODEL_EXPORT const std::shared_ptr<Model_Document>& getDocument(std::string theDocID);
+ //! Returns true if document has been created
+ MODEL_EXPORT bool hasDocument(std::string theDocID);
//! Deletes the document from the application
MODEL_EXPORT void deleteDocument(std::string theDocID);
TDF_Label anObjLab = aGroupLab.NewChild();
std::shared_ptr<Model_Data> aData(new Model_Data);
aData->setLabel(anObjLab);
- aData->setDocument(Model_Application::getApplication()->getDocument(myID));
+ shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
+ aData->setDocument(aThis);
theFeature->setData(aData);
setUniqueName(theFeature);
theFeature->initAttributes();
// event: feature is added
static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
- ModelAPI_FeatureUpdatedMessage aMsg(theFeature, anEvent);
+ ModelAPI_FeatureUpdatedMessage aMsg(aThis, theFeature, anEvent);
Event_Loop::loop()->send(aMsg);
}
void Model_Document::synchronizeFeatures()
{
+ shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
// iterate groups labels
TDF_ChildIDIterator aGroupsIter(myDoc->Main().FindChild(TAG_OBJECTS),
TDataStd_Comment::GetID(), Standard_False);
if (aDSTag > aFeatureTag) { // feature is removed
aFIter = aFeatures.erase(aFIter);
// event: model is updated
- ModelAPI_FeatureDeletedMessage aMsg(
- Model_Application::getApplication()->getDocument(myID), aGroupName);
+ ModelAPI_FeatureDeletedMessage aMsg(aThis, aGroupName);
Event_Loop::loop()->send(aMsg);
} else if (aDSTag < aFeatureTag) { // a new feature is inserted
// create a feature
aFeature->initAttributes();
// event: model is updated
static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
- ModelAPI_FeatureUpdatedMessage aMsg(aFeature, anEvent);
+ ModelAPI_FeatureUpdatedMessage aMsg(aThis, aFeature, anEvent);
Event_Loop::loop()->send(aMsg);
if (aFIter == aFeatures.end()) {
#include <Event_Loop.h>
ModelAPI_FeatureUpdatedMessage::ModelAPI_FeatureUpdatedMessage(
+ const std::shared_ptr<ModelAPI_Document>& theDoc,
const std::shared_ptr<ModelAPI_Feature>& theFeature, const Event_ID& theEvent)
- : Event_Message(theEvent, 0), myFeature(theFeature)
+ : Event_Message(theEvent, 0), myFeature(theFeature), myDoc(theDoc)
{}
ModelAPI_FeatureDeletedMessage::ModelAPI_FeatureDeletedMessage(
/// Message that feature was changed (used for Object Browser update)
class ModelAPI_FeatureUpdatedMessage : public Event_Message {
+ std::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
std::shared_ptr<ModelAPI_Feature> myFeature; ///< which feature is changed
public:
/// sender is not important, all information is located in the feature
- ModelAPI_FeatureUpdatedMessage(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ ModelAPI_FeatureUpdatedMessage(
+ const std::shared_ptr<ModelAPI_Document>& theDoc,
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
const Event_ID& theEvent);
/// Returns the feature that has been updated
- std::shared_ptr<ModelAPI_Feature> feature() {return myFeature;}
+ std::shared_ptr<ModelAPI_Feature> feature() const {return myFeature;}
+ /// Returns the document that has been updated
+ std::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
};
/// Message that feature was deleted (used for Object Browser update)
static const Event_ID messageId();
/// Returns the feature that has been updated
- std::shared_ptr<ModelAPI_Document> document() {return myDoc;}
+ std::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
/// Returns the group where the feature was deleted
- const std::string& group() {return myGroup;}
+ const std::string& group() const {return myGroup;}
};
#endif
Model_Application::getApplication()->getDocument("root"));
}
+bool Model_PluginManager::hasRootDocument()
+{
+ return Model_Application::getApplication()->hasDocument("root");
+}
+
shared_ptr<ModelAPI_Document> Model_PluginManager::currentDocument()
{
if (!myCurrentDoc)
{
myPluginsInfoLoaded = false;
//TODO(sbh): Implement static method to extract event id [SEID]
- static Event_ID aFeatureEvent = Event_Loop::eventByName("FeatureEvent");
+ static Event_ID aFeatureEvent = Event_Loop::eventByName("FeatureRegisterEvent");
ModelAPI_PluginManager::SetPluginManager(std::shared_ptr<ModelAPI_PluginManager>(this));
// register the configuration reading listener
return;
// Read plugins information from XML files
- Config_ModuleReader aXMLReader;
+ Config_ModuleReader aXMLReader("FeatureRegisterEvent");
aXMLReader.setAutoImport(true);
aXMLReader.readAll();
}
/// Returns the root document of the application (that may contains sub-documents)
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> rootDocument();
+ /// Return true if root document has been already created
+ MODEL_EXPORT virtual bool hasRootDocument();
+
/// Returns the current document that used for current work in the application
MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> currentDocument();
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
/// Returns the root document of the application (that may contains sub-documents)
virtual std::shared_ptr<ModelAPI_Document> rootDocument() = 0;
+ /// Return true if root document has been already created
+ virtual bool hasRootDocument() = 0;
+
/// Returns the current document that used for current work in the application
virtual std::shared_ptr<ModelAPI_Document> currentDocument() = 0;
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
INCLUDE(Common)
SET(CMAKE_AUTOMOC ON)
{
std::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
myFeature = aDoc->addFeature(myOperationId.toStdString());
- myFeature->execute();
+ if (myFeature) // TODO: generate an error if feature was not created
+ myFeature->execute();
//emit callSlot();
//commit();
}
*/
void ModuleBase_Operation::commitOperation()
{
- myFeature->execute();
+ if (myFeature) myFeature->execute();
}
/*!
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
INCLUDE(Common)
SET(CMAKE_AUTOMOC ON)
void PartSet_Module::featureCreated(XGUI_Command* theFeature)
{
- QString aFtId = theFeature->getId();
+ QString aFtId = theFeature->id();
theFeature->connectTo(this, SLOT(onFeatureTriggered()));
}
Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginName);
aWdgReader.readAll();
XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(sender());
- QString aCmdId = aCmd->getId();
+ QString aCmdId = aCmd->id();
std::string aXmlCfg = aWdgReader.featureWidgetCfg(aCmdId.toStdString());
//TODO(sbh): Implement static method to extract event id [SEID]
static Event_ID aModuleEvent = Event_Loop::eventByName("PartSetModuleEvent");
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
INCLUDE(Common)
SET(PROJECT_HEADERS
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.10)
-
INCLUDE(FindCAS)
SET(CMAKE_AUTOMOC ON)
virtual void disable();
//! Returns Id of the command
- virtual QString getId() const
+ virtual QString id() const
{
return myId;
}
//! Returns 0 if the given index is not index of a feature
virtual FeaturePtr feature(const QModelIndex& theIndex) const = 0;
+ //! Returns parent index of the given feature
+ virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const = 0;
+
protected:
std::shared_ptr<ModelAPI_Document> myDocument;
};
XGUI_PartModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
XGUI_FeaturesModel(theDocument, theParent) {}
- void setPartId(int theId) { myId = theId; }
+ void setPartId(int theId) { myId = theId; }
+
+ //! Returns true if the given document is a sub-document of this tree
+ virtual bool hasDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) const = 0;
protected:
//! Id of the current part object in the document
#include <QIcon>
+#include <QString>
XGUI_DocumentDataModel::XGUI_DocumentDataModel(QObject* theParent)
void XGUI_DocumentDataModel::processEvent(const Event_Message* theMessage)
{
- beginResetModel();
- int aNbParts = myDocument->featuresIterator(PARTS_GROUP)->numIterationsLeft();
- if (myPartModels.size() != aNbParts) { // resize internal models
- while (myPartModels.size() > aNbParts) {
- delete myPartModels.last();
- myPartModels.removeLast();
+ if (QString(theMessage->eventID().eventText()) == EVENT_FEATURE_CREATED) {
+ const ModelAPI_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const ModelAPI_FeatureUpdatedMessage*>(theMessage);
+ std::shared_ptr<ModelAPI_Document> aDoc = aUpdMsg->document();
+ std::shared_ptr<ModelAPI_Feature> aFeature = aUpdMsg->feature();
+
+ if (aDoc == myDocument) {
+ if (aFeature->getGroup().compare(PARTS_GROUP) == 0) {
+ // Add a new part
+ int aStart = myModel->rowCount(QModelIndex()) + myPartModels.size();
+ beginInsertRows(QModelIndex(), aStart, aStart + 1);
+ XGUI_PartDataModel* aModel = new XGUI_PartDataModel(myDocument, this);
+ aModel->setPartId(myPartModels.count());
+ myPartModels.append(aModel);
+ endInsertRows();
+ } else {
+ QModelIndex aIndex = myModel->findParent(aFeature);
+ int aStart = myModel->rowCount(aIndex);
+ aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
+ beginInsertRows(aIndex, aStart-1, aStart);
+ endInsertRows();
+ if (aStart == 1) // Update parent if this is a first child in order to update node decoration
+ emit dataChanged(aIndex, aIndex);
+ }
+ } else {
+ XGUI_PartModel* aPartModel = 0;
+ QList<XGUI_PartModel*>::const_iterator aIt;
+ for (aIt = myPartModels.constBegin(); aIt != myPartModels.constEnd(); ++aIt) {
+ if ((*aIt)->hasDocument(aDoc)) {
+ aPartModel = (*aIt);
+ break;
+ }
+ }
+ if (aPartModel) {
+ QModelIndex aIndex = aPartModel->findParent(aFeature);
+ int aStart = aPartModel->rowCount(aIndex);
+ aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex));
+ beginInsertRows(aIndex, aStart-1, aStart);
+ endInsertRows();
+ if (aStart == 1) // Update parent if this is a first child in order to update node decoration
+ emit dataChanged(aIndex, aIndex);
+ }
}
- while (myPartModels.size() < aNbParts) {
- myPartModels.append(new XGUI_PartDataModel(myDocument, this));
+ } else {
+ // Reset whole tree
+ beginResetModel();
+ int aNbParts = myDocument->featuresIterator(PARTS_GROUP)->numIterationsLeft();
+ if (myPartModels.size() != aNbParts) { // resize internal models
+ while (myPartModels.size() > aNbParts) {
+ delete myPartModels.last();
+ myPartModels.removeLast();
+ }
+ while (myPartModels.size() < aNbParts) {
+ myPartModels.append(new XGUI_PartDataModel(myDocument, this));
+ }
+ for (int i = 0; i < myPartModels.size(); i++)
+ myPartModels.at(i)->setPartId(i);
}
- for (int i = 0; i < myPartModels.size(); i++)
- myPartModels.at(i)->setPartId(i);
+ clearModelIndexes();
+ endResetModel();
}
- clearModelIndexes();
- endResetModel();
}
QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole) const
#include <QTabWidget>
#include <QLabel>
#include <QDockWidget>
+#include <QEvent>
XGUI_MainMenu::XGUI_MainMenu(XGUI_MainWindow *parent)
: QObject(parent), myDesktop(parent)
{
parent->setTabPosition(Qt::TopDockWidgetArea, QTabWidget::North);
myGeneralPage = addWorkbench(tr("General"));
+ myGeneralPage->parentWidget()->setMaximumWidth(200);
+ myGeneralPage->installEventFilter(this);
}
XGUI_MainMenu::~XGUI_MainMenu(void)
{
return myDesktop->findChild<XGUI_Workbench*>(theObjName);
}
+
+
+bool XGUI_MainMenu::eventFilter(QObject *theWatched, QEvent *theEvent)
+{
+ if (theWatched == myGeneralPage) {
+ if (theEvent->type() == QEvent::Show) {
+ myGeneralPage->parentWidget()->setMaximumWidth(16777215);
+ myGeneralPage->removeEventFilter(this);
+ }
+ }
+ return QObject::eventFilter(theWatched, theEvent);
+}
+
+XGUI_Command* XGUI_MainMenu::feature(const QString& theId) const
+{
+ QList<QDockWidget*>::const_iterator aIt;
+ for (aIt = myMenuTabs.constBegin(); aIt != myMenuTabs.constEnd(); ++aIt) {
+ XGUI_Workbench* aWbn = static_cast<XGUI_Workbench*>((*aIt)->widget());
+ XGUI_Command* aCmd = aWbn->feature(theId);
+ if (aCmd)
+ return aCmd;
+ }
+ return 0;
+}
+
+QList<XGUI_Command*> XGUI_MainMenu::features() const
+{
+ QList<XGUI_Command*> aList;
+ QList<QDockWidget*>::const_iterator aIt;
+ for (aIt = myMenuTabs.constBegin(); aIt != myMenuTabs.constEnd(); ++aIt) {
+ XGUI_Workbench* aWbn = static_cast<XGUI_Workbench*>((*aIt)->widget());
+ aList.append(aWbn->features());
+ }
+ return aList;
+}
\ No newline at end of file
class QLabel;
class QAction;
class QDockWidget;
+class QEvent;
/**\class XGUI_MainMenu
* \ingroup GUI
//! Rerturns last created workbench in dock widget container
QDockWidget* getLastDockWindow() const { return myMenuTabs.last(); }
+ //! Returns already created command by its ID
+ XGUI_Command* feature(const QString& theId) const;
+
+ //! Returns list of created commands
+ QList<XGUI_Command*> features() const;
+
+protected:
+ virtual bool eventFilter(QObject *theWatched, QEvent *theEvent);
+
private:
XGUI_MainWindow* myDesktop;
QList<QDockWidget*> myMenuTabs;
XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
: QMainWindow(parent),
- myObjectBrowser(NULL),
- myPythonConsole(NULL),
- myPropertyPanelDock(NULL)
+ myObjectBrowser(0),
+ myPythonConsole(0),
+ myPropertyPanelDock(0)
{
setWindowTitle(tr("New Geom"));
myMenuBar = new XGUI_MainMenu(this);
myViewer = new XGUI_Viewer(this);
- createDockWidgets();
+ //createDockWidgets();
}
XGUI_MainWindow::~XGUI_MainWindow(void)
aDoc->setMinimumHeight(0);
aDoc->setWindowTitle("Console");
myPythonConsole = new PyConsole_EnhConsole( aDoc, new PyConsole_EnhInterp());
- //myPythonConsole = new QTextEdit(aDoc);
- //myPythonConsole->setGeometry(0,0,200, 50);
- //myPythonConsole->setText(">>>");
aDoc->setWidget(myPythonConsole);
- //myPythonConsole->setMinimumHeight(0);
addDockWidget(Qt::TopDockWidgetArea, aDoc);
tabifyDockWidget(myMenuBar->getLastDockWindow(), aDoc);
}
return myViewer;
}
+ // Creates Dock widgets: Object broewser and Property panel
+ void createDockWidgets();
+
public slots:
void showPythonConsole();
void hidePythonConsole();
void hideObjectBrowser();
private:
- void createDockWidgets();
QDockWidget* createObjectBrowser();
QDockWidget* createPropertyPanel();
addCommand(aCommand);
return aCommand;
}
+
+
+XGUI_Command* XGUI_MenuGroupPanel::feature(const QString& theId) const
+{
+ QList<XGUI_Command*>::const_iterator aIt;
+ for (aIt = myActions.constBegin(); aIt != myActions.constEnd(); ++aIt)
+ if ((*aIt)->id() == theId)
+ return (*aIt);
+ return 0;
+}
\ No newline at end of file
XGUI_Command* addFeature(const QString& theId, const QString& theTitle, const QString& theTip,
const QIcon& theIcon, const QKeySequence& theKeys = QKeySequence());
+ //! Returns already created command by its ID
+ XGUI_Command* feature(const QString& theId) const;
+
+ //! Returns list of created commands
+ QList<XGUI_Command*> features() const { return myActions; }
+
protected:
virtual void resizeEvent(QResizeEvent *theEvent);
case ParamObject:
{
std::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARAMETERS_GROUP, theIndex.row());
- return aFeature->data()->getName().c_str();
+ if (aFeature)
+ return aFeature->data()->getName().c_str();
}
case ConstructFolder:
return tr("Constructions");
case ConstructObject:
{
std::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row());
- return aFeature->data()->getName().c_str();
+ if (aFeature)
+ return aFeature->data()->getName().c_str();
}
}
break;
}
+QModelIndex XGUI_TopDataModel::findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const
+{
+ QString aGroup(theFeature->getGroup().c_str());
+
+ if (theFeature->getGroup().compare(PARAMETERS_GROUP) == 0)
+ return createIndex(0, 0, (quintptr) ParamsFolder);
+ if (theFeature->getGroup().compare(CONSTRUCTIONS_GROUP) == 0)
+ return createIndex(1, 0, (quintptr) ConstructFolder);
+ return QModelIndex();
+}
+
+
//******************************************************************
//******************************************************************
//******************************************************************
case MyRoot:
{
std::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARTS_GROUP, myId);
- return aFeature->data()->getName().c_str();
+ if (aFeature)
+ return aFeature->data()->getName().c_str();
}
case ParamsFolder:
return tr("Parameters");
{
std::shared_ptr<ModelAPI_Feature> aFeature =
featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
- return aFeature->data()->getName().c_str();
+ if (aFeature)
+ return aFeature->data()->getName().c_str();
}
case ConstructObject:
{
std::shared_ptr<ModelAPI_Feature> aFeature =
featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
- return aFeature->data()->getName().c_str();
+ if (aFeature)
+ return aFeature->data()->getName().c_str();
}
}
break;
}
return 0;
}
+
+bool XGUI_PartDataModel::hasDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) const
+{
+ return (featureDocument() == theDoc);
+}
+
+
+QModelIndex XGUI_PartDataModel::findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const
+{
+ QString aGroup(theFeature->getGroup().c_str());
+
+ if (theFeature->getGroup().compare(PARAMETERS_GROUP) == 0)
+ return createIndex(0, 0, (quintptr) ParamsFolder);
+ if (theFeature->getGroup().compare(CONSTRUCTIONS_GROUP) == 0)
+ return createIndex(1, 0, (quintptr) ConstructFolder);
+ return QModelIndex();
+}
\ No newline at end of file
//! Returns 0 if the given index is not index of a feature
virtual FeaturePtr feature(const QModelIndex& theIndex) const;
+ virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
+
private:
//! Types of QModelIndexes
enum DataIds {
//! Returns 0 if the given index is not index of a feature
virtual FeaturePtr feature(const QModelIndex& theIndex) const;
+ //! Returns true if the given document is a sub-document of this tree
+ virtual bool hasDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) const;
+
+ //! Returns parent index of the given feature
+ virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
+
private:
std::shared_ptr<ModelAPI_Document> featureDocument() const;
XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) :
QObject(theParent), myWorkshop(theParent)
{
- XGUI_ObjectsBrowser* aObjBrowser = myWorkshop->mainWindow()->objectBrowser();
-
- connect(aObjBrowser, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
}
+void XGUI_SelectionMgr::connectObjectBrowser(XGUI_ObjectsBrowser* theOB)
+{
+ myObjectBrowser = theOB;
+ connect(myObjectBrowser, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+}
XGUI_SelectionMgr::~XGUI_SelectionMgr()
{
#include <QObject>
class XGUI_Workshop;
+class XGUI_ObjectsBrowser;
/**\class XGUI_SelectionMgr
* \ingroup GUI
//! Returns list of currently selected objects
QFeatureList selectedData() const { return mySelectedData; }
+ void connectObjectBrowser(XGUI_ObjectsBrowser* theOB);
+
signals:
//! Emited when selection in a one of viewers was changed
void selectionChanged();
private:
XGUI_Workshop* myWorkshop;
+ XGUI_ObjectsBrowser* myObjectBrowser;
//! List of selected features
QFeatureList mySelectedData;
}
}
return QWidget::eventFilter(theObj, theEvent);
+}
+
+XGUI_Command* XGUI_Workbench::feature(const QString& theId) const
+{
+ QList<XGUI_MenuGroupPanel*>::const_iterator aIt;
+ for (aIt = myGroups.constBegin(); aIt != myGroups.constEnd(); ++aIt) {
+ XGUI_Command* aCmd = (*aIt)->feature(theId);
+ if (aCmd)
+ return aCmd;
+ }
+ return 0;
+}
+
+QList<XGUI_Command*> XGUI_Workbench::features() const
+{
+ QList<XGUI_Command*> aList;
+ QList<XGUI_MenuGroupPanel*>::const_iterator aIt;
+ for (aIt = myGroups.constBegin(); aIt != myGroups.constEnd(); ++aIt)
+ aList.append((*aIt)->features());
+ return aList;
}
\ No newline at end of file
XGUI_MenuGroupPanel* addGroup(const QString& theId);
XGUI_MenuGroupPanel* findGroup(const QString& theName);
+ //! Returns already created command by its ID
+ XGUI_Command* feature(const QString& theId) const;
+
+ //! Returns list of created commands
+ QList<XGUI_Command*> features() const;
+
private slots:
void onLeftScroll();
void onRightScroll();
virtual void resizeEvent(QResizeEvent * theEvent);
virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
+
private:
void addSeparator();
bool isExceedsLeft();
activateModule();
myMainWindow->show();
+ updateCommandStatus();
// Testing of document creation
//std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
//std::shared_ptr<ModelAPI_Feature> aPoint1 = aMgr->rootDocument()->addFeature("Point");
aCommand = aGroup->addFeature("UNDO_CMD", tr("Undo"), tr("Undo last command"),
QIcon(":pictures/undo.png"), QKeySequence::Undo);
+ aCommand->connectTo(this, SLOT(onUndo()));
aCommand = aGroup->addFeature("REDO_CMD", tr("Redo"), tr("Redo last command"),
QIcon(":pictures/redo.png"), QKeySequence::Redo);
+ aCommand->connectTo(this, SLOT(onRedo()));
aCommand = aGroup->addFeature("REBUILD_CMD", tr("Rebuild"), tr("Rebuild data objects"),
QIcon(":pictures/rebuild.png"));
//******************************************************
void XGUI_Workshop::processEvent(const Event_Message* theMessage)
{
- const Config_FeatureMessage* aFeatureMsg =
- dynamic_cast<const Config_FeatureMessage*>(theMessage);
- if (aFeatureMsg) {
+ static Event_ID aFeatureId = Event_Loop::loop()->eventByName("FeatureEvent");
+ if (theMessage->eventID() == aFeatureId) {
+ const Config_FeatureMessage* aFeatureMsg =
+ dynamic_cast<const Config_FeatureMessage*>(theMessage);
addFeature(aFeatureMsg);
return;
}
if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
myCurrentOperation->start();
myCurrentOperation->commit();
+ updateCommandStatus();
} else {
fillPropertyPanel(aOperation);
}
void XGUI_Workshop::onNew()
{
QApplication::setOverrideCursor(Qt::WaitCursor);
+ if (myMainWindow->objectBrowser() == 0) {
+ myMainWindow->createDockWidgets();
+ mySelector->connectObjectBrowser(myMainWindow->objectBrowser());
+ }
myMainWindow->showObjectBrowser();
myMainWindow->showPythonConsole();
QMdiSubWindow* aWnd = myMainWindow->viewer()->createView();
aWnd->showMaximized();
+ updateCommandStatus();
QApplication::restoreOverrideCursor();
}
//******************************************************
void XGUI_Workshop::onOpen()
{
- QString aFileName = QFileDialog::getOpenFileName(mainWindow());
+ //QString aFileName = QFileDialog::getOpenFileName(mainWindow());
+ updateCommandStatus();
}
//******************************************************
void XGUI_Workshop::onSave()
{
+ updateCommandStatus();
}
//******************************************************
void XGUI_Workshop::onSaveAs()
{
- QString aFileName = QFileDialog::getSaveFileName(mainWindow());
+ //QString aFileName = QFileDialog::getSaveFileName(mainWindow());
+ updateCommandStatus();
+}
+
+//******************************************************
+void XGUI_Workshop::onUndo()
+{
+ std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ aDoc->undo();
+ updateCommandStatus();
}
+//******************************************************
+void XGUI_Workshop::onRedo()
+{
+ std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ aDoc->redo();
+ updateCommandStatus();
+}
+
+
//******************************************************
XGUI_Module* XGUI_Workshop::loadModule(const QString& theModule)
{
myPartSetModule->createFeatures();
return true;
}
+
+//******************************************************
+void XGUI_Workshop::updateCommandStatus()
+{
+ XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
+
+ QList<XGUI_Command*> aCommands = aMenuBar->features();
+ QList<XGUI_Command*>::const_iterator aIt;
+
+ std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ if (aMgr->hasRootDocument()) {
+ XGUI_Command* aUndoCmd;
+ XGUI_Command* aRedoCmd;
+ for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
+ if ((*aIt)->id() == "UNDO_CMD")
+ aUndoCmd = (*aIt);
+ else if ((*aIt)->id() == "REDO_CMD")
+ aRedoCmd = (*aIt);
+ else // Enable all commands
+ (*aIt)->enable();
+ }
+ std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ aUndoCmd->setEnabled(aDoc->canUndo());
+ aRedoCmd->setEnabled(aDoc->canRedo());
+ } else {
+ for (aIt = aCommands.constBegin(); aIt != aCommands.constEnd(); ++aIt) {
+ if ((*aIt)->id() == "NEW_CMD")
+ (*aIt)->enable();
+ else if ((*aIt)->id() == "EXIT_CMD")
+ (*aIt)->enable();
+ else
+ (*aIt)->disable();
+ }
+ }
+}
\ No newline at end of file
virtual void processEvent(const Event_Message* theMessage);
public slots:
+ void updateCommandStatus();
+
void onNew();
void onOpen();
void onSave();
void onSaveAs();
void onExit();
+ void onUndo();
+ void onRedo();
protected:
//Event-loop processing methods: