--- /dev/null
+
+
+SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL directory")
+SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI directory")
+IF(EXISTS ${GUI_ROOT_DIR})
+ SET(HAVE_SALOME YES)
+
+ FIND_LIBRARY(caf caf ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(CAM CAM ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(CASCatch CASCatch ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(DDS DDS ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(Event Event ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(GLViewer GLViewer ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(LightApp LightApp ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(LogWindow LogWindow ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(ObjBrowser ObjBrowser ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(OCCViewer OCCViewer ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(OpenGLUtils OpenGLUtils ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(Plot2d Plot2d ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(PyConsole PyConsole ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(PyInterp PyInterp ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(QDS QDS ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(qtx qtx ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(QxScene QxScene ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SalomeApp SalomeApp ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SalomeIDLGUI SalomeIDLGUI ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SalomeObject SalomeObject ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SalomePrs SalomePrs ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SalomePyQtGUILight SalomePyQtGUILight ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SalomePyQtGUI SalomePyQtGUI ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SalomePyQt SalomePyQt ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SalomePy SalomePy ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SalomeSession SalomeSession ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SalomeStyle SalomeStyle ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SOCC SOCC ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SPlot2d SPlot2d ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(std std ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SUITApp SUITApp ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(suit suit ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SVTK SVTK ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(ToolsGUI ToolsGUI ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(ViewerTools ViewerTools ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(ViewerData ViewerData ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(VTKViewer VTKViewer ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(vtkEDFOverloads vtkEDFOverloads ${GUI_ROOT_DIR}/lib/paraview)
+ FIND_LIBRARY(vtkTools vtkTools ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SalomeGuiHelpers SalomeGuiHelpers ${GUI_ROOT_DIR}/lib/salome)
+ FIND_LIBRARY(SalomeTreeData SalomeTreeData ${GUI_ROOT_DIR}/lib/salome)
+
+ SET(SALOME_GUI_INCLUDE ${GUI_ROOT_DIR}/include/salome)
+ SET(SALOME_KERNEL_INCLUDE ${KERNEL_ROOT_DIR}/include/salome)
+ ADD_DEFINITIONS( -DHAVE_SALOME )
+ENDIF(EXISTS ${GUI_ROOT_DIR})
INCLUDE(Common)
INCLUDE(FindQt)
+INCLUDE(FindBoost)
INCLUDE(FindPython)
+INCLUDE(FindSalome)
IF(UNIX)
IF(CMAKE_COMPILER_IS_GNUCC)
ADD_SUBDIRECTORY (src/Config)
-ADD_SUBDIRECTORY (src/Event)
+ADD_SUBDIRECTORY (src/Events)
ADD_SUBDIRECTORY (src/Model)
ADD_SUBDIRECTORY (src/ModelAPI)
ADD_SUBDIRECTORY (src/GeomAPI)
ADD_SUBDIRECTORY (src/PyInterp)
ADD_SUBDIRECTORY (src/XGUI)
ADD_SUBDIRECTORY (src/GeomApp)
+
+IF(${HAVE_SALOME})
+ ADD_SUBDIRECTORY (src/NewGeom)
+ENDIF(${HAVE_SALOME})
--- /dev/null
+@ECHO OFF
+
+REM Find absolute path to ROOT_DIR
+@SET PARENT_DIR=%~dp0..
+@SET ROOT_DIR=
+pushd %PARENT_DIR%
+@SET ROOT_DIR=%CD%
+popd
+
+@SET SRC_DIR=%ROOT_DIR%\sources
+@SET OCC_LIB_PREFIX=d
+
+call %SRC_DIR%\msvc9_env_Salome.bat
+mkdir %ROOT_DIR%\build
+cd %ROOT_DIR%\build
+
+cmake %SRC_DIR% -G "Visual Studio 9 2008" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:PATH=%ROOT_DIR%\install
+
+start "" %MSVC_EXE% NewGEOM.sln
@SET PATH=%PDIR%\swig-2.0.9\bin;%PATH%
@REM -------------------------
-@REM -------------------------
@REM BOOST
@SET BOOST_ROOT_DIR=%PDIR%\boost-1.52.0
@SET PATH=%BOOST_ROOT_DIR%\lib;%PATH%
@SET NEW_GEOM_CONFIG_FILE=%ROOT_DIR%\install\plugins
@SET PATH=%ROOT_DIR%\install\plugins;%PATH%
+@REM -------------------------
+if "%GUI_ROOT_DIR%" == "" (
+ @SET GUI_ROOT_DIR=%ROOT_DIR%\SALOME\GUI\DEBUG\GUI_INSTALL
+)
+@REM -------------------------
+
+
rem -------- Visual Studio --------------------
rem Detect Visual Studio (either commercial or Express edition)
if "%VS100COMNTOOLS%" == "" (
--- /dev/null
+@echo off
+
+IF NOT EXIST "%VS90COMNTOOLS%..\..\VC\vcvarsall.bat" GOTO ERROR1
+
+@REM Load local settings from file localenv.bat that should be located in the root directory
+if "%ROOT_DIR%" == "" (
+ set ROOT_DIR=%~dp0..
+)
+
+if exist "%ROOT_DIR%\localenv.bat" (
+ echo Setting local environment from %ROOT_DIR%\localenv.bat
+ call "%ROOT_DIR%\localenv.bat"
+) else (
+ echo Warning: file %ROOT_DIR%\localenv.bat does not exist; using default environment
+)
+
+if "%SALOME_ROOT_DIR%" == "" (
+ set SALOME_ROOT_DIR=%ROOT_DIR%\SALOME
+)
+
+call "%SALOME_ROOT_DIR%\WORK\set_env.bat"
+call "%PDIR%\env_compile.bat"
+
+@REM -------------------------
+@REM Python
+@SET PYTHON_LIB_DIR=%PYTHON_ROOT_DIR%\libs
+@SET PYTHON_INC_DIR=%PYTHON_ROOT_DIR%\include
+@REM -------------------------
+
+@REM -------------------------
+@REM CASCADE
+@SET PATH=%CASROOT%;%CASROOT%\win32\bin%OCC_LIB_PREFIX%;%PATH%
+@SET LIB=%CASROOT%\win32\lib%OCC_LIB_PREFIX%;%LIB%
+@set CSF_MDTVFontDirectory=%CASROOT%\src\FontMFT
+@set CSF_LANGUAGE=us
+@set MMGT_CLEAR=1
+@set CSF_EXCEPTION_PROMPT=1
+@set CSF_SHMessage=%CASROOT%\src\SHMessage
+@set CSF_MDTVTexturesDirectory=%CASROOT%\src\Textures
+@set CSF_XSMessage=%CASROOT%\src\XSMessage
+@set CSF_StandardDefaults=%CASROOT%\src\StdResource
+@set CSF_PluginDefaults=%CASROOT%\src\StdResource
+@set CSF_XCAFDefaults=%CASROOT%\src\StdResource
+@set CSF_StandardLiteDefaults=%CASROOT%\src\StdResource
+@set CSF_UnitsLexicon=%CASROOT%\src\UnitsAPI\Lexi_Expr.dat
+@set CSF_UnitsDefinition=%CASROOT%\src\UnitsAPI\Units.dat
+@set CSF_IGESDefaults=%CASROOT%\src\XSTEPResource
+@set CSF_STEPDefaults=%CASROOT%\src\XSTEPResource
+@set CSF_XmlOcafResource=%CASROOT%\src\XmlOcafResource
+@REM -------------------------
+
+@REM -------------------------
+@REM Create launch path
+@SET PATH=%LIBXML2_ROOT_DIR%\bin;%PATH%
+@SET PATH=%PDIR%\tbb\bin;%PATH%
+@SET PATH=%PDIR%\freeimage-3.15.4\bin;%PATH%
+@SET PATH=%PDIR%\ftgl-2.1.3\bin;%PATH%
+@SET PATH=%PDIR%\freetype-2.4.11\bin;%PATH%
+@SET PATH=%PDIR%\gl2ps-1.3.8\bin;%PATH%
+@SET PATH=%PDIR%\qwt-5.2.1\lib;%PATH%
+@REM -------------------------
+
+IF "%ARCH%" == "Win64" (
+ call "%VS90COMNTOOLS%..\..\VC\vcvarsall.bat" x64
+) ELSE (
+ IF "%ARCH%" == "Win32" (
+ call "%VS90COMNTOOLS%..\..\VC\vcvarsall.bat" x86
+ ) ELSE (
+ echo Wrong architecture is used. Win32 or Win64 architecture is allowed only.
+ echo Refer to the set_env.bat script.
+ )
+)
+
+@SET NEW_GEOM_CONFIG_FILE=%ROOT_DIR%\install\plugins
+@SET PATH=%ROOT_DIR%\install\bin;%ROOT_DIR%\install\plugins;%PATH%
+
+@SET LightAppConfig=%ROOT_DIR%\install\share\salome\resources\newgeom;%GUI_ROOT_DIR%\share\salome\resources\gui
--- /dev/null
+@ECHO OFF
+
+REM Find absolute path to ROOT_DIR
+@SET PARENT_DIR=%~dp0..
+@SET ROOT_DIR=
+pushd %PARENT_DIR%
+@SET ROOT_DIR=%CD%
+popd
+
+@SET SRC_DIR=%ROOT_DIR%\sources
+@SET OCC_LIB_PREFIX=d
+
+call %SRC_DIR%\msvc9_env_Salome.bat
+
+
+SuitApp.exe LightApp -style salome --modules=NewGeom --uselicense --noexcepthandling
INCLUDE(Common)
INCLUDE(XMLProcessing)
-INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Event)
+INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events)
SET(PROJECT_HEADERS
Config.h
)
SET(PROJECT_LIBRARIES
- Event
+ Events
${LIBXML2_LIBRARIES}
)
*/
#include "Config_FeatureMessage.h"
-Config_FeatureMessage::Config_FeatureMessage(const Event_ID theId, const void* theParent)
- : Event_Message(theId, theParent)
+Config_FeatureMessage::Config_FeatureMessage(const Events_ID theId, const void* theParent)
+ : Events_Message(theId, theParent)
{
myId = "";
myText = "";
#define CONFIG_MESSAGE_H\r
\r
#include <Config.h>\r
-#include <Event_Message.h>\r
+#include <Events_Message.h>\r
\r
#include <string>\r
\r
* Example of the feature entry:\r
* <feature id="Part" text="New part" tooltip="Creates a new part" icon=":pictures/part_ico.png"/>\r
*/\r
-class Config_FeatureMessage: public Event_Message\r
+class Config_FeatureMessage: public Events_Message\r
{\r
std::string myId; //Feature unique id\r
std::string myText; //Represents action's text\r
bool myUseInput; //Action is being checked until user commit the operation\r
\r
public:\r
- //const Event_ID theID, const void* theSender = 0\r
- CONFIG_EXPORT Config_FeatureMessage(const Event_ID theId, const void* theParent = 0);\r
+ //const Events_ID theID, const void* theSender = 0\r
+ CONFIG_EXPORT Config_FeatureMessage(const Events_ID theId, const void* theParent = 0);\r
\r
//TODO(sbh): Implement static method to extract event id [SEID]\r
//static const char* eventId() { return ""; }\r
CONFIG_EXPORT void setUseInput(bool isUseInput);\r
};\r
\r
-#endif // CONFIG_MESSAGE_H
+#endif // CONFIG_MESSAGE_H\r
#include <Config_Common.h>
#include <Config_FeatureMessage.h>
#include <Config_FeatureReader.h>
-#include <Event_Message.h>
-#include <Event_Loop.h>
+#include <Events_Message.h>
+#include <Events_Loop.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
void Config_FeatureReader::processNode(xmlNodePtr theNode)
{
- Event_ID aMenuItemEvent = Event_Loop::eventByName(myEventGenerated);
+ Events_ID aMenuItemEvent = Events_Loop::eventByName(myEventGenerated);
if (isNode(theNode, NODE_FEATURE, NULL)) {
- Event_Loop* aEvLoop = Event_Loop::loop();
+ Events_Loop* aEvLoop = Events_Loop::loop();
Config_FeatureMessage aMessage(aMenuItemEvent, this);
fillFeature(theNode, aMessage);
myFeatures.push_back(getProperty(theNode, _ID));
#include <Config_PointerMessage.h>
-Config_PointerMessage::Config_PointerMessage(const Event_ID theId, const void* theParent)
- : Event_Message(theId, theParent), myPointer(0)
+Config_PointerMessage::Config_PointerMessage(const Events_ID theId, const void* theParent)
+ : Events_Message(theId, theParent), myPointer(0)
{
}
#define PARTSET_MESSAGE_H_
#include <Config.h>
-#include <Event_Message.h>
+#include <Events_Message.h>
/*
* A general class to pass pointers over the event loop.
*/
-class CONFIG_EXPORT Config_PointerMessage: public Event_Message
+class CONFIG_EXPORT Config_PointerMessage: public Events_Message
{
public:
- Config_PointerMessage(const Event_ID theId, const void* theParent = 0);
+ Config_PointerMessage(const Events_ID theId, const void* theParent = 0);
virtual ~Config_PointerMessage();
void* pointer() const;
#include <Config_Keywords.h>
#include <Config_Common.h>
-#include <Event_Loop.h>
+#include <Events_Loop.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
/*
* Allows to customize reader's behavior for a node. Virtual.
- * The default implementation does nothing. (In debug mode prints
+ * The default impl does nothing. (In debug mode prints
* some info)
*/
void Config_XMLReader::processNode(xmlNodePtr theNode)
/*
* Defines which nodes should be processed recursively. Virtual.
- * The default implementation is to read all nodes.
+ * The default impl is to read all nodes.
*/
bool Config_XMLReader::processChildren(xmlNodePtr aNode)
{
ModelAPI_PluginManager::get()->registerPlugin(this);
}
-shared_ptr<ModelAPI_Feature> ConstructionPlugin_Plugin::createFeature(string theFeatureID)
+boost::shared_ptr<ModelAPI_Feature> ConstructionPlugin_Plugin::createFeature(string theFeatureID)
{
if (theFeatureID == "Point") {
- return shared_ptr<ModelAPI_Feature>(new ConstructionPlugin_Point);
+ return boost::shared_ptr<ModelAPI_Feature>(new ConstructionPlugin_Point);
}
// feature of such kind is not found
- return shared_ptr<ModelAPI_Feature>();
+ return boost::shared_ptr<ModelAPI_Feature>();
}
{
public:
/// Creates the feature object of this plugin by the feature string ID
- virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
+ virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
public:
/// Is needed for python wrapping by swig
+++ /dev/null
-INCLUDE(Common)
-
-SET(PROJECT_HEADERS
- Event.h
- Event_Message.h
- Event_Listener.h
- Event_Loop.h
-)
-
-SET(PROJECT_SOURCES
- Event_Message.cpp
- Event_Listener.cpp
- Event_Loop.cpp
-)
-
-ADD_DEFINITIONS(-DEVENT_EXPORTS)
-ADD_LIBRARY(Event SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-
-TARGET_LINK_LIBRARIES(Event ${PROJECT_LIBRARIES})
-
-INSTALL(TARGETS Event DESTINATION bin)
+++ /dev/null
-#ifndef EVENT_H
-#define EVENT_H
-
-#if defined EVENT_EXPORTS
-#if defined WIN32
-#define EVENT_EXPORT __declspec( dllexport )
-#else
-#define EVENT_EXPORT
-#endif
-#else
-#if defined WIN32
-#define EVENT_EXPORT __declspec( dllimport )
-#else
-#define EVENT_EXPORT
-#endif
-#endif
-
-#endif
+++ /dev/null
-// File: Event_Listener.cxx
-// Created: Thu Mar 13 2014
-// Author: Mikhail PONIKAROV
-
-#include <Event_Listener.h>
+++ /dev/null
-// File: Event_Listener.hxx
-// Created: Thu Mar 13 2014
-// Author: Mikhail PONIKAROV
-
-#ifndef Event_Listener_HeaderFile
-#define Event_Listener_HeaderFile
-
-#include <Event.h>
-class Event_Message;
-
-/**\class Event_Listener
- * \ingroup EventLoop
- * \brief Base interface for any event listener.
- *
- * If some object wants to listen some events it must inherit
- * this class and register in the Loop.
- */
-class EVENT_EXPORT Event_Listener {
-
-public:
- //! This method is called by loop when the event is started to process.
- virtual void processEvent(const Event_Message* theMessage) = 0;
-};
-
-#endif
+++ /dev/null
-// File: Event_Loop.hxx
-// Created: Thu Mar 13 2014
-// Author: Mikhail PONIKAROV
-
-#include <Event_Loop.h>
-
-#include <string>
-#include <cstring>
-
-using namespace std;
-
-Event_Loop* Event_Loop::loop()
-{
- // initialized on initialization of the application
- static Event_Loop MAIN_LOOP;
- return &MAIN_LOOP;
-}
-
-Event_ID Event_Loop::eventByName(const char* theName)
-{
- ///! All events created in this session, uniquely identified by the text and char pointer
- static map<string, char*> CREATED_EVENTS;
- char* aResult;
- string aName(theName);
- map<string, char*>::iterator aFound = CREATED_EVENTS.find(aName);
- if (aFound == CREATED_EVENTS.end()) { //not created yet
- aResult = strdup(theName); // copy to make unique internal pointer
- CREATED_EVENTS[aName] = aResult;
- } else
- aResult = aFound->second;
-
- return Event_ID(aResult);
-}
-
-void Event_Loop::send(Event_Message& theMessage)
-{
- // TO DO: make it in thread and wit husage of semaphores
-
- map<char*, map<void*, list<Event_Listener*> > >::iterator aFindID = myListeners.find(
- theMessage.eventID().eventText());
- if (aFindID != myListeners.end()) {
- map<void*, list<Event_Listener*> >::iterator aFindSender = aFindID->second.find(
- theMessage.sender());
- if (aFindSender != aFindID->second.end()) {
- list<Event_Listener*>& aListeners = aFindSender->second;
- for(list<Event_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
- (*aL)->processEvent(&theMessage);
- }
- if (theMessage.sender()) { // also call for NULL senders registered
- aFindSender = aFindID->second.find(NULL);
- if (aFindSender != aFindID->second.end()) {
- list<Event_Listener*>& aListeners = aFindSender->second;
- for(list<Event_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
- (*aL)->processEvent(&theMessage);
- }
- }
- }
-}
-
-void Event_Loop::registerListener(Event_Listener* theListener, const Event_ID theID,
- void* theSender)
-{
- map<char*, map<void*, list<Event_Listener*> > >::iterator aFindID = myListeners.find(
- theID.eventText());
- if (aFindID == myListeners.end()) { // create container associated with ID
- myListeners[theID.eventText()] = map<void*, list<Event_Listener*> >();
- aFindID = myListeners.find(theID.eventText());
- }
-
- map<void*, list<Event_Listener*> >::iterator aFindSender = aFindID->second.find(theSender);
- if (aFindSender == aFindID->second.end()) { // create container associated with sender
- aFindID->second[theSender] = list<Event_Listener*>();
- aFindSender = aFindID->second.find(theSender);
- }
- // check that listener was not registered wit hsuch parameters before
- list<Event_Listener*>& aListeners = aFindSender->second;
- for(list<Event_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
- if (*aL == theListener)
- return; // avoid duplicates
-
- aListeners.push_back(theListener);
-}
+++ /dev/null
-// File: Event_Loop.hxx
-// Created: Thu Mar 13 2014
-// Author: Mikhail PONIKAROV
-
-#ifndef Event_Loop_HeaderFile
-#define Event_Loop_HeaderFile
-
-#include <Event_Message.h>
-#include <Event_Listener.h>
-
-#include <map>
-#include <list>
-
-/**\class Event_Lopp
- * \ingroup EventLoop
- * \brief Base class that manages the receiving and sending of all
- * not Qt-events in the application.
- *
- * One per application, initialized on start. Listeners must register in this loop
- * to get events, called by senders. Sending of events is very fast (just adding to container).
- * Performing of events is processed in separated thread, so, sender takes
- * control back immideately.
- */
-class Event_Loop {
- std::map<char*, std::map<void*, std::list<Event_Listener*> > >
- myListeners; ///< map from event ID to sender pointer to listeners that must be called for this
-
- //! The empty constructor, will be called at startup of the application, only once
- Event_Loop() {};
-public:
- ///! Returns the main object of the loop, one per application.
- EVENT_EXPORT static Event_Loop* loop();
- //! Returns the unique event by the given name. Call this method only on initialization of object
- //! to speedup the events processing without parsing of the string.
- EVENT_EXPORT static Event_ID eventByName(const char* theName);
-
- //! Allows to send an event
- EVENT_EXPORT void send(Event_Message& theMessage);
-
- //! Registers (or adds if such listener is already registered) a listener
- //! that will be called on the event and from the defined sender
- EVENT_EXPORT void registerListener(Event_Listener* theListener, const Event_ID theID,
- void* theSender = 0);
-};
-
-#endif
+++ /dev/null
-// File: Event_Message.cxx
-// Created: Thu Mar 13 2014
-// Author: Mikhail PONIKAROV
-
-#include <Event_Message.h>
+++ /dev/null
-// File: Event_Message.hxx
-// Created: Thu Mar 13 2014
-// Author: Mikhail PONIKAROV
-
-#ifndef Event_Message_HeaderFile
-#define Event_Message_HeaderFile
-
-#include <Event.h>
-
-/**\class Event_ID
- * \ingroup EventLoop
- * \brief Identifier of the event kind.
- *
- * Each event ID is created in main Envent_Loop class
- * that stores correspondance between the string-name of the
- * identifier and the pointer to the static string that is really
- * used as an identifier (this is usefull for debugging of the events
- * with log files and in debugger).
- */
-class EVENT_EXPORT Event_ID {
- char* myID; ///< pointer to the text-identifier of the event, unique pointer for all events of such type
-
- Event_ID(char* theID) {myID = theID;}
-
- friend class Event_Loop;
-public:
- /// Returns the text-identifier of the event (for debugging reasons)
- char* eventText() const {return myID;}
- /// Allows to compare identifiers
- bool operator==(const Event_ID& theID) const {return myID == theID.myID;}
-};
-
-/**\class Event_Message
- * \ingroup EventLoop
- * \brief Message for communication between sender and listener of event.
- * Normally it is inherited by the higher-level
- */
-class EVENT_EXPORT Event_Message {
- Event_ID myEventId; ///< identifier of the event
- void* mySender; ///< the sender object
-
-public:
-
- //! Creates the message
- Event_Message(const Event_ID theID, const void* theSender = 0)
- : myEventId(theID), mySender((void*) theSender) {}
- //! do nothing in the destructor yet
- virtual ~Event_Message() {}
-
- //! Returns identifier of the message
- const Event_ID& eventID() const {return myEventId;}
-
- //! Returns sender of the message or NULL if it is anonymous message
- void* sender() const {return mySender;}
-};
-
-#endif
--- /dev/null
+INCLUDE(Common)
+
+SET(PROJECT_HEADERS
+ Events.h
+ Events_Message.h
+ Events_Listener.h
+ Events_Loop.h
+)
+
+SET(PROJECT_SOURCES
+ Events_Message.cpp
+ Events_Listener.cpp
+ Events_Loop.cpp
+)
+
+ADD_DEFINITIONS(-DEVENTS_EXPORTS)
+ADD_LIBRARY(Events SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+
+TARGET_LINK_LIBRARIES(Events ${PROJECT_LIBRARIES})
+
+INSTALL(TARGETS Events DESTINATION bin)
--- /dev/null
+#ifndef EVENTS_H
+#define EVENTS_H
+
+#if defined EVENTS_EXPORTS
+#if defined WIN32
+#define EVENTS_EXPORT __declspec( dllexport )
+#else
+#define EVENTS_EXPORT
+#endif
+#else
+#if defined WIN32
+#define EVENTS_EXPORT __declspec( dllimport )
+#else
+#define EVENTS_EXPORT
+#endif
+#endif
+
+#endif
--- /dev/null
+// File: Events_Listener.cxx
+// Created: Thu Mar 13 2014
+// Author: Mikhail PONIKAROV
+
+#include <Events_Listener.h>
--- /dev/null
+// File: Events_Listener.hxx
+// Created: Thu Mar 13 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef Events_Listener_HeaderFile
+#define Events_Listener_HeaderFile
+
+#include <Events.h>
+class Events_Message;
+
+/**\class Events_Listener
+ * \ingroup EventsLoop
+ * \brief Base interface for any event listener.
+ *
+ * If some object wants to listen some events it must inherit
+ * this class and register in the Loop.
+ */
+class EVENTS_EXPORT Events_Listener {
+
+public:
+ //! This method is called by loop when the event is started to process.
+ virtual void processEvent(const Events_Message* theMessage) = 0;
+};
+
+#endif
--- /dev/null
+// File: Events_Loop.hxx
+// Created: Thu Mar 13 2014
+// Author: Mikhail PONIKAROV
+
+#include <Events_Loop.h>
+
+#include <string>
+#include <cstring>
+
+using namespace std;
+
+Events_Loop* Events_Loop::loop()
+{
+ // initialized on initialization of the application
+ static Events_Loop MAIN_LOOP;
+ return &MAIN_LOOP;
+}
+
+Events_ID Events_Loop::eventByName(const char* theName)
+{
+ ///! All events created in this session, uniquely identified by the text and char pointer
+ static map<string, char*> CREATED_EVENTS;
+ char* aResult;
+ string aName(theName);
+ map<string, char*>::iterator aFound = CREATED_EVENTS.find(aName);
+ if (aFound == CREATED_EVENTS.end()) { //not created yet
+ aResult = strdup(theName); // copy to make unique internal pointer
+ CREATED_EVENTS[aName] = aResult;
+ } else
+ aResult = aFound->second;
+
+ return Events_ID(aResult);
+}
+
+void Events_Loop::send(Events_Message& theMessage)
+{
+ // TO DO: make it in thread and wit husage of semaphores
+
+ map<char*, map<void*, list<Events_Listener*> > >::iterator aFindID = myListeners.find(
+ theMessage.eventID().eventText());
+ if (aFindID != myListeners.end()) {
+ map<void*, list<Events_Listener*> >::iterator aFindSender = aFindID->second.find(
+ theMessage.sender());
+ if (aFindSender != aFindID->second.end()) {
+ list<Events_Listener*>& aListeners = aFindSender->second;
+ for(list<Events_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
+ (*aL)->processEvent(&theMessage);
+ }
+ if (theMessage.sender()) { // also call for NULL senders registered
+ aFindSender = aFindID->second.find(NULL);
+ if (aFindSender != aFindID->second.end()) {
+ list<Events_Listener*>& aListeners = aFindSender->second;
+ for(list<Events_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
+ (*aL)->processEvent(&theMessage);
+ }
+ }
+ }
+}
+
+void Events_Loop::registerListener(Events_Listener* theListener, const Events_ID theID,
+ void* theSender)
+{
+ map<char*, map<void*, list<Events_Listener*> > >::iterator aFindID = myListeners.find(
+ theID.eventText());
+ if (aFindID == myListeners.end()) { // create container associated with ID
+ myListeners[theID.eventText()] = map<void*, list<Events_Listener*> >();
+ aFindID = myListeners.find(theID.eventText());
+ }
+
+ map<void*, list<Events_Listener*> >::iterator aFindSender = aFindID->second.find(theSender);
+ if (aFindSender == aFindID->second.end()) { // create container associated with sender
+ aFindID->second[theSender] = list<Events_Listener*>();
+ aFindSender = aFindID->second.find(theSender);
+ }
+ // check that listener was not registered wit hsuch parameters before
+ list<Events_Listener*>& aListeners = aFindSender->second;
+ for(list<Events_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
+ if (*aL == theListener)
+ return; // avoid duplicates
+
+ aListeners.push_back(theListener);
+}
--- /dev/null
+// File: Events_Loop.hxx
+// Created: Thu Mar 13 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef Events_Loop_HeaderFile
+#define Events_Loop_HeaderFile
+
+#include <Events_Message.h>
+#include <Events_Listener.h>
+
+#include <map>
+#include <list>
+
+/**\class Events_Lopp
+ * \ingroup EventsLoop
+ * \brief Base class that manages the receiving and sending of all
+ * not Qt-events in the application.
+ *
+ * One per application, initialized on start. Listeners must register in this loop
+ * to get events, called by senders. Sending of events is very fast (just adding to container).
+ * Performing of events is processed in separated thread, so, sender takes
+ * control back immideately.
+ */
+class Events_Loop {
+ std::map<char*, std::map<void*, std::list<Events_Listener*> > >
+ myListeners; ///< map from event ID to sender pointer to listeners that must be called for this
+
+ //! The empty constructor, will be called at startup of the application, only once
+ Events_Loop() {};
+public:
+ ///! Returns the main object of the loop, one per application.
+ EVENTS_EXPORT static Events_Loop* loop();
+ //! Returns the unique event by the given name. Call this method only on initialization of object
+ //! to speedup the events processing without parsing of the string.
+ EVENTS_EXPORT static Events_ID eventByName(const char* theName);
+
+ //! Allows to send an event
+ EVENTS_EXPORT void send(Events_Message& theMessage);
+
+ //! Registers (or adds if such listener is already registered) a listener
+ //! that will be called on the event and from the defined sender
+ EVENTS_EXPORT void registerListener(Events_Listener* theListener, const Events_ID theID,
+ void* theSender = 0);
+};
+
+#endif
--- /dev/null
+// File: Events_Message.cxx
+// Created: Thu Mar 13 2014
+// Author: Mikhail PONIKAROV
+
+#include <Events_Message.h>
--- /dev/null
+// File: Events_Message.hxx
+// Created: Thu Mar 13 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef Events_Message_HeaderFile
+#define Events_Message_HeaderFile
+
+#include <Events.h>
+
+/**\class Events_ID
+ * \ingroup EventsLoop
+ * \brief Identifier of the event kind.
+ *
+ * Each event ID is created in main Envent_Loop class
+ * that stores correspondance between the string-name of the
+ * identifier and the pointer to the static string that is really
+ * used as an identifier (this is usefull for debugging of the events
+ * with log files and in debugger).
+ */
+class EVENTS_EXPORT Events_ID {
+ char* myID; ///< pointer to the text-identifier of the event, unique pointer for all events of such type
+
+ Events_ID(char* theID) {myID = theID;}
+
+ friend class Events_Loop;
+public:
+ /// Returns the text-identifier of the event (for debugging reasons)
+ char* eventText() const {return myID;}
+ /// Allows to compare identifiers
+ bool operator==(const Events_ID& theID) const {return myID == theID.myID;}
+};
+
+/**\class Events_Message
+ * \ingroup EventsLoop
+ * \brief Message for communication between sender and listener of event.
+ * Normally it is inherited by the higher-level
+ */
+class EVENTS_EXPORT Events_Message {
+ Events_ID myEventsId; ///< identifier of the event
+ void* mySender; ///< the sender object
+
+public:
+
+ //! Creates the message
+ Events_Message(const Events_ID theID, const void* theSender = 0)
+ : myEventsId(theID), mySender((void*) theSender) {}
+ //! do nothing in the destructor yet
+ virtual ~Events_Message() {}
+
+ //! Returns identifier of the message
+ const Events_ID& eventID() const {return myEventsId;}
+
+ //! Returns sender of the message or NULL if it is anonymous message
+ void* sender() const {return mySender;}
+};
+
+#endif
GeomAPI_Interface.h
GeomAPI_Pnt.h
GeomAPI_Dir.h
+ GeomAPI_Pln.h
GeomAPI_Shape.h
)
GeomAPI_Interface.cpp
GeomAPI_Pnt.cpp
GeomAPI_Dir.cpp
+ GeomAPI_Pln.cpp
GeomAPI_Shape.cpp
)
/* GeomAPI.i */
%module GeomAPI
%{
- #include "memory"
+ #include "boost/shared_ptr.hpp"
#include "GeomAPI.h"
#include "GeomAPI_Interface.h"
#include "GeomAPI_Pnt.h"
+ #include "GeomAPI_Dir.h"
+ #include "GeomAPI_Pln.h"
#include "GeomAPI_Shape.h"
%}
// standard definitions
%include "typemaps.i"
%include "std_string.i"
-%include <std_shared_ptr.i>
+//%include <std_shared_ptr.i>
+%include <boost_shared_ptr.i>
// boost pointers
// %include <boost_shared_ptr.i>
%shared_ptr(GeomAPI_Interface)
%shared_ptr(GeomAPI_Pnt)
+%shared_ptr(GeomAPI_Dir)
+%shared_ptr(GeomAPI_Pln)
%shared_ptr(GeomAPI_Shape)
// all supported interfaces
%include "GeomAPI_Interface.h"
%include "GeomAPI_Pnt.h"
+%include "GeomAPI_Dir.h"
+%include "GeomAPI_Pln.h"
%include "GeomAPI_Shape.h"
delete myImpl;
}
-void* GeomAPI_Interface::implementation()
-{
- return myImpl;
-}
-
-void GeomAPI_Interface::setImplementation(void* theImpl)
+void GeomAPI_Interface::setImpl(void* theImpl)
{
if (myImpl)
delete myImpl;
class GEOMAPI_EXPORT GeomAPI_Interface
{
protected:
- void* myImpl; ///< pointer to the internal implementation object
+ void* myImpl; ///< pointer to the internal impl object
public:
/// None - constructor
GeomAPI_Interface();
- /// Constructor by the implementation pointer (used for internal needs)
+ /// Constructor by the impl pointer (used for internal needs)
GeomAPI_Interface(void* theImpl);
/// Destructor
virtual ~GeomAPI_Interface();
- /// Returns the pointer to the implementation
- void* implementation();
- /// Updates the implementation (deletes the old one)
- void setImplementation(void* theImpl);
+ /// Returns the pointer to the impl
+ template<class T> inline T* implPtr() {return dynamic_cast<T*>(myImpl);}
+ /// Returns the reference object of the impl
+ template<class T> inline const T& impl() {return *(static_cast<T*>(myImpl));}
+ /// Updates the impl (deletes the old one)
+ void setImpl(void* theImpl);
};
#endif
-
--- /dev/null
+// File: GeomAPI_Pln.cpp
+// Created: 23 Apr 2014
+// Author: Mikhail PONIKAROV
+
+#include<GeomAPI_Pln.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Dir.h>
+
+#include<gp_Pln.hxx>
+
+using namespace std;
+
+GeomAPI_Pln::GeomAPI_Pln(const boost::shared_ptr<GeomAPI_Pnt>& thePoint,
+ const boost::shared_ptr<GeomAPI_Dir>& theNormal)
+: GeomAPI_Interface(new gp_Pln(thePoint->impl<gp_Pnt>(),
+ theNormal->impl<gp_Dir>()))
+{
+}
+
+GeomAPI_Pln::GeomAPI_Pln(
+ const double theA, const double theB, const double theC, const double theD)
+: GeomAPI_Interface(new gp_Pln(theA, theB, theC, theD))
+{
+}
+
+boost::shared_ptr<GeomAPI_Pnt> GeomAPI_Pln::location()
+{
+ gp_Pnt aLoc = impl<gp_Pln>().Location();
+ return boost::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
+}
+
+boost::shared_ptr<GeomAPI_Dir> GeomAPI_Pln::direction()
+{
+ const gp_Dir& aDir = impl<gp_Pln>().Axis().Direction();
+ return boost::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+}
--- /dev/null
+// File: GeomAPI_Pln.hxx
+// Created: 23 Apr 2014
+// Author: Mikhail PONIKAROV
+
+#ifndef GeomAPI_Pln_HeaderFile
+#define GeomAPI_Pln_HeaderFile
+
+#include <boost/shared_ptr.hpp>
+#include <GeomAPI_Interface.h>
+
+class GeomAPI_Pnt;
+class GeomAPI_Dir;
+
+/**\class GeomAPI_Pln
+ * \ingroup DataModel
+ * \brief 3D point defined by three coordinates
+ */
+
+class GEOMAPI_EXPORT GeomAPI_Pln: public GeomAPI_Interface
+{
+public:
+ /// Creation of plane by the point and normal
+ GeomAPI_Pln(const boost::shared_ptr<GeomAPI_Pnt>& thePoint,
+ const boost::shared_ptr<GeomAPI_Dir>& theNormal);
+
+ /// Creation of plane by coefficients A * X + B * Y + C * Z + D = 0.0
+ GeomAPI_Pln(const double theA, const double theB, const double theC, const double theD);
+
+ /// Returns a point of this plane
+ boost::shared_ptr<GeomAPI_Pnt> location();
+
+ /// Returns a plane normal
+ boost::shared_ptr<GeomAPI_Dir> direction();
+};
+
+#endif
+
SET(PROJECT_HEADERS
GeomAlgoAPI.h
+ GeomAlgoAPI_CompoundBuilder.h
GeomAlgoAPI_FaceBuilder.h
)
SET(PROJECT_SOURCES
+ GeomAlgoAPI_CompoundBuilder.cpp
GeomAlgoAPI_FaceBuilder.cpp
)
// standard definitions
%include "typemaps.i"
%include "std_string.i"
-%include <std_shared_ptr.i>
+//%include <std_shared_ptr.i>
+%include <boost_shared_ptr.i>
// all supported interfaces
%include "GeomAlgoAPI_FaceBuilder.h"
--- /dev/null
+// File: GeomAlgoAPI_CompoundBuilder.cpp
+// Created: 24 Apr 2014
+// Author: Natalia ERMOLAEVA
+
+#include <GeomAlgoAPI_CompoundBuilder.h>
+//#include <gp_Pln.hxx>
+//#include <BRepBuilderAPI_MakeFace.hxx>
+//#include <TopoDS_Face.hxx>
+#include <BRep_Builder.hxx>
+#include <TopoDS_Compound.hxx>
+
+boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_CompoundBuilder::compound
+ (std::list<boost::shared_ptr<GeomAPI_Shape> > theShapes)
+{
+ BRep_Builder aBuilder;
+ TopoDS_Compound aComp;
+ aBuilder.MakeCompound(aComp);
+
+ std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = theShapes.begin(),
+ aLast = theShapes.end();
+ for (; anIt != aLast; anIt++) {
+ aBuilder.Add(aComp, (*anIt)->impl<TopoDS_Shape>());
+ }
+
+ boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+ aRes->setImpl(new TopoDS_Shape(aComp));
+ return aRes;
+}
--- /dev/null
+// File: GeomAlgoAPI_CompoundBuilder.h
+// Created: 24 Apr 2014
+// Author: Natalia ERMOLAEVA
+
+#ifndef GeomAlgoAPI_CompoundBuilder_HeaderFile
+#define GeomAlgoAPI_CompoundBuilder_HeaderFile
+
+#include <GeomAlgoAPI.h>
+#include <GeomAPI_Shape.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Dir.h>
+#include <boost/shared_ptr.hpp>
+
+#include <list>
+
+/**\class GeomAlgoAPI_CompoundBuilder
+ * \ingroup DataAlgo
+ * \brief Allows to create face-shapes by different parameters
+ */
+
+class GEOMALGOAPI_EXPORT GeomAlgoAPI_CompoundBuilder
+{
+public:
+ /// Creates compund of the given shapes
+ /// \param theShapes a list of shapes
+ static boost::shared_ptr<GeomAPI_Shape> compound
+ (std::list<boost::shared_ptr<GeomAPI_Shape> > theShapes);
+};
+
+#endif
#include <BRepBuilderAPI_MakeFace.hxx>
#include <TopoDS_Face.hxx>
-std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
- std::shared_ptr<GeomAPI_Pnt> theCenter, std::shared_ptr<GeomAPI_Dir> theNormal,
+boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
+ boost::shared_ptr<GeomAPI_Pnt> theCenter, boost::shared_ptr<GeomAPI_Dir> theNormal,
const double theSize)
{
- gp_Pnt* aCenter = static_cast<gp_Pnt*>(theCenter->implementation());
- gp_Dir* aDir = static_cast<gp_Dir*>(theNormal->implementation());
- gp_Pln aPlane(*aCenter, *aDir);
+ const gp_Pnt& aCenter = theCenter->impl<gp_Pnt>();
+ const gp_Dir& aDir = theNormal->impl<gp_Dir>();
+ gp_Pln aPlane(aCenter, aDir);
// half of the size in each direction from the center
BRepBuilderAPI_MakeFace aFaceBuilder(aPlane,
-theSize / 2., theSize / 2., -theSize / 2., theSize / 2.);
- std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
- aRes->setImplementation(new TopoDS_Shape(aFaceBuilder.Face()));
+ boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+ aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
return aRes;
}
#include <GeomAPI_Shape.h>
#include <GeomAPI_Pnt.h>
#include <GeomAPI_Dir.h>
-#include <memory>
+#include <boost/shared_ptr.hpp>
/**\class GeomAlgoAPI_FaceBuilder
* \ingroup DataAlgo
public:
/// Creates square planar face by given point of the center,
/// normal to the plane and size of square
- static std::shared_ptr<GeomAPI_Shape> square(std::shared_ptr<GeomAPI_Pnt> theCenter,
- std::shared_ptr<GeomAPI_Dir> theNormal, const double theSize);
+ static boost::shared_ptr<GeomAPI_Shape> square(boost::shared_ptr<GeomAPI_Pnt> theCenter,
+ boost::shared_ptr<GeomAPI_Dir> theNormal, const double theSize);
};
#endif
Model_Events.cpp
)
-ADD_DEFINITIONS(-DMODEL_EXPORTS ${CAS_DEFINITIONS})
+ADD_DEFINITIONS(-DMODEL_EXPORTS ${CAS_DEFINITIONS} ${BOOST_DEFINITIONS})
ADD_LIBRARY(Model SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-TARGET_LINK_LIBRARIES(Model ${PROJECT_LIBRARIES} ${CAS_OCAF} ModelAPI Event Config)
+TARGET_LINK_LIBRARIES(Model ${PROJECT_LIBRARIES} ${CAS_OCAF} ModelAPI Events Config)
INCLUDE_DIRECTORIES(
../ModelAPI
- ../Event
+ ../Events
../Config
${CAS_INCLUDE_DIRS}
)
}
//=======================================================================
-const std::shared_ptr<Model_Document>& Model_Application::getDocument(string theDocID)
+const boost::shared_ptr<Model_Document>& Model_Application::getDocument(string theDocID)
{
if (myDocs.find(theDocID) != myDocs.end())
return myDocs[theDocID];
- std::shared_ptr<Model_Document> aNew(new Model_Document(theDocID));
+ boost::shared_ptr<Model_Document> aNew(new Model_Document(theDocID));
myDocs[theDocID] = aNew;
return myDocs[theDocID];
}
//! Retuns the application: one per process
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);
+ MODEL_EXPORT const boost::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
private:
/// Map from string identifiers to created documents of an application
- std::map<std::string, std::shared_ptr<Model_Document> > myDocs;
+ std::map<std::string, boost::shared_ptr<Model_Document> > myDocs;
};
#endif
using namespace std;
-void Model_AttributeDocRef::setValue(std::shared_ptr<ModelAPI_Document> theDoc)
+void Model_AttributeDocRef::setValue(boost::shared_ptr<ModelAPI_Document> theDoc)
{
myComment->Set(TCollection_ExtendedString(theDoc->id().c_str()));
}
-std::shared_ptr<ModelAPI_Document> Model_AttributeDocRef::value()
+boost::shared_ptr<ModelAPI_Document> Model_AttributeDocRef::value()
{
if (myComment->Get().Length())
return Model_Application::getApplication()->getDocument(
TCollection_AsciiString(myComment->Get()).ToCString());
// not initialized
- return std::shared_ptr<ModelAPI_Document>();
+ return boost::shared_ptr<ModelAPI_Document>();
}
Model_AttributeDocRef::Model_AttributeDocRef(TDF_Label& theLabel)
Handle_TDataStd_Comment myComment; ///< reference to document is identified as string-id
public:
/// Defines the document referenced from this attribute
- MODEL_EXPORT virtual void setValue(std::shared_ptr<ModelAPI_Document> theDoc);
+ MODEL_EXPORT virtual void setValue(boost::shared_ptr<ModelAPI_Document> theDoc);
/// Returns document referenced from this attribute
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> value();
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> value();
protected:
/// Initializes attibutes
anAttr = new Model_AttributeDouble(anAttrLab);
if (anAttr)
- myAttrs[theID] = std::shared_ptr<ModelAPI_Attribute>(anAttr);
+ myAttrs[theID] = boost::shared_ptr<ModelAPI_Attribute>(anAttr);
else
; // TODO: generate error on unknown attribute request and/or add mechanism for customization
}
-shared_ptr<ModelAPI_AttributeDocRef> Model_Data::docRef(const string theID)
+boost::shared_ptr<ModelAPI_AttributeDocRef> Model_Data::docRef(const string theID)
{
- map<string, shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ map<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 std::shared_ptr<ModelAPI_AttributeDocRef>();
+ return boost::shared_ptr<ModelAPI_AttributeDocRef>();
}
- shared_ptr<ModelAPI_AttributeDocRef> aRes =
- dynamic_pointer_cast<ModelAPI_AttributeDocRef>(aFound->second);
+ boost::shared_ptr<ModelAPI_AttributeDocRef> aRes =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeDocRef>(aFound->second);
if (!aRes) {
// TODO: generate error on invalid attribute type request
}
return aRes;
}
-shared_ptr<ModelAPI_AttributeDouble> Model_Data::real(const string theID)
+boost::shared_ptr<ModelAPI_AttributeDouble> Model_Data::real(const string theID)
{
- map<string, shared_ptr<ModelAPI_Attribute> >::iterator aFound = myAttrs.find(theID);
+ map<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 std::shared_ptr<ModelAPI_AttributeDouble>();
+ return boost::shared_ptr<ModelAPI_AttributeDouble>();
}
- shared_ptr<ModelAPI_AttributeDouble> aRes =
- dynamic_pointer_cast<ModelAPI_AttributeDouble>(aFound->second);
+ boost::shared_ptr<ModelAPI_AttributeDouble> aRes =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aFound->second);
if (!aRes) {
// TODO: generate error on invalid attribute type request
}
{
TDF_Label myLab; ///< label of the feature in the document
/// All attributes of the object identified by the attribute ID
- std::map<std::string, std::shared_ptr<ModelAPI_Attribute> > myAttrs;
+ std::map<std::string, boost::shared_ptr<ModelAPI_Attribute> > myAttrs;
- std::shared_ptr<ModelAPI_Document> myDoc; ///< document this feature belongs to
+ boost::shared_ptr<ModelAPI_Document> myDoc; ///< document this feature belongs to
Model_Data();
/// Defines the name of the feature visible by the user in the object browser
MODEL_EXPORT virtual void setName(std::string theName);
/// Returns the attribute that references to another document
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID);
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID);
/// Returns the attribute that contains real value with double precision
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID);
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID);
/// Initializes object by the attributes: must be called just after the object is created
/// for each attribute of the object
MODEL_EXPORT virtual void addAttribute(std::string theID, std::string theAttrType);
/// Returns the document of this data
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> document() {return myDoc;}
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> document() {return myDoc;}
/// Puts feature to the document data sub-structure
MODEL_EXPORT void setLabel(TDF_Label& theLab);
/// Sets the document of this data
- MODEL_EXPORT virtual void setDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) {myDoc = theDoc;}
+ MODEL_EXPORT virtual void setDocument(const boost::shared_ptr<ModelAPI_Document>& theDoc) {myDoc = theDoc;}
};
#endif
#include <Model_PluginManager.h>
#include <Model_Iterator.h>
#include <Model_Events.h>
-#include <Event_Loop.h>
+#include <Events_Loop.h>
#include <TDataStd_Integer.hxx>
#include <TDataStd_Comment.hxx>
subDocument(*aSubIter)->redo();
}
-shared_ptr<ModelAPI_Feature> Model_Document::addFeature(string theID)
+boost::shared_ptr<ModelAPI_Feature> Model_Document::addFeature(string theID)
{
- shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_PluginManager::get()->createFeature(theID);
+ boost::shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_PluginManager::get()->createFeature(theID);
if (aFeature) {
- dynamic_pointer_cast<Model_Document>(aFeature->documentToAdd())->addFeature(aFeature);
+ boost::dynamic_pointer_cast<Model_Document>(aFeature->documentToAdd())->addFeature(aFeature);
} else {
// TODO: generate error that feature is not created
}
return aFeature;
}
-void Model_Document::addFeature(const std::shared_ptr<ModelAPI_Feature> theFeature)
+void Model_Document::addFeature(const boost::shared_ptr<ModelAPI_Feature> theFeature)
{
const std::string& aGroup = theFeature->getGroup();
TDF_Label aGroupLab = groupLabel(aGroup);
TDF_Label anObjLab = aGroupLab.NewChild();
- std::shared_ptr<Model_Data> aData(new Model_Data);
+ boost::shared_ptr<Model_Data> aData(new Model_Data);
aData->setLabel(anObjLab);
- shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
+ boost::shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
aData->setDocument(aThis);
theFeature->setData(aData);
setUniqueName(theFeature);
myFeatures[aGroup].push_back(theFeature);
// event: feature is added
- static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED);
ModelAPI_FeatureUpdatedMessage aMsg(aThis, theFeature, anEvent);
- Event_Loop::loop()->send(aMsg);
+ Events_Loop::loop()->send(aMsg);
}
-shared_ptr<ModelAPI_Feature> Model_Document::feature(TDF_Label& theLabel)
+boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(TDF_Label& theLabel)
{
Handle(TDataStd_Integer) aFeatureIndex;
if (theLabel.FindAttribute(TDataStd_Integer::GetID(), aFeatureIndex)) {
return myFeatures[aGroup][aFeatureIndex->Get()];
}
}
- return std::shared_ptr<ModelAPI_Feature>(); // not found
+ return boost::shared_ptr<ModelAPI_Feature>(); // not found
}
-int Model_Document::featureIndex(shared_ptr<ModelAPI_Feature> theFeature)
+int Model_Document::featureIndex(boost::shared_ptr<ModelAPI_Feature> theFeature)
{
if (theFeature->data()->document().get() != this) {
return theFeature->data()->document()->featureIndex(theFeature);
}
- shared_ptr<Model_Data> aData = dynamic_pointer_cast<Model_Data>(theFeature->data());
+ boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theFeature->data());
Handle(TDataStd_Integer) aFeatureIndex;
if (aData->label().FindAttribute(TDataStd_Integer::GetID(), aFeatureIndex)) {
return aFeatureIndex->Get();
return -1; // not found
}
-shared_ptr<ModelAPI_Document> Model_Document::subDocument(string theDocID)
+boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(string theDocID)
{
// just store sub-document identifier here to manage it later
if (mySubs.find(theDocID) == mySubs.end())
return Model_Application::getApplication()->getDocument(theDocID);
}
-shared_ptr<ModelAPI_Iterator> Model_Document::featuresIterator(const string theGroup)
+boost::shared_ptr<ModelAPI_Iterator> Model_Document::featuresIterator(const string theGroup)
{
- shared_ptr<Model_Document> aThis(Model_Application::getApplication()->getDocument(myID));
+ boost::shared_ptr<Model_Document> aThis(Model_Application::getApplication()->getDocument(myID));
// create an empty iterator for not existing group
// (to avoidance of attributes management outside the transaction)
if (myGroups.find(theGroup) == myGroups.end())
- return shared_ptr<ModelAPI_Iterator>(new Model_Iterator());
- return shared_ptr<ModelAPI_Iterator>(new Model_Iterator(aThis, groupLabel(theGroup)));
+ return boost::shared_ptr<ModelAPI_Iterator>(new Model_Iterator());
+ return boost::shared_ptr<ModelAPI_Iterator>(new Model_Iterator(aThis, groupLabel(theGroup)));
}
-shared_ptr<ModelAPI_Feature> Model_Document::feature(const string& theGroupID, const int theIndex)
+boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(const string& theGroupID, const int theIndex)
{
// TODO: optimize this method
- shared_ptr<ModelAPI_Iterator> anIter = featuresIterator(theGroupID);
+ boost::shared_ptr<ModelAPI_Iterator> anIter = featuresIterator(theGroupID);
for(int a = 0; a != theIndex && anIter->more(); anIter->next()) a++;
- return anIter->more() ? anIter->current() : shared_ptr<ModelAPI_Feature>();
+ return anIter->more() ? anIter->current() : boost::shared_ptr<ModelAPI_Feature>();
}
const vector<string>& Model_Document::getGroups() const
myGroupsNames.push_back(theGroup);
// set to the group label the group idntifier to restore on "open"
TDataStd_Comment::Set(myGroups[theGroup], theGroup.c_str());
- myFeatures[theGroup] = vector<shared_ptr<ModelAPI_Feature> >();
+ myFeatures[theGroup] = vector<boost::shared_ptr<ModelAPI_Feature> >();
}
return myGroups[theGroup];
}
-void Model_Document::setUniqueName(
- shared_ptr<ModelAPI_Feature> theFeature)
+void Model_Document::setUniqueName(boost::shared_ptr<ModelAPI_Feature> theFeature)
{
// first count all objects of such kind to start with index = count + 1
int aNumObjects = 0;
- shared_ptr<ModelAPI_Iterator> anIter = featuresIterator(theFeature->getGroup());
+ boost::shared_ptr<ModelAPI_Iterator> anIter = featuresIterator(theFeature->getGroup());
for(; anIter->more(); anIter->next()) {
if (anIter->currentKind() == theFeature->getKind())
aNumObjects++;
void Model_Document::synchronizeFeatures()
{
- shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(myID);
+ boost::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);
aGroupNamesIter = myGroupsNames.erase(aGroupNamesIter);
// say that features were deleted from group
ModelAPI_FeatureDeletedMessage aMsg(aThis, aGroupName);
- Event_Loop::loop()->send(aMsg);
+ Events_Loop::loop()->send(aMsg);
}
// create new groups basing on the following data model update
for(; aGroupsIter.More(); aGroupsIter.Next()) {
aGroupsIter.Value())->Get()).ToCString();
myGroupsNames.push_back(aGroupName);
myGroups[aGroupName] = aGroupsIter.Value()->Label();
- myFeatures[aGroupName] = vector<shared_ptr<ModelAPI_Feature> >();
+ myFeatures[aGroupName] = vector<boost::shared_ptr<ModelAPI_Feature> >();
}
// update features group by group
aGroupsIter.Initialize(myDoc->Main().FindChild(TAG_OBJECTS),
string aGroupName = TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(
aGroupsIter.Value())->Get()).ToCString();
// iterate features in internal container
- vector<shared_ptr<ModelAPI_Feature> >& aFeatures = myFeatures[aGroupName];
- vector<shared_ptr<ModelAPI_Feature> >::iterator aFIter = aFeatures.begin();
+ vector<boost::shared_ptr<ModelAPI_Feature> >& aFeatures = myFeatures[aGroupName];
+ vector<boost::shared_ptr<ModelAPI_Feature> >::iterator aFIter = aFeatures.begin();
// and in parallel iterate labels of features
TDF_ChildIDIterator aFLabIter(
aGroupsIter.Value()->Label(), TDataStd_Comment::GetID(), Standard_False);
static const int INFINITE_TAG = INT_MAX; // no label means that it exists somwhere in infinite
int aFeatureTag = INFINITE_TAG;
if (aFIter != aFeatures.end()) { // existing tag for feature
- shared_ptr<Model_Data> aData = dynamic_pointer_cast<Model_Data>((*aFIter)->data());
+ boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>((*aFIter)->data());
aFeatureTag = aData->label().Tag();
}
int aDSTag = INFINITE_TAG;
aFIter = aFeatures.erase(aFIter);
// event: model is updated
ModelAPI_FeatureDeletedMessage aMsg(aThis, aGroupName);
- Event_Loop::loop()->send(aMsg);
+ Events_Loop::loop()->send(aMsg);
} else if (aDSTag < aFeatureTag) { // a new feature is inserted
// create a feature
- shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_PluginManager::get()->createFeature(
+ boost::shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_PluginManager::get()->createFeature(
TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(
aFLabIter.Value())->Get()).ToCString());
- std::shared_ptr<Model_Data> aData(new Model_Data);
+ boost::shared_ptr<Model_Data> aData(new Model_Data);
TDF_Label aLab = aFLabIter.Value()->Label();
aData->setLabel(aLab);
aData->setDocument(Model_Application::getApplication()->getDocument(myID));
aFeature->setData(aData);
aFeature->initAttributes();
// event: model is updated
- static Event_ID anEvent = Event_Loop::eventByName(EVENT_FEATURE_CREATED);
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_CREATED);
ModelAPI_FeatureUpdatedMessage aMsg(aThis, aFeature, anEvent);
- Event_Loop::loop()->send(aMsg);
+ Events_Loop::loop()->send(aMsg);
if (aFIter == aFeatures.end()) {
aFeatures.push_back(aFeature);
//! Adds to the document the new feature of the given feature id
//! \param creates feature and puts it in the document
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
//! Returns the existing feature by the label
//! \param theLabel base label of the feature
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature> feature(TDF_Label& theLabel);
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> feature(TDF_Label& theLabel);
//! Adds a new sub-document by the identifier, or returns existing one if it is already exist
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID);
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID);
//! Creates an iterator of the features by the specific groups
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Iterator> featuresIterator(
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Iterator> featuresIterator(
const std::string theGroup);
MODEL_EXPORT virtual const std::string& id() const {return myID;}
//! Returns the feature in the group by the index (started from zero)
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature>
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature>
feature(const std::string& theGroupID, const int theIndex);
///! Returns the vector of groups already added to the document
//! Returns the index of feature in the group (zero based)
//! \retruns -1 if not found
- MODEL_EXPORT virtual int featureIndex(std::shared_ptr<ModelAPI_Feature> theFeature);
+ MODEL_EXPORT virtual int featureIndex(boost::shared_ptr<ModelAPI_Feature> theFeature);
protected:
//! Initializes feature with a unique name in this group (unique name is generated as
//! feature type + "_" + index
- void setUniqueName(std::shared_ptr<ModelAPI_Feature> theFeature);
+ void setUniqueName(boost::shared_ptr<ModelAPI_Feature> theFeature);
//! Adds to the document the new feature
- void addFeature(const std::shared_ptr<ModelAPI_Feature> theFeature);
+ void addFeature(const boost::shared_ptr<ModelAPI_Feature> theFeature);
//! Synchronizes myGroups, myGroupsNames, myFeatures and mySubs list with the updated document
void synchronizeFeatures();
std::map<std::string, TDF_Label> myGroups;
std::vector<std::string> myGroupsNames; ///< names of added groups to the document
/// Features managed by this document: by group name
- std::map<std::string, std::vector<std::shared_ptr<ModelAPI_Feature> > > myFeatures;
+ std::map<std::string, std::vector<boost::shared_ptr<ModelAPI_Feature> > > myFeatures;
std::set<std::string> mySubs; ///< set of identifiers of sub-documents of this document
/// transaction indexes (related to myTransactionsAfterSave) which were empty in this doc
std::map<int, bool> myIsEmptyTr;
// Author: Mikhail PONIKAROV
#include <Model_Events.h>
-#include <Event_Loop.h>
+#include <Events_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), myDoc(theDoc)
+ const boost::shared_ptr<ModelAPI_Document>& theDoc,
+ const boost::shared_ptr<ModelAPI_Feature>& theFeature, const Events_ID& theEvent)
+ : Events_Message(theEvent, 0), myFeature(theFeature), myDoc(theDoc)
{}
ModelAPI_FeatureDeletedMessage::ModelAPI_FeatureDeletedMessage(
- const std::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup)
- : Event_Message(messageId(), 0), myDoc(theDoc), myGroup(theGroup)
+ const boost::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup)
+ : Events_Message(messageId(), 0), myDoc(theDoc), myGroup(theGroup)
{
}
-const Event_ID ModelAPI_FeatureDeletedMessage::messageId()
+const Events_ID ModelAPI_FeatureDeletedMessage::messageId()
{
- static Event_ID MY_ID = Event_Loop::eventByName(EVENT_FEATURE_DELETED);
+ static Events_ID MY_ID = Events_Loop::eventByName(EVENT_FEATURE_DELETED);
return MY_ID;
}
#define Model_Events_HeaderFile
#include <Model.h>
-#include <Event_Message.h>
-#include <memory>
+#include <Events_Message.h>
+#include <boost/shared_ptr.hpp>
#include <string>
class ModelAPI_Feature;
static const char * EVENT_FEATURE_DELETED = "FeatureDeleted";
/// 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
+class ModelAPI_FeatureUpdatedMessage : public Events_Message {
+ boost::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
+ boost::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_Document>& theDoc,
- const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const Event_ID& theEvent);
+ const boost::shared_ptr<ModelAPI_Document>& theDoc,
+ const boost::shared_ptr<ModelAPI_Feature>& theFeature,
+ const Events_ID& theEvent);
/// Returns the feature that has been updated
- std::shared_ptr<ModelAPI_Feature> feature() const {return myFeature;}
+ boost::shared_ptr<ModelAPI_Feature> feature() const {return myFeature;}
/// Returns the document that has been updated
- std::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
+ boost::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
};
/// Message that feature was deleted (used for Object Browser update)
-class ModelAPI_FeatureDeletedMessage : public Event_Message {
- std::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
+class ModelAPI_FeatureDeletedMessage : public Events_Message {
+ boost::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
std::string myGroup; ///< group identifier that contained the deleted feature
public:
/// creates a message by initialization of fields
- ModelAPI_FeatureDeletedMessage(const std::shared_ptr<ModelAPI_Document>& theDoc,
+ ModelAPI_FeatureDeletedMessage(const boost::shared_ptr<ModelAPI_Document>& theDoc,
const std::string& theGroup);
/// Returns the ID of this message (EVENT_FEATURE_DELETED)
- static const Event_ID messageId();
+ static const Events_ID messageId();
/// Returns the feature that has been updated
- std::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
+ boost::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
/// Returns the group where the feature was deleted
const std::string& group() const {return myGroup;}
return myIter.More() == Standard_True;
}
-shared_ptr<ModelAPI_Feature> Model_Iterator::current()
+boost::shared_ptr<ModelAPI_Feature> Model_Iterator::current()
{
TDF_Label aLab = myIter.Value()->Label();
return myDoc->feature(aLab);
return aResult;
}
-bool Model_Iterator::isEqual(std::shared_ptr<ModelAPI_Feature> theFeature)
+bool Model_Iterator::isEqual(boost::shared_ptr<ModelAPI_Feature> theFeature)
{
return (myIter.Value()->Label() ==
- dynamic_pointer_cast<Model_Data>(theFeature->data())->label()) == Standard_True;
+ boost::dynamic_pointer_cast<Model_Data>(theFeature->data())->label()) == Standard_True;
}
{
}
-Model_Iterator::Model_Iterator(std::shared_ptr<Model_Document> theDoc, TDF_Label theLab)
+Model_Iterator::Model_Iterator(boost::shared_ptr<Model_Document> theDoc, TDF_Label theLab)
: myDoc(theDoc), myIter(theLab, TDataStd_Comment::GetID(), Standard_False)
{}
class Model_Iterator : public ModelAPI_Iterator
{
- std::shared_ptr<Model_Document> myDoc; ///< the document of iterated objects
+ boost::shared_ptr<Model_Document> myDoc; ///< the document of iterated objects
TDF_ChildIDIterator myIter; ///< iterator of the features-labels
public:
/// Iterates to the next feature
/// Returns true if the current iteration is valid and next iteration is possible
MODEL_EXPORT virtual bool more();
/// Returns the currently iterated feature
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature> current();
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> current();
/// Returns the kind of the current feature (faster than Current()->getKind())
MODEL_EXPORT virtual std::string currentKind();
/// Returns the name of the current feature (faster than Current()->getName())
/// Compares the current feature with the given one
/// \returns true if given feature equals to the current one
- MODEL_EXPORT virtual bool isEqual(std::shared_ptr<ModelAPI_Feature> theFeature);
+ MODEL_EXPORT virtual bool isEqual(boost::shared_ptr<ModelAPI_Feature> theFeature);
protected:
/// Creates an empty iterator that alway returns More false
/// Initializes iterator
/// \param theDoc document where the iteration is performed
/// \param theLab label of the features group to iterate
- Model_Iterator(std::shared_ptr<Model_Document> theDoc, TDF_Label theLab);
+ Model_Iterator(boost::shared_ptr<Model_Document> theDoc, TDF_Label theLab);
friend class Model_Document;
};
#include <Model_Data.h>
#include <Model_Document.h>
#include <Model_Application.h>
-#include <Event_Loop.h>
+#include <Events_Loop.h>
#include <Config_FeatureMessage.h>
#include <Config_ModuleReader.h>
static Model_PluginManager* myImpl = new Model_PluginManager();
-shared_ptr<ModelAPI_Feature> Model_PluginManager::createFeature(string theFeatureID)
+boost::shared_ptr<ModelAPI_Feature> Model_PluginManager::createFeature(string theFeatureID)
{
if (this != myImpl) return myImpl->createFeature(theFeatureID);
LoadPluginsInfo();
if (myPlugins.find(theFeatureID) != myPlugins.end()) {
- if (myPluginObjs.find(myPlugins[theFeatureID]) == myPluginObjs.end()) {
+ myCurrentPluginName = myPlugins[theFeatureID];
+ if (myPluginObjs.find(myCurrentPluginName) == myPluginObjs.end()) {
// load plugin library if not yet done
- myCurrentPluginName = myPlugins[theFeatureID];
loadLibrary(myCurrentPluginName);
}
if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) {
- std::shared_ptr<ModelAPI_Feature> aCreated =
+ boost::shared_ptr<ModelAPI_Feature> aCreated =
myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID);
return aCreated;
}
}
- return std::shared_ptr<ModelAPI_Feature>(); // return nothing
+ return boost::shared_ptr<ModelAPI_Feature>(); // return nothing
}
-std::shared_ptr<ModelAPI_Document> Model_PluginManager::rootDocument()
+boost::shared_ptr<ModelAPI_Document> Model_PluginManager::rootDocument()
{
- return std::shared_ptr<ModelAPI_Document>(
+ return boost::shared_ptr<ModelAPI_Document>(
Model_Application::getApplication()->getDocument("root"));
}
return Model_Application::getApplication()->hasDocument("root");
}
-shared_ptr<ModelAPI_Document> Model_PluginManager::currentDocument()
+boost::shared_ptr<ModelAPI_Document> Model_PluginManager::currentDocument()
{
if (!myCurrentDoc)
myCurrentDoc = rootDocument();
return myCurrentDoc;
}
-void Model_PluginManager::setCurrentDocument(shared_ptr<ModelAPI_Document> theDoc)
+void Model_PluginManager::setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc)
{
myCurrentDoc = theDoc;
}
{
myPluginsInfoLoaded = false;
//TODO(sbh): Implement static method to extract event id [SEID]
- static Event_ID aFeatureEvent = Event_Loop::eventByName("FeatureRegisterEvent");
+ static Events_ID aFeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent");
- ModelAPI_PluginManager::SetPluginManager(std::shared_ptr<ModelAPI_PluginManager>(this));
+ ModelAPI_PluginManager::SetPluginManager(boost::shared_ptr<ModelAPI_PluginManager>(this));
// register the configuration reading listener
- Event_Loop* aLoop = Event_Loop::loop();
+ Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, aFeatureEvent);
}
-void Model_PluginManager::processEvent(const Event_Message* theMessage)
+void Model_PluginManager::processEvent(const Events_Message* theMessage)
{
const Config_FeatureMessage* aMsg =
dynamic_cast<const Config_FeatureMessage*>(theMessage);
#include "Model.h"
#include <ModelAPI_PluginManager.h>
-#include <Event_Listener.h>
+#include <Events_Listener.h>
#include <map>
class Model_Document;
* plugin contains which feature, loads and stores reference to loaded plugins by
* the feature functionality request.
*/
-class Model_PluginManager : public ModelAPI_PluginManager, public Event_Listener
+class Model_PluginManager : public ModelAPI_PluginManager, public Events_Listener
{
bool myPluginsInfoLoaded; ///< it true if plugins information is loaded
/// map of feature IDs to plugin name
std::map<std::string, std::string> myPlugins;
std::map<std::string, ModelAPI_Plugin*> myPluginObjs; ///< instances of the already plugins
std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently
- std::shared_ptr<ModelAPI_Document> myCurrentDoc; ///< current working document
+ boost::shared_ptr<ModelAPI_Document> myCurrentDoc; ///< current working document
public:
/// Returns the root document of the application (that may contains sub-documents)
- MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Document> rootDocument();
+ MODEL_EXPORT virtual boost::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();
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> currentDocument();
/// Defines the current document that used for current work in the application
- MODEL_EXPORT virtual void setCurrentDocument(std::shared_ptr<ModelAPI_Document> theDoc);
+ MODEL_EXPORT virtual void setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc);
/// Registers the plugin that creates features.
/// It is obligatory for each plugin to call this function on loading to be found by
MODEL_EXPORT virtual void registerPlugin(ModelAPI_Plugin* thePlugin);
/// Processes the configuration file reading
- MODEL_EXPORT virtual void processEvent(const Event_Message* theMessage);
+ MODEL_EXPORT virtual void processEvent(const Events_Message* theMessage);
/// Is called only once, on startup of the application
Model_PluginManager();
void LoadPluginsInfo();
/// Creates the feature object using plugins functionality
- virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
+ virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
};
#endif
// standard definitions
%include "typemaps.i"
%include "std_string.i"
-%include <std_shared_ptr.i>
+//%include <std_shared_ptr.i>
// boost pointers
-// %include <boost_shared_ptr.i>
+%include <boost_shared_ptr.i>
%shared_ptr(ModelAPI_Document)
%shared_ptr(ModelAPI_PluginManager)
%shared_ptr(ModelAPI_Feature)
{
public:
/// Defines the document referenced from this attribute
- virtual void setValue(std::shared_ptr<ModelAPI_Document> theDoc) = 0;
+ virtual void setValue(boost::shared_ptr<ModelAPI_Document> theDoc) = 0;
/// Returns document referenced from this attribute
- virtual std::shared_ptr<ModelAPI_Document> value() = 0;
+ virtual boost::shared_ptr<ModelAPI_Document> value() = 0;
/// Returns the type of this class of attributes
static std::string type() {return "DocRef";}
#include "ModelAPI.h"
#include <string>
-#include <memory>
+#include <boost/shared_ptr.hpp>
class ModelAPI_AttributeDocRef;
class ModelAPI_AttributeDouble;
virtual void setName(std::string theName) = 0;
/// Returns the attribute that references to another document
- virtual std::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID) = 0;
+ virtual boost::shared_ptr<ModelAPI_AttributeDocRef> docRef(const std::string theID) = 0;
/// Returns the attribute that contains real value with double precision
- virtual std::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID) = 0;
+ virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string theID) = 0;
/// Initializes object by the attributes: must be called just after the object is created
/// for each attribute of the object
virtual void addAttribute(std::string theID, std::string theAttrType) = 0;
/// Returns the document of this data
- virtual std::shared_ptr<ModelAPI_Document> document() = 0;
+ virtual boost::shared_ptr<ModelAPI_Document> document() = 0;
/// To virtually destroy the fields of successors
virtual ~ModelAPI_Data() {}
#include <ModelAPI.h>
#include <string>
-#include <memory>
+#include <boost/shared_ptr.hpp>
#include <vector>
class ModelAPI_Feature;
//! Adds to the document the new feature of the given feature id
//! \param creates feature and puts it in the document
- MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
+ MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
- MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID) = 0;
+ MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> subDocument(std::string theDocID) = 0;
///! Creates an iterator of the features by the specific groups
- MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Iterator> featuresIterator(
+ MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Iterator> featuresIterator(
const std::string theGroup) = 0;
///! Returns the id of hte document
MODELAPI_EXPORT virtual const std::string& id() const = 0;
//! Returns the feature in the group by the index (started from zero)
- MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Feature>
+ MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Feature>
feature(const std::string& theGroupID, const int theIndex) = 0;
//! Returns the index of feature in the group (zero based)
- MODELAPI_EXPORT virtual int featureIndex(std::shared_ptr<ModelAPI_Feature> theFeature) = 0;
+ MODELAPI_EXPORT virtual int featureIndex(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
///! Returns the vector of groups already added to the document
MODELAPI_EXPORT virtual const std::vector<std::string>& getGroups() const = 0;
#include "ModelAPI_PluginManager.h"
#include <string>
-#include <memory>
+#include <boost/shared_ptr.hpp>
class ModelAPI_Data;
class ModelAPI_Document;
*/
class ModelAPI_Feature
{
- std::shared_ptr<ModelAPI_Data> myData; ///< manager of the data model of a feature
+ boost::shared_ptr<ModelAPI_Data> myData; ///< manager of the data model of a feature
public:
/// Returns the kind of a feature (like "Point")
MODELAPI_EXPORT virtual void execute() = 0;
/// Returns the data manager of this feature
- MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Data> data() {return myData;}
+ MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Data> data() {return myData;}
/// Must return document where the new feature must be added to
/// By default it is current document
- MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> documentToAdd()
+ MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> documentToAdd()
{return ModelAPI_PluginManager::get()->currentDocument();}
/// To virtually destroy the fields of successors
{}
/// Sets the data manager of an object (document does)
- MODELAPI_EXPORT void setData(std::shared_ptr<ModelAPI_Data> theData) {myData = theData;}
+ MODELAPI_EXPORT void setData(boost::shared_ptr<ModelAPI_Data> theData) {myData = theData;}
friend class Model_Document;
};
#include "ModelAPI.h"
#include <string>
-#include <memory>
+#include <boost/shared_ptr.hpp>
class ModelAPI_Feature;
class ModelAPI_Document;
/// Returns true if the current iteration is valid and next iteration is possible
virtual bool more() = 0;
/// Returns the currently iterated feature
- virtual std::shared_ptr<ModelAPI_Feature> current() = 0;
+ virtual boost::shared_ptr<ModelAPI_Feature> current() = 0;
/// Returns the kind of the current feature (faster than Current()->getKind())
virtual std::string currentKind() = 0;
/// Returns the name of the current feature (faster than Current()->getName())
virtual int numIterationsLeft() = 0;
/// Compares the current feature with the given one
/// \returns true if given feature equals to the current one
- virtual bool isEqual(std::shared_ptr<ModelAPI_Feature> theFeature) = 0;
+ virtual bool isEqual(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
/// To virtually destroy the fields of successors
virtual ~ModelAPI_Iterator() {}
#include "ModelAPI.h"
#include <string>
-#include <memory>
+#include <boost/shared_ptr.hpp>
class ModelAPI_Feature;
{
public:
/// Creates the feature object of this plugin by the feature string ID
- virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
+ virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
/// To virtually destroy the fields of successors
virtual ~ModelAPI_Plugin() {}
string library(const string& theLibName);
/// Manager that will be initialized from Model package, one per application
-std::shared_ptr<ModelAPI_PluginManager> MY_MANAGER;
+boost::shared_ptr<ModelAPI_PluginManager> MY_MANAGER;
ModelAPI_PluginManager::ModelAPI_PluginManager()
{
}
void ModelAPI_PluginManager::SetPluginManager(
- std::shared_ptr<ModelAPI_PluginManager> theManager)
+ boost::shared_ptr<ModelAPI_PluginManager> theManager)
{
MY_MANAGER = theManager;
}
-std::shared_ptr<ModelAPI_PluginManager> ModelAPI_PluginManager::get()
+boost::shared_ptr<ModelAPI_PluginManager> ModelAPI_PluginManager::get()
{
if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI
loadLibrary("Model");
#include "ModelAPI.h"
#include <string>
-#include <memory>
+#include <boost/shared_ptr.hpp>
class ModelAPI_Feature;
class ModelAPI_Plugin;
{
public:
/// Returns the real implementation (the alone instance per application) of the plugin manager
- static std::shared_ptr<ModelAPI_PluginManager> get();
+ static boost::shared_ptr<ModelAPI_PluginManager> get();
/// Registers the plugin that creates features.
/// It is obligatory for each plugin to call this function on loading to be found by
virtual void registerPlugin(ModelAPI_Plugin* thePlugin) = 0;
/// Returns the root document of the application (that may contains sub-documents)
- virtual std::shared_ptr<ModelAPI_Document> rootDocument() = 0;
+ virtual boost::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;
+ virtual boost::shared_ptr<ModelAPI_Document> currentDocument() = 0;
/// Defines the current document that used for current work in the application
- virtual void setCurrentDocument(std::shared_ptr<ModelAPI_Document> theDoc) = 0;
+ virtual void setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc) = 0;
/// loads the library with specific name, appends "lib*.dll" or "*.so" depending on the platform
static void loadLibrary(const std::string theLibName);
protected:
/// Creates the feature object using plugins functionality
- virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
+ virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
- static void SetPluginManager(std::shared_ptr<ModelAPI_PluginManager> theManager);
+ static void SetPluginManager(boost::shared_ptr<ModelAPI_PluginManager> theManager);
friend class Model_Document;
};
return myOperationId;
}
-std::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::feature() const
+boost::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::feature() const
{
return myFeature;
}
* \return Returns TRUE if current operation must not be checked for ActiveOperation->IsValid( this )
*
* This method must be redefined in derived operation if operation of derived class
- * must be always can start above any launched one. Default implementation returns FALSE,
+ * must be always can start above any launched one. Default impl returns FALSE,
* so it is being checked for IsValid, but some operations may overload IsGranted()
* In this case they will always start, no matter what operation is running.
*/
/*
* Returns pointer to the root document.
*/
-std::shared_ptr<ModelAPI_Document> ModuleBase_Operation::document() const
+boost::shared_ptr<ModelAPI_Document> ModuleBase_Operation::document() const
{
return ModelAPI_PluginManager::get()->rootDocument();
}
return;
}
QString anId = sender()->objectName();
- std::shared_ptr<ModelAPI_Data> aData = myFeature->data();
- std::shared_ptr<ModelAPI_AttributeDouble> aReal = aData->real(anId.toStdString());
+ boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
+ boost::shared_ptr<ModelAPI_AttributeDouble> aReal = aData->real(anId.toStdString());
aReal->setValue(theValue);
}
* \brief Verifies whether operator is ready to start.
* \return TRUE if operation is ready to start
*
- * Default implementation returns TRUE. Redefine this method to add own verifications
+ * Default impl returns TRUE. Redefine this method to add own verifications
*/
bool ModuleBase_Operation::isReadyToStart() const
{
* \brief Virtual method called when operation is started
*
* Virtual method called when operation started (see start() method for more description)
- * Default implementation calls corresponding slot and commits immediately.
+ * Default impl calls corresponding slot and commits immediately.
*/
void ModuleBase_Operation::startOperation()
{
- std::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
+ boost::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
myFeature = aDoc->addFeature(myOperationId.toStdString());
if (myFeature) // TODO: generate an error if feature was not created
myFeature->execute();
#include <QObject>
#include <QString>
-#include <memory>
+#include <boost/shared_ptr.hpp>
class SUIT_Study;
class XGUI_Workshop;
// Operation processing.
virtual QString operationId() const;
- std::shared_ptr<ModelAPI_Feature> feature() const;
+ boost::shared_ptr<ModelAPI_Feature> feature() const;
OperationState state() const;
bool isRunning() const;
void setExecStatus(const int);
void setState(const OperationState);
- std::shared_ptr<ModelAPI_Document> document() const;
+ boost::shared_ptr<ModelAPI_Document> document() const;
private:
int myFlags; //!< Operation flags
//!< Next fields could be extracted into a subclass;
QString myOperationId;
- std::shared_ptr<ModelAPI_Feature> myFeature;
+ boost::shared_ptr<ModelAPI_Feature> myFeature;
};
#endif
ModuleBase_PropPanelOperation(const QString& theId = "", QObject* parent = 0);
virtual ~ModuleBase_PropPanelOperation();
+ /*!
+ * \brief Replied whether the operation should be commited after the start, or the operation itself
+ * do that. The default realization provides the check by the operation having the xml prepresentation
+ * @return the boolean value
+ */
+ virtual bool isPerformedImmediately() const
+ {
+ return xmlRepresentation().isEmpty();
+ }
/*!
* \brief Returns XML representation of the operation's widget.
* \return XML QString
--- /dev/null
+
+INCLUDE(FindCAS)
+
+SET(CMAKE_AUTOMOC ON)
+
+SET(PROJECT_HEADERS
+ NewGeom.h
+ NewGeom_Module.h
+)
+
+SET(PROJECT_AUTOMOC
+ ${CMAKE_CURRENT_BINARY_DIR}/XGUI_automoc.cpp
+)
+
+SET(PROJECT_SOURCES
+ NewGeom_Module.cpp
+)
+
+SET(PROJECT_RESOURCES
+ resources/LightApp.xml
+ resources/newgeom.png
+)
+
+SET(PROJECT_LIBRARIES
+ Events
+ Config
+ XGUI
+ ${QT_LIBRARIES}
+ ${LightApp}
+ ${CAM}
+ ${OCCViewer}
+)
+
+ADD_DEFINITIONS( -DNewGeom_EXPORTS ${CAS_DEFINITIONS} )
+
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/XGUI
+ ${PROJECT_SOURCE_DIR}/src/Events
+ ${SALOME_GUI_INCLUDE}
+ ${SALOME_KERNEL_INCLUDE}
+ ${CAS_INCLUDE_DIRS}
+)
+
+ADD_LIBRARY(NewGeom SHARED
+ ${PROJECT_SOURCES}
+ ${PROJECT_HEADERS}
+)
+
+ADD_DEPENDENCIES(NewGeom XGUI)
+
+# The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore
+TARGET_LINK_LIBRARIES(NewGeom ${PROJECT_LIBRARIES})
+
+INSTALL(TARGETS NewGeom DESTINATION bin)
+INSTALL(FILES ${PROJECT_RESOURCES} DESTINATION share/salome/resources/newgeom )
\ No newline at end of file
--- /dev/null
+#ifndef NewGeom_H
+#define NewGeom_H
+
+#if defined NewGeom_EXPORTS
+#if defined WIN32
+#define NewGeom_EXPORT __declspec( dllexport )
+#else
+#define NewGeom_EXPORT
+#endif
+#else
+#if defined WIN32
+#define NewGeom_EXPORT __declspec( dllimport )
+#else
+#define NewGeom_EXPORT
+#endif
+#endif
+
+#endif
+
+
+
--- /dev/null
+
+
+#include "NewGeom_Module.h"
+
+#include <LightApp_Application.h>
+#include <OCCViewer_ViewModel.h>
+
+
+
+NewGeom_Module::NewGeom_Module()
+: LightApp_Module( "NewGeom" )
+{
+}
+
+
+NewGeom_Module::~NewGeom_Module()
+{
+}
+
+void NewGeom_Module::initialize(CAM_Application* theApp)
+{
+}
+
+void NewGeom_Module::windows(QMap<int, int>& theWndMap) const
+{
+ theWndMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
+}
+
+void NewGeom_Module::viewManagers(QStringList& theList) const
+{
+ theList.append( OCCViewer_Viewer::Type() );
+}
+
+bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
+{
+ return LightApp_Module::activateModule(theStudy);
+}
+
+bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
+{
+ return LightApp_Module::deactivateModule(theStudy);
+}
+
+
--- /dev/null
+
+
+#ifndef NewGeom_Module_H
+#define NewGeom_Module_H
+
+#include "NewGeom.h"
+#include <LightApp_Module.h>
+
+class NewGeom_EXPORT NewGeom_Module: public LightApp_Module
+{
+ Q_OBJECT
+public:
+ NewGeom_Module();
+ virtual ~NewGeom_Module();
+
+ virtual void initialize( CAM_Application* theApp);
+ virtual void windows( QMap<int, int>& theWndMap) const;
+ virtual void viewManagers( QStringList& theList) const;
+
+public slots:
+ bool activateModule( SUIT_Study* theStudy);
+ bool deactivateModule( SUIT_Study* theStudy);
+
+private:
+
+};
+
+#endif
--- /dev/null
+<!--
+ Copyright (C) 2005-2013 OPEN CASCADE
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+-->
+<document>
+ <section name="NewGeom">
+ <!-- Major module parameters -->
+ <parameter name="name" value="NewGeom"/>
+ <parameter name="icon" value="newgeom.png"/>
+ </section>
+ <section name="resources">
+ <!-- Module resources -->
+ <parameter name="NewGeom" value="${NEWGEOM_ROOT_DIR}/share/salome/resources/newgeom"/>
+ </section>
+</document>
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI
${CMAKE_SOURCE_DIR}/src/Config
- ${CMAKE_SOURCE_DIR}/src/Event
+ ${CMAKE_SOURCE_DIR}/src/Events
${CMAKE_SOURCE_DIR}/src/ModuleBase
${CMAKE_SOURCE_DIR}/src/ModelAPI
${CMAKE_SOURCE_DIR}/src/SketchPlugin
#include <XGUI_MainWindow.h>
#include <XGUI_Displayer.h>
+#include <XGUI_Viewer.h>
+#include <XGUI_Workshop.h>
+#include <XGUI_OperationMgr.h>
#include <Config_PointerMessage.h>
#include <Config_ModuleReader.h>
#include <Config_WidgetReader.h>
-#include <Event_Loop.h>
-#include <Event_Message.h>
+#include <Events_Loop.h>
+#include <Events_Message.h>
#include <QObject>
#include <QString>
PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
{
myWorkshop = theWshop;
+ XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
+
+ connect(anOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
+ connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
+ this, SLOT(onOperationStopped(ModuleBase_Operation*)));
}
PartSet_Module::~PartSet_Module()
} else {
aPartSetOp = new ModuleBase_PropPanelOperation(aCmdId, this);
}
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(aPartSetOp);
- if (aPreviewOp) {
- connect(aPreviewOp, SIGNAL(visualizePreview()), this, SLOT(onVisualizePreview()));
- }
aPartSetOp->setXmlRepresentation(QString::fromStdString(aXmlCfg));
aPartSetOp->setDescription(QString::fromStdString(aDescription));
//TODO(sbh): Implement static method to extract event id [SEID]
- static Event_ID aModuleEvent = Event_Loop::eventByName("PartSetModuleEvent");
+ static Events_ID aModuleEvent = Events_Loop::eventByName("PartSetModuleEvent");
Config_PointerMessage aMessage(aModuleEvent, this);
aMessage.setPointer(aPartSetOp);
- Event_Loop::loop()->send(aMessage);
+ Events_Loop::loop()->send(aMessage);
}
-void PartSet_Module::onVisualizePreview()
+void PartSet_Module::onOperationStarted()
{
- ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
+ ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
+
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+ if (aPreviewOp) {
+ connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
+ aPreviewOp, SLOT(onViewSelectionChanged()));
+ visualizePreview(true);
+ }
+}
+
+void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
+{
+ ModuleBase_PropPanelOperation* anOperation = dynamic_cast<ModuleBase_PropPanelOperation*>(theOperation);
+ if (!anOperation)
+ return;
+
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+ if (aPreviewOp) {
+ disconnect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()),
+ aPreviewOp, SLOT(onViewSelectionChanged()));
+ visualizePreview(false);
+ }
+}
+
+void PartSet_Module::visualizePreview(bool isDisplay)
+{
+ ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
if (!anOperation)
return;
if (!aPreviewOp)
return;
- myWorkshop->displayer()->Display(anOperation->feature(), aPreviewOp->preview());
+ if (isDisplay) {
+ myWorkshop->displayer()->LocalSelection(anOperation->feature(), aPreviewOp->preview(),
+ aPreviewOp->getSelectionMode());
+ }
+ else {
+ myWorkshop->displayer()->GlobalSelection(false);
+ myWorkshop->displayer()->Erase(anOperation->feature(), aPreviewOp->preview());
+ }
}
public slots:
void onFeatureTriggered();
- void onVisualizePreview();
+ /// SLOT, that is called after the operation is started. Perform some specific for module
+ /// actions, e.g. connect the sketch feature to the viewer selection and show the sketch preview.
+ void onOperationStarted();
+ /// SLOT, that is called after the operation is stopped. Disconnect the sketch feature
+ /// from the viewer selection and show the sketch preview.
+ void onOperationStopped(ModuleBase_Operation* theOperation);
+
+private:
+ /// Displays or erase the current operation preview, if it has it.
+ /// \param isDisplay the state whether the presentation should be displayed or erased
+ void visualizePreview(bool isDisplay);
private:
XGUI_Workshop* myWorkshop;
+// File: PartSet_OperationSketch.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#include <PartSet_OperationSketch.h>
#include <SketchPlugin_Feature.h>
{
}
-/*!
- * \brief Destructor
- */
PartSet_OperationSketch::~PartSet_OperationSketch()
{
}
+
+bool PartSet_OperationSketch::isPerformedImmediately() const
+{
+ return false;
+}
+
+int PartSet_OperationSketch::getSelectionMode() const
+{
+ return TopAbs_FACE;
+}
+// File: PartSet_OperationSketch.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#ifndef PartSet_OperationSketch_H
#define PartSet_OperationSketch_H
/*!
\class PartSet_OperationSketch
- * \brief The operation for the sketch creation
- *
- * Base class for all operations. If you perform an action it is reasonable to create
+ * \brief The operation for the sketch feature creation
*/
class PARTSET_EXPORT PartSet_OperationSketch : public PartSet_OperationSketchBase
{
-Q_OBJECT
+ Q_OBJECT
public:
+ /// Constructor
+ /// \param theId the feature identifier
+ /// \param theParent the operation parent
PartSet_OperationSketch(const QString& theId, QObject* theParent);
+ /// Destructor
virtual ~PartSet_OperationSketch();
+
+ /// The sketch can not be created immediately, firstly a plane should be set
+ virtual bool isPerformedImmediately() const;
+
+ /// Returns the operation local selection mode
+ /// \return the selection mode
+ virtual int getSelectionMode() const;
};
#endif
+// File: PartSet_OperationSketchBase.cpp
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#include <PartSet_OperationSketchBase.h>
#include <SketchPlugin_Feature.h>
using namespace std;
-/*!
- \brief Constructor
- \param theId an feature index
- \param theParent the object parent
- */
PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId,
QObject* theParent)
: ModuleBase_PropPanelOperation(theId, theParent)
{
}
-/*!
- * \brief Destructor
- */
PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
{
}
-/**
- * Returns the feature preview shape
- */
const TopoDS_Shape& PartSet_OperationSketchBase::preview() const
{
- shared_ptr<SketchPlugin_Feature> aFeature = dynamic_pointer_cast<SketchPlugin_Feature>(feature());
- return *(static_cast<TopoDS_Shape*>(aFeature->preview()->implementation()));
+ boost::shared_ptr<SketchPlugin_Feature> aFeature =
+ boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
+ return aFeature->preview()->impl<TopoDS_Shape>();
}
-/*!
- * Perform the operation start and emit signal about visualization of the operation preview
- */
-void PartSet_OperationSketchBase::startOperation()
+int PartSet_OperationSketchBase::getSelectionMode() const
{
- ModuleBase_PropPanelOperation::startOperation();
-
- emit visualizePreview();
+ return 0;
}
+// File: PartSet_OperationSketchBase.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#ifndef PartSet_OperationSketchBase_H
#define PartSet_OperationSketchBase_H
#include <QObject>
/*!
- \class PartSet_OperationSketchBase
- * \brief The base operation for the sketch features.
- *
- * Base class for all sketch operations. It provides an access to the feature preview
+ \class PartSet_OperationSketchBase
+ * \brief The base operation for the sketch features.
+ * Base class for all sketch operations. It provides an access to the feature preview
*/
class PARTSET_EXPORT PartSet_OperationSketchBase : public ModuleBase_PropPanelOperation
{
-Q_OBJECT
+ Q_OBJECT
public:
+ /// Constructor
+ /// \param theId an feature index
+ /// \param theParent the object parent
PartSet_OperationSketchBase(const QString& theId, QObject* theParent);
+ /// Destructor
virtual ~PartSet_OperationSketchBase();
+ /// Returns the feature preview shape
const TopoDS_Shape& preview() const;
-signals:
- void visualizePreview();
-
-protected:
- virtual void startOperation();
+ /// Returns the operation local selection mode
+ /// \return the selection mode
+ virtual int getSelectionMode() const;
};
#endif
void PartSetPlugin_Part::execute()
{
- shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->docRef(PART_ATTR_DOC_REF);
+ boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->docRef(PART_ATTR_DOC_REF);
if (!aDocRef->value()) { // create a document if not yet created
- shared_ptr<ModelAPI_Document> aPartSetDoc = ModelAPI_PluginManager::get()->rootDocument();
+ boost::shared_ptr<ModelAPI_Document> aPartSetDoc = ModelAPI_PluginManager::get()->rootDocument();
aDocRef->setValue(aPartSetDoc->subDocument(data()->getName()));
}
}
-shared_ptr<ModelAPI_Document> PartSetPlugin_Part::documentToAdd() {
+boost::shared_ptr<ModelAPI_Document> PartSetPlugin_Part::documentToAdd() {
return ModelAPI_PluginManager::get()->rootDocument();
}
/// Request for initialization of data model of the feature: adding all attributes
PARTSETPLUGIN_EXPORT virtual void initAttributes();
- PARTSETPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Document> documentToAdd();
+ PARTSETPLUGIN_EXPORT virtual boost::shared_ptr<ModelAPI_Document> documentToAdd();
/// Use plugin manager for features creation
PartSetPlugin_Part();
ModelAPI_PluginManager::get()->registerPlugin(this);
}
-shared_ptr<ModelAPI_Feature> PartSetPlugin_Plugin::createFeature(string theFeatureID)
+boost::shared_ptr<ModelAPI_Feature> PartSetPlugin_Plugin::createFeature(string theFeatureID)
{
if (theFeatureID == "Part") {
- return shared_ptr<ModelAPI_Feature>(new PartSetPlugin_Part);
+ return boost::shared_ptr<ModelAPI_Feature>(new PartSetPlugin_Part);
}
// feature of such kind is not found
- return shared_ptr<ModelAPI_Feature>();
+ return boost::shared_ptr<ModelAPI_Feature>();
}
{
public:
/// Creates the feature object of this plugin by the feature string ID
- virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
+ virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
public:
/// Is needed for python wrapping by swig
#include "SketchPlugin_Feature.h"
-/**
- * Returns the sketch preview
- */
-const std::shared_ptr<GeomAPI_Shape>& SketchPlugin_Feature::preview()
+void SketchPlugin_Feature::setPreview(const boost::shared_ptr<GeomAPI_Shape>& theShape)
{
- return myPreview;
+ myPreview = theShape;
}
-/**
- * Set the shape to the internal preview field
- * \param theShape a preview shape
- */
-void SketchPlugin_Feature::setPreview(const std::shared_ptr<GeomAPI_Shape>& theShape)
+const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Feature::getPreview() const
{
- myPreview = theShape;
+ return myPreview;
}
/**\class SketchPlugin_Feature
* \ingroup DataModel
- * \brief Feature for creation of the new part in PartSet.
+ * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
+ * an interface to create the sketch feature preview.
*/
class SketchPlugin_Feature: public ModelAPI_Feature
{
public:
- SKETCHPLUGIN_EXPORT virtual const std::shared_ptr<GeomAPI_Shape>& preview() = 0;
+ /// Returns the sketch preview
+ /// \return the built preview
+ SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview() = 0;
protected:
- void setPreview(const std::shared_ptr<GeomAPI_Shape>& theShape); ///< the preview shape
+ /// Set the shape to the internal preview field
+ /// \param theShape a preview shape
+ void setPreview(const boost::shared_ptr<GeomAPI_Shape>& theShape); ///< the preview shape
+ /// Return the shape from the internal preview field
+ /// \return theShape a preview shape
+ const boost::shared_ptr<GeomAPI_Shape>& getPreview() const;
private:
- std::shared_ptr<GeomAPI_Shape> myPreview; ///< the preview shape
+ boost::shared_ptr<GeomAPI_Shape> myPreview; ///< the preview shape
};
#endif
ModelAPI_PluginManager::get()->registerPlugin(this);
}
-shared_ptr<ModelAPI_Feature> SketchPlugin_Plugin::createFeature(string theFeatureID)
+boost::shared_ptr<ModelAPI_Feature> SketchPlugin_Plugin::createFeature(string theFeatureID)
{
if (theFeatureID == "Sketch") {
- return shared_ptr<ModelAPI_Feature>(new SketchPlugin_Sketch);
+ return boost::shared_ptr<ModelAPI_Feature>(new SketchPlugin_Sketch);
}
/*else if (theFeatureID == "Point") {
return shared_ptr<ModelAPI_Feature>(new SketchPlugin_Point);
}*/
// feature of such kind is not found
- return shared_ptr<ModelAPI_Feature>();
+ return boost::shared_ptr<ModelAPI_Feature>();
}
{
public:
/// Creates the feature object of this plugin by the feature string ID
- virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
+ virtual boost::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
public:
/// Is needed for python wrapping by swig
#include "SketchPlugin_Sketch.h"
#include <ModelAPI_Data.h>
#include <GeomAlgoAPI_FaceBuilder.h>
+#include <GeomAlgoAPI_CompoundBuilder.h>
using namespace std;
{
}
-const shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
+const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
{
- if (!SketchPlugin_Feature::preview())
- {
-
- shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
- shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(1, 0, 0));
- shared_ptr<GeomAPI_Shape> aFace =
- GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
- setPreview(aFace);
- }
- return SketchPlugin_Feature::preview();
+ std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
+
+ addPlane(1, 0, 0, aFaces); // YZ plane
+ addPlane(0, 1, 0, aFaces); // XZ plane
+ addPlane(0, 0, 1, aFaces); // XY plane
+ boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
+ setPreview(aCompound);
+
+ return getPreview();
+}
+
+void SketchPlugin_Sketch::addPlane(double theX, double theY, double theZ,
+ std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const
+{
+ boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
+ boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
+ boost::shared_ptr<GeomAPI_Shape> aFace =
+ GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
+ theShapes.push_back(aFace);
}
#include "SketchPlugin.h"
#include <SketchPlugin_Feature.h>
+#include <list>
+
/// part reference attribute
const std::string PART_ATTR_DOC_REF = "SketchDocument";
SKETCHPLUGIN_EXPORT virtual void initAttributes();
/// Returns the sketch preview
- SKETCHPLUGIN_EXPORT virtual const std::shared_ptr<GeomAPI_Shape>& preview();
+ SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
/// Use plugin manager for features creation
SketchPlugin_Sketch();
+protected:
+ /// Creates a plane and append it to the list
+ /// \param theX the X normal value
+ /// \param theY the Y normal value
+ /// \param theZ the Z normal value
+ /// \param theShapes the list of result shapes
+ void addPlane(double theX, double theY, double theZ,
+ std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;
+
};
#endif
XGUI_MainMenu.h
XGUI_MainWindow.h
XGUI_MenuGroupPanel.h
+ XGUI_Module.h
XGUI_Tools.h
XGUI_Workbench.h
XGUI_Workshop.h
XGUI_DocumentDataModel.h
XGUI_PartDataModel.h
XGUI_ObjectsBrowser.h
+ XGUI_OperationMgr.h
XGUI_DataTreeModel.h
XGUI_SelectionMgr.h
XGUI_SwitchWidget.h
XGUI_DocumentDataModel.cpp
XGUI_PartDataModel.cpp
XGUI_ObjectsBrowser.cpp
+ XGUI_OperationMgr.cpp
XGUI_SelectionMgr.cpp
XGUI_SwitchWidget.cpp
)
#)
SET(PROJECT_LIBRARIES
- Event
+ Events
Config
${QT_LIBRARIES}
${CAS_VIEWER}
ADD_DEFINITIONS( -DXGUI_EXPORTS ${CAS_DEFINITIONS} )
-INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Event
+INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events
${PROJECT_SOURCE_DIR}/src/Config
${PROJECT_SOURCE_DIR}/src/PyInterp
${PROJECT_SOURCE_DIR}/src/PyConsole
typedef QList<double> QDoubleList; //!< list of double values
//! Pointer on feature object
-typedef std::shared_ptr<ModelAPI_Feature> FeaturePtr;
+typedef boost::shared_ptr<ModelAPI_Feature> FeaturePtr;
typedef QList<FeaturePtr> QFeatureList; //!< List of features
namespace XGUI
class XGUI_EXPORT XGUI_FeaturesModel : public QAbstractItemModel
{
public:
- XGUI_FeaturesModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
+ XGUI_FeaturesModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
QAbstractItemModel(theParent), myDocument(theDocument) {}
//! Returns Feature object by the given Model index.
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;
+ virtual QModelIndex findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const = 0;
//! Returns index corresponded to the group
virtual QModelIndex findGroup(const std::string& theGroup) const = 0;
protected:
- std::shared_ptr<ModelAPI_Document> myDocument;
+ boost::shared_ptr<ModelAPI_Document> myDocument;
};
class XGUI_PartModel : public XGUI_FeaturesModel
{
public:
- XGUI_PartModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
+ XGUI_PartModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent):
XGUI_FeaturesModel(theDocument, theParent) {}
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;
+ virtual bool hasDocument(const boost::shared_ptr<ModelAPI_Document>& theDoc) const = 0;
protected:
//! Id of the current part object in the document
+// File: XGUI_Displayer.cpp
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#include "XGUI_Displayer.h"
-#include "XGUI_Tools.h"
#include "XGUI_Viewer.h"
#include <ModelAPI_Document.h>
#include <AIS_InteractiveContext.hxx>
+#include <AIS_ListOfInteractive.hxx>
+
#include <AIS_Shape.hxx>
-/*!
- \brief Constructor
- */
XGUI_Displayer::XGUI_Displayer(XGUI_Viewer* theViewer)
: myViewer(theViewer)
{
}
-/*!
- \brief Destructor
- */
XGUI_Displayer::~XGUI_Displayer()
{
}
-/*!
- * Display the feature
- * \param theFeature a feature instance
- */
-void XGUI_Displayer::Display(std::shared_ptr<ModelAPI_Feature> theFeature)
+void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
+ const bool isUpdateViewer)
{
}
-/*!
- * Display the feature and a shape. This shape would be associated to the given feature
- * \param theFeature a feature instance
- * \param theFeature a shape
- */
-void XGUI_Displayer::Display(std::shared_ptr<ModelAPI_Feature> theFeature,
- const TopoDS_Shape& theShape)
+void XGUI_Displayer::Display(boost::shared_ptr<ModelAPI_Feature> theFeature,
+ const TopoDS_Shape& theShape, const bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
aContext->Display(anAIS, Standard_False);
- aContext->UpdateCurrentViewer();
+ if (isUpdateViewer)
+ aContext->UpdateCurrentViewer();
}
+
+void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
+ const TopoDS_Shape& theShape, const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
+ aContext->EraseAll();
+ if (isUpdateViewer)
+ aContext->UpdateCurrentViewer();
+}
+
+void XGUI_Displayer::LocalSelection(boost::shared_ptr<ModelAPI_Feature> theFeature,
+ const TopoDS_Shape& theShape,
+ const int theMode, const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
+
+ Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
+ aContext->Display(anAIS, Standard_False);
+ AIS_ListOfInteractive anAISList;
+ anAISList.Append(anAIS);
+ myViewer->setLocalSelection(anAISList, theMode, true);
+}
+
+void XGUI_Displayer::GlobalSelection(const bool isUpdateViewer)
+{
+ myViewer->setGlobalSelection(true);
+}
+
+// File: XGUI_Displayer.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
#ifndef XGUI_Displayer_H
#define XGUI_Displayer_H
#include "XGUI.h"
#include <QString>
+#include <boost/shared_ptr.hpp>
#include <TopoDS_Shape.hxx>
/**\class XGUI_Displayer
* \ingroup GUI
- * \brief Displayer. Provides mechanizm of displa/erase of objects in viewer
+ * \brief Displayer. Provides mechanizm of display/erase of objects in the viewer
*/
class XGUI_EXPORT XGUI_Displayer
{
public:
+ /// Constructor
+ /// \param theViewer the viewer
XGUI_Displayer(XGUI_Viewer* theViewer);
+ /// Destructor
virtual ~XGUI_Displayer();
- void Display(std::shared_ptr<ModelAPI_Feature> theFeature);
+ /// Display the feature. Obtain the visualized object from the feature.
+ /// \param theFeature a feature instance
+ /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+ void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const bool isUpdateViewer = true);
+
+ /// Display the feature and a shape. This shape would be associated to the given feature
+ /// \param theFeature a feature instance
+ /// \param theShape a shape
+ /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+ void Display(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
+ const bool isUpdateViewer = true);
+
+ /// Display the shape and activate selection of sub-shapes
+ /// \param theFeature a feature instance
+ /// \param theShape a shape
+ /// \param theMode a local selection mode
+ /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+ void LocalSelection(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
+ const int theMode, const bool isUpdateViewer = true);
+
+ /// Erase the feature and a shape.
+ /// \param theFeature a feature instance
+ /// \param theFeature a shape
+ /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+ void Erase(boost::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape,
+ const bool isUpdateViewer = true);
- void Display(std::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape);
+ /// Deactivates selection of sub-shapes
+ /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
+ void GlobalSelection(const bool isUpdateViewer = true);
protected:
- XGUI_Viewer* myViewer; ///< the viewer
+ XGUI_Viewer* myViewer; ///< the viewer where the objects should be visualized
};
#endif
#include <ModelAPI_Data.h>
#include <Model_Events.h>
-#include <Event_Loop.h>
+#include <Events_Loop.h>
#include <QIcon>
: QAbstractItemModel(theParent)
{
// Find Document object
- std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
myDocument = aMgr->currentDocument();
// Register in event loop
- Event_Loop::loop()->registerListener(this, Event_Loop::eventByName(EVENT_FEATURE_CREATED));
- Event_Loop::loop()->registerListener(this, Event_Loop::eventByName(EVENT_FEATURE_UPDATED));
- Event_Loop::loop()->registerListener(this, Event_Loop::eventByName(EVENT_FEATURE_DELETED));
+ Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED));
+ Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED));
+ Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED));
// Create a top part of data tree model
myModel = new XGUI_TopDataModel(myDocument, this);
}
-void XGUI_DocumentDataModel::processEvent(const Event_Message* theMessage)
+void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
{
// Created object event *******************
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();
+ boost::shared_ptr<ModelAPI_Document> aDoc = aUpdMsg->document();
+ boost::shared_ptr<ModelAPI_Feature> aFeature = aUpdMsg->feature();
if (aDoc == myDocument) { // If root objects
if (aFeature->getGroup().compare(PARTS_GROUP) == 0) { // Updsate only Parts group
// Deteted object event ***********************
} else if (QString(theMessage->eventID().eventText()) == EVENT_FEATURE_DELETED) {
const ModelAPI_FeatureDeletedMessage* aUpdMsg = dynamic_cast<const ModelAPI_FeatureDeletedMessage*>(theMessage);
- std::shared_ptr<ModelAPI_Document> aDoc = aUpdMsg->document();
+ boost::shared_ptr<ModelAPI_Document> aDoc = aUpdMsg->document();
if (aDoc == myDocument) { // If root objects
if (aUpdMsg->group().compare(PARTS_GROUP) == 0) { // Updsate only Parts group
#include "XGUI_Constants.h"
#include <QAbstractItemModel>
-#include <Event_Listener.h>
+#include <Events_Listener.h>
#include <QList>
* \brief This is a proxy data model for Object Browser (QTreeView).
* It contains several sub-models for generation of each sub-part of data tree.
*/
-class XGUI_EXPORT XGUI_DocumentDataModel : public QAbstractItemModel, public Event_Listener
+class XGUI_EXPORT XGUI_DocumentDataModel : public QAbstractItemModel, public Events_Listener
{
Q_OBJECT
public:
virtual ~XGUI_DocumentDataModel();
// Event Listener method
- virtual void processEvent(const Event_Message* theMessage);
+ virtual void processEvent(const Events_Message* theMessage);
virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
bool hasSubModel(const QAbstractItemModel* theModel) const;
//! Document
- std::shared_ptr<ModelAPI_Document> myDocument;
+ boost::shared_ptr<ModelAPI_Document> myDocument;
//! Data model of top part of data tree (not parts object)
XGUI_TopDataModel* myModel;
\r
#define CREATE_MODULE "createModule"\r
\r
-#endif //XGUI_Module\r
\ No newline at end of file
+#endif //XGUI_Module\r
--- /dev/null
+// File: XGUI_OperationMgr.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
+#include "XGUI_OperationMgr.h"
+
+#include "ModuleBase_Operation.h"
+
+#include <QMessageBox>
+
+XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent)
+: QObject(theParent)
+{
+}
+
+XGUI_OperationMgr::~XGUI_OperationMgr()
+{
+}
+
+ModuleBase_Operation* XGUI_OperationMgr::currentOperation() const
+{
+ return myOperations.count() > 0 ? myOperations.last() : 0;
+}
+
+bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
+{
+ if (!canStartOperation(theOperation))
+ return false;
+
+ myOperations.append(theOperation);
+
+ connect(theOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped()));
+ connect(theOperation, SIGNAL(started()), this, SIGNAL(operationStarted()));
+
+ theOperation->start();
+ return true;
+}
+
+bool XGUI_OperationMgr::canStartOperation(ModuleBase_Operation* theOperation)
+{
+ bool aCanStart = true;
+ ModuleBase_Operation* aCurrentOp = currentOperation();
+ if (aCurrentOp && !theOperation->isGranted())
+ {
+ int anAnswer = QMessageBox::question(0, tr("Operation launch"),
+ tr("Previous operation is not finished and will be aborted"),
+ QMessageBox::Ok, QMessageBox::Cancel);
+ if (anAnswer == QMessageBox::Ok)
+ aCurrentOp->abort();
+ else
+ aCanStart = false;
+ }
+ return aCanStart;
+}
+
+void XGUI_OperationMgr::onOperationStopped()
+{
+ ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
+ ModuleBase_Operation* anOperation = currentOperation();
+ if (!aSenderOperation || !anOperation || aSenderOperation != anOperation )
+ return;
+
+ emit operationStopped(anOperation);
+
+ myOperations.removeAll(anOperation);
+ anOperation->deleteLater();
+
+ // get last operation which can be resumed
+ ModuleBase_Operation* aResultOp = 0;
+ QListIterator<ModuleBase_Operation*> anIt(myOperations);
+ anIt.toBack();
+ while(anIt.hasPrevious())
+ {
+ ModuleBase_Operation* anOp = anIt.previous();
+ if (anOp) {
+ aResultOp = anOp;
+ break;
+ }
+ }
+ if (aResultOp)
+ startOperation(aResultOp);
+}
--- /dev/null
+// File: XGUI_OperationMgr.h
+// Created: 20 Apr 2014
+// Author: Natalia ERMOLAEVA
+
+#ifndef XGUI_OperationMgr_H
+#define XGUI_OperationMgr_H
+
+#include "XGUI.h"
+
+#include <ModuleBase_Operation.h>
+
+#include <QList>
+#include <QObject>
+
+/**\class XGUI_OperationMgr
+ * \ingroup GUI
+ * \brief Operation manager. Servers to manupulate to the workshop operations. Contains a stack
+ * of started operations. In simple case, if only one operration is started, the stack contains
+ * one operation. It is possible for some kind of operations to start them above already
+ * started one. In that case, the previous active operation becames suspended, a new one - active.
+ * The new operation is added to the top of the stack. Then it is finished, it is removed from
+ * the stack and the previous operation is activated.
+ */
+class XGUI_EXPORT XGUI_OperationMgr : public QObject
+{
+ Q_OBJECT
+public:
+ /// Constructor
+ /// \param theParent the parent
+ XGUI_OperationMgr(QObject* theParent);
+ /// Destructor
+ virtual ~XGUI_OperationMgr();
+
+ /// Returns the current operation or NULL
+ /// \return the current operation
+ ModuleBase_Operation* currentOperation() const;
+ /// Sets the current operation or NULL
+ /// \return the current operation
+ bool startOperation(ModuleBase_Operation* theOperation);
+
+signals:
+ /// Signal about an operation is started. It is emitted after the start() of operation is done.
+ void operationStarted();
+ /// Signal about an operation is stopped. It is emitted after the stop() of operation is done.
+ /// \param theOperation a stopped operation
+ void operationStopped(ModuleBase_Operation* theOperation);
+
+protected:
+ /// Returns whether the operation can be started. Check if there is already started operation and
+ /// the granted parameter of the launched operation
+ /// \param theOperation an operation to check
+ bool canStartOperation(ModuleBase_Operation* theOperation);
+
+protected slots:
+ /// Slot that is called by an operation stop. Removes the stopped operation form the stack.
+ /// If there is a suspended operation, restart it.
+ void onOperationStopped();
+
+private:
+ typedef QList<ModuleBase_Operation*> Operations; ///< definition for a list of operations
+ Operations myOperations; ///< a stack of started operations. The active operation is on top,
+ // others are suspended and started by the active is finished
+};
+
+#endif
#include <QIcon>
-XGUI_TopDataModel::XGUI_TopDataModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent)
+XGUI_TopDataModel::XGUI_TopDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent)
: XGUI_FeaturesModel(theDocument, theParent)
{
}
return tr("Parameters");
case ParamObject:
{
- std::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARAMETERS_GROUP, theIndex.row());
+ boost::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARAMETERS_GROUP, theIndex.row());
if (aFeature)
return aFeature->data()->getName().c_str();
}
return tr("Constructions");
case ConstructObject:
{
- std::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ boost::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row());
if (aFeature)
return aFeature->data()->getName().c_str();
}
}
-QModelIndex XGUI_TopDataModel::findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const
+QModelIndex XGUI_TopDataModel::findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const
{
QString aGroup(theFeature->getGroup().c_str());
//******************************************************************
//******************************************************************
//******************************************************************
-XGUI_PartDataModel::XGUI_PartDataModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent)
+XGUI_PartDataModel::XGUI_PartDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent)
: XGUI_PartModel(theDocument, theParent)
{
}
switch (theIndex.internalId()) {
case MyRoot:
{
- std::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARTS_GROUP, myId);
+ boost::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARTS_GROUP, myId);
if (aFeature)
return aFeature->data()->getName().c_str();
}
return tr("Constructions");
case ParamObject:
{
- std::shared_ptr<ModelAPI_Feature> aFeature =
+ boost::shared_ptr<ModelAPI_Feature> aFeature =
featureDocument()->feature(PARAMETERS_GROUP, theIndex.row());
if (aFeature)
return aFeature->data()->getName().c_str();
}
case ConstructObject:
{
- std::shared_ptr<ModelAPI_Feature> aFeature =
+ boost::shared_ptr<ModelAPI_Feature> aFeature =
featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
if (aFeature)
return aFeature->data()->getName().c_str();
}
-std::shared_ptr<ModelAPI_Document> XGUI_PartDataModel::featureDocument() const
+boost::shared_ptr<ModelAPI_Document> XGUI_PartDataModel::featureDocument() const
{
- std::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARTS_GROUP, myId);
+ boost::shared_ptr<ModelAPI_Feature> aFeature = myDocument->feature(PARTS_GROUP, myId);
return aFeature->data()->docRef("PartDocument")->value();
}
return FeaturePtr();
}
-bool XGUI_PartDataModel::hasDocument(const std::shared_ptr<ModelAPI_Document>& theDoc) const
+bool XGUI_PartDataModel::hasDocument(const boost::shared_ptr<ModelAPI_Document>& theDoc) const
{
return (featureDocument() == theDoc);
}
-QModelIndex XGUI_PartDataModel::findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const
+QModelIndex XGUI_PartDataModel::findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const
{
QString aGroup(theFeature->getGroup().c_str());
{
Q_OBJECT
public:
- XGUI_TopDataModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
+ XGUI_TopDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
virtual ~XGUI_TopDataModel();
- // Reimplementation from QAbstractItemModel
+ // Reimpl from QAbstractItemModel
virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
virtual QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
virtual FeaturePtr feature(const QModelIndex& theIndex) const;
//! Returns parent index of the given feature
- virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
+ virtual QModelIndex findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const;
//! Returns index corresponded to the group
virtual QModelIndex findGroup(const std::string& theGroup) const;
{
Q_OBJECT
public:
- XGUI_PartDataModel(const std::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
+ XGUI_PartDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
virtual ~XGUI_PartDataModel();
- // Reimplementation from QAbstractItemModel
+ // Reimpl from QAbstractItemModel
virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
virtual QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
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;
+ virtual bool hasDocument(const boost::shared_ptr<ModelAPI_Document>& theDoc) const;
//! Returns parent index of the given feature
- virtual QModelIndex findParent(const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
+ virtual QModelIndex findParent(const boost::shared_ptr<ModelAPI_Feature>& theFeature) const;
//! Returns index corresponded to the group
virtual QModelIndex findGroup(const std::string& theGroup) const;
private:
- std::shared_ptr<ModelAPI_Document> featureDocument() const;
+ boost::shared_ptr<ModelAPI_Document> featureDocument() const;
//! Types of QModelIndexes
enum DataIds {
if (mySelectedData.size() > 0) {
FeaturePtr aFeature = mySelectedData.first();
- std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
+ boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
if (aDocRef)
aMgr->setCurrentDocument(aDocRef->value());
}
#include <V3d_View.hxx>
#include <Visual3d_View.hxx>
#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_Shape.hxx>
#include <QMouseEvent>
return aWnd;
}
+void XGUI_Viewer::setLocalSelection(const AIS_ListOfInteractive& theAISObjects, const int theMode,
+ const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) ic = AISContext();
+
+ // Open local context if there is no one
+ bool allObjects = false; // calculate by AIS shape
+ if (!ic->HasOpenedContext()) {
+ ic->ClearCurrents(false);
+ ic->OpenLocalContext(allObjects, true, true);
+ }
+
+ // Activate selection of objects from prs
+ AIS_ListIteratorOfListOfInteractive aIter(theAISObjects);
+ for (; aIter.More(); aIter.Next()) {
+ Handle(AIS_InteractiveObject) anAIS = aIter.Value();
+ if (!anAIS.IsNull()) {
+ if (anAIS->IsKind(STANDARD_TYPE(AIS_Shape))) {
+ ic->Load(anAIS, -1, false);
+ ic->Activate(anAIS, AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theMode));
+ }
+ else if (anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron)) {
+ ic->Load(anAIS, -1, false);
+ ic->Activate(anAIS, theMode);
+ }
+ }
+ }
+ if (isUpdateViewer)
+ ic->UpdateCurrentViewer();
+}
+
+void XGUI_Viewer::setGlobalSelection(const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) ic = AISContext();
+ if (!ic.IsNull()) {
+ ic->CloseAllContexts(false);
+ if (isUpdateViewer)
+ ic->UpdateCurrentViewer();
+ }
+}
+
/*! Sets hot button
*\param theOper - hot operation
*\param theState - adding state to state map operations.
class QMouseEvent;
class QKeyEvent;
+class AIS_ListOfInteractive;
+
/**\class XGUI_Viewer
* \ingroup GUI
* \brief Represents a 3d viewer. The viewer manages 3d scene and a set of view windows
return myAISContext;
}
+ //! Activate local selection
+ //! \param theAIS the list of objects
+ //! \param theMode the selection mode
+ //! \param isUpdateViewer the state wether the viewer should be updated immediatelly
+ void setLocalSelection(const AIS_ListOfInteractive& theAISObjects, const int theMode,
+ const bool isUpdateViewer);
+ //! Deactivate local selection
+ //! \param isUpdateViewer the state wether the viewer should be updated immediatelly
+ void setGlobalSelection(const bool isUpdateViewer);
+
//! Trihedron 3d object shown in the viewer
Handle(AIS_Trihedron) trihedron() const
{
#include "XGUI_SelectionMgr.h"
#include "XGUI_ObjectsBrowser.h"
#include "XGUI_Displayer.h"
+#include "XGUI_OperationMgr.h"
#include <ModelAPI_PluginManager.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDocRef.h>
-#include <Event_Loop.h>
+#include <Events_Loop.h>
#include <ModuleBase_PropPanelOperation.h>
#include <ModuleBase_Operation.h>
#include <Config_FeatureMessage.h>
XGUI_Workshop::XGUI_Workshop()
: QObject(),
- myCurrentOperation(NULL),
myPartSetModule(NULL)
{
myMainWindow = new XGUI_MainWindow();
mySelector = new XGUI_SelectionMgr(this);
myDisplayer = new XGUI_Displayer(myMainWindow->viewer());
+ myOperationMgr = new XGUI_OperationMgr(this);
+ connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
+ connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
+ this, SLOT(onOperationStopped(ModuleBase_Operation*)));
}
//******************************************************
{
initMenu();
//Initialize event listening
- Event_Loop* aLoop = Event_Loop::loop();
+ Events_Loop* aLoop = Events_Loop::loop();
//TODO(sbh): Implement static method to extract event id [SEID]
- Event_ID aFeatureId = aLoop->eventByName("FeatureEvent");
+ Events_ID aFeatureId = aLoop->eventByName("FeatureEvent");
aLoop->registerListener(this, aFeatureId);
- Event_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
+ Events_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
aLoop->registerListener(this, aPartSetId);
activateModule();
myMainWindow->show();
updateCommandStatus();
onNew();
// Testing of document creation
- //std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- //std::shared_ptr<ModelAPI_Feature> aPoint1 = aMgr->rootDocument()->addFeature("Point");
- //std::shared_ptr<ModelAPI_Feature> aPart = aMgr->rootDocument()->addFeature("Part");
+ //boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ //boost::shared_ptr<ModelAPI_Feature> aPoint1 = aMgr->rootDocument()->addFeature("Point");
+ //boost::shared_ptr<ModelAPI_Feature> aPart = aMgr->rootDocument()->addFeature("Part");
//aPart->execute();
//aMgr->setCurrentDocument(aPart->data()->docRef("PartDocument")->value());
- //std::shared_ptr<ModelAPI_Feature> aPoint2 = aMgr->rootDocument()->addFeature("Point");
+ //boost::shared_ptr<ModelAPI_Feature> aPoint2 = aMgr->rootDocument()->addFeature("Point");
//aPoint2 = aMgr->rootDocument()->addFeature("Point");
//aPart = aMgr->rootDocument()->addFeature("Part");
}
//******************************************************
-void XGUI_Workshop::processEvent(const Event_Message* theMessage)
+void XGUI_Workshop::processEvent(const Events_Message* theMessage)
{
- static Event_ID aFeatureId = Event_Loop::loop()->eventByName("FeatureEvent");
+ static Events_ID aFeatureId = Events_Loop::loop()->eventByName("FeatureEvent");
if (theMessage->eventID() == aFeatureId) {
const Config_FeatureMessage* aFeatureMsg =
dynamic_cast<const Config_FeatureMessage*>(theMessage);
const Config_PointerMessage* aPartSetMsg =
dynamic_cast<const Config_PointerMessage*>(theMessage);
if (aPartSetMsg) {
- ModuleBase_PropPanelOperation* aOperation =
+ ModuleBase_PropPanelOperation* anOperation =
(ModuleBase_PropPanelOperation*)(aPartSetMsg->pointer());
- setCurrentOperation(aOperation);
- if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
- myCurrentOperation->start();
- myCurrentOperation->commit();
- updateCommandStatus();
- } else {
- fillPropertyPanel(aOperation);
+
+ if (myOperationMgr->startOperation(anOperation)) {
+ if (anOperation->isPerformedImmediately()) {
+ anOperation->commit();
+ updateCommandStatus();
+ }
}
return;
}
}
+//******************************************************
+void XGUI_Workshop::onOperationStarted()
+{
+ ModuleBase_PropPanelOperation* aOperation =
+ (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation());
+
+ if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
+ } else {
+ connectWithOperation(aOperation);
+ QWidget* aPropWidget = myMainWindow->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
+ qDeleteAll(aPropWidget->children());
+
+ myMainWindow->showPropertyPanel();
+
+ XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(aOperation);
+ aFactory.createWidget(aPropWidget);
+ myMainWindow->setPropertyPannelTitle(aOperation->description());
+ }
+}
+
+//******************************************************
+void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
+{
+ myMainWindow->hidePropertyPanel();
+ updateCommandStatus();
+
+ XGUI_MainMenu* aMenu = myMainWindow->menuObject();
+ aMenu->restoreCommandState();
+}
+
/*
*
*/
myPartSetModule->featureCreated(aCommand);
}
-/*
- *
- */
-void XGUI_Workshop::fillPropertyPanel(ModuleBase_PropPanelOperation* theOperation)
-{
- connectWithOperation(theOperation);
- QWidget* aPropWidget = myMainWindow->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
- qDeleteAll(aPropWidget->children());
- theOperation->start();
- XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(theOperation);
- aFactory.createWidget(aPropWidget);
- myMainWindow->setPropertyPannelTitle(theOperation->description());
-}
-
-void XGUI_Workshop::setCurrentOperation(ModuleBase_Operation* theOperation)
-{
- //FIXME: Ask user about aborting of current operation?
- if (myCurrentOperation) {
- //TODO get isOperation from document
- if (myCurrentOperation->isRunning())
- myCurrentOperation->abort();
-
- myCurrentOperation->deleteLater();
- }
- myCurrentOperation = theOperation;
-}
-
/*
* Makes a signal/slot connections between Property Panel
* and given operation. The given operation becomes a
QPushButton* aCancelBtn = aPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
- connect(theOperation, SIGNAL(started()), myMainWindow, SLOT(showPropertyPanel()));
- connect(theOperation, SIGNAL(stopped()), myMainWindow, SLOT(hidePropertyPanel()));
- connect(theOperation, SIGNAL(stopped()), this, SLOT(updateCommandStatus()));
-
XGUI_MainMenu* aMenu = myMainWindow->menuObject();
- connect(theOperation, SIGNAL(stopped()), aMenu, SLOT(restoreCommandState()));
-
XGUI_Command* aCommand = aMenu->feature(theOperation->operationId());
//Abort operation on uncheck the command
connect(aCommand, SIGNAL(toggled(bool)), theOperation, SLOT(setRunning(bool)));
void XGUI_Workshop::onUndo()
{
myMainWindow->objectBrowser()->setCurrentIndex(QModelIndex());
- std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
aDoc->undo();
updateCommandStatus();
}
void XGUI_Workshop::onRedo()
{
myMainWindow->objectBrowser()->setCurrentIndex(QModelIndex());
- std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
aDoc->redo();
updateCommandStatus();
}
QList<XGUI_Command*> aCommands = aMenuBar->features();
QList<XGUI_Command*>::const_iterator aIt;
- std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
if (aMgr->hasRootDocument()) {
XGUI_Command* aUndoCmd;
XGUI_Command* aRedoCmd;
else // Enable all commands
(*aIt)->enable();
}
- std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
+ boost::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
aUndoCmd->setEnabled(aDoc->canUndo());
aRedoCmd->setEnabled(aDoc->canRedo());
} else {
#define XGUI_WORKSHOP_H
#include "XGUI.h"
-#include <Event_Listener.h>
+#include <Events_Listener.h>
#include <QObject>
#include <QMap>
class XGUI_Workbench;
class XGUI_SelectionMgr;
class XGUI_Displayer;
+class XGUI_OperationMgr;
class ModuleBase_Operation;
class ModuleBase_PropPanelOperation;
* \ingroup GUI
* \brief Class which defines a configuration of the application (Workshop) and launches it.
*/
-class XGUI_EXPORT XGUI_Workshop: public QObject, public Event_Listener
+class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener
{
Q_OBJECT
public:
//! Returns displayer
XGUI_Displayer* displayer() const { return myDisplayer; }
+ //! ! Returns operation manager.
+ XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
+
//! Creates and adds a new workbench (menu group) with the given name and returns it
XGUI_Workbench* addWorkbench(const QString& theName);
- //! Returns the current operation or NULL
- ModuleBase_Operation* currentOperation() { return myCurrentOperation; }
-
- //! Redefinition of Event_Listener method
- virtual void processEvent(const Event_Message* theMessage);
+ //! Redefinition of Events_Listener method
+ virtual void processEvent(const Events_Message* theMessage);
public slots:
void updateCommandStatus();
protected:
//Event-loop processing methods:
void addFeature(const Config_FeatureMessage*);
- void fillPropertyPanel(ModuleBase_PropPanelOperation* theOperation);
void connectWithOperation(ModuleBase_Operation* theOperation);
- void setCurrentOperation(ModuleBase_Operation* theOperation);
+
+protected slots:
+ /// SLOT, that is called after the operation is started. Update workshop state according to
+ /// the started operation, e.g. visualizes the property panel and connect to it.
+ void onOperationStarted();
+ /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
+ /// hides the property panel and udpate the command status.
+ /// \param theOpertion a stopped operation
+ void onOperationStopped(ModuleBase_Operation* theOperation);
private:
void initMenu();
XGUI_SelectionMgr* mySelector;
XGUI_Displayer* myDisplayer;
- ModuleBase_Operation* myCurrentOperation;
+ XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
};
#endif