From: sbh Date: Thu, 21 Aug 2014 11:55:17 +0000 (+0400) Subject: Sources formated according to the codeing standards X-Git-Tag: V_0.4.4~98 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cd9217d7e87997ec8bc150a6d8c389e742ca0f84;p=modules%2Fshaper.git Sources formated according to the codeing standards --- diff --git a/src/Config/Config_Common.cpp b/src/Config/Config_Common.cpp index 84e6328a2..a6a9ee512 100644 --- a/src/Config/Config_Common.cpp +++ b/src/Config/Config_Common.cpp @@ -1,98 +1,96 @@ -/* - * Config_Common.cpp - * - * Created on: Apr 17, 2014 - * Author: sbh - */ - -#include "Config_Common.h" -#include - -#include -#include - -#include //for stringstream - -bool isElementNode(xmlNodePtr theNode) -{ - return theNode->type == XML_ELEMENT_NODE; -} - -bool isNode(xmlNodePtr theNode, const char* theNodeName, ...) -{ - bool result = false; - const xmlChar* aName = theNode->name; - if (!aName || !isElementNode(theNode)) { - return false; - } - if (!xmlStrcmp(aName, (const xmlChar *) theNodeName)) { - return true; - } - va_list args; // define argument list variable - va_start(args, theNodeName); // init list; point to last defined argument - while(true) { - char *anArg = va_arg (args, char*); // get next argument - if (anArg == NULL) - break; - if (!xmlStrcmp(aName, (const xmlChar *) anArg)) { - va_end(args); // cleanup the system stack - return true; - } - } - va_end(args); // cleanup the system stack - return false; -} - -bool hasChild(xmlNodePtr theNode) -{ - xmlNodePtr aNode = theNode->children; - for( ; aNode; aNode = aNode->next) { - if (isElementNode(theNode)) { - return true; - } - } - return false; -} - -bool getValidatorInfo(xmlNodePtr theNode, - std::string& outValidatorId, - std::list& outValidatorParameters) -{ - //Validator id: - char* anIdProp = (char*) xmlGetProp(theNode, BAD_CAST _ID); - if (!anIdProp || anIdProp[0] == 0) { - return false; - } - outValidatorId = std::string(anIdProp); - - //Validator parameters: - char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST VALIDATOR_PARAMETERS); - if (aParamProp && aParamProp[0] != 0) { - std::string aPropString = std::string(aParamProp); - std::stringstream aPropStringStream(aPropString); - char COMMA_DELIM = ','; - std::string aValidatorParameter; - while (std::getline(aPropStringStream, aValidatorParameter, ',')) { - outValidatorParameters.push_back(aValidatorParameter); - } - } - return true; -} - -std::string library(const std::string& theLibName) -{ - std::string aLibName = theLibName; -#ifndef WIN32 - static std::string aLibExt( ".so" ); - if (aLibName.size() < 3 || aLibName.substr(0, 3) !="lib") { - aLibName = "lib" + aLibName; - } -#else - static std::string aLibExt(".dll"); -#endif - std::string anExt = aLibName.substr(aLibName.size() - 4); - if (anExt != aLibExt) - aLibName += aLibExt; - - return aLibName; -} +/* + * Config_Common.cpp + * + * Created on: Apr 17, 2014 + * Author: sbh + */ + +#include "Config_Common.h" +#include + +#include +#include + +#include //for stringstream +bool isElementNode(xmlNodePtr theNode) +{ + return theNode->type == XML_ELEMENT_NODE; +} + +bool isNode(xmlNodePtr theNode, const char* theNodeName, ...) +{ + bool result = false; + const xmlChar* aName = theNode->name; + if (!aName || !isElementNode(theNode)) { + return false; + } + if (!xmlStrcmp(aName, (const xmlChar *) theNodeName)) { + return true; + } + va_list args; // define argument list variable + va_start(args, theNodeName); // init list; point to last defined argument + while (true) { + char *anArg = va_arg (args, char*); // get next argument + if (anArg == NULL) + break; + if (!xmlStrcmp(aName, (const xmlChar *) anArg)) { + va_end(args); // cleanup the system stack + return true; + } + } + va_end(args); // cleanup the system stack + return false; +} + +bool hasChild(xmlNodePtr theNode) +{ + xmlNodePtr aNode = theNode->children; + for (; aNode; aNode = aNode->next) { + if (isElementNode(theNode)) { + return true; + } + } + return false; +} + +bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId, + std::list& outValidatorParameters) +{ + //Validator id: + char* anIdProp = (char*) xmlGetProp(theNode, BAD_CAST _ID); + if (!anIdProp || anIdProp[0] == 0) { + return false; + } + outValidatorId = std::string(anIdProp); + + //Validator parameters: + char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST VALIDATOR_PARAMETERS); + if (aParamProp && aParamProp[0] != 0) { + std::string aPropString = std::string(aParamProp); + std::stringstream aPropStringStream(aPropString); + char COMMA_DELIM = ','; + std::string aValidatorParameter; + while (std::getline(aPropStringStream, aValidatorParameter, ',')) { + outValidatorParameters.push_back(aValidatorParameter); + } + } + return true; +} + +std::string library(const std::string& theLibName) +{ + std::string aLibName = theLibName; +#ifndef WIN32 + static std::string aLibExt( ".so" ); + if (aLibName.size() < 3 || aLibName.substr(0, 3) !="lib") { + aLibName = "lib" + aLibName; + } +#else + static std::string aLibExt(".dll"); +#endif + std::string anExt = aLibName.substr(aLibName.size() - 4); + if (anExt != aLibExt) + aLibName += aLibExt; + + return aLibName; +} diff --git a/src/Config/Config_Common.h b/src/Config/Config_Common.h index 4a204f59b..a8459c107 100644 --- a/src/Config/Config_Common.h +++ b/src/Config/Config_Common.h @@ -53,8 +53,7 @@ CONFIG_EXPORT bool hasChild(xmlNodePtr theNode); /* * */ -CONFIG_EXPORT bool getValidatorInfo(xmlNodePtr theNode, - std::string& outValidatorId, +CONFIG_EXPORT bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId, std::list& outValidatorParameters); /*! diff --git a/src/Config/Config_FeatureMessage.h b/src/Config/Config_FeatureMessage.h index 752169fb4..4c32b0b86 100644 --- a/src/Config/Config_FeatureMessage.h +++ b/src/Config/Config_FeatureMessage.h @@ -14,52 +14,38 @@ static const char * EVENT_FEATURE_LOADED = "FeatureLoaded"; * Example of the feature entry: * */ -class Config_FeatureMessage: public Events_Message +class Config_FeatureMessage : public Events_Message { std::string myId; //Feature unique id - std::string myText; //Represents action's text + std::string myText; //Represents action's text std::string myTooltip; //Represents action's tooltip - std::string myIcon; //Represents action's icon + std::string myIcon; //Represents action's icon std::string myKeysequence; //Represents action's key sequence std::string myGroupId; //Id of feature's group std::string myWorkbenchId; //Id of feature's workbench std::string myPluginLibrary; //Name of feature's library - bool myUseInput; //Action is being checked until user commit the operation - bool myInternal; //Internal feature without GUI representation + bool myUseInput; //Action is being checked until user commit the operation + bool myInternal; //Internal feature without GUI representation std::string myNestedFeatures; -public: + public: //const Events_ID theID, const void* theSender = 0 - CONFIG_EXPORT Config_FeatureMessage(const Events_ID theId, const void* theParent = 0); - CONFIG_EXPORT virtual ~Config_FeatureMessage(); + CONFIG_EXPORT Config_FeatureMessage(const Events_ID theId, const void* theParent = 0);CONFIG_EXPORT virtual ~Config_FeatureMessage(); //Auto-generated getters/setters - CONFIG_EXPORT const std::string& icon() const; - CONFIG_EXPORT const std::string& id() const; - CONFIG_EXPORT const std::string& keysequence() const; - CONFIG_EXPORT const std::string& text() const; - CONFIG_EXPORT const std::string& tooltip() const; + CONFIG_EXPORT const std::string& icon() const;CONFIG_EXPORT const std::string& id() const;CONFIG_EXPORT const std::string& keysequence() const;CONFIG_EXPORT const std::string& text() const;CONFIG_EXPORT const std::string& tooltip() const; - CONFIG_EXPORT const std::string& groupId() const; - CONFIG_EXPORT const std::string& workbenchId() const; - CONFIG_EXPORT const std::string& pluginLibrary() const; - CONFIG_EXPORT const std::string& nestedFeatures() const; - CONFIG_EXPORT bool isUseInput() const; - CONFIG_EXPORT bool isInternal() const; + CONFIG_EXPORT const std::string& groupId() const;CONFIG_EXPORT const std::string& workbenchId() const;CONFIG_EXPORT const std::string& pluginLibrary() const;CONFIG_EXPORT const std::string& nestedFeatures() const;CONFIG_EXPORT bool isUseInput() const;CONFIG_EXPORT bool isInternal() const; - CONFIG_EXPORT void setIcon(const std::string& icon); - CONFIG_EXPORT void setId(const std::string& id); - CONFIG_EXPORT void setKeysequence(const std::string& keysequence); - CONFIG_EXPORT void setText(const std::string& text); - CONFIG_EXPORT void setTooltip(const std::string& tooltip); - CONFIG_EXPORT void setGroupId(const std::string& groupId); - CONFIG_EXPORT void setWorkbenchId(const std::string& workbenchId); - CONFIG_EXPORT void setPluginLibrary(const std::string& thePluginLibrary); - CONFIG_EXPORT void setNestedFeatures(const std::string& theNestedFeatures); - CONFIG_EXPORT void setUseInput(bool isUseInput); - CONFIG_EXPORT void setInternal(bool isInternal); + CONFIG_EXPORT void setIcon(const std::string& icon);CONFIG_EXPORT void setId( + const std::string& id);CONFIG_EXPORT void setKeysequence(const std::string& keysequence);CONFIG_EXPORT void setText( + const std::string& text);CONFIG_EXPORT void setTooltip(const std::string& tooltip);CONFIG_EXPORT void setGroupId( + const std::string& groupId);CONFIG_EXPORT void setWorkbenchId(const std::string& workbenchId);CONFIG_EXPORT void setPluginLibrary( + const std::string& thePluginLibrary);CONFIG_EXPORT void setNestedFeatures( + const std::string& theNestedFeatures);CONFIG_EXPORT void setUseInput(bool isUseInput);CONFIG_EXPORT void setInternal( + bool isInternal); }; -#endif // CONFIG_MESSAGE_H +#endif // CONFIG_MESSAGE_H \ No newline at end of file diff --git a/src/Config/Config_FeatureReader.cpp b/src/Config/Config_FeatureReader.cpp index bdd6e0801..69d7176e4 100644 --- a/src/Config/Config_FeatureReader.cpp +++ b/src/Config/Config_FeatureReader.cpp @@ -24,7 +24,6 @@ #include #endif - Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile, const std::string& theLibraryName, const char* theEventGenerated) @@ -54,12 +53,12 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode) //If a feature has xml definition for it's widget: aMessage.setUseInput(hasChild(theNode)); aEvLoop->send(aMessage); - //The m_last* variables always defined before fillFeature() call. XML is a tree. + //The m_last* variables always defined before fillFeature() call. XML is a tree. } else if (isNode(theNode, NODE_GROUP, NULL)) { myLastGroup = getProperty(theNode, _ID); } else if (isNode(theNode, NODE_WORKBENCH, NULL)) { myLastWorkbench = getProperty(theNode, _ID); - //Process SOURCE, VALIDATOR nodes. + //Process SOURCE, VALIDATOR nodes. } Config_XMLReader::processNode(theNode); } @@ -69,8 +68,7 @@ bool Config_FeatureReader::processChildren(xmlNodePtr theNode) return isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NODE_FEATURE, NULL); } -void Config_FeatureReader::fillFeature(xmlNodePtr theNode, - Config_FeatureMessage& outFeatureMessage) +void Config_FeatureReader::fillFeature(xmlNodePtr theNode, Config_FeatureMessage& outFeatureMessage) { outFeatureMessage.setId(getProperty(theNode, _ID)); outFeatureMessage.setPluginLibrary(myLibraryName); @@ -78,7 +76,7 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theNode, bool isInternal = isInternalFeature(theNode); outFeatureMessage.setInternal(isInternal); - if(isInternal) { + if (isInternal) { //Internal feature has no visual representation. return; } @@ -94,7 +92,7 @@ bool Config_FeatureReader::isInternalFeature(xmlNodePtr theNode) { std::string prop = getProperty(theNode, FEATURE_INTERNAL); std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower); - if(prop.empty() || prop == "false" || prop == "0") { + if (prop.empty() || prop == "false" || prop == "0") { return false; } return true; diff --git a/src/Config/Config_FeatureReader.h b/src/Config/Config_FeatureReader.h index 468cb9911..f7547785c 100644 --- a/src/Config/Config_FeatureReader.h +++ b/src/Config/Config_FeatureReader.h @@ -16,24 +16,23 @@ class Config_FeatureMessage; -class Config_FeatureReader: public Config_XMLReader +class Config_FeatureReader : public Config_XMLReader { -public: - Config_FeatureReader(const std::string& theXmlFile, - const std::string& theLibraryName, + public: + Config_FeatureReader(const std::string& theXmlFile, const std::string& theLibraryName, const char* theEventGenerated = 0); virtual ~Config_FeatureReader(); std::list features() const; -protected: + protected: void processNode(xmlNodePtr aNode); bool processChildren(xmlNodePtr aNode); void fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFeatureMessage); bool isInternalFeature(xmlNodePtr theRoot); -private: + private: std::string myLastWorkbench; std::string myLastGroup; std::string myLibraryName; diff --git a/src/Config/Config_Keywords.h b/src/Config/Config_Keywords.h index f8f4f222f..434857827 100644 --- a/src/Config/Config_Keywords.h +++ b/src/Config/Config_Keywords.h @@ -66,7 +66,6 @@ const static char* DOUBLE_WDG_DFLT = "default"; //toolbox/switch properties const static char* CONTAINER_PAGE_NAME = "title"; - /* * Hardcoded xml entities of plugins.xml */ diff --git a/src/Config/Config_ModuleReader.cpp b/src/Config/Config_ModuleReader.cpp index ab9a42f35..f2fcda4b7 100644 --- a/src/Config/Config_ModuleReader.cpp +++ b/src/Config/Config_ModuleReader.cpp @@ -24,7 +24,8 @@ #endif Config_ModuleReader::Config_ModuleReader(const char* theEventGenerated) - : Config_XMLReader("plugins.xml"), myEventGenerated(theEventGenerated) + : Config_XMLReader("plugins.xml"), + myEventGenerated(theEventGenerated) { } @@ -57,7 +58,7 @@ void Config_ModuleReader::processNode(xmlNodePtr theNode) std::string aPluginLibrary = getProperty(theNode, PLUGIN_LIBRARY); std::list aFeatures = importPlugin(aPluginLibrary, aPluginConf); std::list::iterator it = aFeatures.begin(); - for(; it != aFeatures.end(); it++) { + for (; it != aFeatures.end(); it++) { myFeaturesInFiles[*it] = aPluginConf; } } @@ -71,7 +72,7 @@ bool Config_ModuleReader::processChildren(xmlNodePtr theNode) std::list Config_ModuleReader::importPlugin(const std::string& thePluginLibrary, const std::string& thePluginFile) { - if (thePluginFile.empty()) { //probably a third party library + if (thePluginFile.empty()) { //probably a third party library loadLibrary(thePluginLibrary); return std::list(); } @@ -90,14 +91,14 @@ void Config_ModuleReader::loadLibrary(const std::string theLibName) #ifdef WIN32 HINSTANCE aModLib = ::LoadLibrary(aFileName.c_str()); - if (!aModLib && theLibName != "DFBrowser") { // don't shor error for internal debugging tool + if (!aModLib && theLibName != "DFBrowser") { // don't shor error for internal debugging tool std::string errorMsg = "Failed to load " + aFileName; std::cerr << errorMsg << std::endl; Events_Error::send(errorMsg); } #else void* aModLib = dlopen( aFileName.c_str(), RTLD_LAZY | RTLD_GLOBAL ); - if ( !aModLib && theLibName != "DFBrowser") { // don't shor error for internal debugging tool + if ( !aModLib && theLibName != "DFBrowser") { // don't shor error for internal debugging tool std::cerr << "Failed to load " << aFileName.c_str() << std::endl; } #endif diff --git a/src/Config/Config_ModuleReader.h b/src/Config/Config_ModuleReader.h index 3bd5d39f3..18962f348 100644 --- a/src/Config/Config_ModuleReader.h +++ b/src/Config/Config_ModuleReader.h @@ -15,13 +15,11 @@ #include #include - -class Config_ModuleReader: public Config_XMLReader +class Config_ModuleReader : public Config_XMLReader { -public: - CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0); - CONFIG_EXPORT virtual ~Config_ModuleReader(); + public: + CONFIG_EXPORT Config_ModuleReader(const char* theEventGenerated = 0);CONFIG_EXPORT virtual ~Config_ModuleReader(); CONFIG_EXPORT const std::map& featuresInFiles() const; @@ -30,15 +28,14 @@ public: /// loads the library with specific name, appends "lib*.dll" or "*.so" depending on the platform CONFIG_EXPORT static void loadLibrary(const std::string theLibName); -protected: + protected: void processNode(xmlNodePtr aNode); bool processChildren(xmlNodePtr aNode); std::list importPlugin(const std::string& thePluginLibrary, const std::string& thePluginFile); - -private: + private: std::map myFeaturesInFiles; const char* myEventGenerated; diff --git a/src/Config/Config_PointerMessage.cpp b/src/Config/Config_PointerMessage.cpp index 91e9d10f3..60f27398f 100644 --- a/src/Config/Config_PointerMessage.cpp +++ b/src/Config/Config_PointerMessage.cpp @@ -8,7 +8,8 @@ #include Config_PointerMessage::Config_PointerMessage(const Events_ID theId, const void* theParent) - : Events_Message(theId, theParent), myPointer(0) + : Events_Message(theId, theParent), + myPointer(0) { } diff --git a/src/Config/Config_PointerMessage.h b/src/Config/Config_PointerMessage.h index 0e3c726ca..87aee3171 100644 --- a/src/Config/Config_PointerMessage.h +++ b/src/Config/Config_PointerMessage.h @@ -14,16 +14,16 @@ /* * A general class to pass pointers over the event loop. */ -class CONFIG_EXPORT Config_PointerMessage: public Events_Message +class CONFIG_EXPORT Config_PointerMessage : public Events_Message { -public: + public: Config_PointerMessage(const Events_ID theId, const void* theParent = 0); virtual ~Config_PointerMessage(); void* pointer() const; void setPointer(void* pointer); -private: + private: void* myPointer; }; diff --git a/src/Config/Config_Prop.h b/src/Config/Config_Prop.h index 246df8074..f74137c3c 100644 --- a/src/Config/Config_Prop.h +++ b/src/Config/Config_Prop.h @@ -13,26 +13,43 @@ /// Class which describes a one property class Config_Prop { -public: - - enum PropType { Disabled, Space, Bool, Color, String, Selector, - DblSpin, IntSpin, Double, Integer, - GroupBox, Tab, Frame, Font, DirList, File, - Slider, Shortcut, ShortcutTree, BiColor, Background }; + public: + enum PropType + { + Disabled, + Space, + Bool, + Color, + String, + Selector, + DblSpin, + IntSpin, + Double, + Integer, + GroupBox, + Tab, + Frame, + Font, + DirList, + File, + Slider, + Shortcut, + ShortcutTree, + BiColor, + Background + }; /** - * Creates a one property - * \param theSection - name of section (domain of using) of the property. - * \param theName - name (title) of the value. - * \param theType - type of the value. - * \param theValue - initial value of the property. - */ - Config_Prop(const std::string& theSection, - const std::string& theName, - const std::string& theTitle, - PropType theType, - const std::string& theValue ) { + * Creates a one property + * \param theSection - name of section (domain of using) of the property. + * \param theName - name (title) of the value. + * \param theType - type of the value. + * \param theValue - initial value of the property. + */ + Config_Prop(const std::string& theSection, const std::string& theName, + const std::string& theTitle, PropType theType, const std::string& theValue) + { mySection = theSection; myName = theName; myTitle = theTitle; @@ -40,24 +57,48 @@ public: myValue = theValue; } - std::string section() const { return mySection; } - std::string name() const { return myName; } + std::string section() const + { + return mySection; + } + std::string name() const + { + return myName; + } - std::string title() const { return myTitle; } - void setTitle(const std::string& theTitle) { myTitle = theTitle; } + std::string title() const + { + return myTitle; + } + void setTitle(const std::string& theTitle) + { + myTitle = theTitle; + } - PropType type() const { return myType; } - void setType(PropType theType) { myType = theType; } + PropType type() const + { + return myType; + } + void setType(PropType theType) + { + myType = theType; + } - std::string value() const { return myValue; } - void setValue(const std::string& theValue) { myValue = theValue; } + std::string value() const + { + return myValue; + } + void setValue(const std::string& theValue) + { + myValue = theValue; + } bool operator==(const Config_Prop* theProp) const { return (mySection == theProp->section()) && (myName == theProp->name()); } -private: + private: std::string mySection; std::string myName; std::string myTitle; @@ -67,4 +108,4 @@ private: typedef std::list Config_Properties; -#endif \ No newline at end of file +#endif diff --git a/src/Config/Config_PropManager.cpp b/src/Config/Config_PropManager.cpp index 4fa3d7090..c296cc864 100644 --- a/src/Config/Config_PropManager.cpp +++ b/src/Config/Config_PropManager.cpp @@ -4,21 +4,14 @@ #include "Config_PropManager.h" - - std::vector stringToRGB(const std::string& theColor); int stringToInteger(const std::string& theInt); double stringToDouble(const std::string& theDouble); - Config_Properties Config_PropManager::myProps; - - -bool Config_PropManager::registerProp(const std::string& theSection, - const std::string& theName, - const std::string& theTitle, - Config_Prop::PropType theType, +bool Config_PropManager::registerProp(const std::string& theSection, const std::string& theName, + const std::string& theTitle, Config_Prop::PropType theType, const std::string& theValue) { Config_Prop* aProp = findProp(theSection, theName); @@ -35,8 +28,7 @@ bool Config_PropManager::registerProp(const std::string& theSection, return true; } -Config_Prop* Config_PropManager::findProp(const std::string& theSection, - const std::string& theName) +Config_Prop* Config_PropManager::findProp(const std::string& theSection, const std::string& theName) { Config_Properties::const_iterator aIt; for (aIt = myProps.cbegin(); aIt != myProps.cend(); ++aIt) { @@ -47,7 +39,6 @@ Config_Prop* Config_PropManager::findProp(const std::string& theSection, return NULL; } - Config_Properties Config_PropManager::getProperties() { Config_Properties aRes; @@ -86,10 +77,8 @@ Config_Properties Config_PropManager::getProperties(const std::string& theSectio return aRes; } - -std::string Config_PropManager::string(const std::string& theSection, - const std::string& theName, - const std::string& theDefault) +std::string Config_PropManager::string(const std::string& theSection, const std::string& theName, + const std::string& theDefault) { Config_Properties aProps = getProperties(theSection); Config_Properties::const_iterator aIt; @@ -101,8 +90,7 @@ std::string Config_PropManager::string(const std::string& theSection, return theDefault; } - -std::vector Config_PropManager::color(const std::string& theSection, +std::vector Config_PropManager::color(const std::string& theSection, const std::string& theName, const std::string& theDefault) { @@ -110,24 +98,20 @@ std::vector Config_PropManager::color(const std::string& theSection, return stringToRGB(aStr); } -int Config_PropManager::integer(const std::string& theSection, - const std::string& theName, - const std::string& theDefault) +int Config_PropManager::integer(const std::string& theSection, const std::string& theName, + const std::string& theDefault) { std::string aStr = string(theSection, theName, theDefault); return stringToInteger(aStr); } -double Config_PropManager::real(const std::string& theSection, - const std::string& theName, - const std::string& theDefault) +double Config_PropManager::real(const std::string& theSection, const std::string& theName, + const std::string& theDefault) { std::string aStr = string(theSection, theName, theDefault); return stringToDouble(aStr); } - - std::vector stringToRGB(const std::string& theColor) { std::vector aRes(3); diff --git a/src/Config/Config_PropManager.h b/src/Config/Config_PropManager.h index d650b0e38..8f36c3500 100644 --- a/src/Config/Config_PropManager.h +++ b/src/Config/Config_PropManager.h @@ -15,25 +15,22 @@ //! Class wihich let to register properties class CONFIG_EXPORT Config_PropManager { -public: + public: /** - * Registers property parameters - * \param theOwnerId - name of owner (name of plugin for example) - * \param theSection - name of section (domain of using) of the property. - * \param theName - name (title) of the value. - * \param theType - type of the value. - * \param theValue - initial value of the property - * Returns True if the property succesfully registered - */ - static bool registerProp(const std::string& theSection, - const std::string& theName, - const std::string& theTitle, - Config_Prop::PropType theType, + * Registers property parameters + * \param theOwnerId - name of owner (name of plugin for example) + * \param theSection - name of section (domain of using) of the property. + * \param theName - name (title) of the value. + * \param theType - type of the value. + * \param theValue - initial value of the property + * Returns True if the property succesfully registered + */ + static bool registerProp(const std::string& theSection, const std::string& theName, + const std::string& theTitle, Config_Prop::PropType theType, const std::string& theValue); - static Config_Prop* findProp(const std::string& theSection, - const std::string& theName); + static Config_Prop* findProp(const std::string& theSection, const std::string& theName); static Config_Properties getProperties(); @@ -44,22 +41,17 @@ public: static Config_Properties getProperties(const std::string& theSection); //! Returns value of the property by its owner, section, and name - static std::string string(const std::string& theSection, - const std::string& theName, - const std::string& theDefault); - static std::vector color(const std::string& theSection, - const std::string& theName, - const std::string& theDefault); - static int integer(const std::string& theSection, - const std::string& theName, - const std::string& theDefault); - static double real(const std::string& theSection, - const std::string& theName, - const std::string& theDefault); - -private: + static std::string string(const std::string& theSection, const std::string& theName, + const std::string& theDefault); + static std::vector color(const std::string& theSection, const std::string& theName, + const std::string& theDefault); + static int integer(const std::string& theSection, const std::string& theName, + const std::string& theDefault); + static double real(const std::string& theSection, const std::string& theName, + const std::string& theDefault); + + private: static Config_Properties myProps; }; - -#endif \ No newline at end of file +#endif diff --git a/src/Config/Config_ValidatorMessage.cpp b/src/Config/Config_ValidatorMessage.cpp index b70511796..61ee376c0 100644 --- a/src/Config/Config_ValidatorMessage.cpp +++ b/src/Config/Config_ValidatorMessage.cpp @@ -8,7 +8,7 @@ #include Config_ValidatorMessage::Config_ValidatorMessage(const Events_ID theId, const void* theParent) -: Events_Message(theId, theParent) + : Events_Message(theId, theParent) { myValidatorId = ""; myFeatureId = ""; diff --git a/src/Config/Config_ValidatorMessage.h b/src/Config/Config_ValidatorMessage.h index f43c351b0..e344cd886 100644 --- a/src/Config/Config_ValidatorMessage.h +++ b/src/Config/Config_ValidatorMessage.h @@ -24,22 +24,17 @@ class Config_ValidatorMessage : public Events_Message std::string myAttributeId; std::list myVaidatorParameters; -public: - CONFIG_EXPORT Config_ValidatorMessage(const Events_ID theId, const void* theParent = 0); - CONFIG_EXPORT virtual ~Config_ValidatorMessage(); + public: + CONFIG_EXPORT Config_ValidatorMessage(const Events_ID theId, const void* theParent = 0);CONFIG_EXPORT virtual ~Config_ValidatorMessage(); //CONFIG_EXPORT static const char* UID() const; - CONFIG_EXPORT const std::string& validatorId() const; - CONFIG_EXPORT const std::string& featureId() const; - CONFIG_EXPORT const std::string& attributeId() const; - CONFIG_EXPORT const std::list& parameters() const; - CONFIG_EXPORT bool isValid() const; + CONFIG_EXPORT const std::string& validatorId() const;CONFIG_EXPORT const std::string& featureId() const;CONFIG_EXPORT const std::string& attributeId() const;CONFIG_EXPORT const std::list< + std::string>& parameters() const;CONFIG_EXPORT bool isValid() const; - CONFIG_EXPORT void setValidatorId(const std::string& theId); - CONFIG_EXPORT void setFeatureId(const std::string& theId); - CONFIG_EXPORT void setAttributeId(const std::string& theId); - CONFIG_EXPORT void setValidatorParameters(const std::list& parameters); + CONFIG_EXPORT void setValidatorId(const std::string& theId);CONFIG_EXPORT void setFeatureId( + const std::string& theId);CONFIG_EXPORT void setAttributeId(const std::string& theId);CONFIG_EXPORT void setValidatorParameters( + const std::list& parameters); }; #endif /* Config_ValidatorMessage_H_ */ diff --git a/src/Config/Config_WidgetAPI.cpp b/src/Config/Config_WidgetAPI.cpp index 8d295ce05..333f9219a 100644 --- a/src/Config/Config_WidgetAPI.cpp +++ b/src/Config/Config_WidgetAPI.cpp @@ -12,14 +12,12 @@ #include #include - Config_WidgetAPI::Config_WidgetAPI(std::string theRawXml) { myDoc = xmlParseDoc(BAD_CAST theRawXml.c_str()); myCurrentNode = xmlDocGetRootElement(myDoc); } - Config_WidgetAPI::~Config_WidgetAPI() { xmlFreeDoc(myDoc); @@ -31,9 +29,9 @@ bool Config_WidgetAPI::toNextWidget() xmlNodePtr aNextNode = myCurrentNode; do { aNextNode = aNextNode->next; - } while(aNextNode && !isElementNode(aNextNode)); + } while (aNextNode && !isElementNode(aNextNode)); - if(!aNextNode) { + if (!aNextNode) { toParentWidget(); return false; } @@ -43,11 +41,11 @@ bool Config_WidgetAPI::toNextWidget() bool Config_WidgetAPI::toChildWidget() { - if(myCurrentNode && hasChild(myCurrentNode)) { + if (myCurrentNode && hasChild(myCurrentNode)) { myCurrentNode = myCurrentNode->children; - while(!isElementNode(myCurrentNode)) { + while (!isElementNode(myCurrentNode)) { myCurrentNode = myCurrentNode->next; - } + } return true; } return false; @@ -55,7 +53,7 @@ bool Config_WidgetAPI::toChildWidget() bool Config_WidgetAPI::toParentWidget() { - if(myCurrentNode) { + if (myCurrentNode) { myCurrentNode = myCurrentNode->parent; } return myCurrentNode != NULL; @@ -64,7 +62,7 @@ bool Config_WidgetAPI::toParentWidget() std::string Config_WidgetAPI::widgetType() const { std::string result = ""; - if(myCurrentNode) { + if (myCurrentNode) { result = std::string((char *) myCurrentNode->name); } return result; @@ -73,13 +71,13 @@ std::string Config_WidgetAPI::widgetType() const bool Config_WidgetAPI::isContainerWidget() const { return isNode(myCurrentNode, WDG_GROUP, WDG_CHECK_GROUP, - NULL); + NULL); } bool Config_WidgetAPI::isPagedWidget() const { return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH, - NULL); + NULL); } std::string Config_WidgetAPI::getProperty(const char* thePropName) const diff --git a/src/Config/Config_WidgetAPI.h b/src/Config/Config_WidgetAPI.h index 190ccfc7f..d7c12e957 100644 --- a/src/Config/Config_WidgetAPI.h +++ b/src/Config/Config_WidgetAPI.h @@ -25,10 +25,9 @@ typedef xmlDoc *xmlDocPtr; struct _xmlDoc; //<< - class CONFIG_EXPORT Config_WidgetAPI { -public: + public: Config_WidgetAPI(std::string theRawXml); virtual ~Config_WidgetAPI(); @@ -47,7 +46,7 @@ public: std::string getProperty(const char* thePropName) const; -private: + private: xmlDocPtr myDoc; xmlNodePtr myCurrentNode; diff --git a/src/Config/Config_WidgetReader.cpp b/src/Config/Config_WidgetReader.cpp index f0214657b..e4125b3e6 100644 --- a/src/Config/Config_WidgetReader.cpp +++ b/src/Config/Config_WidgetReader.cpp @@ -20,7 +20,6 @@ #include #endif - Config_WidgetReader::Config_WidgetReader(const std::string& theXmlFile) : Config_XMLReader(theXmlFile) @@ -41,7 +40,6 @@ std::string Config_WidgetReader::featureDescription(const std::string& theFeatur return myDescriptionCache[theFeatureName]; } - void Config_WidgetReader::processNode(xmlNodePtr theNode) { if (isNode(theNode, NODE_FEATURE, NULL)) { @@ -63,7 +61,7 @@ void Config_WidgetReader::resolveSourceNodes(xmlNodePtr theNode) { xmlNodePtr aNode = xmlFirstElementChild(theNode); std::list aSourceNodes; - while(aNode != NULL) { + while (aNode != NULL) { if (isNode(aNode, NODE_SOURCE, NULL)) { Config_XMLReader aSourceReader = Config_XMLReader(getProperty(aNode, SOURCE_FILE)); xmlNodePtr aSourceRoot = aSourceReader.findRoot(); @@ -72,7 +70,7 @@ void Config_WidgetReader::resolveSourceNodes(xmlNodePtr theNode) } xmlNodePtr aSourceNode = xmlFirstElementChild(aSourceRoot); xmlNodePtr aTargetNode = xmlDocCopyNodeList(aNode->doc, aSourceNode); - while(aTargetNode != NULL) { + while (aTargetNode != NULL) { xmlNodePtr aNextNode = xmlNextElementSibling(aTargetNode); xmlAddPrevSibling(aNode, aTargetNode); aTargetNode = aNextNode; @@ -83,7 +81,7 @@ void Config_WidgetReader::resolveSourceNodes(xmlNodePtr theNode) } //Remove "SOURCE" node. std::list::iterator it = aSourceNodes.begin(); - for(; it != aSourceNodes.end(); it++) { + for (; it != aSourceNodes.end(); it++) { xmlUnlinkNode(*it); xmlFreeNode(*it); } diff --git a/src/Config/Config_WidgetReader.h b/src/Config/Config_WidgetReader.h index c9c2f0602..55ce4e932 100644 --- a/src/Config/Config_WidgetReader.h +++ b/src/Config/Config_WidgetReader.h @@ -14,23 +14,21 @@ #include #include - -class Config_WidgetReader: public Config_XMLReader +class Config_WidgetReader : public Config_XMLReader { -public: - CONFIG_EXPORT Config_WidgetReader(const std::string& theXmlFile); - CONFIG_EXPORT virtual ~Config_WidgetReader(); + public: + CONFIG_EXPORT Config_WidgetReader(const std::string& theXmlFile);CONFIG_EXPORT virtual ~Config_WidgetReader(); - CONFIG_EXPORT std::string featureWidgetCfg(const std::string& theFeatureName); - CONFIG_EXPORT std::string featureDescription(const std::string& theFeatureName); + CONFIG_EXPORT std::string featureWidgetCfg(const std::string& theFeatureName);CONFIG_EXPORT std::string featureDescription( + const std::string& theFeatureName); -protected: + protected: void processNode(xmlNodePtr theNode); bool processChildren(xmlNodePtr theNode); std::string dumpNode(xmlNodePtr theNode); void resolveSourceNodes(xmlNodePtr theNode); -private: + private: std::map myWidgetCache; std::map myDescriptionCache; diff --git a/src/Config/Config_XMLReader.cpp b/src/Config/Config_XMLReader.cpp index 8d618b102..f75748f18 100644 --- a/src/Config/Config_XMLReader.cpp +++ b/src/Config/Config_XMLReader.cpp @@ -15,11 +15,11 @@ #include /* -#ifdef WIN32 -//For GetModuleFileNameW -#include -#endif -*/ + #ifdef WIN32 + //For GetModuleFileNameW + #include + #endif + */ #ifdef _DEBUG #include @@ -70,9 +70,9 @@ void Config_XMLReader::processNode(xmlNodePtr theNode) std::string aSourceFile = getProperty(theNode, SOURCE_FILE); Config_XMLReader aSourceReader = Config_XMLReader(aSourceFile); readRecursively(aSourceReader.findRoot()); - #ifdef _DEBUG +#ifdef _DEBUG std::cout << "Config_XMLReader::sourced node: " << aSourceFile << std::endl; - #endif +#endif } else if (isNode(theNode, NODE_VALIDATOR, NULL)) { processValidator(theNode); } @@ -121,9 +121,9 @@ void Config_XMLReader::readRecursively(xmlNodePtr theParent) if (!theParent) return; xmlNodePtr aNode = theParent->xmlChildrenNode; - for(; aNode; aNode = aNode->next) { + for (; aNode; aNode = aNode->next) { //Still no text processing in features... - if(!isElementNode(aNode)) { + if (!isElementNode(aNode)) { continue; } processNode(aNode); @@ -165,7 +165,7 @@ void Config_XMLReader::processValidator(xmlNodePtr theNode) aMessage.setValidatorId(aValidatorId); aMessage.setValidatorParameters(aValidatorParameters); xmlNodePtr aFeatureOrWdgNode = theNode->parent; - if(isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) { + if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) { aMessage.setFeatureId(getProperty(aFeatureOrWdgNode, _ID)); } else { aMessage.setAttributeId(getProperty(aFeatureOrWdgNode, _ID)); diff --git a/src/Config/Config_XMLReader.h b/src/Config/Config_XMLReader.h index 3a8219cda..b3e1554ee 100644 --- a/src/Config/Config_XMLReader.h +++ b/src/Config/Config_XMLReader.h @@ -32,16 +32,15 @@ struct _xmlDoc; */ class Config_XMLReader { -public: - CONFIG_EXPORT Config_XMLReader(const std::string& theXmlFile); - CONFIG_EXPORT virtual ~Config_XMLReader(); + public: + CONFIG_EXPORT Config_XMLReader(const std::string& theXmlFile);CONFIG_EXPORT virtual ~Config_XMLReader(); CONFIG_EXPORT void readAll(); -public: + public: CONFIG_EXPORT xmlNodePtr findRoot(); -protected: + protected: virtual void processNode(xmlNodePtr aNode); virtual bool processChildren(xmlNodePtr aNode); @@ -51,12 +50,12 @@ protected: std::string getProperty(xmlNodePtr theNode, const char* property); void processValidator(xmlNodePtr theNode); -protected: + protected: std::string myCurrentFeature; -protected: + protected: std::string myDocumentPath; - xmlDocPtr myXmlDoc; + xmlDocPtr myXmlDoc; }; #endif /* CONFIG_XMLREADER_H_ */ diff --git a/src/Config/Config_def.h b/src/Config/Config_def.h index 587ac534d..1edcc6c10 100644 --- a/src/Config/Config_def.h +++ b/src/Config/Config_def.h @@ -1,18 +1,18 @@ -#ifndef CONFIG_H -#define CONFIG_H - -#if defined CONFIG_EXPORTS -#if defined WIN32 -#define CONFIG_EXPORT __declspec( dllexport ) -#else -#define CONFIG_EXPORT -#endif -#else -#if defined WIN32 -#define CONFIG_EXPORT __declspec( dllimport ) -#else -#define CONFIG_EXPORT -#endif -#endif - -#endif //CONFIG_H +#ifndef CONFIG_H +#define CONFIG_H + +#if defined CONFIG_EXPORTS +#if defined WIN32 +#define CONFIG_EXPORT __declspec( dllexport ) +#else +#define CONFIG_EXPORT +#endif +#else +#if defined WIN32 +#define CONFIG_EXPORT __declspec( dllimport ) +#else +#define CONFIG_EXPORT +#endif +#endif + +#endif //CONFIG_H \ No newline at end of file diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp index 6b0d729a4..60d5694f5 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp @@ -9,7 +9,7 @@ using namespace std; // the only created instance of this plugin static ConstructionPlugin_Plugin* MY_INSTANCE = new ConstructionPlugin_Plugin(); -ConstructionPlugin_Plugin::ConstructionPlugin_Plugin() +ConstructionPlugin_Plugin::ConstructionPlugin_Plugin() { // register this plugin ModelAPI_PluginManager::get()->registerPlugin(this); diff --git a/src/ConstructionPlugin/ConstructionPlugin_Plugin.h b/src/ConstructionPlugin/ConstructionPlugin_Plugin.h index 95ab19376..143b786e5 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Plugin.h +++ b/src/ConstructionPlugin/ConstructionPlugin_Plugin.h @@ -5,18 +5,17 @@ #ifndef ConstructionPlugin_Plugin_H_ #define ConstructionPlugin_Plugin_H_ - #include "ConstructionPlugin.h" #include "ModelAPI_Plugin.h" #include "ModelAPI_Feature.h" -class CONSTRUCTIONPLUGIN_EXPORT ConstructionPlugin_Plugin: public ModelAPI_Plugin +class CONSTRUCTIONPLUGIN_EXPORT ConstructionPlugin_Plugin : public ModelAPI_Plugin { -public: + public: /// Creates the feature object of this plugin by the feature string ID virtual FeaturePtr createFeature(std::string theFeatureID); -public: + public: /// Is needed for python wrapping by swig ConstructionPlugin_Plugin(); }; diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp index 5a879d49d..e39bcc06e 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp @@ -24,12 +24,11 @@ void ConstructionPlugin_Point::initAttributes() data()->addAttribute(POINT_ATTR_Z, ModelAPI_AttributeDouble::type()); } -void ConstructionPlugin_Point::execute() +void ConstructionPlugin_Point::execute() { - boost::shared_ptr aPnt(new GeomAPI_Pnt( - data()->real(POINT_ATTR_X)->value(), - data()->real(POINT_ATTR_Y)->value(), - data()->real(POINT_ATTR_Z)->value())); + boost::shared_ptr aPnt( + new GeomAPI_Pnt(data()->real(POINT_ATTR_X)->value(), data()->real(POINT_ATTR_Y)->value(), + data()->real(POINT_ATTR_Z)->value())); boost::shared_ptr aConstr = document()->createConstruction(data()); aConstr->setShape(GeomAlgoAPI_PointBuilder::point(aPnt)); diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.h b/src/ConstructionPlugin/ConstructionPlugin_Point.h index a5f183690..63a134226 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.h +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.h @@ -22,16 +22,22 @@ const std::string POINT_ATTR_Z = "z"; * \ingroup DataModel * \brief Feature for creation of the new part in PartSet. */ -class ConstructionPlugin_Point: public ModelAPI_Feature +class ConstructionPlugin_Point : public ModelAPI_Feature { -public: + public: /// Returns the kind of a feature - CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = CONSTRUCTION_POINT_KIND; return MY_KIND;} + CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = CONSTRUCTION_POINT_KIND; + return MY_KIND; + } /// Returns to which group in the document must be added feature - CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = "Construction"; return MY_GROUP;} + CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getGroup() + { + static std::string MY_GROUP = "Construction"; + return MY_GROUP; + } /// Creates a new part document if needed CONSTRUCTIONPLUGIN_EXPORT virtual void execute(); diff --git a/src/Events/Events_Error.cpp b/src/Events/Events_Error.cpp index ff3fd58e8..7fe307b6a 100644 --- a/src/Events/Events_Error.cpp +++ b/src/Events/Events_Error.cpp @@ -9,7 +9,7 @@ #include Events_Error::Events_Error(char* theDescription, const void* theSender) - : Events_Message(Events_Error::errorID(), theSender) + : Events_Message(Events_Error::errorID(), theSender) { myDescription = theDescription; } @@ -37,5 +37,5 @@ void Events_Error::send(char* theDescription, const void* theSender) void Events_Error::send(std::string theDescription, const void* theSender) { - Events_Error::send((char*)theDescription.c_str(), theSender); + Events_Error::send((char*) theDescription.c_str(), theSender); } diff --git a/src/Events/Events_Error.h b/src/Events/Events_Error.h index 7e2e62e29..f3c7f8024 100644 --- a/src/Events/Events_Error.h +++ b/src/Events/Events_Error.h @@ -13,11 +13,11 @@ #include -class EVENTS_EXPORT Events_Error: public Events_Message +class EVENTS_EXPORT Events_Error : public Events_Message { - char* myDescription; ///< pointer to the description of the error + char* myDescription; ///< pointer to the description of the error -public: + public: virtual ~Events_Error(); static Events_ID errorID(); @@ -25,7 +25,7 @@ public: static void send(char* theDescription, const void* theSender = 0); static void send(std::string theDescription, const void* theSender = 0); -protected: + protected: Events_Error(char* theDescription, const void* theSender = 0); }; diff --git a/src/Events/Events_Listener.h b/src/Events/Events_Listener.h index 5bac8dc8a..ac7714f02 100644 --- a/src/Events/Events_Listener.h +++ b/src/Events/Events_Listener.h @@ -15,9 +15,10 @@ class Events_Message; * If some object wants to listen some events it must inherit * this class and register in the Loop. */ -class EVENTS_EXPORT Events_Listener { +class EVENTS_EXPORT Events_Listener +{ -public: + public: //! This method is called by loop when the event is started to process. virtual void processEvent(const Events_Message* theMessage) = 0; }; diff --git a/src/Events/Events_LongOp.cpp b/src/Events/Events_LongOp.cpp index 647d2bb4c..b4718608a 100644 --- a/src/Events/Events_LongOp.cpp +++ b/src/Events/Events_LongOp.cpp @@ -10,7 +10,7 @@ std::map MY_SENDERS; Events_LongOp::Events_LongOp(void* theSender) - : Events_Message(Events_LongOp::eventID(), theSender) + : Events_Message(Events_LongOp::eventID(), theSender) { } @@ -29,7 +29,7 @@ void Events_LongOp::start(void* theSender) bool toSend = MY_SENDERS.empty(); if (MY_SENDERS.find(theSender) == MY_SENDERS.end()) MY_SENDERS[theSender] = 1; - else + else MY_SENDERS[theSender]++; if (toSend) { @@ -42,8 +42,10 @@ void Events_LongOp::end(void* theSender) { if (MY_SENDERS.find(theSender) != MY_SENDERS.end()) { int aCount = MY_SENDERS[theSender]; - if (aCount <= 1) MY_SENDERS.erase(theSender); - else MY_SENDERS[theSender] = aCount - 1; + if (aCount <= 1) + MY_SENDERS.erase(theSender); + else + MY_SENDERS[theSender] = aCount - 1; } if (MY_SENDERS.empty()) { Events_LongOp anEvent(theSender); diff --git a/src/Events/Events_LongOp.h b/src/Events/Events_LongOp.h index dfb06cae4..32240f7c1 100644 --- a/src/Events/Events_LongOp.h +++ b/src/Events/Events_LongOp.h @@ -12,9 +12,9 @@ * Informs the application that the long operation is performed. * Causes waiting coursor in GUI. */ -class EVENTS_EXPORT Events_LongOp: public Events_Message +class EVENTS_EXPORT Events_LongOp : public Events_Message { -public: + public: virtual ~Events_LongOp(); /// Returns the identifier of this event static Events_ID eventID(); @@ -23,9 +23,9 @@ public: /// Stops the long operation static void end(void* theSender = 0); /// Returns true if the long operation is performed - static bool isPerformed(); + static bool isPerformed(); -protected: + protected: Events_LongOp(void* theSender = 0); }; diff --git a/src/Events/Events_Loop.cpp b/src/Events/Events_Loop.cpp index 40917a64f..c8cf0e86e 100644 --- a/src/Events/Events_Loop.cpp +++ b/src/Events/Events_Loop.cpp @@ -24,8 +24,8 @@ Events_ID Events_Loop::eventByName(const char* theName) char* aResult; string aName(theName); map::iterator aFound = CREATED_EVENTS.find(aName); - if (aFound == CREATED_EVENTS.end()) { //not created yet - aResult = strdup(theName); // copy to make unique internal pointer + 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; @@ -39,9 +39,9 @@ void Events_Loop::send(Events_Message& theMessage, bool isGroup) if (isGroup) { Events_MessageGroup* aGroup = dynamic_cast(&theMessage); if (aGroup) { - std::map::iterator aMyGroup = - myGroups.find(aGroup->eventID().eventText()); - if (aMyGroup == myGroups.end()) { // create a new group of messages for accumulation + std::map::iterator aMyGroup = myGroups.find( + aGroup->eventID().eventText()); + if (aMyGroup == myGroups.end()) { // create a new group of messages for accumulation myGroups[aGroup->eventID().eventText()] = aGroup->newEmpty(); aMyGroup = myGroups.find(aGroup->eventID().eventText()); } @@ -59,14 +59,14 @@ void Events_Loop::send(Events_Message& theMessage, bool isGroup) theMessage.sender()); if (aFindSender != aFindID->second.end()) { list& aListeners = aFindSender->second; - for(list::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++) + for (list::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++) (*aL)->processEvent(&theMessage); } - if (theMessage.sender()) { // also call for NULL senders registered + if (theMessage.sender()) { // also call for NULL senders registered aFindSender = aFindID->second.find(NULL); if (aFindSender != aFindID->second.end()) { list& aListeners = aFindSender->second; - for(list::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++) + for (list::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++) (*aL)->processEvent(&theMessage); } } @@ -74,34 +74,33 @@ void Events_Loop::send(Events_Message& theMessage, bool isGroup) } void Events_Loop::registerListener(Events_Listener* theListener, const Events_ID theID, - void* theSender) + void* theSender) { map > >::iterator aFindID = myListeners.find( theID.eventText()); - if (aFindID == myListeners.end()) { // create container associated with ID + if (aFindID == myListeners.end()) { // create container associated with ID myListeners[theID.eventText()] = map >(); aFindID = myListeners.find(theID.eventText()); } map >::iterator aFindSender = aFindID->second.find(theSender); - if (aFindSender == aFindID->second.end()) { // create container associated with sender + if (aFindSender == aFindID->second.end()) { // create container associated with sender aFindID->second[theSender] = list(); aFindSender = aFindID->second.find(theSender); } // check that listener was not registered wit hsuch parameters before list& aListeners = aFindSender->second; - for(list::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++) + for (list::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++) if (*aL == theListener) - return; // avoid duplicates + return; // avoid duplicates aListeners.push_back(theListener); } void Events_Loop::flush(const Events_ID& theID) { - std::map::iterator aMyGroup = - myGroups.find(theID.eventText()); - if (aMyGroup != myGroups.end()) { // really sends + std::map::iterator aMyGroup = myGroups.find(theID.eventText()); + if (aMyGroup != myGroups.end()) { // really sends Events_MessageGroup* aGroup = aMyGroup->second; myGroups.erase(aMyGroup); send(*aGroup, false); diff --git a/src/Events/Events_Loop.h b/src/Events/Events_Loop.h index e7a0b3a2a..d62cea6ad 100644 --- a/src/Events/Events_Loop.h +++ b/src/Events/Events_Loop.h @@ -23,17 +23,20 @@ class Events_MessageGroup; * Performing of events is processed in separated thread, so, sender takes * control back immideately. */ -class Events_Loop { +class Events_Loop +{ /// map from event ID to sender pointer to listeners that must be called for this - std::map > > - myListeners; + std::map > > myListeners; /// map from event ID to groupped messages (accumulated on flush) std::map myGroups; //! The empty constructor, will be called at startup of the application, only once - Events_Loop() {}; -public: + 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 @@ -46,8 +49,8 @@ public: //! 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); + EVENTS_EXPORT void registerListener(Events_Listener* theListener, const Events_ID theID, + void* theSender = 0); //! Initializes sending of a group-message by the given ID EVENTS_EXPORT void flush(const Events_ID& theID); diff --git a/src/Events/Events_Message.h b/src/Events/Events_Message.h index fe829a468..ef8837c93 100644 --- a/src/Events/Events_Message.h +++ b/src/Events/Events_Message.h @@ -17,17 +17,27 @@ * 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 +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;} + Events_ID(char* theID) + { + myID = theID; + } friend class Events_Loop; -public: + public: /// Returns the text-identifier of the event (for debugging reasons) - char* eventText() const {return myID;} + char* eventText() const + { + return myID; + } /// Allows to compare identifiers - bool operator==(const Events_ID& theID) const {return myID == theID.myID;} + bool operator==(const Events_ID& theID) const + { + return myID == theID.myID; + } }; /**\class Events_Message @@ -35,23 +45,35 @@ public: * \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 +class EVENTS_EXPORT Events_Message +{ + Events_ID myEventsId; ///< identifier of the event + void* mySender; ///< the sender object -public: + public: //! Creates the message Events_Message(const Events_ID theID, const void* theSender = 0) - : myEventsId(theID), mySender((void*) theSender) {} + : myEventsId(theID), + mySender((void*) theSender) + { + } //! do nothing in the destructor yet - virtual ~Events_Message() {} + virtual ~Events_Message() + { + } //! Returns identifier of the message - const Events_ID& eventID() const {return myEventsId;} + const Events_ID& eventID() const + { + return myEventsId; + } //! Returns sender of the message or NULL if it is anonymous message - void* sender() const {return mySender;} + void* sender() const + { + return mySender; + } }; #endif diff --git a/src/Events/Events_MessageGroup.h b/src/Events/Events_MessageGroup.h index 46d7c420a..232c8d1b6 100644 --- a/src/Events/Events_MessageGroup.h +++ b/src/Events/Events_MessageGroup.h @@ -14,15 +14,20 @@ * Loop detects such messages and accumulates them without sending. On "flush" loop sends it * as a group-message. */ -class EVENTS_EXPORT Events_MessageGroup : public Events_Message { +class EVENTS_EXPORT Events_MessageGroup : public Events_Message +{ -public: + public: //! Creates the message Events_MessageGroup(const Events_ID theID, const void* theSender = 0) - : Events_Message(theID, theSender) {} + : Events_Message(theID, theSender) + { + } //! do nothing in the destructor yet - virtual ~Events_MessageGroup() {} + virtual ~Events_MessageGroup() + { + } //! Creates a new empty group (to store it in the loop before flush) virtual Events_MessageGroup* newEmpty() = 0; diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index b232f18e7..7c6a0eaeb 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -29,13 +29,13 @@ void FeaturesPlugin_Extrusion::initAttributes() void FeaturesPlugin_Extrusion::execute() { - boost::shared_ptr aFaceRef = - boost::dynamic_pointer_cast(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID())); + boost::shared_ptr aFaceRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeReference>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID())); if (!aFaceRef) return; - boost::shared_ptr aConstr = - boost::dynamic_pointer_cast(aFaceRef->value()); - if (!aConstr) + boost::shared_ptr aConstr = boost::dynamic_pointer_cast< + ModelAPI_ResultConstruction>(aFaceRef->value()); + if (!aConstr) return; boost::shared_ptr aFace = aConstr->shape(); if (!aFace) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h index f42a7d7f5..13a8c226e 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.h @@ -8,9 +8,9 @@ #include "FeaturesPlugin.h" #include -class FeaturesPlugin_Extrusion: public ModelAPI_Feature +class FeaturesPlugin_Extrusion : public ModelAPI_Feature { -public: + public: /// Extrusion kind inline static const std::string& ID() { @@ -29,7 +29,7 @@ public: static const std::string MY_SIZE_ID("extrusion_size"); return MY_SIZE_ID; } - /// attribute name of reverse direction + /// attribute name of reverse direction inline static const std::string& REVERSE_ID() { static const std::string MY_REVERSE_ID("extrusion_reverse"); @@ -37,8 +37,11 @@ public: } /// Returns the kind of a feature - FEATURESPLUGIN_EXPORT virtual const std::string& getKind() - { static std::string MY_KIND = FeaturesPlugin_Extrusion::ID(); return MY_KIND; } + FEATURESPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = FeaturesPlugin_Extrusion::ID(); + return MY_KIND; + } /// Creates a new part document if needed FEATURESPLUGIN_EXPORT virtual void execute(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp index 1ae9381cd..c84ddf680 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp @@ -9,7 +9,7 @@ using namespace std; // the only created instance of this plugin static FeaturesPlugin_Plugin* MY_INSTANCE = new FeaturesPlugin_Plugin(); -FeaturesPlugin_Plugin::FeaturesPlugin_Plugin() +FeaturesPlugin_Plugin::FeaturesPlugin_Plugin() { // register this plugin ModelAPI_PluginManager::get()->registerPlugin(this); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.h b/src/FeaturesPlugin/FeaturesPlugin_Plugin.h index 1b49efe58..560a2242a 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Plugin.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Plugin.h @@ -5,18 +5,17 @@ #ifndef FeaturesPlugin_Plugin_H_ #define FeaturesPlugin_Plugin_H_ - #include "FeaturesPlugin.h" #include #include -class FEATURESPLUGIN_EXPORT FeaturesPlugin_Plugin: public ModelAPI_Plugin +class FEATURESPLUGIN_EXPORT FeaturesPlugin_Plugin : public ModelAPI_Plugin { -public: + public: /// Creates the feature object of this plugin by the feature string ID virtual FeaturePtr createFeature(std::string theFeatureID); -public: + public: /// Is needed for python wrapping by swig FeaturesPlugin_Plugin(); }; diff --git a/src/GeomAPI/GeomAPI_AISObject.cpp b/src/GeomAPI/GeomAPI_AISObject.cpp index ec44e1c63..4ba7232b3 100644 --- a/src/GeomAPI/GeomAPI_AISObject.cpp +++ b/src/GeomAPI/GeomAPI_AISObject.cpp @@ -23,9 +23,8 @@ #include #include - -const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint -const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance +const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint +const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance // Initialization of color constants int Colors::COLOR_BROWN = Quantity_NOC_BROWN; @@ -33,23 +32,21 @@ int Colors::COLOR_RED = Quantity_NOC_RED; int Colors::COLOR_GREEN = Quantity_NOC_GREEN; int Colors::COLOR_BLUE = Quantity_NOC_BLUE1; - GeomAPI_AISObject::GeomAPI_AISObject() - : GeomAPI_Interface(new Handle(AIS_InteractiveObject)()) + : GeomAPI_Interface(new Handle(AIS_InteractiveObject)()) { } void GeomAPI_AISObject::createShape(boost::shared_ptr theShape) { - const TopoDS_Shape& aTDS = (theShape && theShape->implPtr()) ? - theShape->impl() : TopoDS_Shape(); + const TopoDS_Shape& aTDS = + (theShape && theShape->implPtr()) ? + theShape->impl() : TopoDS_Shape(); Handle(AIS_InteractiveObject) anAIS = impl(); - if (!anAIS.IsNull()) - { + if (!anAIS.IsNull()) { Handle(AIS_Shape) aShapeAIS = Handle(AIS_Shape)::DownCast(anAIS); - if (aShapeAIS) - { + if (aShapeAIS) { // if the AIS object is displayed in the opened local context in some mode, additional // AIS sub objects are created there. They should be rebuild for correct selecting. // It is possible to correct it by closing local context before the shape set and opening @@ -59,27 +56,24 @@ void GeomAPI_AISObject::createShape(boost::shared_ptr theShape) aShapeAIS->Set(aTDS); aShapeAIS->Redisplay(Standard_True); } - } - else + } else setImpl(new Handle(AIS_InteractiveObject)(new AIS_Shape(aTDS))); } - void GeomAPI_AISObject::createDistance(boost::shared_ptr theStartPoint, boost::shared_ptr theEndPoint, boost::shared_ptr theFlyoutPoint, - boost::shared_ptr thePlane, - double theDistance) + boost::shared_ptr thePlane, double theDistance) { double aFlyout = 0; - if (theFlyoutPoint) - { - boost::shared_ptr aLine = - boost::shared_ptr(new GeomAPI_Lin(theStartPoint, theEndPoint)); + if (theFlyoutPoint) { + boost::shared_ptr aLine = boost::shared_ptr( + new GeomAPI_Lin(theStartPoint, theEndPoint)); double aDist = aLine->distance(theFlyoutPoint); boost::shared_ptr aLineDir = theEndPoint->xyz()->decreased(theStartPoint->xyz()); - boost::shared_ptr aFOutDir = theFlyoutPoint->xyz()->decreased(theStartPoint->xyz()); + boost::shared_ptr aFOutDir = theFlyoutPoint->xyz()->decreased( + theStartPoint->xyz()); boost::shared_ptr aNorm = thePlane->direction()->xyz(); if (aLineDir->cross(aFOutDir)->dot(aNorm) < 0) aDist = -aDist; @@ -87,14 +81,14 @@ void GeomAPI_AISObject::createDistance(boost::shared_ptr theStartPo } Handle(AIS_InteractiveObject) anAIS = impl(); - if (anAIS.IsNull()) - { - Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension( - theStartPoint->impl(), theEndPoint->impl(), thePlane->impl()); + if (anAIS.IsNull()) { + Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension(theStartPoint->impl(), + theEndPoint->impl(), + thePlane->impl()); aDimAIS->SetCustomValue(theDistance); Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect(); - anAspect->MakeArrows3d (Standard_False); + anAspect->MakeArrows3d(Standard_False); anAspect->MakeText3d(false); anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT); anAspect->MakeTextShaded(false); @@ -104,12 +98,11 @@ void GeomAPI_AISObject::createDistance(boost::shared_ptr theStartPo aDimAIS->SetFlyout(aFlyout); setImpl(new Handle(AIS_InteractiveObject)(aDimAIS)); - } - else { + } else { // update presentation Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS); if (!aDimAIS.IsNull()) { - aDimAIS->SetMeasuredGeometry(theStartPoint->impl(), theEndPoint->impl(), + aDimAIS->SetMeasuredGeometry(theStartPoint->impl(), theEndPoint->impl(), thePlane->impl()); aDimAIS->SetCustomValue(theDistance); aDimAIS->SetFlyout(aFlyout); @@ -120,8 +113,8 @@ void GeomAPI_AISObject::createDistance(boost::shared_ptr theStartPo } void GeomAPI_AISObject::createRadius(boost::shared_ptr theCircle, - boost::shared_ptr theFlyoutPoint, - double theRadius) + boost::shared_ptr theFlyoutPoint, + double theRadius) { boost::shared_ptr aCenter = theCircle->center(); @@ -141,29 +134,25 @@ void GeomAPI_AISObject::createRadius(boost::shared_ptr theCircle, anAnchor->setZ(anAnchor->z() + aDelta * aDeltaDir->z()); Handle(AIS_InteractiveObject) anAIS = impl(); - if (anAIS.IsNull()) - { - Handle(AIS_RadiusDimension) aDimAIS = - new AIS_RadiusDimension(theCircle->impl(), anAnchor->impl()); + if (anAIS.IsNull()) { + Handle(AIS_RadiusDimension) aDimAIS = new AIS_RadiusDimension(theCircle->impl(), + anAnchor->impl()); aDimAIS->SetCustomValue(theRadius); Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect(); - anAspect->MakeArrows3d (Standard_False); + anAspect->MakeArrows3d(Standard_False); anAspect->MakeText3d(false); anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT); anAspect->MakeTextShaded(false); aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false); - aDimAIS->SetDimensionAspect (anAspect); + aDimAIS->SetDimensionAspect(anAspect); aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE); setImpl(new Handle(AIS_InteractiveObject)(aDimAIS)); - } - else - { + } else { // update presentation Handle(AIS_RadiusDimension) aDimAIS = Handle(AIS_RadiusDimension)::DownCast(anAIS); - if (!aDimAIS.IsNull()) - { + if (!aDimAIS.IsNull()) { aDimAIS->SetMeasuredGeometry(theCircle->impl(), anAnchor->impl()); aDimAIS->SetCustomValue(theRadius); aDimAIS->Redisplay(Standard_True); @@ -173,25 +162,21 @@ void GeomAPI_AISObject::createRadius(boost::shared_ptr theCircle, void GeomAPI_AISObject::createParallel(boost::shared_ptr theLine1, boost::shared_ptr theLine2, - boost::shared_ptr theFlyoutPoint, - boost::shared_ptr thePlane) + boost::shared_ptr theFlyoutPoint, + boost::shared_ptr thePlane) { Handle(Geom_Plane) aPlane = new Geom_Plane(thePlane->impl()); Handle(AIS_InteractiveObject) anAIS = impl(); - if (anAIS.IsNull()) - { - Handle(AIS_ParallelRelation) aParallel = - new AIS_ParallelRelation(theLine1->impl(), theLine2->impl(), aPlane); + if (anAIS.IsNull()) { + Handle(AIS_ParallelRelation) aParallel = new AIS_ParallelRelation( + theLine1->impl(), theLine2->impl(), aPlane); if (theFlyoutPoint) aParallel->SetPosition(theFlyoutPoint->impl()); setImpl(new Handle(AIS_InteractiveObject)(aParallel)); - } - else - { + } else { Handle(AIS_ParallelRelation) aParallel = Handle(AIS_ParallelRelation)::DownCast(anAIS); - if (!aParallel.IsNull()) - { + if (!aParallel.IsNull()) { aParallel->SetFirstShape(theLine1->impl()); aParallel->SetSecondShape(theLine2->impl()); aParallel->SetPlane(aPlane); @@ -204,22 +189,19 @@ void GeomAPI_AISObject::createParallel(boost::shared_ptr theLine1 void GeomAPI_AISObject::createPerpendicular(boost::shared_ptr theLine1, boost::shared_ptr theLine2, - boost::shared_ptr thePlane) + boost::shared_ptr thePlane) { Handle(Geom_Plane) aPlane = new Geom_Plane(thePlane->impl()); Handle(AIS_InteractiveObject) anAIS = impl(); - if (anAIS.IsNull()) - { - Handle(AIS_PerpendicularRelation) aPerpendicular = - new AIS_PerpendicularRelation(theLine1->impl(), theLine2->impl(), aPlane); + if (anAIS.IsNull()) { + Handle(AIS_PerpendicularRelation) aPerpendicular = new AIS_PerpendicularRelation( + theLine1->impl(), theLine2->impl(), aPlane); setImpl(new Handle(AIS_InteractiveObject)(aPerpendicular)); - } - else - { - Handle(AIS_PerpendicularRelation) aPerpendicular = Handle(AIS_PerpendicularRelation)::DownCast(anAIS); - if (!aPerpendicular.IsNull()) - { + } else { + Handle(AIS_PerpendicularRelation) aPerpendicular = Handle(AIS_PerpendicularRelation)::DownCast( + anAIS); + if (!aPerpendicular.IsNull()) { aPerpendicular->SetFirstShape(theLine1->impl()); aPerpendicular->SetSecondShape(theLine2->impl()); aPerpendicular->SetPlane(aPlane); @@ -228,13 +210,12 @@ void GeomAPI_AISObject::createPerpendicular(boost::shared_ptr the } } - void GeomAPI_AISObject::setColor(const int& theColor) { Handle(AIS_InteractiveObject) anAIS = impl(); if (anAIS.IsNull()) - return ; - Quantity_Color aColor((Quantity_NameOfColor)theColor); + return; + Quantity_Color aColor((Quantity_NameOfColor) theColor); anAIS->SetColor(aColor); Handle(AIS_Dimension) aDimAIS = Handle(AIS_Dimension)::DownCast(anAIS); if (!aDimAIS.IsNull()) { @@ -246,7 +227,7 @@ void GeomAPI_AISObject::setWidth(const double& theWidth) { Handle(AIS_InteractiveObject) anAIS = impl(); if (anAIS.IsNull()) - return ; + return; anAIS->SetWidth(theWidth); } @@ -254,8 +235,8 @@ void GeomAPI_AISObject::setColor(int theR, int theG, int theB) { Handle(AIS_InteractiveObject) anAIS = impl(); if (anAIS.IsNull()) - return ; - Quantity_Color aColor(theR/255., theG/255., theB/255., Quantity_TOC_RGB); + return; + Quantity_Color aColor(theR / 255., theG / 255., theB / 255., Quantity_TOC_RGB); anAIS->SetColor(aColor); Handle(AIS_Dimension) aDimAIS = Handle(AIS_Dimension)::DownCast(anAIS); if (!aDimAIS.IsNull()) { @@ -265,8 +246,8 @@ void GeomAPI_AISObject::setColor(int theR, int theG, int theB) bool GeomAPI_AISObject::empty() const { - Handle(AIS_InteractiveObject) anAIS = - const_cast(this)->impl(); + Handle(AIS_InteractiveObject) anAIS = const_cast(this) + ->impl(); if (anAIS.IsNull()) return true; return false; diff --git a/src/GeomAPI/GeomAPI_AISObject.h b/src/GeomAPI/GeomAPI_AISObject.h index 215aa69b7..574d39f13 100644 --- a/src/GeomAPI/GeomAPI_AISObject.h +++ b/src/GeomAPI/GeomAPI_AISObject.h @@ -30,7 +30,7 @@ struct GEOMAPI_EXPORT Colors class GEOMAPI_EXPORT GeomAPI_AISObject : public GeomAPI_Interface { -public: + public: /// \brief Creation of empty AIS object GeomAPI_AISObject(); @@ -47,8 +47,7 @@ public: void createDistance(boost::shared_ptr theStartPoint, boost::shared_ptr theEndPoint, boost::shared_ptr theFlyoutPoint, - boost::shared_ptr thePlane, - double theDistance); + boost::shared_ptr thePlane, double theDistance); /** \brief Creates AIS_RadiusDimension object * \param[in] theCircle the radius is created for this circle @@ -56,8 +55,7 @@ public: * \param[in] theRadius value of the radius to be shown */ void createRadius(boost::shared_ptr theCircle, - boost::shared_ptr theFlyoutPoint, - double theRadius); + boost::shared_ptr theFlyoutPoint, double theRadius); /** \brief Creates AIS_ParallelRelation object for two lines * \param[in] theLine1 first parallel line @@ -67,8 +65,8 @@ public: */ void createParallel(boost::shared_ptr theLine1, boost::shared_ptr theLine2, - boost::shared_ptr theFlyoutPoint, - boost::shared_ptr thePlane); + boost::shared_ptr theFlyoutPoint, + boost::shared_ptr thePlane); /** \brief Creates AIS_PerpendicularRelation object for two lines * \param[in] theLine1 first parallel line @@ -77,7 +75,7 @@ public: */ void createPerpendicular(boost::shared_ptr theLine1, boost::shared_ptr theLine2, - boost::shared_ptr thePlane); + boost::shared_ptr thePlane); /** \brief Assigns the color for the shape * \param[in] theColor index of the color diff --git a/src/GeomAPI/GeomAPI_Circ.cpp b/src/GeomAPI/GeomAPI_Circ.cpp index 31dbfab6c..566824e06 100644 --- a/src/GeomAPI/GeomAPI_Circ.cpp +++ b/src/GeomAPI/GeomAPI_Circ.cpp @@ -16,26 +16,23 @@ #define MY_CIRC static_cast(myImpl) -static gp_Circ* newCirc(const gp_Pnt& theCenter, - const gp_Dir& theDir, - const double theRadius) +static gp_Circ* newCirc(const gp_Pnt& theCenter, const gp_Dir& theDir, const double theRadius) { return new gp_Circ(gp_Ax2(theCenter, theDir), theRadius); } GeomAPI_Circ::GeomAPI_Circ(const boost::shared_ptr& theCenter, - const boost::shared_ptr& theDir, - double theRadius) - : GeomAPI_Interface(newCirc(theCenter->impl(), - theDir->impl(), theRadius)) + const boost::shared_ptr& theDir, double theRadius) + : GeomAPI_Interface(newCirc(theCenter->impl(), theDir->impl(), theRadius)) { } -const boost::shared_ptr GeomAPI_Circ::project(const boost::shared_ptr& thePoint) const +const boost::shared_ptr GeomAPI_Circ::project( + const boost::shared_ptr& thePoint) const { boost::shared_ptr aResult; if (!MY_CIRC) - return aResult; + return aResult; Handle(Geom_Circle) aCircle = new Geom_Circle(*MY_CIRC); @@ -43,18 +40,15 @@ const boost::shared_ptr GeomAPI_Circ::project(const boost::shared_p GeomAPI_ProjectPointOnCurve aProj(aPoint, aCircle); Standard_Integer aNbPoint = aProj.NbPoints(); - if (aNbPoint > 0) - { + if (aNbPoint > 0) { double aMinDistance = 0, aDistance; - for (Standard_Integer j = 1; j <= aNbPoint; j++) - { + for (Standard_Integer j = 1; j <= aNbPoint; j++) { gp_Pnt aNewPoint = aProj.Point(j); aDistance = aNewPoint.Distance(aPoint); - if (!aMinDistance || aDistance < aMinDistance) - { + if (!aMinDistance || aDistance < aMinDistance) { aMinDistance = aDistance; aResult = boost::shared_ptr( - new GeomAPI_Pnt(aNewPoint.X(), aNewPoint.Y(), aNewPoint.Z())); + new GeomAPI_Pnt(aNewPoint.X(), aNewPoint.Y(), aNewPoint.Z())); } } } diff --git a/src/GeomAPI/GeomAPI_Circ.h b/src/GeomAPI/GeomAPI_Circ.h index c74e76c01..37f8bfaf2 100644 --- a/src/GeomAPI/GeomAPI_Circ.h +++ b/src/GeomAPI/GeomAPI_Circ.h @@ -16,13 +16,12 @@ class GeomAPI_Dir; * \brief Circle in 3D */ -class GEOMAPI_EXPORT GeomAPI_Circ: public GeomAPI_Interface +class GEOMAPI_EXPORT GeomAPI_Circ : public GeomAPI_Interface { -public: + public: /// Creation of circle defined by center point, direction and circle radius GeomAPI_Circ(const boost::shared_ptr& theCenter, - const boost::shared_ptr& theDir, - double theRadius); + const boost::shared_ptr& theDir, double theRadius); /// Return center of the circle const boost::shared_ptr center() const; @@ -31,7 +30,8 @@ public: double radius() const; /// Project point on circle - const boost::shared_ptr project(const boost::shared_ptr& thePoint) const; + const boost::shared_ptr project( + const boost::shared_ptr& thePoint) const; }; #endif diff --git a/src/GeomAPI/GeomAPI_Circ2d.cpp b/src/GeomAPI/GeomAPI_Circ2d.cpp index 78c26d69f..65ef9b107 100644 --- a/src/GeomAPI/GeomAPI_Circ2d.cpp +++ b/src/GeomAPI/GeomAPI_Circ2d.cpp @@ -18,15 +18,15 @@ #define MY_CIRC2D static_cast(myImpl) -static gp_Circ2d* newCirc2d(const double theCenterX, const double theCenterY, - const gp_Dir2d theDir, const double theRadius) +static gp_Circ2d* newCirc2d(const double theCenterX, const double theCenterY, const gp_Dir2d theDir, + const double theRadius) { gp_Pnt2d aCenter(theCenterX, theCenterY); return new gp_Circ2d(gp_Ax2d(aCenter, theDir), theRadius); } static gp_Circ2d* newCirc2d(const double theCenterX, const double theCenterY, - const double thePointX, const double thePointY) + const double thePointX, const double thePointY) { gp_Pnt2d aCenter(theCenterX, theCenterY); gp_Pnt2d aPoint(thePointX, thePointY); @@ -34,35 +34,36 @@ static gp_Circ2d* newCirc2d(const double theCenterX, const double theCenterY, double aRadius = aCenter.Distance(aPoint); if (aCenter.IsEqual(aPoint, Precision::Confusion())) - return NULL; + return NULL; gp_Dir2d aDir(theCenterX - thePointX, theCenterY - thePointY); - + return newCirc2d(theCenterX, theCenterY, aDir, aRadius); } GeomAPI_Circ2d::GeomAPI_Circ2d(const boost::shared_ptr& theCenter, const boost::shared_ptr& theCirclePoint) - : GeomAPI_Interface(newCirc2d(theCenter->x(), theCenter->y(), - theCirclePoint->x(), theCirclePoint->y())) -{} + : GeomAPI_Interface( + newCirc2d(theCenter->x(), theCenter->y(), theCirclePoint->x(), theCirclePoint->y())) +{ +} GeomAPI_Circ2d::GeomAPI_Circ2d(const boost::shared_ptr& theCenter, - const boost::shared_ptr& theDir, - double theRadius) - : GeomAPI_Interface(newCirc2d(theCenter->x(), theCenter->y(), - theDir->impl(), theRadius)) + const boost::shared_ptr& theDir, double theRadius) + : GeomAPI_Interface( + newCirc2d(theCenter->x(), theCenter->y(), theDir->impl(), theRadius)) { } -const boost::shared_ptr GeomAPI_Circ2d::project(const boost::shared_ptr& thePoint) const +const boost::shared_ptr GeomAPI_Circ2d::project( + const boost::shared_ptr& thePoint) const { boost::shared_ptr aResult; if (!MY_CIRC2D) - return aResult; + return aResult; - Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(MY_CIRC2D->Axis(), MY_CIRC2D->Radius());//(aCirc); + Handle(Geom2d_Circle) aCircle = new Geom2d_Circle(MY_CIRC2D->Axis(), MY_CIRC2D->Radius()); //(aCirc); const gp_Pnt2d& aPoint = thePoint->impl(); diff --git a/src/GeomAPI/GeomAPI_Circ2d.h b/src/GeomAPI/GeomAPI_Circ2d.h index d4ec763e4..58a292c16 100644 --- a/src/GeomAPI/GeomAPI_Circ2d.h +++ b/src/GeomAPI/GeomAPI_Circ2d.h @@ -16,17 +16,16 @@ class GeomAPI_Dir2d; * \brief Circle in 2D */ -class GEOMAPI_EXPORT GeomAPI_Circ2d: public GeomAPI_Interface +class GEOMAPI_EXPORT GeomAPI_Circ2d : public GeomAPI_Interface { -public: + public: /// Creation of circle defined by center point and circle radius GeomAPI_Circ2d(const boost::shared_ptr& theCenter, const boost::shared_ptr& theCirclePoint); /// Creation of circle defined by center point, direction and circle radius GeomAPI_Circ2d(const boost::shared_ptr& theCenter, - const boost::shared_ptr& theDir, - double theRadius); + const boost::shared_ptr& theDir, double theRadius); /// Return center of the circle const boost::shared_ptr center() const; @@ -35,7 +34,8 @@ public: double radius() const; /// Project point on line - const boost::shared_ptr project(const boost::shared_ptr& thePoint) const; + const boost::shared_ptr project( + const boost::shared_ptr& thePoint) const; }; #endif diff --git a/src/GeomAPI/GeomAPI_Dir.cpp b/src/GeomAPI/GeomAPI_Dir.cpp index e3badb440..c1b88a78d 100644 --- a/src/GeomAPI/GeomAPI_Dir.cpp +++ b/src/GeomAPI/GeomAPI_Dir.cpp @@ -10,12 +10,14 @@ #define MY_DIR static_cast(myImpl) GeomAPI_Dir::GeomAPI_Dir(const double theX, const double theY, const double theZ) - : GeomAPI_Interface(new gp_Dir(theX, theY, theZ)) -{} + : GeomAPI_Interface(new gp_Dir(theX, theY, theZ)) +{ +} GeomAPI_Dir::GeomAPI_Dir(const boost::shared_ptr& theCoords) - : GeomAPI_Interface(new gp_Dir(theCoords->x(), theCoords->y(), theCoords->z())) -{} + : GeomAPI_Interface(new gp_Dir(theCoords->x(), theCoords->y(), theCoords->z())) +{ +} double GeomAPI_Dir::x() const { @@ -32,7 +34,7 @@ double GeomAPI_Dir::z() const return MY_DIR->Z(); } -const boost::shared_ptr GeomAPI_Dir::xyz() +const boost::shared_ptr GeomAPI_Dir::xyz() { return boost::shared_ptr(new GeomAPI_XYZ(MY_DIR->X(), MY_DIR->Y(), MY_DIR->Z())); } @@ -42,7 +44,8 @@ double GeomAPI_Dir::dot(const boost::shared_ptr& theArg) const return MY_DIR->Dot(theArg->impl()); } -const boost::shared_ptr GeomAPI_Dir::cross(const boost::shared_ptr& theArg) const +const boost::shared_ptr GeomAPI_Dir::cross( + const boost::shared_ptr& theArg) const { gp_XYZ aResult = MY_DIR->XYZ().Crossed(theArg->impl().XYZ()); return boost::shared_ptr(new GeomAPI_XYZ(aResult.X(), aResult.Y(), aResult.Z())); diff --git a/src/GeomAPI/GeomAPI_Dir.h b/src/GeomAPI/GeomAPI_Dir.h index 223eb7452..3d666af67 100644 --- a/src/GeomAPI/GeomAPI_Dir.h +++ b/src/GeomAPI/GeomAPI_Dir.h @@ -15,9 +15,9 @@ class GeomAPI_XYZ; * \brief 3D direction defined by three normalized coordinates */ -class GEOMAPI_EXPORT GeomAPI_Dir: public GeomAPI_Interface +class GEOMAPI_EXPORT GeomAPI_Dir : public GeomAPI_Interface { -public: + public: /// Creation of direction by coordinates GeomAPI_Dir(const double theX, const double theY, const double theZ); /// Creation of direction by coordinates diff --git a/src/GeomAPI/GeomAPI_Dir2d.cpp b/src/GeomAPI/GeomAPI_Dir2d.cpp index fd795ab19..e3089d8b9 100644 --- a/src/GeomAPI/GeomAPI_Dir2d.cpp +++ b/src/GeomAPI/GeomAPI_Dir2d.cpp @@ -10,12 +10,14 @@ #define MY_DIR static_cast(myImpl) GeomAPI_Dir2d::GeomAPI_Dir2d(const double theX, const double theY) - : GeomAPI_Interface(new gp_Dir2d(theX, theY)) -{} + : GeomAPI_Interface(new gp_Dir2d(theX, theY)) +{ +} GeomAPI_Dir2d::GeomAPI_Dir2d(const boost::shared_ptr& theCoords) - : GeomAPI_Interface(new gp_Dir2d(theCoords->x(), theCoords->y())) -{} + : GeomAPI_Interface(new gp_Dir2d(theCoords->x(), theCoords->y())) +{ +} double GeomAPI_Dir2d::x() const { @@ -27,7 +29,7 @@ double GeomAPI_Dir2d::y() const return MY_DIR->Y(); } -const boost::shared_ptr GeomAPI_Dir2d::xy() +const boost::shared_ptr GeomAPI_Dir2d::xy() { return boost::shared_ptr(new GeomAPI_XY(MY_DIR->X(), MY_DIR->Y())); } diff --git a/src/GeomAPI/GeomAPI_Dir2d.h b/src/GeomAPI/GeomAPI_Dir2d.h index e31059f44..906e1af0f 100644 --- a/src/GeomAPI/GeomAPI_Dir2d.h +++ b/src/GeomAPI/GeomAPI_Dir2d.h @@ -15,9 +15,9 @@ class GeomAPI_XY; * \brief 2D direction defined by three normalized coordinates */ -class GEOMAPI_EXPORT GeomAPI_Dir2d: public GeomAPI_Interface +class GEOMAPI_EXPORT GeomAPI_Dir2d : public GeomAPI_Interface { -public: + public: /// Creation of direction by coordinates GeomAPI_Dir2d(const double theX, const double theY); /// Creation of direction by coordinates diff --git a/src/GeomAPI/GeomAPI_Edge.cpp b/src/GeomAPI/GeomAPI_Edge.cpp index 8d8bf022a..4e95756cb 100644 --- a/src/GeomAPI/GeomAPI_Edge.cpp +++ b/src/GeomAPI/GeomAPI_Edge.cpp @@ -12,15 +12,16 @@ #include GeomAPI_Edge::GeomAPI_Edge() - : GeomAPI_Shape() -{} + : GeomAPI_Shape() +{ +} bool GeomAPI_Edge::isLine() const { const TopoDS_Shape& aShape = const_cast(this)->impl(); Handle(BRep_TEdge) anEdge = Handle(BRep_TEdge)::DownCast(aShape.TShape()); if (anEdge->Curves().Extent() != 1) - return false; // too many curves in the edge + return false; // too many curves in the edge Handle(Geom_Curve) aCurve = anEdge->Curves().First()->Curve3D(); if (aCurve->IsKind(STANDARD_TYPE(Geom_Line))) return true; @@ -32,7 +33,7 @@ bool GeomAPI_Edge::isCircle() const const TopoDS_Shape& aShape = const_cast(this)->impl(); Handle(BRep_TEdge) anEdge = Handle(BRep_TEdge)::DownCast(aShape.TShape()); if (anEdge->Curves().Extent() != 1) - return false; // too many curves in the edge + return false; // too many curves in the edge Handle(Geom_Curve) aCurve = anEdge->Curves().First()->Curve3D(); if (aCurve->IsKind(STANDARD_TYPE(Geom_Circle)) && aCurve->IsClosed()) return true; @@ -44,7 +45,7 @@ bool GeomAPI_Edge::isArc() const const TopoDS_Shape& aShape = const_cast(this)->impl(); Handle(BRep_TEdge) anEdge = Handle(BRep_TEdge)::DownCast(aShape.TShape()); if (anEdge->Curves().Extent() != 1) - return false; // too many curves in the edge + return false; // too many curves in the edge Handle(Geom_Curve) aCurve = anEdge->Curves().First()->Curve3D(); if (aCurve->IsKind(STANDARD_TYPE(Geom_Circle)) && !aCurve->IsClosed()) return true; diff --git a/src/GeomAPI/GeomAPI_Edge.h b/src/GeomAPI/GeomAPI_Edge.h index bd186c22b..f1c74c5d5 100644 --- a/src/GeomAPI/GeomAPI_Edge.h +++ b/src/GeomAPI/GeomAPI_Edge.h @@ -12,19 +12,23 @@ * \brief Interface to the edge object */ -class GEOMAPI_EXPORT GeomAPI_Edge: public GeomAPI_Shape +class GEOMAPI_EXPORT GeomAPI_Edge : public GeomAPI_Shape { -public: + public: /// Creation of empty (null) shape GeomAPI_Edge(); /// Returns whether the shape is a vertex virtual bool isVertex() const - { return false; } + { + return false; + } /// Returns whether the shape is an edge virtual bool isEdge() const - { return true; } + { + return true; + } /// Verifies that the edge is a line bool isLine() const; diff --git a/src/GeomAPI/GeomAPI_IPresentable.h b/src/GeomAPI/GeomAPI_IPresentable.h index c300c1b42..34868048a 100644 --- a/src/GeomAPI/GeomAPI_IPresentable.h +++ b/src/GeomAPI/GeomAPI_IPresentable.h @@ -8,14 +8,14 @@ #include "GeomAPI_AISObject.h" /** -* A class which defines an interface of object which is able to create its own presentation -*/ + * A class which defines an interface of object which is able to create its own presentation + */ class GeomAPI_IPresentable { -public: + public: /** Returns the AIS preview - * \param thePrevious - defines a presentation if it was created previously - */ + * \param thePrevious - defines a presentation if it was created previously + */ virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious) = 0; }; diff --git a/src/GeomAPI/GeomAPI_Interface.h b/src/GeomAPI/GeomAPI_Interface.h index 141571688..3dca34854 100644 --- a/src/GeomAPI/GeomAPI_Interface.h +++ b/src/GeomAPI/GeomAPI_Interface.h @@ -14,23 +14,29 @@ class GEOMAPI_EXPORT GeomAPI_Interface { -protected: - void* myImpl; ///< pointer to the internal impl object + protected: + void* myImpl; ///< pointer to the internal impl object -public: + public: /// None - constructor GeomAPI_Interface(); /// Constructor by the impl pointer (used for internal needs) GeomAPI_Interface(void* theImpl); - + /// Destructor virtual ~GeomAPI_Interface(); /// Returns the pointer to the impl - template inline T* implPtr() {return static_cast(myImpl);} + template inline T* implPtr() + { + return static_cast(myImpl); + } /// Returns the reference object of the impl - template inline const T& impl() {return *(static_cast(myImpl));} + template inline const T& impl() + { + return *(static_cast(myImpl)); + } /// Updates the impl (deletes the old one) void setImpl(void* theImpl); }; diff --git a/src/GeomAPI/GeomAPI_Lin.cpp b/src/GeomAPI/GeomAPI_Lin.cpp index 9d0407024..58095f0e8 100644 --- a/src/GeomAPI/GeomAPI_Lin.cpp +++ b/src/GeomAPI/GeomAPI_Lin.cpp @@ -20,24 +20,25 @@ #define MY_LIN static_cast(myImpl) static gp_Lin* newLine(const double theStartX, const double theStartY, const double theStartZ, - const double theEndX, const double theEndY, const double theEndZ) + const double theEndX, const double theEndY, const double theEndZ) { gp_XYZ aDir(theEndX - theStartX, theEndY - theStartY, theEndZ - theStartZ); gp_Pnt aStart(theStartX, theStartY, theStartZ); return new gp_Lin(aStart, gp_Dir(aDir)); } - GeomAPI_Lin::GeomAPI_Lin(const double theStartX, const double theStartY, const double theStartZ, - const double theEndX, const double theEndY, const double theEndZ) - : GeomAPI_Interface(newLine(theStartX, theStartY, theStartZ, theEndX, theEndY, theEndZ)) -{} + const double theEndX, const double theEndY, const double theEndZ) + : GeomAPI_Interface(newLine(theStartX, theStartY, theStartZ, theEndX, theEndY, theEndZ)) +{ +} GeomAPI_Lin::GeomAPI_Lin(const boost::shared_ptr& theStart, const boost::shared_ptr& theEnd) - : GeomAPI_Interface(newLine(theStart->x(), theStart->y(), theStart->z(), - theEnd->x(), theEnd->y(), theEnd->z())) -{} + : GeomAPI_Interface( + newLine(theStart->x(), theStart->y(), theStart->z(), theEnd->x(), theEnd->y(), theEnd->z())) +{ +} double GeomAPI_Lin::distance(const boost::shared_ptr& thePoint) const { @@ -45,30 +46,31 @@ double GeomAPI_Lin::distance(const boost::shared_ptr& thePoint) con } const boost::shared_ptr GeomAPI_Lin::intersect( - const boost::shared_ptr& theLine) const + const boost::shared_ptr& theLine) const { if (MY_LIN->SquareDistance(theLine->impl()) > Precision::Confusion()) - return boost::shared_ptr(); + return boost::shared_ptr(); const gp_Dir& aDir1 = MY_LIN->Direction(); const gp_Dir& aDir2 = theLine->impl().Direction(); gp_Dir aCross = aDir1.Crossed(aDir2); - gp_Pln aPlane(MY_LIN->Location(), aCross); // plane containing both lines + gp_Pln aPlane(MY_LIN->Location(), aCross); // plane containing both lines gp_Lin2d aPrjLine1 = ProjLib::Project(aPlane, *MY_LIN); gp_Lin2d aPrjLine2 = ProjLib::Project(aPlane, theLine->impl()); IntAna2d_AnaIntersection anInter(aPrjLine1, aPrjLine1); if (!anInter.IsDone() || anInter.IsEmpty()) - return boost::shared_ptr(); + return boost::shared_ptr(); const gp_Pnt2d& anIntPnt2d = anInter.Point(0).Value(); gp_Pnt aResult = ElSLib::Value(anIntPnt2d.X(), anIntPnt2d.Y(), aPlane); return boost::shared_ptr( - new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z())); + new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z())); } -const boost::shared_ptr GeomAPI_Lin::project(const boost::shared_ptr& thePoint) const +const boost::shared_ptr GeomAPI_Lin::project( + const boost::shared_ptr& thePoint) const { const gp_XYZ& aDir = MY_LIN->Direction().XYZ(); const gp_XYZ& aLoc = MY_LIN->Location().XYZ(); diff --git a/src/GeomAPI/GeomAPI_Lin.h b/src/GeomAPI/GeomAPI_Lin.h index b0b3e265f..69d1ba48a 100644 --- a/src/GeomAPI/GeomAPI_Lin.h +++ b/src/GeomAPI/GeomAPI_Lin.h @@ -15,12 +15,12 @@ class GeomAPI_Pnt; * \brief Line in 3D */ -class GEOMAPI_EXPORT GeomAPI_Lin: public GeomAPI_Interface +class GEOMAPI_EXPORT GeomAPI_Lin : public GeomAPI_Interface { -public: + public: /// Creation of line defined by cordinates of start and end points GeomAPI_Lin(const double theStartX, const double theStartY, const double theStartZ, - const double theEndX, const double theEndY, const double theEndZ); + const double theEndX, const double theEndY, const double theEndZ); /// Creation of line defined by start and end points GeomAPI_Lin(const boost::shared_ptr& theStart, const boost::shared_ptr& theEnd); @@ -28,9 +28,11 @@ public: /// Distance between two points double distance(const boost::shared_ptr& thePoint) const; /// Intersection of two lines - const boost::shared_ptr intersect(const boost::shared_ptr& theLine) const; + const boost::shared_ptr intersect( + const boost::shared_ptr& theLine) const; /// Project point on line - const boost::shared_ptr project(const boost::shared_ptr& thePoint) const; + const boost::shared_ptr project( + const boost::shared_ptr& thePoint) const; }; #endif diff --git a/src/GeomAPI/GeomAPI_Lin2d.cpp b/src/GeomAPI/GeomAPI_Lin2d.cpp index 5267000f3..1e902f4b5 100644 --- a/src/GeomAPI/GeomAPI_Lin2d.cpp +++ b/src/GeomAPI/GeomAPI_Lin2d.cpp @@ -14,25 +14,25 @@ #define MY_LIN2D static_cast(myImpl) -static gp_Lin2d* newLine2d(const double theStartX, const double theStartY, - const double theEndX, const double theEndY) +static gp_Lin2d* newLine2d(const double theStartX, const double theStartY, const double theEndX, + const double theEndY) { gp_XY aDir(theEndX - theStartX, theEndY - theStartY); gp_Pnt2d aStart(theStartX, theStartY); return new gp_Lin2d(aStart, gp_Dir2d(aDir)); } - -GeomAPI_Lin2d::GeomAPI_Lin2d(const double theStartX, const double theStartY, - const double theEndX, const double theEndY) - : GeomAPI_Interface(newLine2d(theStartX, theStartY, theEndX, theEndY)) -{} +GeomAPI_Lin2d::GeomAPI_Lin2d(const double theStartX, const double theStartY, const double theEndX, + const double theEndY) + : GeomAPI_Interface(newLine2d(theStartX, theStartY, theEndX, theEndY)) +{ +} GeomAPI_Lin2d::GeomAPI_Lin2d(const boost::shared_ptr& theStart, - const boost::shared_ptr& theEnd) - : GeomAPI_Interface(newLine2d(theStart->x(), theStart->y(), - theEnd->x(), theEnd->y())) -{} + const boost::shared_ptr& theEnd) + : GeomAPI_Interface(newLine2d(theStart->x(), theStart->y(), theEnd->x(), theEnd->y())) +{ +} double GeomAPI_Lin2d::distance(const boost::shared_ptr& theOther) const { @@ -40,16 +40,17 @@ double GeomAPI_Lin2d::distance(const boost::shared_ptr& theOther) } const boost::shared_ptr GeomAPI_Lin2d::intersect( - const boost::shared_ptr& theLine) const + const boost::shared_ptr& theLine) const { IntAna2d_AnaIntersection anInter(*MY_LIN2D, theLine->impl()); if (!anInter.IsDone() || anInter.IsEmpty()) - return boost::shared_ptr(); + return boost::shared_ptr(); const gp_Pnt2d& aResult = anInter.Point(1).Value(); return boost::shared_ptr(new GeomAPI_Pnt2d(aResult.X(), aResult.Y())); } -const boost::shared_ptr GeomAPI_Lin2d::project(const boost::shared_ptr& thePoint) const +const boost::shared_ptr GeomAPI_Lin2d::project( + const boost::shared_ptr& thePoint) const { const gp_XY& aDir = MY_LIN2D->Direction().XY(); const gp_XY& aLoc = MY_LIN2D->Location().XY(); diff --git a/src/GeomAPI/GeomAPI_Lin2d.h b/src/GeomAPI/GeomAPI_Lin2d.h index b213a0d4d..82afee29a 100644 --- a/src/GeomAPI/GeomAPI_Lin2d.h +++ b/src/GeomAPI/GeomAPI_Lin2d.h @@ -15,12 +15,12 @@ class GeomAPI_Pnt2d; * \brief Line in 2D */ -class GEOMAPI_EXPORT GeomAPI_Lin2d: public GeomAPI_Interface +class GEOMAPI_EXPORT GeomAPI_Lin2d : public GeomAPI_Interface { -public: + public: /// Creation of line defined by cordinates of start and end points - GeomAPI_Lin2d(const double theStartX, const double theStartY, - const double theEndX, const double theEndY); + GeomAPI_Lin2d(const double theStartX, const double theStartY, const double theEndX, + const double theEndY); /// Creation of line defined by start and end points GeomAPI_Lin2d(const boost::shared_ptr& theStart, const boost::shared_ptr& theEnd); @@ -28,9 +28,11 @@ public: /// Distance between two points double distance(const boost::shared_ptr& theOther) const; /// Intersection of two lines - const boost::shared_ptr intersect(const boost::shared_ptr& theLine) const; + const boost::shared_ptr intersect( + const boost::shared_ptr& theLine) const; /// Project point on line - const boost::shared_ptr project(const boost::shared_ptr& thePoint) const; + const boost::shared_ptr project( + const boost::shared_ptr& thePoint) const; /// Computes the cross product of the line direction and a vector from the line start point to the point bool isRight(const boost::shared_ptr& thePoint) const; }; diff --git a/src/GeomAPI/GeomAPI_Pln.cpp b/src/GeomAPI/GeomAPI_Pln.cpp index 5780b3d81..2f4e0cec4 100644 --- a/src/GeomAPI/GeomAPI_Pln.cpp +++ b/src/GeomAPI/GeomAPI_Pln.cpp @@ -11,15 +11,13 @@ using namespace std; GeomAPI_Pln::GeomAPI_Pln(const boost::shared_ptr& thePoint, - const boost::shared_ptr& theNormal) -: GeomAPI_Interface(new gp_Pln(thePoint->impl(), - theNormal->impl())) + const boost::shared_ptr& theNormal) + : GeomAPI_Interface(new gp_Pln(thePoint->impl(), theNormal->impl())) { } -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)) +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)) { } diff --git a/src/GeomAPI/GeomAPI_Pln.h b/src/GeomAPI/GeomAPI_Pln.h index c0d0d69f1..5471a34ad 100644 --- a/src/GeomAPI/GeomAPI_Pln.h +++ b/src/GeomAPI/GeomAPI_Pln.h @@ -16,9 +16,9 @@ class GeomAPI_Dir; * \brief 3D point defined by three coordinates */ -class GEOMAPI_EXPORT GeomAPI_Pln: public GeomAPI_Interface +class GEOMAPI_EXPORT GeomAPI_Pln : public GeomAPI_Interface { -public: + public: /// Creation of plane by the point and normal GeomAPI_Pln(const boost::shared_ptr& thePoint, const boost::shared_ptr& theNormal); diff --git a/src/GeomAPI/GeomAPI_Pnt.cpp b/src/GeomAPI/GeomAPI_Pnt.cpp index abf73f07b..0455c1513 100644 --- a/src/GeomAPI/GeomAPI_Pnt.cpp +++ b/src/GeomAPI/GeomAPI_Pnt.cpp @@ -10,12 +10,14 @@ #define MY_PNT static_cast(myImpl) GeomAPI_Pnt::GeomAPI_Pnt(const double theX, const double theY, const double theZ) - : GeomAPI_Interface(new gp_Pnt(theX, theY, theZ)) -{} + : GeomAPI_Interface(new gp_Pnt(theX, theY, theZ)) +{ +} GeomAPI_Pnt::GeomAPI_Pnt(const boost::shared_ptr& theCoords) - : GeomAPI_Interface(new gp_Pnt(theCoords->x(), theCoords->y(), theCoords->z())) -{} + : GeomAPI_Interface(new gp_Pnt(theCoords->x(), theCoords->y(), theCoords->z())) +{ +} double GeomAPI_Pnt::x() const { @@ -47,7 +49,7 @@ void GeomAPI_Pnt::setZ(const double theZ) return MY_PNT->SetZ(theZ); } -const boost::shared_ptr GeomAPI_Pnt::xyz() +const boost::shared_ptr GeomAPI_Pnt::xyz() { return boost::shared_ptr(new GeomAPI_XYZ(MY_PNT->X(), MY_PNT->Y(), MY_PNT->Z())); } diff --git a/src/GeomAPI/GeomAPI_Pnt.h b/src/GeomAPI/GeomAPI_Pnt.h index 3991b0977..6e4e527d5 100644 --- a/src/GeomAPI/GeomAPI_Pnt.h +++ b/src/GeomAPI/GeomAPI_Pnt.h @@ -15,9 +15,9 @@ class GeomAPI_XYZ; * \brief 3D point defined by three coordinates */ -class GEOMAPI_EXPORT GeomAPI_Pnt: public GeomAPI_Interface +class GEOMAPI_EXPORT GeomAPI_Pnt : public GeomAPI_Interface { -public: + public: /// Creation of point by coordinates GeomAPI_Pnt(const double theX, const double theY, const double theZ); /// Creation of point by coordinates diff --git a/src/GeomAPI/GeomAPI_Pnt2d.cpp b/src/GeomAPI/GeomAPI_Pnt2d.cpp index e1cdf3d28..70bc64693 100644 --- a/src/GeomAPI/GeomAPI_Pnt2d.cpp +++ b/src/GeomAPI/GeomAPI_Pnt2d.cpp @@ -13,12 +13,14 @@ #define MY_PNT2D static_cast(myImpl) GeomAPI_Pnt2d::GeomAPI_Pnt2d(const double theX, const double theY) - : GeomAPI_Interface(new gp_Pnt2d(theX, theY)) -{} + : GeomAPI_Interface(new gp_Pnt2d(theX, theY)) +{ +} GeomAPI_Pnt2d::GeomAPI_Pnt2d(const boost::shared_ptr& theCoords) - : GeomAPI_Interface(new gp_Pnt2d(theCoords->x(), theCoords->y())) -{} + : GeomAPI_Interface(new gp_Pnt2d(theCoords->x(), theCoords->y())) +{ +} double GeomAPI_Pnt2d::x() const { @@ -44,8 +46,8 @@ boost::shared_ptr GeomAPI_Pnt2d::to3D(const boost::shared_ptr& theDirX, const boost::shared_ptr& theDirY) { - boost::shared_ptr aSum = theOrigin->xyz()->added( - theDirX->xyz()->multiplied(x()))->added(theDirY->xyz()->multiplied(y())); + boost::shared_ptr aSum = theOrigin->xyz()->added(theDirX->xyz()->multiplied(x())) + ->added(theDirY->xyz()->multiplied(y())); return boost::shared_ptr(new GeomAPI_Pnt(aSum)); } diff --git a/src/GeomAPI/GeomAPI_Pnt2d.h b/src/GeomAPI/GeomAPI_Pnt2d.h index eaea875cc..b7f978908 100644 --- a/src/GeomAPI/GeomAPI_Pnt2d.h +++ b/src/GeomAPI/GeomAPI_Pnt2d.h @@ -17,9 +17,9 @@ class GeomAPI_Dir; * \brief 2D point defined by two coordinates */ -class GEOMAPI_EXPORT GeomAPI_Pnt2d: public GeomAPI_Interface +class GEOMAPI_EXPORT GeomAPI_Pnt2d : public GeomAPI_Interface { -public: + public: /// Creation of point by coordinates GeomAPI_Pnt2d(const double theX, const double theY); /// Creation of point by coordinates diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index 10bd21df9..30e2f3425 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -9,7 +9,8 @@ #define MY_PNT static_cast(myImpl) GeomAPI_Shape::GeomAPI_Shape() - : GeomAPI_Interface(new TopoDS_Shape()) { + : GeomAPI_Interface(new TopoDS_Shape()) +{ } bool GeomAPI_Shape::isNull() @@ -17,7 +18,6 @@ bool GeomAPI_Shape::isNull() return MY_SHAPE->IsNull(); } - bool GeomAPI_Shape::isVertex() const { const TopoDS_Shape& aShape = const_cast(this)->impl(); diff --git a/src/GeomAPI/GeomAPI_Shape.h b/src/GeomAPI/GeomAPI_Shape.h index 4b526589f..64292dee3 100644 --- a/src/GeomAPI/GeomAPI_Shape.h +++ b/src/GeomAPI/GeomAPI_Shape.h @@ -15,9 +15,9 @@ class TopoDS_Shape; #define MY_SHAPE static_cast(myImpl) -class GEOMAPI_EXPORT GeomAPI_Shape: public GeomAPI_Interface +class GEOMAPI_EXPORT GeomAPI_Shape : public GeomAPI_Interface { -public: + public: /// Creation of empty (null) shape GeomAPI_Shape(); diff --git a/src/GeomAPI/GeomAPI_XY.cpp b/src/GeomAPI/GeomAPI_XY.cpp index 94341c31e..d3c2b86f3 100644 --- a/src/GeomAPI/GeomAPI_XY.cpp +++ b/src/GeomAPI/GeomAPI_XY.cpp @@ -9,8 +9,9 @@ #define MY_XY static_cast(myImpl) GeomAPI_XY::GeomAPI_XY(const double theX, const double theY) - : GeomAPI_Interface(new gp_XY(theX, theY)) -{} + : GeomAPI_Interface(new gp_XY(theX, theY)) +{ +} double GeomAPI_XY::x() const { @@ -32,18 +33,15 @@ void GeomAPI_XY::setY(const double theY) return MY_XY->SetY(theY); } -const boost::shared_ptr GeomAPI_XY::added( - const boost::shared_ptr& theArg) +const boost::shared_ptr GeomAPI_XY::added(const boost::shared_ptr& theArg) { - boost::shared_ptr aResult( - new GeomAPI_XY(MY_XY->X() + theArg->x(), MY_XY->Y() + theArg->y())); + boost::shared_ptr aResult(new GeomAPI_XY(MY_XY->X() + theArg->x(), MY_XY->Y() + theArg->y())); return aResult; } const boost::shared_ptr GeomAPI_XY::multiplied(const double theArg) { - boost::shared_ptr aResult( - new GeomAPI_XY(MY_XY->X() * theArg, MY_XY->Y() * theArg)); + boost::shared_ptr aResult(new GeomAPI_XY(MY_XY->X() * theArg, MY_XY->Y() * theArg)); return aResult; } diff --git a/src/GeomAPI/GeomAPI_XY.h b/src/GeomAPI/GeomAPI_XY.h index 1ff89a8f6..5e0fef8c9 100644 --- a/src/GeomAPI/GeomAPI_XY.h +++ b/src/GeomAPI/GeomAPI_XY.h @@ -13,9 +13,9 @@ * \brief 2 coordinates: they may represent vector or point or something else */ -class GEOMAPI_EXPORT GeomAPI_XY: public GeomAPI_Interface +class GEOMAPI_EXPORT GeomAPI_XY : public GeomAPI_Interface { -public: + public: /// Creation by coordinates GeomAPI_XY(const double theX, const double theY); diff --git a/src/GeomAPI/GeomAPI_XYZ.cpp b/src/GeomAPI/GeomAPI_XYZ.cpp index f413005fd..37ba3aa9f 100644 --- a/src/GeomAPI/GeomAPI_XYZ.cpp +++ b/src/GeomAPI/GeomAPI_XYZ.cpp @@ -9,8 +9,9 @@ #define MY_XYZ static_cast(myImpl) GeomAPI_XYZ::GeomAPI_XYZ(const double theX, const double theY, const double theZ) - : GeomAPI_Interface(new gp_XYZ(theX, theY, theZ)) -{} + : GeomAPI_Interface(new gp_XYZ(theX, theY, theZ)) +{ +} double GeomAPI_XYZ::x() const { @@ -43,25 +44,25 @@ void GeomAPI_XYZ::setZ(const double theZ) } const boost::shared_ptr GeomAPI_XYZ::added( - const boost::shared_ptr& theArg) + const boost::shared_ptr& theArg) { boost::shared_ptr aResult(new GeomAPI_XYZ(MY_XYZ->X() + theArg->x(), - MY_XYZ->Y() + theArg->y(), MY_XYZ->Z() + theArg->z())); + MY_XYZ->Y() + theArg->y(), MY_XYZ->Z() + theArg->z())); return aResult; } const boost::shared_ptr GeomAPI_XYZ::decreased( - const boost::shared_ptr& theArg) + const boost::shared_ptr& theArg) { boost::shared_ptr aResult(new GeomAPI_XYZ(MY_XYZ->X() - theArg->x(), - MY_XYZ->Y() - theArg->y(), MY_XYZ->Z() - theArg->z())); + MY_XYZ->Y() - theArg->y(), MY_XYZ->Z() - theArg->z())); return aResult; } const boost::shared_ptr GeomAPI_XYZ::multiplied(const double theArg) { boost::shared_ptr aResult(new GeomAPI_XYZ(MY_XYZ->X() * theArg, - MY_XYZ->Y() * theArg, MY_XYZ->Z() * theArg)); + MY_XYZ->Y() * theArg, MY_XYZ->Z() * theArg)); return aResult; } @@ -70,7 +71,8 @@ double GeomAPI_XYZ::dot(const boost::shared_ptr& theArg) const return MY_XYZ->Dot(theArg->impl()); } -const boost::shared_ptr GeomAPI_XYZ::cross(const boost::shared_ptr& theArg) const +const boost::shared_ptr GeomAPI_XYZ::cross( + const boost::shared_ptr& theArg) const { gp_XYZ aResult = MY_XYZ->Crossed(theArg->impl()); return boost::shared_ptr(new GeomAPI_XYZ(aResult.X(), aResult.Y(), aResult.Z())); diff --git a/src/GeomAPI/GeomAPI_XYZ.h b/src/GeomAPI/GeomAPI_XYZ.h index 840362535..eadee91a3 100644 --- a/src/GeomAPI/GeomAPI_XYZ.h +++ b/src/GeomAPI/GeomAPI_XYZ.h @@ -13,9 +13,9 @@ * \brief 3 coordinates: they may represent vector or point or something else */ -class GEOMAPI_EXPORT GeomAPI_XYZ: public GeomAPI_Interface +class GEOMAPI_EXPORT GeomAPI_XYZ : public GeomAPI_Interface { -public: + public: /// Creation by coordinates GeomAPI_XYZ(const double theX, const double theY, const double theZ); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.cpp index 2882ee2fa..934390faa 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.cpp @@ -9,15 +9,15 @@ #include #include -boost::shared_ptr GeomAlgoAPI_CompoundBuilder::compound - (std::list > theShapes) +boost::shared_ptr GeomAlgoAPI_CompoundBuilder::compound( + std::list > theShapes) { BRep_Builder aBuilder; TopoDS_Compound aComp; aBuilder.MakeCompound(aComp); - std::list >::const_iterator anIt = theShapes.begin(), - aLast = theShapes.end(); + std::list >::const_iterator anIt = theShapes.begin(), aLast = + theShapes.end(); for (; anIt != aLast; anIt++) { aBuilder.Add(aComp, (*anIt)->impl()); } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.h b/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.h index ea727ef9e..bf9f8374a 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.h @@ -20,11 +20,11 @@ class GEOMALGOAPI_EXPORT GeomAlgoAPI_CompoundBuilder { -public: + public: /// Creates compund of the given shapes /// \param theShapes a list of shapes - static boost::shared_ptr compound - (std::list > theShapes); + static boost::shared_ptr compound( + std::list > theShapes); }; #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp index 0e622ba36..5f3aba03e 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.cpp @@ -14,7 +14,7 @@ #include boost::shared_ptr GeomAlgoAPI_EdgeBuilder::line( - boost::shared_ptr theStart, boost::shared_ptr theEnd) + boost::shared_ptr theStart, boost::shared_ptr theEnd) { const gp_Pnt& aStart = theStart->impl(); const gp_Pnt& anEnd = theEnd->impl(); @@ -31,8 +31,8 @@ boost::shared_ptr GeomAlgoAPI_EdgeBuilder::line( } boost::shared_ptr GeomAlgoAPI_EdgeBuilder::lineCircle( - boost::shared_ptr theCenter, - boost::shared_ptr theNormal, double theRadius) + boost::shared_ptr theCenter, boost::shared_ptr theNormal, + double theRadius) { const gp_Pnt& aCenter = theCenter->impl(); const gp_Dir& aDir = theNormal->impl(); @@ -47,10 +47,8 @@ boost::shared_ptr GeomAlgoAPI_EdgeBuilder::lineCircle( } boost::shared_ptr GeomAlgoAPI_EdgeBuilder::lineCircleArc( - boost::shared_ptr theCenter, - boost::shared_ptr theStartPoint, - boost::shared_ptr theEndPoint, - boost::shared_ptr theNormal) + boost::shared_ptr theCenter, boost::shared_ptr theStartPoint, + boost::shared_ptr theEndPoint, boost::shared_ptr theNormal) { const gp_Pnt& aCenter = theCenter->impl(); const gp_Dir& aDir = theNormal->impl(); @@ -62,8 +60,8 @@ boost::shared_ptr GeomAlgoAPI_EdgeBuilder::lineCircleArc( const gp_Pnt& anEnd = theEndPoint->impl(); BRepBuilderAPI_MakeEdge anEdgeBuilder; - if (aStart.IsEqual(anEnd, Precision::Confusion()) || - gp_Pnt(0, 0, 0).IsEqual(anEnd, Precision::Confusion())) + if (aStart.IsEqual(anEnd, Precision::Confusion()) + || gp_Pnt(0, 0, 0).IsEqual(anEnd, Precision::Confusion())) anEdgeBuilder = BRepBuilderAPI_MakeEdge(aCircle); else anEdgeBuilder = BRepBuilderAPI_MakeEdge(aCircle, aStart, anEnd); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.h b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.h index 68c239278..1db144ed1 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_EdgeBuilder.h @@ -18,22 +18,21 @@ class GEOMALGOAPI_EXPORT GeomAlgoAPI_EdgeBuilder { -public: + public: /// Creates linear edge by two points - static boost::shared_ptr line( - boost::shared_ptr theStart, boost::shared_ptr theEnd); + static boost::shared_ptr line(boost::shared_ptr theStart, + boost::shared_ptr theEnd); /// Creates linear edge in a form of a circle by a point and a circle radius - static boost::shared_ptr lineCircle( - boost::shared_ptr theCenter, - boost::shared_ptr theNormal, double theRadius); + static boost::shared_ptr lineCircle(boost::shared_ptr theCenter, + boost::shared_ptr theNormal, + double theRadius); /// Creates linear edge in a form of a circle arc by a three points - static boost::shared_ptr lineCircleArc( - boost::shared_ptr theCenter, - boost::shared_ptr theStartPoint, - boost::shared_ptr theEndPoint, - boost::shared_ptr theNormal); + static boost::shared_ptr lineCircleArc(boost::shared_ptr theCenter, + boost::shared_ptr theStartPoint, + boost::shared_ptr theEndPoint, + boost::shared_ptr theNormal); }; #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.cpp index d5affc094..fb58d0c53 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.cpp @@ -15,9 +15,8 @@ const double tolerance = Precision::Angular(); boost::shared_ptr GeomAlgoAPI_Extrusion::makeExtrusion( - boost::shared_ptr theShape, - boost::shared_ptr theDir, - double theSize) + boost::shared_ptr theShape, boost::shared_ptr theDir, + double theSize) { const TopoDS_Shape& aShape = theShape->impl(); gp_Vec aDir(theDir->impl().XYZ() * theSize); @@ -32,37 +31,33 @@ boost::shared_ptr GeomAlgoAPI_Extrusion::makeExtrusion( } boost::shared_ptr GeomAlgoAPI_Extrusion::makeExtrusion( - boost::shared_ptr theShape, - double theSize) + boost::shared_ptr theShape, double theSize) { bool isFirstNorm = true; gp_Dir aShapeNormal; const TopoDS_Shape& aShape = theShape->impl(); TopExp_Explorer aFaceExp(aShape, TopAbs_FACE); - for ( ; aFaceExp.More(); aFaceExp.Next()) - { - const TopoDS_Face& aFace = (const TopoDS_Face&)aFaceExp.Current(); + for (; aFaceExp.More(); aFaceExp.Next()) { + const TopoDS_Face& aFace = (const TopoDS_Face&) aFaceExp.Current(); Handle(BRep_TFace) aBFace = Handle(BRep_TFace)::DownCast(aFace.TShape()); if (aBFace.IsNull()) return boost::shared_ptr(); Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aBFace->Surface()); - if (aPlane.IsNull()) // non-planar shapes is not supported for extrusion yet + if (aPlane.IsNull()) // non-planar shapes is not supported for extrusion yet continue; const gp_Dir& aNormal = aPlane->Pln().Axis().Direction(); - if (isFirstNorm) - { + if (isFirstNorm) { aShapeNormal = aNormal; isFirstNorm = false; - } - else if (!aShapeNormal.IsEqual(aNormal, tolerance)) // non-planar shapes is not supported for extrusion yet + } else if (!aShapeNormal.IsEqual(aNormal, tolerance)) // non-planar shapes is not supported for extrusion yet return boost::shared_ptr(); } boost::shared_ptr aDir( - new GeomAPI_Dir(aShapeNormal.X(), aShapeNormal.Y(), aShapeNormal.Z())); + new GeomAPI_Dir(aShapeNormal.X(), aShapeNormal.Y(), aShapeNormal.Z())); return GeomAlgoAPI_Extrusion::makeExtrusion(theShape, aDir, theSize); } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.h b/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.h index a41ae8db4..31b3d4406 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Extrusion.h @@ -17,26 +17,24 @@ class GEOMALGOAPI_EXPORT GeomAlgoAPI_Extrusion { -public: + public: /* \brief Creates extrusion for the given shape * \param[in] theShape face or wire to be extruded * \param[in] theDir direction of extrusion * \param[in] theSize the length of extrusion (if the value is less than 0, the extrusion in opposite direction) * \return a solid or a face which is obtained from specified one */ - static boost::shared_ptr makeExtrusion( - boost::shared_ptr theShape, - boost::shared_ptr theDir, - double theSize); + static boost::shared_ptr makeExtrusion(boost::shared_ptr theShape, + boost::shared_ptr theDir, + double theSize); /* \brief Creates extrusion for the given shape along the normal for this shape * \param[in] theShape face or wire to be extruded * \param[in] theSize the length of extrusion (if the value is less than 0, the extrusion in opposite normal) * \return a solid or a face which is obtained from specified one */ - static boost::shared_ptr makeExtrusion( - boost::shared_ptr theShape, - double theSize); + static boost::shared_ptr makeExtrusion(boost::shared_ptr theShape, + double theSize); }; #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp index f543c06a6..3c9a61fda 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp @@ -11,33 +11,38 @@ #include boost::shared_ptr GeomAlgoAPI_FaceBuilder::square( - boost::shared_ptr theCenter, boost::shared_ptr theNormal, - const double theSize) + boost::shared_ptr theCenter, boost::shared_ptr theNormal, + const double theSize) { const gp_Pnt& aCenter = theCenter->impl(); const gp_Dir& aDir = theNormal->impl(); 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.); + BRepBuilderAPI_MakeFace aFaceBuilder(aPlane, -theSize / 2., theSize / 2., -theSize / 2., + theSize / 2.); boost::shared_ptr aRes(new GeomAPI_Shape); aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face())); return aRes; } boost::shared_ptr GeomAlgoAPI_FaceBuilder::plane( - boost::shared_ptr theFace) + boost::shared_ptr theFace) { boost::shared_ptr aResult; - if (!theFace) return aResult; // bad shape + if (!theFace) + return aResult; // bad shape TopoDS_Shape aShape = theFace->impl(); - if (aShape.IsNull()) return aResult; // null shape + if (aShape.IsNull()) + return aResult; // null shape TopoDS_Face aFace = TopoDS::Face(aShape); - if (aFace.IsNull()) return aResult; // not face + if (aFace.IsNull()) + return aResult; // not face Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); - if (aSurf.IsNull()) return aResult; // no surface + if (aSurf.IsNull()) + return aResult; // no surface Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurf); - if (aPlane.IsNull()) return aResult; // not planar + if (aPlane.IsNull()) + return aResult; // not planar double aA, aB, aC, aD; aPlane->Coefficients(aA, aB, aC, aD); aResult = boost::shared_ptr(new GeomAPI_Pln(aA, aB, aC, aD)); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.h b/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.h index d14357a93..b95fad92b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.h @@ -19,11 +19,12 @@ class GEOMALGOAPI_EXPORT GeomAlgoAPI_FaceBuilder { -public: + public: /// Creates square planar face by given point of the center, /// normal to the plane and size of square static boost::shared_ptr square(boost::shared_ptr theCenter, - boost::shared_ptr theNormal, const double theSize); + boost::shared_ptr theNormal, + const double theSize); /// Returns the plane of the planar face. If it is not planar, returns empty ptr. static boost::shared_ptr plane(boost::shared_ptr theFace); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp index d12bd6a86..053504d79 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.cpp @@ -2,8 +2,6 @@ // Created: 02 Jun 2014 // Author: Mikhail PONIKAROV - - #include #include #include diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h index 7e24a360a..ec6e417e4 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_PointBuilder.h @@ -18,10 +18,9 @@ class GeomAPI_Pnt; class GEOMALGOAPI_EXPORT GeomAlgoAPI_PointBuilder { -public: + public: /// Creates linear edge by two points - static boost::shared_ptr point( - boost::shared_ptr thePoint); + static boost::shared_ptr point(boost::shared_ptr thePoint); }; #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp index 334f0da24..528227b61 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.cpp @@ -37,69 +37,56 @@ #define DBL_MAX 1.7976931348623158e+308 #endif - const double tolerance = Precision::Confusion(); // This value helps to find direction on the boundaries of curve. // It is not significant for lines, but is used for circles to avoid // wrong directions of movement (when two edges are tangent on the certain vertex) -const double shift = acos(1.0 - 3.0 * tolerance); +const double shift = acos(1.0 - 3.0 * tolerance); /// \brief Search first vertex - the vertex with lowest x coordinate, which is used in 2 edges at least -static const TopoDS_Shape& findStartVertex( - const BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE, - const gp_Dir& theDirX, const gp_Dir& theDirY); +static const TopoDS_Shape& findStartVertex(const BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE, + const gp_Dir& theDirX, const gp_Dir& theDirY); /// \brief Search the vertex on the sketch candidate to be the next one in the loop -static void findNextVertex( - const TopoDS_Shape& theStartVertex, - const BOPCol_IndexedDataMapOfShapeListOfShape& theVertexEdgeMap, - const gp_Dir& theStartDir, - const gp_Dir& theNormal, - TopoDS_Shape& theNextVertex, - TopoDS_Shape& theNextEdge, - gp_Dir& theNextDir); +static void findNextVertex(const TopoDS_Shape& theStartVertex, + const BOPCol_IndexedDataMapOfShapeListOfShape& theVertexEdgeMap, + const gp_Dir& theStartDir, const gp_Dir& theNormal, + TopoDS_Shape& theNextVertex, TopoDS_Shape& theNextEdge, + gp_Dir& theNextDir); /// \brief Create planar face using the edges surrounding it -static void createFace(const TopoDS_Shape& theStartVertex, +static void createFace(const TopoDS_Shape& theStartVertex, const std::list::iterator& theStartEdge, const std::list::iterator& theEndOfEdges, - const gp_Pln& thePlane, - TopoDS_Face& theResFace); + const gp_Pln& thePlane, TopoDS_Face& theResFace); /// \bief Create planar wire -static void createWireList(const TopoDS_Shape& theStartVertex, +static void createWireList(const TopoDS_Shape& theStartVertex, const std::list::iterator& theStartEdge, const std::list::iterator& theEndOfEdges, - const std::set& theEdgesInLoops, - std::list& theResWires); + const std::set& theEdgesInLoops, + std::list& theResWires); /// \brief Calculate outer tengency on the edge in specified vertex -static gp_Dir getOuterEdgeDirection(const TopoDS_Shape& theEdge, - const TopoDS_Shape& theVertex); +static gp_Dir getOuterEdgeDirection(const TopoDS_Shape& theEdge, const TopoDS_Shape& theVertex); /// \brief Unnecessary edges will be removed from the map. /// Positions of iterator will be updated -static void removeWasteEdges( - std::list::iterator& theStartVertex, - std::list::iterator& theStartEdge, - const std::list::iterator& theEndOfVertexes, - const std::list::iterator& theEndOfEdges, - BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE); - - - +static void removeWasteEdges(std::list::iterator& theStartVertex, + std::list::iterator& theStartEdge, + const std::list::iterator& theEndOfVertexes, + const std::list::iterator& theEndOfEdges, + BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE); void GeomAlgoAPI_SketchBuilder::createFaces( - const boost::shared_ptr& theOrigin, - const boost::shared_ptr& theDirX, - const boost::shared_ptr& theDirY, - const boost::shared_ptr& theNorm, - const std::list< boost::shared_ptr >& theFeatures, - std::list< boost::shared_ptr >& theResultFaces, - std::list< boost::shared_ptr >& theResultWires) + const boost::shared_ptr& theOrigin, const boost::shared_ptr& theDirX, + const boost::shared_ptr& theDirY, const boost::shared_ptr& theNorm, + const std::list >& theFeatures, + std::list >& theResultFaces, + std::list >& theResultWires) { if (theFeatures.empty()) - return ; + return; // Create the list of edges with shared vertexes BOPAlgo_Builder aBuilder; @@ -107,41 +94,38 @@ void GeomAlgoAPI_SketchBuilder::createFaces( TopoDS_Shape aFeaturesCompound; // Obtain only edges from the features list - std::list< boost::shared_ptr > anEdges; - std::list< boost::shared_ptr >::const_iterator aFeatIt = theFeatures.begin(); - for ( ; aFeatIt != theFeatures.end(); aFeatIt++) - { + std::list > anEdges; + std::list >::const_iterator aFeatIt = theFeatures.begin(); + for (; aFeatIt != theFeatures.end(); aFeatIt++) { boost::shared_ptr aShape(*aFeatIt); const TopoDS_Edge& anEdge = aShape->impl(); if (anEdge.ShapeType() == TopAbs_EDGE) anEdges.push_back(aShape); } - if (anEdges.size() == 1) - { // If there is only one feature, BOPAlgo_Builder will decline to work. Need to process it anyway + if (anEdges.size() == 1) { // If there is only one feature, BOPAlgo_Builder will decline to work. Need to process it anyway aFeaturesCompound = anEdges.front()->impl(); - } - else - { - std::list< boost::shared_ptr >::const_iterator anIt = anEdges.begin(); - for (; anIt != anEdges.end(); anIt++) - { + } else { + std::list >::const_iterator anIt = anEdges.begin(); + for (; anIt != anEdges.end(); anIt++) { boost::shared_ptr aPreview(*anIt); aBuilder.AddArgument(aPreview->impl()); } aPF.SetArguments(aBuilder.Arguments()); aPF.Perform(); int aErr = aPF.ErrorStatus(); - if (aErr) return ; + if (aErr) + return; aBuilder.PerformWithFiller(aPF); aErr = aBuilder.ErrorStatus(); - if (aErr) return ; + if (aErr) + return; aFeaturesCompound = aBuilder.Shape(); } - BOPCol_IndexedDataMapOfShapeListOfShape aMapVE; // map between vertexes and edges + BOPCol_IndexedDataMapOfShapeListOfShape aMapVE; // map between vertexes and edges BOPTools::MapShapesAndAncestors(aFeaturesCompound, TopAbs_VERTEX, TopAbs_EDGE, aMapVE); - if (aMapVE.IsEmpty()) // in case of not-initialized circle + if (aMapVE.IsEmpty()) // in case of not-initialized circle return; gp_Dir aDirX = theDirX->impl(); @@ -168,18 +152,16 @@ void GeomAlgoAPI_SketchBuilder::createFaces( TopoDS_Shape aNextVertex; TopoDS_Shape aBindingEdge; gp_Dir aNextDir; - while (aMapVE.Extent() > 0) - { + while (aMapVE.Extent() > 0) { if (aCurVertex.IsNull()) return; findNextVertex(aCurVertex, aMapVE, aCurDir, aCurNorm, aNextVertex, aBindingEdge, aNextDir); aCurNorm = aNorm; // Try to find next vertex in the list of already processed - std::list::iterator aVertIter = aProcVertexes.begin(); - std::list::iterator anEdgeIter = aProcEdges.begin(); - for ( ; aVertIter != aProcVertexes.end(); aVertIter++) - { + std::list::iterator aVertIter = aProcVertexes.begin(); + std::list::iterator anEdgeIter = aProcEdges.begin(); + for (; aVertIter != aProcVertexes.end(); aVertIter++) { if (aVertIter->TShape() == aNextVertex.TShape()) break; if (anEdgeIter != aProcEdges.end()) @@ -190,21 +172,18 @@ void GeomAlgoAPI_SketchBuilder::createFaces( aProcEdges.push_back(aBindingEdge); // The loop was found - if (aVertIter != aProcVertexes.end()) - { + if (aVertIter != aProcVertexes.end()) { // If the binding edge is a full circle, then the list may be empty before addition. Need to update edge iterator if (aProcEdges.size() == 1) anEdgeIter = aProcEdges.begin(); - if (aVertIter != aProcVertexes.begin()) - { + if (aVertIter != aProcVertexes.begin()) { // Check the orientation of the loop gp_Dir aCN = getOuterEdgeDirection(*anEdgeIter, *aVertIter); gp_Dir aCP = getOuterEdgeDirection(aProcEdges.back(), *aVertIter); aCN.Reverse(); aCP.Reverse(); - if (aCN.DotCross(aCP, aNorm) < -tolerance) - { + if (aCN.DotCross(aCP, aNorm) < -tolerance) { // The found loop has wrong orientation and may contain sub-loops. // Need to check it onle again with another initial direction. aCurVertex = *aVertIter; @@ -222,8 +201,7 @@ void GeomAlgoAPI_SketchBuilder::createFaces( // the first element, create new face and remove unnecessary edges. TopoDS_Face aPatch; createFace(*aVertIter, anEdgeIter, aProcEdges.end(), aPlane, aPatch); - if (!aPatch.IsNull()) - { + if (!aPatch.IsNull()) { boost::shared_ptr aFace(new GeomAPI_Shape); aFace->setImpl(new TopoDS_Face(aPatch)); theResultFaces.push_back(aFace); @@ -239,10 +217,10 @@ void GeomAlgoAPI_SketchBuilder::createFaces( // revert the list of remaining edges std::list aRemainVertexes; - for ( ; aVertIter != aProcVertexes.end(); aVertIter++) + for (; aVertIter != aProcVertexes.end(); aVertIter++) aRemainVertexes.push_front(*aVertIter); std::list aRemainEdges; - for ( ; anEdgeIter != aProcEdges.end(); anEdgeIter++) + for (; anEdgeIter != aProcEdges.end(); anEdgeIter++) aRemainEdges.push_front(*anEdgeIter); // remove edges and vertexes used in the loop and add remaining ones aProcVertexes.erase(aCopyVLoop, aProcVertexes.end()); @@ -251,20 +229,19 @@ void GeomAlgoAPI_SketchBuilder::createFaces( aProcEdges.insert(aProcEdges.end(), aRemainEdges.begin(), aRemainEdges.end()); // Recalculate current vertex and current direction - if (!aProcVertexes.empty()) - { + if (!aProcVertexes.empty()) { aNextVertex = aProcVertexes.back(); if (!aProcEdges.empty()) aNextDir = getOuterEdgeDirection(aProcEdges.back(), aNextVertex); - else aNextDir = aDirY; + else + aNextDir = aDirY; } } // if next vertex connected only to alone edge, this is a part of wire (not a closed loop), // we need to go back through the list of already checked edges to find a branching vertex - if (!aMapVE.IsEmpty() && aMapVE.Contains(aNextVertex) && - aMapVE.FindFromKey(aNextVertex).Size() == 1) - { + if (!aMapVE.IsEmpty() && aMapVE.Contains(aNextVertex) + && aMapVE.FindFromKey(aNextVertex).Size() == 1) { std::list::reverse_iterator aVRIter = aProcVertexes.rbegin(); std::list::reverse_iterator aERIter = aProcEdges.rbegin(); if (aVRIter != aProcVertexes.rend()) @@ -272,27 +249,23 @@ void GeomAlgoAPI_SketchBuilder::createFaces( if (aERIter != aProcEdges.rend()) aERIter++; - for ( ; aERIter != aProcEdges.rend(); aERIter++, aVRIter++) + for (; aERIter != aProcEdges.rend(); aERIter++, aVRIter++) if (aMapVE.FindFromKey(*aVRIter).Size() > 2) break; - if (aERIter != aProcEdges.rend() || - (aVRIter != aProcVertexes.rend() && aMapVE.FindFromKey(*aVRIter).Size() == 1)) - { // the branching vertex was found or current list of edges is a wire without branches + if (aERIter != aProcEdges.rend() + || (aVRIter != aProcVertexes.rend() && aMapVE.FindFromKey(*aVRIter).Size() == 1)) { // the branching vertex was found or current list of edges is a wire without branches std::list::iterator aEIter; TopoDS_Shape aCurEdge; - if (aERIter != aProcEdges.rend()) - { + if (aERIter != aProcEdges.rend()) { aEIter = aERIter.base(); aCurEdge = *aERIter; - } - else + } else aEIter = aProcEdges.begin(); std::list aTail; createWireList(*aVRIter, aEIter, aProcEdges.end(), anEdgesInLoops, aTail); std::list::const_iterator aTailIter = aTail.begin(); - for ( ; aTailIter != aTail.end(); aTailIter++) - if (!aTailIter->IsNull()) - { + for (; aTailIter != aTail.end(); aTailIter++) + if (!aTailIter->IsNull()) { boost::shared_ptr aWire(new GeomAPI_Shape); aWire->setImpl(new TopoDS_Shape(*aTailIter)); theResultWires.push_back(aWire); @@ -305,28 +278,24 @@ void GeomAlgoAPI_SketchBuilder::createFaces( aVIter = aVRIter.base(); aProcVertexes.erase(aVIter, aProcVertexes.end()); - if (!aProcVertexes.empty()) - { + if (!aProcVertexes.empty()) { aNextVertex = aProcVertexes.back(); if (!aCurEdge.IsNull()) aNextDir = getOuterEdgeDirection(aCurEdge, aNextVertex); } - } - else - { // there is no branching vertex in the list of proceeded, - // so we should revert the list and go the opposite way + } else { // there is no branching vertex in the list of proceeded, + // so we should revert the list and go the opposite way aProcVertexes.reverse(); aProcEdges.reverse(); aNextVertex = aProcVertexes.back(); - aNextDir = aProcEdges.empty() ? aDirY : - getOuterEdgeDirection(aProcEdges.back(), aNextVertex); + aNextDir = + aProcEdges.empty() ? aDirY : getOuterEdgeDirection(aProcEdges.back(), aNextVertex); } } // When all edges of current component of connectivity are processed, // we should repeat procedure for finding initial vertex in the remaining - if (!aMapVE.IsEmpty() && !aMapVE.Contains(aNextVertex)) - { + if (!aMapVE.IsEmpty() && !aMapVE.Contains(aNextVertex)) { aProcVertexes.clear(); aProcEdges.clear(); @@ -347,63 +316,51 @@ void GeomAlgoAPI_SketchBuilder::createFaces( } void GeomAlgoAPI_SketchBuilder::fixIntersections( - std::list< boost::shared_ptr >& theFaces) + std::list >& theFaces) { BRepClass_FaceClassifier aClassifier; - std::list< boost::shared_ptr >::iterator anIter1 = theFaces.begin(); - std::list< boost::shared_ptr >::iterator anIter2; - for ( ; anIter1 != theFaces.end(); anIter1++) - { + std::list >::iterator anIter1 = theFaces.begin(); + std::list >::iterator anIter2; + for (; anIter1 != theFaces.end(); anIter1++) { anIter2 = anIter1; - for (++anIter2; anIter2 != theFaces.end(); anIter2++) - { + for (++anIter2; anIter2 != theFaces.end(); anIter2++) { const TopoDS_Face& aF1 = (*anIter1)->impl(); - assert(aF1.ShapeType() == TopAbs_FACE); // all items in result list should be faces + assert(aF1.ShapeType() == TopAbs_FACE); // all items in result list should be faces TopExp_Explorer aVert2((*anIter2)->impl(), TopAbs_VERTEX); - for ( ; aVert2.More(); aVert2.Next()) - { + for (; aVert2.More(); aVert2.Next()) { Handle(BRep_TVertex) aV = Handle(BRep_TVertex)::DownCast(aVert2.Current().TShape()); aClassifier.Perform(aF1, aV->Pnt(), tolerance); if (aClassifier.State() != TopAbs_IN) break; } - if (aVert2.More()) - { // second shape is not inside first, change the shapes order and repeat comparision + if (aVert2.More()) { // second shape is not inside first, change the shapes order and repeat comparision const TopoDS_Face& aF2 = (*anIter2)->impl(); - assert(aF2.ShapeType() == TopAbs_FACE); // all items in result list should be faces + assert(aF2.ShapeType() == TopAbs_FACE); // all items in result list should be faces TopExp_Explorer aVert1((*anIter1)->impl(), TopAbs_VERTEX); - for ( ; aVert1.More(); aVert1.Next()) - { + for (; aVert1.More(); aVert1.Next()) { Handle(BRep_TVertex) aV = Handle(BRep_TVertex)::DownCast(aVert1.Current().TShape()); aClassifier.Perform(aF2, aV->Pnt(), tolerance); if (aClassifier.State() != TopAbs_IN) break; } - if (!aVert1.More()) - { // first shape should be cut from the second - BRepAlgoAPI_Cut aCut((*anIter2)->impl(), - (*anIter1)->impl()); + if (!aVert1.More()) { // first shape should be cut from the second + BRepAlgoAPI_Cut aCut((*anIter2)->impl(), (*anIter1)->impl()); aCut.Build(); TopExp_Explorer anExp(aCut.Shape(), TopAbs_FACE); (*anIter2)->setImpl(new TopoDS_Shape(anExp.Current())); - for (anExp.Next(); anExp.More(); anExp.Next()) - { + for (anExp.Next(); anExp.More(); anExp.Next()) { boost::shared_ptr aShape(new GeomAPI_Shape); aShape->setImpl(new TopoDS_Shape(anExp.Current())); theFaces.push_back(aShape); } } - } - else - { // second shape should be cut from the first - BRepAlgoAPI_Cut aCut((*anIter1)->impl(), - (*anIter2)->impl()); + } else { // second shape should be cut from the first + BRepAlgoAPI_Cut aCut((*anIter1)->impl(), (*anIter2)->impl()); aCut.Build(); TopExp_Explorer anExp(aCut.Shape(), TopAbs_FACE); (*anIter1)->setImpl(new TopoDS_Shape(anExp.Current())); - for (anExp.Next(); anExp.More(); anExp.Next()) - { + for (anExp.Next(); anExp.More(); anExp.Next()) { boost::shared_ptr aShape(new GeomAPI_Shape); aShape->setImpl(new TopoDS_Shape(anExp.Current())); theFaces.push_back(aShape); @@ -413,27 +370,23 @@ void GeomAlgoAPI_SketchBuilder::fixIntersections( } } - // =================== Auxiliary functions ==================================== -const TopoDS_Shape& findStartVertex( - const BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE, - const gp_Dir& theDirX, const gp_Dir& theDirY) +const TopoDS_Shape& findStartVertex(const BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE, + const gp_Dir& theDirX, const gp_Dir& theDirY) { int aStartVertexInd = 1; double aMaxX = -DBL_MAX; double aMaxY = -DBL_MAX; int aNbVert = theMapVE.Extent(); - for (int i = 1; i <= aNbVert; i++) - { - const TopoDS_Vertex& aV = (const TopoDS_Vertex&)theMapVE.FindKey(i); - const Handle(BRep_TVertex)& aVert = (const Handle(BRep_TVertex)&)aV.TShape(); + for (int i = 1; i <= aNbVert; i++) { + const TopoDS_Vertex& aV = (const TopoDS_Vertex&) theMapVE.FindKey(i); + const Handle(BRep_TVertex)& aVert = (const Handle(BRep_TVertex)&) aV.TShape(); const gp_Pnt& aVertPnt = aVert->Pnt(); double aX = aVertPnt.XYZ().Dot(theDirX.XYZ()); double aY = aVertPnt.XYZ().Dot(theDirY.XYZ()); - if ((aX > aMaxX || (fabs(aX - aMaxX) < tolerance && aY > aMaxY)) && - theMapVE.FindFromIndex(i).Extent() > 1) - { + if ((aX > aMaxX || (fabs(aX - aMaxX) < tolerance && aY > aMaxY)) + && theMapVE.FindFromIndex(i).Extent() > 1) { aMaxX = aX; aMaxY = aY; aStartVertexInd = i; @@ -442,20 +395,15 @@ const TopoDS_Shape& findStartVertex( return theMapVE.FindKey(aStartVertexInd); } -void findNextVertex( - const TopoDS_Shape& theStartVertex, - const BOPCol_IndexedDataMapOfShapeListOfShape& theVertexEdgeMap, - const gp_Dir& theStartDir, - const gp_Dir& theNormal, - TopoDS_Shape& theNextVertex, - TopoDS_Shape& theNextEdge, - gp_Dir& theNextDir) +void findNextVertex(const TopoDS_Shape& theStartVertex, + const BOPCol_IndexedDataMapOfShapeListOfShape& theVertexEdgeMap, + const gp_Dir& theStartDir, const gp_Dir& theNormal, TopoDS_Shape& theNextVertex, + TopoDS_Shape& theNextEdge, gp_Dir& theNextDir) { const BOPCol_ListOfShape& anEdgesList = theVertexEdgeMap.FindFromKey(theStartVertex); BOPCol_ListOfShape::Iterator aEdIter(anEdgesList); double aBestEdgeProj = DBL_MAX; - for ( ; aEdIter.More(); aEdIter.Next()) - { + for (; aEdIter.More(); aEdIter.Next()) { gp_Dir aTang = getOuterEdgeDirection(aEdIter.Value(), theStartVertex); aTang.Reverse(); @@ -468,22 +416,19 @@ void findNextVertex( if (theStartDir.DotCross(aTang, theNormal) < tolerance) aProj *= -1.0; - if (aProj < aBestEdgeProj) - { + if (aProj < aBestEdgeProj) { aBestEdgeProj = aProj; theNextEdge = aEdIter.Value(); TopExp_Explorer aVertExp(theNextEdge, TopAbs_VERTEX); - for ( ; aVertExp.More(); aVertExp.Next()) - if (aVertExp.Current().TShape() != theStartVertex.TShape()) - { + for (; aVertExp.More(); aVertExp.Next()) + if (aVertExp.Current().TShape() != theStartVertex.TShape()) { theNextVertex = aVertExp.Current(); theNextDir = getOuterEdgeDirection(aEdIter.Value(), theNextVertex); break; } - if (!aVertExp.More()) - { // This edge is a full circle + if (!aVertExp.More()) { // This edge is a full circle TopoDS_Vertex aV1, aV2; - TopExp::Vertices(*(const TopoDS_Edge*)(&theNextEdge), aV1, aV2); + TopExp::Vertices(*(const TopoDS_Edge*) (&theNextEdge), aV1, aV2); if (aV1.Orientation() == theStartVertex.Orientation()) theNextVertex = aV2; else @@ -494,27 +439,22 @@ void findNextVertex( } } -static void addEdgeToWire(const TopoDS_Edge& theEdge, - const BRep_Builder& theBuilder, - TopoDS_Shape& theSpliceVertex, - TopoDS_Wire& theWire) +static void addEdgeToWire(const TopoDS_Edge& theEdge, const BRep_Builder& theBuilder, + TopoDS_Shape& theSpliceVertex, TopoDS_Wire& theWire) { TopoDS_Edge anEdge = theEdge; bool isCurVertChanged = false; TopoDS_Shape aCurVertChanged; TopExp_Explorer aVertExp(theEdge, TopAbs_VERTEX); - for ( ; aVertExp.More(); aVertExp.Next()) - { + for (; aVertExp.More(); aVertExp.Next()) { const TopoDS_Shape& aVertex = aVertExp.Current(); - if (aVertex.TShape() == theSpliceVertex.TShape() && - aVertex.Orientation() != theEdge.Orientation()) - { // Current vertex is the last for the edge, so its orientation is wrong, need to revert the edge + if (aVertex.TShape() == theSpliceVertex.TShape() + && aVertex.Orientation() != theEdge.Orientation()) { // Current vertex is the last for the edge, so its orientation is wrong, need to revert the edge anEdge.Reverse(); break; } - if (aVertex.TShape() != theSpliceVertex.TShape()) - { + if (aVertex.TShape() != theSpliceVertex.TShape()) { aCurVertChanged = aVertex; isCurVertChanged = true; } @@ -524,11 +464,10 @@ static void addEdgeToWire(const TopoDS_Edge& theEdge, theBuilder.Add(theWire, anEdge); } -void createFace(const TopoDS_Shape& theStartVertex, +void createFace(const TopoDS_Shape& theStartVertex, const std::list::iterator& theStartEdge, - const std::list::iterator& theEndOfEdges, - const gp_Pln& thePlane, - TopoDS_Face& theResFace) + const std::list::iterator& theEndOfEdges, const gp_Pln& thePlane, + TopoDS_Face& theResFace) { TopoDS_Wire aResWire; BRep_Builder aBuilder; @@ -536,9 +475,8 @@ void createFace(const TopoDS_Shape& theStartVertex, TopoDS_Shape aCurVertex = theStartVertex; std::list::const_iterator anEdgeIter = theStartEdge; - for ( ; anEdgeIter != theEndOfEdges; anEdgeIter++) - { - TopoDS_Edge anEdge = *((TopoDS_Edge*)(&(*anEdgeIter))); + for (; anEdgeIter != theEndOfEdges; anEdgeIter++) { + TopoDS_Edge anEdge = *((TopoDS_Edge*) (&(*anEdgeIter))); if (!anEdge.IsNull()) addEdgeToWire(anEdge, aBuilder, aCurVertex, aResWire); } @@ -548,26 +486,22 @@ void createFace(const TopoDS_Shape& theStartVertex, theResFace = aFaceBuilder.Face(); } -void createWireList(const TopoDS_Shape& theStartVertex, +void createWireList(const TopoDS_Shape& theStartVertex, const std::list::iterator& theStartEdge, const std::list::iterator& theEndOfEdges, - const std::set& theEdgesInLoops, - std::list& theResWires) + const std::set& theEdgesInLoops, + std::list& theResWires) { BRep_Builder aBuilder; bool needNewWire = true; TopoDS_Shape aCurVertex = theStartVertex; std::list::iterator anIter = theStartEdge; - while (anIter != theEndOfEdges) - { - while (anIter != theEndOfEdges && needNewWire && - theEdgesInLoops.count(anIter->TShape()) != 0) - { + while (anIter != theEndOfEdges) { + while (anIter != theEndOfEdges && needNewWire && theEdgesInLoops.count(anIter->TShape()) != 0) { TopExp_Explorer aVertExp(*anIter, TopAbs_VERTEX); - for ( ; aVertExp.More(); aVertExp.Next()) - if (aVertExp.Current().TShape() != aCurVertex.TShape()) - { + for (; aVertExp.More(); aVertExp.Next()) + if (aVertExp.Current().TShape() != aCurVertex.TShape()) { aCurVertex = aVertExp.Current(); break; } @@ -576,39 +510,34 @@ void createWireList(const TopoDS_Shape& theStartVertex, if (anIter == theEndOfEdges) break; - if (needNewWire) - { // The new wire should be created + if (needNewWire) { // The new wire should be created TopoDS_Wire aWire; aBuilder.MakeWire(aWire); theResWires.push_back(aWire); needNewWire = false; - } - else if (theEdgesInLoops.count(anIter->TShape()) != 0) - { // There was found the edge already used in loop. - // Current wire should be released and new one should started + } else if (theEdgesInLoops.count(anIter->TShape()) != 0) { // There was found the edge already used in loop. + // Current wire should be released and new one should started needNewWire = true; continue; } - TopoDS_Edge anEdge = *((TopoDS_Edge*)(&(*anIter))); + TopoDS_Edge anEdge = *((TopoDS_Edge*) (&(*anIter))); addEdgeToWire(anEdge, aBuilder, aCurVertex, theResWires.back()); anIter++; } } - -gp_Dir getOuterEdgeDirection(const TopoDS_Shape& theEdge, - const TopoDS_Shape& theVertex) +gp_Dir getOuterEdgeDirection(const TopoDS_Shape& theEdge, const TopoDS_Shape& theVertex) { - const Handle(BRep_TVertex)& aVertex = (const Handle(BRep_TVertex)&)theVertex.TShape(); + const Handle(BRep_TVertex)& aVertex = (const Handle(BRep_TVertex)&) theVertex.TShape(); gp_Pnt aVertexPnt = aVertex->Pnt(); - const Handle(BRep_TEdge)& anEdge = (const Handle(BRep_TEdge)&)theEdge.TShape(); + const Handle(BRep_TEdge)& anEdge = (const Handle(BRep_TEdge)&) theEdge.TShape(); // Convert the edge to the curve to calculate the tangency. // There should be only one curve in the edge. - Handle(BRep_Curve3D) aEdCurve = - Handle(BRep_Curve3D)::DownCast(anEdge->Curves().First()); + Handle(BRep_Curve3D) aEdCurve = + Handle(BRep_Curve3D)::DownCast(anEdge->Curves().First()); double aFirst, aLast; aEdCurve->Range(aFirst, aLast); Handle(Geom_Curve) aCurve = aEdCurve->Curve3D(); @@ -626,19 +555,17 @@ gp_Dir getOuterEdgeDirection(const TopoDS_Shape& theEdge, return gp_Dir(aTang); } -void removeWasteEdges( - std::list::iterator& theStartVertex, - std::list::iterator& theStartEdge, - const std::list::iterator& theEndOfVertexes, - const std::list::iterator& theEndOfEdges, - BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE) +void removeWasteEdges(std::list::iterator& theStartVertex, + std::list::iterator& theStartEdge, + const std::list::iterator& theEndOfVertexes, + const std::list::iterator& theEndOfEdges, + BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE) { bool isVertStep = true; - while (theStartVertex != theEndOfVertexes && theStartEdge != theEndOfEdges) - { + while (theStartVertex != theEndOfVertexes && theStartEdge != theEndOfEdges) { BOPCol_ListOfShape& aBunch = theMapVE.ChangeFromKey(*theStartVertex); BOPCol_ListOfShape::Iterator anApprEdge(aBunch); - for ( ; anApprEdge.More(); anApprEdge.Next()) + for (; anApprEdge.More(); anApprEdge.Next()) if (anApprEdge.Value() == *theStartEdge) break; if (anApprEdge.More()) @@ -646,8 +573,7 @@ void removeWasteEdges( if (isVertStep) theStartVertex++; - else - { + else { theStartEdge++; // check current vertex to be a branching point // if so, it will be a new starting point to find a loop diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.h b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.h index 1a75da204..22eafe77e 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_SketchBuilder.h @@ -20,7 +20,7 @@ */ class GEOMALGOAPI_EXPORT GeomAlgoAPI_SketchBuilder { -public: + public: /** \brief Creates list of faces and unclosed wires on basis of the features of the sketch * \param[in] theOrigin origin point of the sketch * \param[in] theDirX x-direction of the sketch @@ -34,19 +34,19 @@ public: * It finds the vertex with minimal coordinates along X axis (theDirX) and then * goes through the edges passing the surrounding area on the left. */ - static void createFaces(const boost::shared_ptr& theOrigin, - const boost::shared_ptr& theDirX, - const boost::shared_ptr& theDirY, - const boost::shared_ptr& theNorm, - const std::list< boost::shared_ptr >& theFeatures, - std::list< boost::shared_ptr >& theResultFaces, - std::list< boost::shared_ptr >& theResultWires); + static void createFaces(const boost::shared_ptr& theOrigin, + const boost::shared_ptr& theDirX, + const boost::shared_ptr& theDirY, + const boost::shared_ptr& theNorm, + const std::list >& theFeatures, + std::list >& theResultFaces, + std::list >& theResultWires); /** \brief Searches intersections between the faces in the list * and make holes in the faces to avoid intersections * \param[in,out] theFaces list of faces to proccess */ - static void fixIntersections(std::list< boost::shared_ptr >& theFaces); + static void fixIntersections(std::list >& theFaces); }; #endif diff --git a/src/GeomData/GeomData_Dir.cpp b/src/GeomData/GeomData_Dir.cpp index 3800c938c..b7c2b1c30 100644 --- a/src/GeomData/GeomData_Dir.cpp +++ b/src/GeomData/GeomData_Dir.cpp @@ -12,8 +12,8 @@ using namespace std; void GeomData_Dir::setValue(const double theX, const double theY, const double theZ) { - if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY || - myCoords->Value(2) != theZ) { + if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY + || myCoords->Value(2) != theZ) { myCoords->SetValue(0, theX); myCoords->SetValue(1, theY); myCoords->SetValue(2, theZ); @@ -44,8 +44,8 @@ double GeomData_Dir::z() const boost::shared_ptr GeomData_Dir::dir() { - return boost::shared_ptr(new GeomAPI_Dir( - myCoords->Value(0), myCoords->Value(1), myCoords->Value(2))); + return boost::shared_ptr( + new GeomAPI_Dir(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2))); } GeomData_Dir::GeomData_Dir(TDF_Label& theLabel) diff --git a/src/GeomData/GeomData_Dir.h b/src/GeomData/GeomData_Dir.h index 55688d100..b4dea091a 100644 --- a/src/GeomData/GeomData_Dir.h +++ b/src/GeomData/GeomData_Dir.h @@ -19,8 +19,8 @@ class GeomAPI_Dir; */ class GeomData_Dir : public GeomDataAPI_Dir { - Handle_TDataStd_RealArray myCoords; ///< X, Y and Z doubles as real array attribute [0; 2] -public: + Handle_TDataStd_RealArray myCoords; ///< X, Y and Z doubles as real array attribute [0; 2] + public: /// Defines the double value GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY, const double theZ); /// Defines the direction @@ -35,7 +35,7 @@ public: /// Returns the direction of this attribute GEOMDATA_EXPORT virtual boost::shared_ptr dir(); -protected: + protected: /// Initializes attributes GEOMDATA_EXPORT GeomData_Dir(TDF_Label& theLabel); diff --git a/src/GeomData/GeomData_Point.cpp b/src/GeomData/GeomData_Point.cpp index db942aff6..023b12d96 100644 --- a/src/GeomData/GeomData_Point.cpp +++ b/src/GeomData/GeomData_Point.cpp @@ -11,8 +11,8 @@ using namespace std; void GeomData_Point::setValue(const double theX, const double theY, const double theZ) { - if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY || - myCoords->Value(2) != theZ) { + if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY + || myCoords->Value(2) != theZ) { myCoords->SetValue(0, theX); myCoords->SetValue(1, theY); myCoords->SetValue(2, theZ); @@ -43,8 +43,8 @@ double GeomData_Point::z() const boost::shared_ptr GeomData_Point::pnt() { - boost::shared_ptr aResult(new GeomAPI_Pnt( - myCoords->Value(0), myCoords->Value(1), myCoords->Value(2))); + boost::shared_ptr aResult( + new GeomAPI_Pnt(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2))); return aResult; } diff --git a/src/GeomData/GeomData_Point.h b/src/GeomData/GeomData_Point.h index 6a3069527..3d1ae7cef 100644 --- a/src/GeomData/GeomData_Point.h +++ b/src/GeomData/GeomData_Point.h @@ -17,8 +17,8 @@ class GeomData_Point : public GeomDataAPI_Point { - Handle_TDataStd_RealArray myCoords; ///< X, Y and Z doubles as real array attribute [0; 2] -public: + Handle_TDataStd_RealArray myCoords; ///< X, Y and Z doubles as real array attribute [0; 2] + public: /// Defines the double value GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY, const double theZ); /// Defines the point @@ -33,7 +33,7 @@ public: /// Returns the 3D point GEOMDATA_EXPORT virtual boost::shared_ptr pnt(); -protected: + protected: /// Initializes attributes GEOMDATA_EXPORT GeomData_Point(TDF_Label& theLabel); diff --git a/src/GeomData/GeomData_Point2D.cpp b/src/GeomData/GeomData_Point2D.cpp index 7e6f889c4..08913436c 100644 --- a/src/GeomData/GeomData_Point2D.cpp +++ b/src/GeomData/GeomData_Point2D.cpp @@ -37,7 +37,7 @@ double GeomData_Point2D::y() const boost::shared_ptr GeomData_Point2D::pnt() { boost::shared_ptr aResult( - new GeomAPI_Pnt2d(myCoords->Value(0), myCoords->Value(1))); + new GeomAPI_Pnt2d(myCoords->Value(0), myCoords->Value(1))); return aResult; } diff --git a/src/GeomData/GeomData_Point2D.h b/src/GeomData/GeomData_Point2D.h index 0041f5cfe..4990948b8 100644 --- a/src/GeomData/GeomData_Point2D.h +++ b/src/GeomData/GeomData_Point2D.h @@ -17,8 +17,8 @@ class GeomData_Point2D : public GeomDataAPI_Point2D { - Handle_TDataStd_RealArray myCoords; ///< X and Y doubles as real array attribute [0; 1] -public: + Handle_TDataStd_RealArray myCoords; ///< X and Y doubles as real array attribute [0; 1] + public: /// Defines the double value GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY); /// Defines the point @@ -31,7 +31,7 @@ public: /// Returns the 2D point GEOMDATA_EXPORT virtual boost::shared_ptr pnt(); -protected: + protected: /// Initializes attributes GEOMDATA_EXPORT GeomData_Point2D(TDF_Label& theLabel); diff --git a/src/GeomDataAPI/GeomDataAPI_Dir.h b/src/GeomDataAPI/GeomDataAPI_Dir.h index c2239633f..e8c86f46a 100644 --- a/src/GeomDataAPI/GeomDataAPI_Dir.h +++ b/src/GeomDataAPI/GeomDataAPI_Dir.h @@ -17,7 +17,7 @@ class GeomAPI_Dir; class GeomDataAPI_Dir : public ModelAPI_Attribute { -public: + public: /// Defines the double value virtual void setValue(const double theX, const double theY, const double theZ) = 0; /// Defines the direction @@ -33,15 +33,22 @@ public: virtual boost::shared_ptr dir() = 0; /// Returns the type of this class of attributes - static inline std::string type() {return std::string("Dir");} + static inline std::string type() + { + return std::string("Dir"); + } /// Returns the type of this class of attributes, not static method - virtual std::string attributeType() {return type();} + virtual std::string attributeType() + { + return type(); + } -protected: + protected: /// Objects are created for features automatically GeomDataAPI_Dir() - {} + { + } }; #endif diff --git a/src/GeomDataAPI/GeomDataAPI_Point.h b/src/GeomDataAPI/GeomDataAPI_Point.h index 227a1be51..08ee73951 100644 --- a/src/GeomDataAPI/GeomDataAPI_Point.h +++ b/src/GeomDataAPI/GeomDataAPI_Point.h @@ -17,7 +17,7 @@ class GeomAPI_Pnt; class GeomDataAPI_Point : public ModelAPI_Attribute { -public: + public: /// Defines the double value virtual void setValue(const double theX, const double theY, const double theZ) = 0; /// Defines the point @@ -33,15 +33,22 @@ public: virtual boost::shared_ptr pnt() = 0; /// Returns the type of this class of attributes - static inline std::string type() {return std::string("Point");} + static inline std::string type() + { + return std::string("Point"); + } /// Returns the type of this class of attributes, not static method - virtual std::string attributeType() {return type();} + virtual std::string attributeType() + { + return type(); + } -protected: + protected: /// Objects are created for features automatically GeomDataAPI_Point() - {} + { + } }; #endif diff --git a/src/GeomDataAPI/GeomDataAPI_Point2D.h b/src/GeomDataAPI/GeomDataAPI_Point2D.h index 02249c24f..6189e87d2 100644 --- a/src/GeomDataAPI/GeomDataAPI_Point2D.h +++ b/src/GeomDataAPI/GeomDataAPI_Point2D.h @@ -17,7 +17,7 @@ class GeomAPI_Pnt2d; class GeomDataAPI_Point2D : public ModelAPI_Attribute { -public: + public: /// Defines the double value virtual void setValue(const double theX, const double theY) = 0; /// Defines the point @@ -31,15 +31,22 @@ public: virtual boost::shared_ptr pnt() = 0; /// Returns the type of this class of attributes - static inline std::string type() {return std::string("Point2D");} + static inline std::string type() + { + return std::string("Point2D"); + } /// Returns the type of this class of attributes, not static method - virtual std::string attributeType() {return type();} + virtual std::string attributeType() + { + return type(); + } -protected: + protected: /// Objects are created for features automatically GeomDataAPI_Point2D() - {} + { + } }; #endif diff --git a/src/Model/Model_Application.cpp b/src/Model/Model_Application.cpp index df32ef977..fe51e99a8 100644 --- a/src/Model/Model_Application.cpp +++ b/src/Model/Model_Application.cpp @@ -29,7 +29,7 @@ const boost::shared_ptr& Model_Application::getDocument(string t // load it if it must be loaded by demand if (myLoadedByDemand.find(theDocID) != myLoadedByDemand.end() && !myPath.empty()) { aNew->load(myPath.c_str()); - myLoadedByDemand.erase(theDocID); // done, don't do it anymore + myLoadedByDemand.erase(theDocID); // done, don't do it anymore } return myDocs[theDocID]; @@ -69,7 +69,7 @@ Model_Application::Model_Application() //======================================================================= void Model_Application::Formats(TColStd_SequenceOfExtendedString& theFormats) { - theFormats.Append(TCollection_ExtendedString("BinOcaf")); // standard binary schema + theFormats.Append(TCollection_ExtendedString("BinOcaf")); // standard binary schema } //======================================================================= diff --git a/src/Model/Model_Application.h b/src/Model/Model_Application.h index 0d6bef774..09a1694c3 100644 --- a/src/Model/Model_Application.h +++ b/src/Model/Model_Application.h @@ -19,13 +19,14 @@ DEFINE_STANDARD_HANDLE(Model_Application, TDocStd_Application) * Application supports the formats and document management. It is uses OCAF-lke * architecture and just implements specific features of the module. */ -class Model_Application: public TDocStd_Application +class Model_Application : public TDocStd_Application { -public: + public: // useful methods inside of the module // CASCADE RTTI - DEFINE_STANDARD_RTTI(Model_Application); + DEFINE_STANDARD_RTTI(Model_Application) + ; //! Retuns the application: one per process MODEL_EXPORT static Handle_Model_Application getApplication(); @@ -41,7 +42,7 @@ public: //! Defines that specified document must be loaded by demand void setLoadByDemand(std::string theID); -public: + public: // Redefined OCAF methods //! Return name of resource (i.e. "Standard") Standard_CString ResourcesName(); @@ -53,7 +54,7 @@ public: //! the static instance of the object (or derive your own application) Model_Application(); -private: + private: /// Map from string identifiers to created documents of an application std::map > myDocs; /// Path for the loaded by demand documents diff --git a/src/Model/Model_AttributeBoolean.cpp b/src/Model/Model_AttributeBoolean.cpp index 07c482b07..74901271e 100644 --- a/src/Model/Model_AttributeBoolean.cpp +++ b/src/Model/Model_AttributeBoolean.cpp @@ -19,7 +19,7 @@ void Model_AttributeBoolean::setValue(bool theValue) bool Model_AttributeBoolean::value() { - return myBool->Get() == Standard_True; + return myBool->Get() == Standard_True ; } Model_AttributeBoolean::Model_AttributeBoolean(TDF_Label& theLabel) diff --git a/src/Model/Model_AttributeBoolean.h b/src/Model/Model_AttributeBoolean.h index 8626cdc11..0e4fbdf61 100644 --- a/src/Model/Model_AttributeBoolean.h +++ b/src/Model/Model_AttributeBoolean.h @@ -17,15 +17,15 @@ class Model_AttributeBoolean : public ModelAPI_AttributeBoolean { - Handle_TDataStd_Integer myBool; ///< double is Real attribute -public: + Handle_TDataStd_Integer myBool; ///< double is Real attribute + public: /// Defines the double value MODEL_EXPORT virtual void setValue(bool theValue); /// Returns the double value MODEL_EXPORT virtual bool value(); -protected: + protected: /// Initializes attibutes Model_AttributeBoolean(TDF_Label& theLabel); diff --git a/src/Model/Model_AttributeDocRef.cpp b/src/Model/Model_AttributeDocRef.cpp index 83615e30e..806408d33 100644 --- a/src/Model/Model_AttributeDocRef.cpp +++ b/src/Model/Model_AttributeDocRef.cpp @@ -22,7 +22,7 @@ boost::shared_ptr Model_AttributeDocRef::value() { if (myComment->Get().Length()) return Model_Application::getApplication()->getDocument( - TCollection_AsciiString(myComment->Get()).ToCString()); + TCollection_AsciiString(myComment->Get()).ToCString()); // not initialized return boost::shared_ptr(); } @@ -33,7 +33,7 @@ Model_AttributeDocRef::Model_AttributeDocRef(TDF_Label& theLabel) if (!myIsInitialized) { // create attribute: not initialized by value yet, just empty string myComment = TDataStd_Comment::Set(theLabel, ""); - } else { // document was already referenced: try to set it as loaded by demand + } else { // document was already referenced: try to set it as loaded by demand Handle(Model_Application) anApp = Model_Application::getApplication(); string anID(TCollection_AsciiString(myComment->Get()).ToCString()); if (!anApp->hasDocument(anID)) { diff --git a/src/Model/Model_AttributeDocRef.h b/src/Model/Model_AttributeDocRef.h index b17ddf147..dc731701d 100644 --- a/src/Model/Model_AttributeDocRef.h +++ b/src/Model/Model_AttributeDocRef.h @@ -17,15 +17,15 @@ class Model_AttributeDocRef : public ModelAPI_AttributeDocRef { - Handle_TDataStd_Comment myComment; ///< reference to document is identified as string-id -public: + 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(boost::shared_ptr theDoc); /// Returns document referenced from this attribute MODEL_EXPORT virtual boost::shared_ptr value(); -protected: + protected: /// Initializes attibutes Model_AttributeDocRef(TDF_Label& theLabel); diff --git a/src/Model/Model_AttributeDouble.h b/src/Model/Model_AttributeDouble.h index 5b206afe2..c9b54b863 100644 --- a/src/Model/Model_AttributeDouble.h +++ b/src/Model/Model_AttributeDouble.h @@ -17,15 +17,15 @@ class Model_AttributeDouble : public ModelAPI_AttributeDouble { - Handle_TDataStd_Real myReal; ///< double is Real attribute -public: + Handle_TDataStd_Real myReal; ///< double is Real attribute + public: /// Defines the double value MODEL_EXPORT virtual void setValue(const double theValue); /// Returns the double value MODEL_EXPORT virtual double value(); -protected: + protected: /// Initializes attibutes Model_AttributeDouble(TDF_Label& theLabel); diff --git a/src/Model/Model_AttributeRefAttr.cpp b/src/Model/Model_AttributeRefAttr.cpp index 09ea70ef7..560a3fd06 100644 --- a/src/Model/Model_AttributeRefAttr.cpp +++ b/src/Model/Model_AttributeRefAttr.cpp @@ -16,11 +16,11 @@ bool Model_AttributeRefAttr::isObject() void Model_AttributeRefAttr::setAttr(boost::shared_ptr theAttr) { - boost::shared_ptr aData = - boost::dynamic_pointer_cast(theAttr->owner()->data()); + boost::shared_ptr aData = boost::dynamic_pointer_cast( + theAttr->owner()->data()); string anID = aData->id(theAttr); if (myIsInitialized && object() == theAttr->owner() && myID->Get().IsEqual(anID.c_str())) - return; // nothing is changed + return; // nothing is changed myRef->Set(aData->label().Father()); myID->Set(aData->id(theAttr).c_str()); @@ -31,8 +31,7 @@ boost::shared_ptr Model_AttributeRefAttr::attr() { ObjectPtr anObj = object(); if (anObj) { - boost::shared_ptr aData = - boost::dynamic_pointer_cast(anObj->data()); + boost::shared_ptr aData = boost::dynamic_pointer_cast(anObj->data()); return aData->attribute(TCollection_AsciiString(myID->Get()).ToCString()); } // not initialized @@ -42,19 +41,19 @@ boost::shared_ptr Model_AttributeRefAttr::attr() void Model_AttributeRefAttr::setObject(ObjectPtr theObject) { if (!myIsInitialized || myID->Get().Length() != 0 || object() != theObject) { - boost::shared_ptr aData = - boost::dynamic_pointer_cast(theObject->data()); + boost::shared_ptr aData = boost::dynamic_pointer_cast( + theObject->data()); myRef->Set(aData->label().Father()); - myID->Set(""); // feature is identified by the empty ID + myID->Set(""); // feature is identified by the empty ID owner()->data()->sendAttributeUpdated(this); } } ObjectPtr Model_AttributeRefAttr::object() { - if (myRef->Get() != myRef->Label()) { // initialized - boost::shared_ptr aDoc = - boost::dynamic_pointer_cast(owner()->document()); + if (myRef->Get() != myRef->Label()) { // initialized + boost::shared_ptr aDoc = boost::dynamic_pointer_cast( + owner()->document()); if (aDoc) { TDF_Label aRefLab = myRef->Get(); return aDoc->object(aRefLab); @@ -70,7 +69,7 @@ Model_AttributeRefAttr::Model_AttributeRefAttr(TDF_Label& theLabel) if (!myIsInitialized) { // create attribute: not initialized by value yet myID = TDataStd_Comment::Set(theLabel, ""); - myRef = TDF_Reference::Set(theLabel, theLabel); // not initialized: reference to itself + myRef = TDF_Reference::Set(theLabel, theLabel); // not initialized: reference to itself } else { theLabel.FindAttribute(TDF_Reference::GetID(), myRef); } diff --git a/src/Model/Model_AttributeRefAttr.h b/src/Model/Model_AttributeRefAttr.h index efb879c6d..83eaf77f2 100644 --- a/src/Model/Model_AttributeRefAttr.h +++ b/src/Model/Model_AttributeRefAttr.h @@ -19,10 +19,10 @@ class Model_AttributeRefAttr : public ModelAPI_AttributeRefAttr { - Handle_TDF_Reference myRef; ///< reference to the feature label - ///< ID of the referenced attirbute (empty if this is a reference to a feature) + Handle_TDF_Reference myRef; ///< reference to the feature label + ///< ID of the referenced attirbute (empty if this is a reference to a feature) Handle_TDataStd_Comment myID; -public: + public: /// Returns true if this attribute references to a object (not to the attribute) MODEL_EXPORT virtual bool isObject(); @@ -38,7 +38,7 @@ public: /// Returns object referenced from this attribute MODEL_EXPORT virtual ObjectPtr object(); -protected: + protected: /// Objects are created for features automatically MODEL_EXPORT Model_AttributeRefAttr(TDF_Label& theLabel); diff --git a/src/Model/Model_AttributeRefList.cpp b/src/Model/Model_AttributeRefList.cpp index a341ad2bd..3d3af3467 100644 --- a/src/Model/Model_AttributeRefList.cpp +++ b/src/Model/Model_AttributeRefList.cpp @@ -12,17 +12,15 @@ using namespace std; void Model_AttributeRefList::append(ObjectPtr theObject) { - boost::shared_ptr aData = - boost::dynamic_pointer_cast(theObject->data()); - myRef->Append(aData->label().Father()); // store label of the object + boost::shared_ptr aData = boost::dynamic_pointer_cast(theObject->data()); + myRef->Append(aData->label().Father()); // store label of the object owner()->data()->sendAttributeUpdated(this); } void Model_AttributeRefList::remove(ObjectPtr theObject) { - boost::shared_ptr aData = - boost::dynamic_pointer_cast(theObject->data()); + boost::shared_ptr aData = boost::dynamic_pointer_cast(theObject->data()); myRef->Remove(aData->label().Father()); owner()->data()->sendAttributeUpdated(this); @@ -35,12 +33,12 @@ int Model_AttributeRefList::size() list Model_AttributeRefList::list() { - std::list< ObjectPtr > aResult; - boost::shared_ptr aDoc = - boost::dynamic_pointer_cast(owner()->document()); + std::list aResult; + boost::shared_ptr aDoc = boost::dynamic_pointer_cast( + owner()->document()); if (aDoc) { const TDF_LabelList& aList = myRef->List(); - for(TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) { + for (TDF_ListIteratorOfLabelList aLIter(aList); aLIter.More(); aLIter.Next()) { ObjectPtr anObj = aDoc->object(aLIter.Value()); aResult.push_back(anObj); } diff --git a/src/Model/Model_AttributeRefList.h b/src/Model/Model_AttributeRefList.h index 87525753e..d784769e6 100644 --- a/src/Model/Model_AttributeRefList.h +++ b/src/Model/Model_AttributeRefList.h @@ -18,8 +18,8 @@ class Model_AttributeRefList : public ModelAPI_AttributeRefList { - Handle_TDataStd_ReferenceList myRef; ///< references to the features labels -public: + Handle_TDataStd_ReferenceList myRef; ///< references to the features labels + public: /// Appends the feature to the end of a list MODEL_EXPORT virtual void append(ObjectPtr theObject); @@ -30,9 +30,9 @@ public: MODEL_EXPORT virtual int size(); /// Returns the list of features - MODEL_EXPORT virtual std::list list(); + MODEL_EXPORT virtual std::list list(); -protected: + protected: /// Objects are created for features automatically MODEL_EXPORT Model_AttributeRefList(TDF_Label& theLabel); diff --git a/src/Model/Model_AttributeReference.cpp b/src/Model/Model_AttributeReference.cpp index 3169bd57a..dfb54c5f1 100644 --- a/src/Model/Model_AttributeReference.cpp +++ b/src/Model/Model_AttributeReference.cpp @@ -13,9 +13,9 @@ using namespace std; void Model_AttributeReference::setValue(ObjectPtr theObject) { if (!myIsInitialized || value() != theObject) { - boost::shared_ptr aData = - boost::dynamic_pointer_cast(theObject->data()); - myRef->Set(aData->label().Father()); // references to the feature label + boost::shared_ptr aData = boost::dynamic_pointer_cast( + theObject->data()); + myRef->Set(aData->label().Father()); // references to the feature label owner()->data()->sendAttributeUpdated(this); } } @@ -23,8 +23,8 @@ void Model_AttributeReference::setValue(ObjectPtr theObject) ObjectPtr Model_AttributeReference::value() { if (myIsInitialized) { - boost::shared_ptr aDoc = - boost::dynamic_pointer_cast(owner()->document()); + boost::shared_ptr aDoc = boost::dynamic_pointer_cast( + owner()->document()); if (aDoc) { TDF_Label aRefLab = myRef->Get(); return aDoc->object(aRefLab); @@ -38,5 +38,5 @@ Model_AttributeReference::Model_AttributeReference(TDF_Label& theLabel) { myIsInitialized = theLabel.FindAttribute(TDF_Reference::GetID(), myRef) == Standard_True; if (!myIsInitialized) - myRef = TDF_Reference::Set(theLabel, theLabel); // not initialized references to itself + myRef = TDF_Reference::Set(theLabel, theLabel); // not initialized references to itself } diff --git a/src/Model/Model_AttributeReference.h b/src/Model/Model_AttributeReference.h index 356a519b2..da4eb7fbc 100644 --- a/src/Model/Model_AttributeReference.h +++ b/src/Model/Model_AttributeReference.h @@ -18,15 +18,15 @@ class Model_AttributeReference : public ModelAPI_AttributeReference { - Handle_TDF_Reference myRef; ///< references to the feature label -public: + Handle_TDF_Reference myRef; ///< references to the feature label + public: /// Defines the object referenced from this attribute MODEL_EXPORT virtual void setValue(ObjectPtr theObject); /// Returns object referenced from this attribute MODEL_EXPORT virtual ObjectPtr value(); -protected: + protected: /// Objects are created for features automatically MODEL_EXPORT Model_AttributeReference(TDF_Label& theLabel); diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 2cf5b1b86..592fc75db 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -17,7 +17,6 @@ #include #include - using namespace std; Model_Data::Model_Data() @@ -34,7 +33,7 @@ string Model_Data::name() Handle(TDataStd_Name) aName; if (myLab.FindAttribute(TDataStd_Name::GetID(), aName)) return string(TCollection_AsciiString(aName->Get()).ToCString()); - return ""; // not defined + return ""; // not defined } void Model_Data::setName(const string& theName) @@ -51,9 +50,9 @@ void Model_Data::setName(const string& theName) } // to do not cause the update of the result on name change /*if (isModified) { - static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); - ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false); - }*/ + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); + ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false); + }*/ } void Model_Data::addAttribute(const string& theID, const string theAttrType) @@ -82,8 +81,7 @@ void Model_Data::addAttribute(const string& theID, const string theAttrType) if (anAttr) { myAttrs[theID] = boost::shared_ptr(anAttr); anAttr->setObject(myObject); - } - else { + } else { Events_Error::send("Can not create unknown type of attribute " + theAttrType); } } @@ -95,8 +93,8 @@ boost::shared_ptr Model_Data::docRef(const string& the // TODO: generate error on unknown attribute request and/or add mechanism for customization return boost::shared_ptr(); } - boost::shared_ptr aRes = - boost::dynamic_pointer_cast(aFound->second); + boost::shared_ptr aRes = boost::dynamic_pointer_cast< + ModelAPI_AttributeDocRef>(aFound->second); if (!aRes) { // TODO: generate error on invalid attribute type request } @@ -110,8 +108,8 @@ boost::shared_ptr Model_Data::real(const string& theID // TODO: generate error on unknown attribute request and/or add mechanism for customization return boost::shared_ptr(); } - boost::shared_ptr aRes = - boost::dynamic_pointer_cast(aFound->second); + boost::shared_ptr aRes = boost::dynamic_pointer_cast< + ModelAPI_AttributeDouble>(aFound->second); if (!aRes) { // TODO: generate error on invalid attribute type request } @@ -125,8 +123,8 @@ boost::shared_ptr Model_Data::boolean(const std::stri // TODO: generate error on unknown attribute request and/or add mechanism for customization return boost::shared_ptr(); } - boost::shared_ptr aRes = - boost::dynamic_pointer_cast(aFound->second); + boost::shared_ptr aRes = boost::dynamic_pointer_cast< + ModelAPI_AttributeBoolean>(aFound->second); if (!aRes) { // TODO: generate error on invalid attribute type request } @@ -140,8 +138,8 @@ boost::shared_ptr Model_Data::reference(const strin // TODO: generate error on unknown attribute request and/or add mechanism for customization return boost::shared_ptr(); } - boost::shared_ptr aRes = - boost::dynamic_pointer_cast(aFound->second); + boost::shared_ptr aRes = boost::dynamic_pointer_cast< + ModelAPI_AttributeReference>(aFound->second); if (!aRes) { // TODO: generate error on invalid attribute type request } @@ -155,8 +153,8 @@ boost::shared_ptr Model_Data::refattr(const string& t // TODO: generate error on unknown attribute request and/or add mechanism for customization return boost::shared_ptr(); } - boost::shared_ptr aRes = - boost::dynamic_pointer_cast(aFound->second); + boost::shared_ptr aRes = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aFound->second); if (!aRes) { // TODO: generate error on invalid attribute type request } @@ -170,8 +168,8 @@ boost::shared_ptr Model_Data::reflist(const string& t // TODO: generate error on unknown attribute request and/or add mechanism for customization return boost::shared_ptr(); } - boost::shared_ptr aRes = - boost::dynamic_pointer_cast(aFound->second); + boost::shared_ptr aRes = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefList>(aFound->second); if (!aRes) { // TODO: generate error on invalid attribute type request } @@ -181,7 +179,7 @@ boost::shared_ptr Model_Data::reflist(const string& t boost::shared_ptr Model_Data::attribute(const std::string& theID) { boost::shared_ptr aResult; - if (myAttrs.find(theID) == myAttrs.end()) // no such attribute + if (myAttrs.find(theID) == myAttrs.end()) // no such attribute return aResult; return myAttrs[theID]; } @@ -189,8 +187,9 @@ boost::shared_ptr Model_Data::attribute(const std::string& t const string& Model_Data::id(const boost::shared_ptr& theAttr) { map >::iterator anAttr = myAttrs.begin(); - for(; anAttr != myAttrs.end(); anAttr++) { - if (anAttr->second == theAttr) return anAttr->first; + for (; anAttr != myAttrs.end(); anAttr++) { + if (anAttr->second == theAttr) + return anAttr->first; } // not found static string anEmpty; @@ -201,7 +200,7 @@ bool Model_Data::isEqual(const boost::shared_ptr& theData) { boost::shared_ptr aData = boost::dynamic_pointer_cast(theData); if (aData) - return myLab.IsEqual(aData->myLab) == Standard_True; + return myLab.IsEqual(aData->myLab) == Standard_True ; return false; } @@ -214,7 +213,7 @@ list > Model_Data::attributes(const string { list > aResult; map >::iterator anAttrsIter = myAttrs.begin(); - for(; anAttrsIter != myAttrs.end(); anAttrsIter++) { + for (; anAttrsIter != myAttrs.end(); anAttrsIter++) { if (theType.empty() || anAttrsIter->second->attributeType() == theType) { aResult.push_back(anAttrsIter->second); } diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index cf002ad19..ce939de8f 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -20,9 +20,9 @@ class ModelAPI_Attribute; * to get/set attributes from the document and compute result of an operation. */ -class Model_Data: public ModelAPI_Data +class Model_Data : public ModelAPI_Data { - TDF_Label myLab; ///< label of the feature in the document + TDF_Label myLab; ///< label of the feature in the document /// All attributes of the object identified by the attribute ID std::map > myAttrs; @@ -32,14 +32,17 @@ class Model_Data: public ModelAPI_Data Model_Data(); /// Returns label of this feature - TDF_Label label() {return myLab;} + TDF_Label label() + { + return myLab; + } friend class Model_Document; friend class Model_AttributeReference; friend class Model_AttributeRefAttr; friend class Model_AttributeRefList; -public: + public: /// Returns the name of the feature visible by the user in the object browser MODEL_EXPORT virtual std::string name(); /// Defines the name of the feature visible by the user in the object browser @@ -49,24 +52,24 @@ public: /// Returns the attribute that contains real value with double precision MODEL_EXPORT virtual boost::shared_ptr real(const std::string& theID); /// Returns the attribute that contains reference to a feature - MODEL_EXPORT virtual boost::shared_ptr - reference(const std::string& theID); + MODEL_EXPORT virtual boost::shared_ptr + reference(const std::string& theID); /// Returns the attribute that contains reference to an attribute of a feature MODEL_EXPORT virtual boost::shared_ptr - refattr(const std::string& theID); + refattr(const std::string& theID); /// Returns the attribute that contains list of references to features - MODEL_EXPORT virtual boost::shared_ptr - reflist(const std::string& theID); + MODEL_EXPORT virtual boost::shared_ptr + reflist(const std::string& theID); /// Returns the attribute that contains boolean value - MODEL_EXPORT virtual boost::shared_ptr - boolean(const std::string& theID); + MODEL_EXPORT virtual boost::shared_ptr + boolean(const std::string& theID); /// Returns the generic attribute by identifier /// \param theID identifier of the attribute MODEL_EXPORT virtual boost::shared_ptr attribute(const std::string& theID); /// Returns all attributes ofthe feature of the given type /// or all attributes if "theType" is empty MODEL_EXPORT virtual std::list > - attributes(const std::string& theType); + attributes(const std::string& theType); /// Identifier by the id (not fast, iteration by map) /// \param theAttr attribute already created in this data @@ -77,7 +80,10 @@ public: MODEL_EXPORT virtual bool isValid(); /// Returns the label where the shape must be stored (used in ResultBody) - TDF_Label& shapeLab() {return myLab;} + TDF_Label& shapeLab() + { + return myLab; + } /// Initializes object by the attributes: must be called just after the object is created /// for each attribute of the object @@ -94,7 +100,9 @@ public: /// Sets the object of this data MODEL_EXPORT virtual void setObject(ObjectPtr theObject) - {myObject = theObject;} + { + myObject = theObject; + } }; #endif diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 9d8cb9b8a..e667f2e61 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -34,19 +34,19 @@ # define _separator_ '/' #endif -static const int UNDO_LIMIT = 10; // number of possible undo operations +static const int UNDO_LIMIT = 10; // number of possible undo operations -static const int TAG_GENERAL = 1; // general properties tag -static const int TAG_OBJECTS = 2; // tag of the objects sub-tree (features, results) -static const int TAG_HISTORY = 3; // tag of the history sub-tree (python dump) +static const int TAG_GENERAL = 1; // general properties tag +static const int TAG_OBJECTS = 2; // tag of the objects sub-tree (features, results) +static const int TAG_HISTORY = 3; // tag of the history sub-tree (python dump) // feature sub-labels -static const int TAG_FEATURE_ARGUMENTS = 1; ///< where the arguments are located -static const int TAG_FEATURE_RESULTS = 2; ///< where the results are located - +static const int TAG_FEATURE_ARGUMENTS = 1; ///< where the arguments are located +static const int TAG_FEATURE_RESULTS = 2; ///< where the results are located Model_Document::Model_Document(const std::string theID) - : myID(theID), myDoc(new TDocStd_Document("BinOcaf")) // binary OCAF format + : myID(theID), + myDoc(new TDocStd_Document("BinOcaf")) // binary OCAF format { myDoc->SetUndoLimit(UNDO_LIMIT); myTransactionsAfterSave = 0; @@ -62,10 +62,10 @@ Model_Document::Model_Document(const std::string theID) /// Returns the file name of this document by the nameof directory and identifuer of a document static TCollection_ExtendedString DocFileName(const char* theFileName, const std::string& theID) { - TCollection_ExtendedString aPath ((const Standard_CString)theFileName); + TCollection_ExtendedString aPath((const Standard_CString) theFileName); aPath += _separator_; aPath += theID.c_str(); - aPath += ".cbf"; // standard binary file extension + aPath += ".cbf"; // standard binary file extension return aPath; } @@ -75,59 +75,68 @@ bool Model_Document::load(const char* theFileName) if (this == Model_PluginManager::get()->rootDocument().get()) { anApp->setLoadPath(theFileName); } - TCollection_ExtendedString aPath (DocFileName(theFileName, myID)); + TCollection_ExtendedString aPath(DocFileName(theFileName, myID)); PCDM_ReaderStatus aStatus = (PCDM_ReaderStatus) -1; - try - { + try { aStatus = anApp->Open(aPath, myDoc); - } - catch (Standard_Failure) - { + } catch (Standard_Failure) { Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - Events_Error::send(std::string("Exception in opening of document: ") + aFail->GetMessageString()); + Events_Error::send( + std::string("Exception in opening of document: ") + aFail->GetMessageString()); return false; } bool isError = aStatus != PCDM_RS_OK; - if (isError) - { - switch (aStatus) - { - case PCDM_RS_UnknownDocument: - Events_Error::send(std::string("Can not open document: PCDM_RS_UnknownDocument")); break; - case PCDM_RS_AlreadyRetrieved: - Events_Error::send(std::string("Can not open document: PCDM_RS_AlreadyRetrieved")); break; - case PCDM_RS_AlreadyRetrievedAndModified: - Events_Error::send( - std::string("Can not open document: PCDM_RS_AlreadyRetrievedAndModified")); - break; - case PCDM_RS_NoDriver: - Events_Error::send(std::string("Can not open document: PCDM_RS_NoDriver")); break; - case PCDM_RS_UnknownFileDriver: - Events_Error::send(std::string("Can not open document: PCDM_RS_UnknownFileDriver")); break; - case PCDM_RS_OpenError: - Events_Error::send(std::string("Can not open document: PCDM_RS_OpenError")); break; - case PCDM_RS_NoVersion: - Events_Error::send(std::string("Can not open document: PCDM_RS_NoVersion")); break; - case PCDM_RS_NoModel: - Events_Error::send(std::string("Can not open document: PCDM_RS_NoModel")); break; - case PCDM_RS_NoDocument: - Events_Error::send(std::string("Can not open document: PCDM_RS_NoDocument")); break; - case PCDM_RS_FormatFailure: - Events_Error::send(std::string("Can not open document: PCDM_RS_FormatFailure")); break; - case PCDM_RS_TypeNotFoundInSchema: - Events_Error::send(std::string("Can not open document: PCDM_RS_TypeNotFoundInSchema")); - break; - case PCDM_RS_UnrecognizedFileFormat: - Events_Error::send(std::string("Can not open document: PCDM_RS_UnrecognizedFileFormat")); - break; - case PCDM_RS_MakeFailure: - Events_Error::send(std::string("Can not open document: PCDM_RS_MakeFailure")); break; - case PCDM_RS_PermissionDenied: - Events_Error::send(std::string("Can not open document: PCDM_RS_PermissionDenied")); break; - case PCDM_RS_DriverFailure: - Events_Error::send(std::string("Can not open document: PCDM_RS_DriverFailure")); break; - default: - Events_Error::send(std::string("Can not open document: unknown error")); break; + if (isError) { + switch (aStatus) { + case PCDM_RS_UnknownDocument: + Events_Error::send(std::string("Can not open document: PCDM_RS_UnknownDocument")); + break; + case PCDM_RS_AlreadyRetrieved: + Events_Error::send(std::string("Can not open document: PCDM_RS_AlreadyRetrieved")); + break; + case PCDM_RS_AlreadyRetrievedAndModified: + Events_Error::send( + std::string("Can not open document: PCDM_RS_AlreadyRetrievedAndModified")); + break; + case PCDM_RS_NoDriver: + Events_Error::send(std::string("Can not open document: PCDM_RS_NoDriver")); + break; + case PCDM_RS_UnknownFileDriver: + Events_Error::send(std::string("Can not open document: PCDM_RS_UnknownFileDriver")); + break; + case PCDM_RS_OpenError: + Events_Error::send(std::string("Can not open document: PCDM_RS_OpenError")); + break; + case PCDM_RS_NoVersion: + Events_Error::send(std::string("Can not open document: PCDM_RS_NoVersion")); + break; + case PCDM_RS_NoModel: + Events_Error::send(std::string("Can not open document: PCDM_RS_NoModel")); + break; + case PCDM_RS_NoDocument: + Events_Error::send(std::string("Can not open document: PCDM_RS_NoDocument")); + break; + case PCDM_RS_FormatFailure: + Events_Error::send(std::string("Can not open document: PCDM_RS_FormatFailure")); + break; + case PCDM_RS_TypeNotFoundInSchema: + Events_Error::send(std::string("Can not open document: PCDM_RS_TypeNotFoundInSchema")); + break; + case PCDM_RS_UnrecognizedFileFormat: + Events_Error::send(std::string("Can not open document: PCDM_RS_UnrecognizedFileFormat")); + break; + case PCDM_RS_MakeFailure: + Events_Error::send(std::string("Can not open document: PCDM_RS_MakeFailure")); + break; + case PCDM_RS_PermissionDenied: + Events_Error::send(std::string("Can not open document: PCDM_RS_PermissionDenied")); + break; + case PCDM_RS_DriverFailure: + Events_Error::send(std::string("Can not open document: PCDM_RS_DriverFailure")); + break; + default: + Events_Error::send(std::string("Can not open document: unknown error")); + break; } } if (!isError) { @@ -144,7 +153,7 @@ bool Model_Document::save(const char* theFileName) #ifdef WIN32 CreateDirectory(theFileName, NULL); #else - mkdir(theFileName, 0x1ff); + mkdir(theFileName, 0x1ff); #endif } // filename in the dir is id of document inside of the given directory @@ -152,33 +161,31 @@ bool Model_Document::save(const char* theFileName) PCDM_StoreStatus aStatus; try { aStatus = Model_Application::getApplication()->SaveAs(myDoc, aPath); - } - catch (Standard_Failure) { + } catch (Standard_Failure) { Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - Events_Error::send(std::string("Exception in saving of document: ") + aFail->GetMessageString()); + Events_Error::send( + std::string("Exception in saving of document: ") + aFail->GetMessageString()); return false; } bool isDone = aStatus == PCDM_SS_OK || aStatus == PCDM_SS_No_Obj; - if (!isDone) - { - switch (aStatus) - { - case PCDM_SS_DriverFailure: - Events_Error::send(std::string("Can not save document: PCDM_SS_DriverFailure")); - break; - case PCDM_SS_WriteFailure: - Events_Error::send(std::string("Can not save document: PCDM_SS_WriteFailure")); - break; - case PCDM_SS_Failure: - default: - Events_Error::send(std::string("Can not save document: PCDM_SS_Failure")); - break; + if (!isDone) { + switch (aStatus) { + case PCDM_SS_DriverFailure: + Events_Error::send(std::string("Can not save document: PCDM_SS_DriverFailure")); + break; + case PCDM_SS_WriteFailure: + Events_Error::send(std::string("Can not save document: PCDM_SS_WriteFailure")); + break; + case PCDM_SS_Failure: + default: + Events_Error::send(std::string("Can not save document: PCDM_SS_Failure")); + break; } } myTransactionsAfterSave = 0; - if (isDone) { // save also sub-documents if any + if (isDone) { // save also sub-documents if any std::set::iterator aSubIter = mySubs.begin(); - for(; aSubIter != mySubs.end() && isDone; aSubIter++) + for (; aSubIter != mySubs.end() && isDone; aSubIter++) isDone = subDocument(*aSubIter)->save(theFileName); } return isDone; @@ -187,26 +194,25 @@ bool Model_Document::save(const char* theFileName) void Model_Document::close() { boost::shared_ptr aPM = Model_PluginManager::get(); - if (this != aPM->rootDocument().get() && - this == aPM->currentDocument().get()) { + if (this != aPM->rootDocument().get() && this == aPM->currentDocument().get()) { aPM->setCurrentDocument(aPM->rootDocument()); } // close all subs std::set::iterator aSubIter = mySubs.begin(); - for(; aSubIter != mySubs.end(); aSubIter++) + for (; aSubIter != mySubs.end(); aSubIter++) subDocument(*aSubIter)->close(); mySubs.clear(); // close this /* do not close because it can be undoed - if (myDoc->CanClose() == CDM_CCS_OK) - myDoc->Close(); - Model_Application::getApplication()->deleteDocument(myID); - */ + if (myDoc->CanClose() == CDM_CCS_OK) + myDoc->Close(); + Model_Application::getApplication()->deleteDocument(myID); + */ } void Model_Document::startOperation() { - if (myDoc->HasOpenCommand()) { // start of nested command + if (myDoc->HasOpenCommand()) { // start of nested command if (myNestedNum == -1) { myNestedNum = 0; myDoc->InitDeltaCompaction(); @@ -214,18 +220,19 @@ void Model_Document::startOperation() myIsEmptyTr[myTransactionsAfterSave] = false; myTransactionsAfterSave++; myDoc->NewCommand(); - } else { // start the simple command + } else { // start the simple command myDoc->NewCommand(); } // new command for all subs std::set::iterator aSubIter = mySubs.begin(); - for(; aSubIter != mySubs.end(); aSubIter++) + for (; aSubIter != mySubs.end(); aSubIter++) subDocument(*aSubIter)->startOperation(); } -void Model_Document::compactNested() { +void Model_Document::compactNested() +{ bool allWasEmpty = true; - while(myNestedNum != -1) { + while (myNestedNum != -1) { myTransactionsAfterSave--; if (!myIsEmptyTr[myTransactionsAfterSave]) { allWasEmpty = false; @@ -241,19 +248,19 @@ void Model_Document::compactNested() { void Model_Document::finishOperation() { // just to be sure that everybody knows that changes were performed - + if (!myDoc->HasOpenCommand() && myNestedNum != -1) - boost::static_pointer_cast(Model_PluginManager::get())-> - setCheckTransactions(false); // for nested transaction commit + boost::static_pointer_cast(Model_PluginManager::get()) + ->setCheckTransactions(false); // for nested transaction commit Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED)); if (!myDoc->HasOpenCommand() && myNestedNum != -1) - boost::static_pointer_cast(Model_PluginManager::get())-> - setCheckTransactions(true); // for nested transaction commit + boost::static_pointer_cast(Model_PluginManager::get()) + ->setCheckTransactions(true); // for nested transaction commit - if (myNestedNum != -1) // this nested transaction is owervritten + if (myNestedNum != -1) // this nested transaction is owervritten myNestedNum++; if (!myDoc->HasOpenCommand()) { if (myNestedNum != -1) { @@ -262,20 +269,20 @@ void Model_Document::finishOperation() } } else { // returns false if delta is empty and no transaction was made - myIsEmptyTr[myTransactionsAfterSave] = !myDoc->CommitCommand();// && (myNestedNum == -1); + myIsEmptyTr[myTransactionsAfterSave] = !myDoc->CommitCommand(); // && (myNestedNum == -1); myTransactionsAfterSave++; } // finish for all subs std::set::iterator aSubIter = mySubs.begin(); - for(; aSubIter != mySubs.end(); aSubIter++) + for (; aSubIter != mySubs.end(); aSubIter++) subDocument(*aSubIter)->finishOperation(); } void Model_Document::abortOperation() { - if (myNestedNum > 0 && !myDoc->HasOpenCommand()) { // abort all what was done in nested - // first compact all nested + if (myNestedNum > 0 && !myDoc->HasOpenCommand()) { // abort all what was done in nested + // first compact all nested compactNested(); // for nested it is undo and clear redos myDoc->Undo(); @@ -283,21 +290,21 @@ void Model_Document::abortOperation() myTransactionsAfterSave--; myIsEmptyTr.erase(myTransactionsAfterSave); } else { - if (myNestedNum == 0) // abort only high-level + if (myNestedNum == 0) // abort only high-level myNestedNum = -1; myDoc->AbortCommand(); } synchronizeFeatures(true); // abort for all subs std::set::iterator aSubIter = mySubs.begin(); - for(; aSubIter != mySubs.end(); aSubIter++) + for (; aSubIter != mySubs.end(); aSubIter++) subDocument(*aSubIter)->abortOperation(); } bool Model_Document::isOperation() { // operation is opened for all documents: no need to check subs - return myDoc->HasOpenCommand() == Standard_True; + return myDoc->HasOpenCommand() == Standard_True ; } bool Model_Document::isModified() @@ -308,11 +315,12 @@ bool Model_Document::isModified() bool Model_Document::canUndo() { - if (myDoc->GetAvailableUndos() > 0 && myNestedNum != 0 && myTransactionsAfterSave != 0 /* for omitting the first useless transaction */) + if (myDoc->GetAvailableUndos() > 0 && myNestedNum != 0 + && myTransactionsAfterSave != 0 /* for omitting the first useless transaction */) return true; // check other subs contains operation that can be undoed std::set::iterator aSubIter = mySubs.begin(); - for(; aSubIter != mySubs.end(); aSubIter++) + for (; aSubIter != mySubs.end(); aSubIter++) if (subDocument(*aSubIter)->canUndo()) return true; return false; @@ -321,13 +329,14 @@ bool Model_Document::canUndo() void Model_Document::undo() { myTransactionsAfterSave--; - if (myNestedNum > 0) myNestedNum--; + if (myNestedNum > 0) + myNestedNum--; if (!myIsEmptyTr[myTransactionsAfterSave]) myDoc->Undo(); synchronizeFeatures(true); // undo for all subs std::set::iterator aSubIter = mySubs.begin(); - for(; aSubIter != mySubs.end(); aSubIter++) + for (; aSubIter != mySubs.end(); aSubIter++) subDocument(*aSubIter)->undo(); } @@ -337,7 +346,7 @@ bool Model_Document::canRedo() return true; // check other subs contains operation that can be redoed std::set::iterator aSubIter = mySubs.begin(); - for(; aSubIter != mySubs.end(); aSubIter++) + for (; aSubIter != mySubs.end(); aSubIter++) if (subDocument(*aSubIter)->canRedo()) return true; return false; @@ -345,27 +354,29 @@ bool Model_Document::canRedo() void Model_Document::redo() { - if (myNestedNum != -1) myNestedNum++; + if (myNestedNum != -1) + myNestedNum++; if (!myIsEmptyTr[myTransactionsAfterSave]) myDoc->Redo(); myTransactionsAfterSave++; synchronizeFeatures(true); // redo for all subs std::set::iterator aSubIter = mySubs.begin(); - for(; aSubIter != mySubs.end(); aSubIter++) + for (; aSubIter != mySubs.end(); aSubIter++) subDocument(*aSubIter)->redo(); } /// Appenad to the array of references a new referenced label -static void AddToRefArray(TDF_Label& theArrayLab, TDF_Label& theReferenced) { +static void AddToRefArray(TDF_Label& theArrayLab, TDF_Label& theReferenced) +{ Handle(TDataStd_ReferenceArray) aRefs; if (!theArrayLab.FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) { aRefs = TDataStd_ReferenceArray::Set(theArrayLab, 0, 0); aRefs->SetValue(0, theReferenced); - } else { // extend array by one more element - Handle(TDataStd_HLabelArray1) aNewArray = - new TDataStd_HLabelArray1(aRefs->Lower(), aRefs->Upper() + 1); - for(int a = aRefs->Lower(); a <= aRefs->Upper(); a++) { + } else { // extend array by one more element + Handle(TDataStd_HLabelArray1) aNewArray = new TDataStd_HLabelArray1(aRefs->Lower(), + aRefs->Upper() + 1); + for (int a = aRefs->Lower(); a <= aRefs->Upper(); a++) { aNewArray->SetValue(a, aRefs->Value(a)); } aNewArray->SetValue(aRefs->Upper() + 1, theReferenced); @@ -378,11 +389,11 @@ FeaturePtr Model_Document::addFeature(std::string theID) TDF_Label anEmptyLab; FeaturePtr anEmptyFeature; FeaturePtr aFeature = ModelAPI_PluginManager::get()->createFeature(theID); - boost::shared_ptr aDocToAdd = - boost::dynamic_pointer_cast(aFeature->documentToAdd()); + boost::shared_ptr aDocToAdd = boost::dynamic_pointer_cast( + aFeature->documentToAdd()); if (aFeature) { TDF_Label aFeatureLab; - if (!aFeature->isAction()) {// do not add action to the data model + if (!aFeature->isAction()) { // do not add action to the data model TDF_Label aFeaturesLab = aDocToAdd->featuresLabel(); aFeatureLab = aFeaturesLab.NewChild(); aDocToAdd->initData(aFeature, aFeatureLab, TAG_FEATURE_ARGUMENTS); @@ -394,7 +405,7 @@ FeaturePtr Model_Document::addFeature(std::string theID) AddToRefArray(aFeaturesLab, aFeatureLab); } } - if (!aFeature->isAction()) {// do not add action to the data model + if (!aFeature->isAction()) { // do not add action to the data model // event: feature is added static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent); @@ -406,21 +417,22 @@ FeaturePtr Model_Document::addFeature(std::string theID) /// Appenad to the array of references a new referenced label. /// If theIndex is not -1, removes element at thisindex, not theReferenced. /// \returns the index of removed element -static int RemoveFromRefArray( - TDF_Label theArrayLab, TDF_Label theReferenced, const int theIndex = -1) { - int aResult = -1; // no returned +static int RemoveFromRefArray(TDF_Label theArrayLab, TDF_Label theReferenced, const int theIndex = + -1) +{ + int aResult = -1; // no returned Handle(TDataStd_ReferenceArray) aRefs; if (theArrayLab.FindAttribute(TDataStd_ReferenceArray::GetID(), aRefs)) { - if (aRefs->Length() == 1) { // just erase an array + if (aRefs->Length() == 1) { // just erase an array if ((theIndex == -1 && aRefs->Value(0) == theReferenced) || theIndex == 0) { theArrayLab.ForgetAttribute(TDataStd_ReferenceArray::GetID()); } aResult = 0; - } else { // reduce the array - Handle(TDataStd_HLabelArray1) aNewArray = - new TDataStd_HLabelArray1(aRefs->Lower(), aRefs->Upper() - 1); + } else { // reduce the array + Handle(TDataStd_HLabelArray1) aNewArray = new TDataStd_HLabelArray1(aRefs->Lower(), + aRefs->Upper() - 1); int aCount = aRefs->Lower(); - for(int a = aCount; a <= aRefs->Upper(); a++, aCount++) { + for (int a = aCount; a <= aRefs->Upper(); a++, aCount++) { if ((theIndex == -1 && aRefs->Value(a) == theReferenced) || theIndex == a) { aCount--; aResult = a; @@ -438,9 +450,10 @@ void Model_Document::removeFeature(FeaturePtr theFeature) { boost::shared_ptr aData = boost::static_pointer_cast(theFeature->data()); TDF_Label aFeatureLabel = aData->label().Father(); - if (myObjs.IsBound(aFeatureLabel)) + if (myObjs.IsBound(aFeatureLabel)) myObjs.UnBind(aFeatureLabel); - else return; // not found feature => do not remove + else + return; // not found feature => do not remove // erase all attributes under the label of feature aFeatureLabel.ForgetAllAttributes(); @@ -453,9 +466,9 @@ void Model_Document::removeFeature(FeaturePtr theFeature) static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); const std::list >& aResults = theFeature->results(); std::list >::const_iterator aRIter = aResults.begin(); - for(; aRIter != aResults.cend(); aRIter++) { + for (; aRIter != aResults.cend(); aRIter++) { boost::shared_ptr aRes = *aRIter; - aRes->setData(boost::shared_ptr()); // deleted flag + aRes->setData(boost::shared_ptr()); // deleted flag ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP); ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), aRes->groupName()); } @@ -465,7 +478,7 @@ FeaturePtr Model_Document::feature(TDF_Label& theLabel) { if (myObjs.IsBound(theLabel)) return myObjs.Find(theLabel); - return FeaturePtr(); // not found + return FeaturePtr(); // not found } ObjectPtr Model_Document::object(TDF_Label theLabel) @@ -474,19 +487,19 @@ ObjectPtr Model_Document::object(TDF_Label theLabel) FeaturePtr aFeature = feature(theLabel); if (aFeature) return feature(theLabel); - TDF_Label aFeatureLabel = theLabel.Father().Father(); // let's suppose it is result + TDF_Label aFeatureLabel = theLabel.Father().Father(); // let's suppose it is result aFeature = feature(aFeatureLabel); if (aFeature) { const std::list >& aResults = aFeature->results(); std::list >::const_iterator aRIter = aResults.cbegin(); - for(; aRIter != aResults.cend(); aRIter++) { - boost::shared_ptr aResData = - boost::dynamic_pointer_cast((*aRIter)->data()); + for (; aRIter != aResults.cend(); aRIter++) { + boost::shared_ptr aResData = boost::dynamic_pointer_cast( + (*aRIter)->data()); if (aResData->label().Father().IsEqual(theLabel)) return *aRIter; } } - return FeaturePtr(); // not found + return FeaturePtr(); // not found } boost::shared_ptr Model_Document::subDocument(std::string theDocID) @@ -497,14 +510,14 @@ boost::shared_ptr Model_Document::subDocument(std::string the return Model_Application::getApplication()->getDocument(theDocID); } -ObjectPtr Model_Document::object(const std::string& theGroupID, - const int theIndex, const bool theHidden) +ObjectPtr Model_Document::object(const std::string& theGroupID, const int theIndex, + const bool theHidden) { if (theGroupID == ModelAPI_Feature::group()) { if (theHidden) { int anIndex = 0; TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID()); - for(; aLabIter.More(); aLabIter.Next()) { + for (; aLabIter.More(); aLabIter.Next()) { if (theIndex == anIndex) { TDF_Label aFLabel = aLabIter.Value()->Label(); return feature(aFLabel); @@ -524,12 +537,12 @@ ObjectPtr Model_Document::object(const std::string& theGroupID, // comment must be in any feature: it is kind int anIndex = 0; TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID()); - for(; aLabIter.More(); aLabIter.Next()) { + for (; aLabIter.More(); aLabIter.Next()) { TDF_Label aFLabel = aLabIter.Value()->Label(); FeaturePtr aFeature = feature(aFLabel); const std::list >& aResults = aFeature->results(); std::list >::const_iterator aRIter = aResults.begin(); - for(; aRIter != aResults.cend(); aRIter++) { + for (; aRIter != aResults.cend(); aRIter++) { if ((theHidden || (*aRIter)->isInHistory()) && (*aRIter)->groupName() == theGroupID) { if (anIndex == theIndex) return *aRIter; @@ -542,7 +555,7 @@ ObjectPtr Model_Document::object(const std::string& theGroupID, return ObjectPtr(); } -int Model_Document::size(const std::string& theGroupID, const bool theHidden) +int Model_Document::size(const std::string& theGroupID, const bool theHidden) { int aResult = 0; if (theGroupID == ModelAPI_Feature::group()) { @@ -556,12 +569,12 @@ int Model_Document::size(const std::string& theGroupID, const bool theHidden) } else { // comment must be in any feature: it is kind TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID()); - for(; aLabIter.More(); aLabIter.Next()) { + for (; aLabIter.More(); aLabIter.Next()) { TDF_Label aFLabel = aLabIter.Value()->Label(); FeaturePtr aFeature = feature(aFLabel); const std::list >& aResults = aFeature->results(); std::list >::const_iterator aRIter = aResults.begin(); - for(; aRIter != aResults.cend(); aRIter++) { + for (; aRIter != aResults.cend(); aRIter++) { if ((theHidden || (*aRIter)->isInHistory()) && (*aRIter)->groupName() == theGroupID) { aResult++; } @@ -579,45 +592,48 @@ TDF_Label Model_Document::featuresLabel() void Model_Document::setUniqueName(FeaturePtr theFeature) { - if (!theFeature->data()->name().empty()) return; // not needed, name is already defined - std::string aName; // result + if (!theFeature->data()->name().empty()) + return; // not needed, name is already defined + std::string aName; // result // first count all objects of such kind to start with index = count + 1 int aNumObjects = 0; NCollection_DataMap::Iterator aFIter(myObjs); - for(; aFIter.More(); aFIter.Next()) { + for (; aFIter.More(); aFIter.Next()) { if (aFIter.Value()->getKind() == theFeature->getKind()) aNumObjects++; } // generate candidate name std::stringstream aNameStream; - aNameStream<getKind()<<"_"<getKind() << "_" << aNumObjects + 1; aName = aNameStream.str(); // check this is unique, if not, increase index by 1 - for(aFIter.Initialize(myObjs); aFIter.More(); ) { + for (aFIter.Initialize(myObjs); aFIter.More();) { FeaturePtr aFeature = aFIter.Value(); bool isSameName = aFeature->isInHistory() && aFeature->data()->name() == aName; - if (!isSameName) { // check also results to avoid same results names (actual for Parts) + if (!isSameName) { // check also results to avoid same results names (actual for Parts) const std::list >& aResults = aFeature->results(); std::list >::const_iterator aRIter = aResults.begin(); - for(; aRIter != aResults.cend(); aRIter++) { + for (; aRIter != aResults.cend(); aRIter++) { isSameName = (*aRIter)->isInHistory() && (*aRIter)->data()->name() == aName; } } if (isSameName) { aNumObjects++; std::stringstream aNameStream; - aNameStream<getKind()<<"_"<getKind() << "_" << aNumObjects + 1; aName = aNameStream.str(); // reinitialize iterator to make sure a new name is unique aFIter.Initialize(myObjs); - } else aFIter.Next(); + } else + aFIter.Next(); } theFeature->data()->setName(aName); } -void Model_Document::initData(ObjectPtr theObj, TDF_Label theLab, const int theTag) { - boost::shared_ptr aThis = - Model_Application::getApplication()->getDocument(myID); +void Model_Document::initData(ObjectPtr theObj, TDF_Label theLab, const int theTag) +{ + boost::shared_ptr aThis = Model_Application::getApplication()->getDocument( + myID); boost::shared_ptr aData(new Model_Data); aData->setLabel(theLab.FindChild(theTag)); aData->setObject(theObj); @@ -625,26 +641,26 @@ void Model_Document::initData(ObjectPtr theObj, TDF_Label theLab, const int theT theObj->setData(aData); FeaturePtr aFeature = boost::dynamic_pointer_cast(theObj); if (aFeature) { - setUniqueName(aFeature); // must be before "initAttributes" because duplicate part uses name + setUniqueName(aFeature); // must be before "initAttributes" because duplicate part uses name aFeature->initAttributes(); } } void Model_Document::synchronizeFeatures(const bool theMarkUpdated) { - boost::shared_ptr aThis = - Model_Application::getApplication()->getDocument(myID); + boost::shared_ptr aThis = Model_Application::getApplication()->getDocument( + myID); // update all objects by checking are they of labels or not std::set aNewFeatures, aKeptFeatures; TDF_ChildIDIterator aLabIter(featuresLabel(), TDataStd_Comment::GetID()); - for(; aLabIter.More(); aLabIter.Next()) { + for (; aLabIter.More(); aLabIter.Next()) { TDF_Label aFeatureLabel = aLabIter.Value()->Label(); - if (!myObjs.IsBound(aFeatureLabel)) { // a new feature is inserted + if (!myObjs.IsBound(aFeatureLabel)) { // a new feature is inserted // create a feature FeaturePtr aNewObj = ModelAPI_PluginManager::get()->createFeature( - TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(aLabIter.Value())->Get()) - .ToCString()); - if (!aNewObj) { // somethig is wrong, most probably, the opened document has invalid structure + TCollection_AsciiString(Handle(TDataStd_Comment)::DownCast(aLabIter.Value())->Get()) + .ToCString()); + if (!aNewObj) { // somethig is wrong, most probably, the opened document has invalid structure Events_Error::send("Invalid type of object in the document"); aLabIter.Value()->Label().ForgetAllAttributes(); continue; @@ -658,7 +674,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated) static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); ModelAPI_EventCreator::get()->sendUpdated(aNewObj, anEvent); // feature for this label is added, so go to the next label - } else { // nothing is changed, both iterators are incremented + } else { // nothing is changed, both iterators are incremented aKeptFeatures.insert(myObjs.Find(aFeatureLabel)); if (theMarkUpdated) { static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); @@ -668,14 +684,14 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated) } // execute new features to restore results: after features creation to make all references valid /*std::set::iterator aNewIter = aNewFeatures.begin(); - for(; aNewIter != aNewFeatures.end(); aNewIter++) { - (*aNewIter)->execute(); - }*/ + for(; aNewIter != aNewFeatures.end(); aNewIter++) { + (*aNewIter)->execute(); + }*/ // check all features are checked: if not => it was removed NCollection_DataMap::Iterator aFIter(myObjs); - while(aFIter.More()) { - if (aKeptFeatures.find(aFIter.Value()) == aKeptFeatures.end() && - aNewFeatures.find(aFIter.Value()) == aNewFeatures.end()) { + while (aFIter.More()) { + if (aKeptFeatures.find(aFIter.Value()) == aKeptFeatures.end() + && aNewFeatures.find(aFIter.Value()) == aNewFeatures.end()) { FeaturePtr aFeature = aFIter.Value(); TDF_Label aLab = aFIter.Key(); aFIter.Next(); @@ -688,7 +704,7 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated) static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); const std::list >& aResults = aFeature->results(); std::list >::const_iterator aRIter = aResults.begin(); - for(; aRIter != aResults.cend(); aRIter++) { + for (; aRIter != aResults.cend(); aRIter++) { boost::shared_ptr aRes = *aRIter; //aRes->setData(boost::shared_ptr()); // deleted flag ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP); @@ -696,39 +712,45 @@ void Model_Document::synchronizeFeatures(const bool theMarkUpdated) } // redisplay also removed feature (used for sketch and AISObject) ModelAPI_EventCreator::get()->sendUpdated(aFeature, EVENT_DISP); - } else aFIter.Next(); + } else + aFIter.Next(); } // after all updates, sends a message that groups of features were created or updated - boost::static_pointer_cast(Model_PluginManager::get())-> - setCheckTransactions(false); + boost::static_pointer_cast(Model_PluginManager::get())->setCheckTransactions( + false); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED)); if (theMarkUpdated) Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED)); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); - boost::static_pointer_cast(Model_PluginManager::get())-> - setCheckTransactions(true); + boost::static_pointer_cast(Model_PluginManager::get())->setCheckTransactions( + true); } void Model_Document::storeResult(boost::shared_ptr theFeatureData, - boost::shared_ptr theResult, const int theResultIndex) + boost::shared_ptr theResult, + const int theResultIndex) { - boost::shared_ptr aThis = - Model_Application::getApplication()->getDocument(myID); + boost::shared_ptr aThis = Model_Application::getApplication()->getDocument( + myID); theResult->setDoc(aThis); - initData(theResult, boost::dynamic_pointer_cast(theFeatureData)->label(). - Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theResultIndex + 1), TAG_FEATURE_ARGUMENTS); - if (theResult->data()->name().empty()) { // if was not initialized, generate event and set a name + initData( + theResult, + boost::dynamic_pointer_cast(theFeatureData)->label().Father().FindChild( + TAG_FEATURE_RESULTS).FindChild(theResultIndex + 1), + TAG_FEATURE_ARGUMENTS); + if (theResult->data()->name().empty()) { // if was not initialized, generate event and set a name theResult->data()->setName(theFeatureData->name()); } } boost::shared_ptr Model_Document::createConstruction( - const boost::shared_ptr& theFeatureData, const int theIndex) + const boost::shared_ptr& theFeatureData, const int theIndex) { - ObjectPtr anOldObject = object(boost::dynamic_pointer_cast(theFeatureData)-> - label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theIndex + 1)); + ObjectPtr anOldObject = object( + boost::dynamic_pointer_cast(theFeatureData)->label().Father().FindChild( + TAG_FEATURE_RESULTS).FindChild(theIndex + 1)); boost::shared_ptr aResult; if (anOldObject) { aResult = boost::dynamic_pointer_cast(anOldObject); @@ -741,10 +763,11 @@ boost::shared_ptr Model_Document::createConstructio } boost::shared_ptr Model_Document::createBody( - const boost::shared_ptr& theFeatureData, const int theIndex) + const boost::shared_ptr& theFeatureData, const int theIndex) { - ObjectPtr anOldObject = object(boost::dynamic_pointer_cast(theFeatureData)-> - label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theIndex + 1)); + ObjectPtr anOldObject = object( + boost::dynamic_pointer_cast(theFeatureData)->label().Father().FindChild( + TAG_FEATURE_RESULTS).FindChild(theIndex + 1)); boost::shared_ptr aResult; if (anOldObject) { aResult = boost::dynamic_pointer_cast(anOldObject); @@ -757,10 +780,11 @@ boost::shared_ptr Model_Document::createBody( } boost::shared_ptr Model_Document::createPart( - const boost::shared_ptr& theFeatureData, const int theIndex) + const boost::shared_ptr& theFeatureData, const int theIndex) { - ObjectPtr anOldObject = object(boost::dynamic_pointer_cast(theFeatureData)-> - label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theIndex + 1)); + ObjectPtr anOldObject = object( + boost::dynamic_pointer_cast(theFeatureData)->label().Father().FindChild( + TAG_FEATURE_RESULTS).FindChild(theIndex + 1)); boost::shared_ptr aResult; if (anOldObject) { aResult = boost::dynamic_pointer_cast(anOldObject); @@ -773,7 +797,7 @@ boost::shared_ptr Model_Document::createPart( } boost::shared_ptr Model_Document::feature( - const boost::shared_ptr& theResult) + const boost::shared_ptr& theResult) { boost::shared_ptr aData = boost::dynamic_pointer_cast(theResult->data()); if (aData) { @@ -783,12 +807,12 @@ boost::shared_ptr Model_Document::feature( return FeaturePtr(); } -Standard_Integer HashCode(const TDF_Label& theLab,const Standard_Integer theUpper) +Standard_Integer HashCode(const TDF_Label& theLab, const Standard_Integer theUpper) { return TDF_LabelMapHasher::HashCode(theLab, theUpper); } -Standard_Boolean IsEqual(const TDF_Label& theLab1,const TDF_Label& theLab2) +Standard_Boolean IsEqual(const TDF_Label& theLab1, const TDF_Label& theLab2) { return TDF_LabelMapHasher::IsEqual(theLab1, theLab2); } diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 4e8278ca5..240082532 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -19,8 +19,8 @@ class Handle_Model_Document; // for TDF_Label map usage -static Standard_Integer HashCode(const TDF_Label& theLab,const Standard_Integer theUpper); -static Standard_Boolean IsEqual(const TDF_Label& theLab1,const TDF_Label& theLab2); +static Standard_Integer HashCode(const TDF_Label& theLab, const Standard_Integer theUpper); +static Standard_Boolean IsEqual(const TDF_Label& theLab1, const TDF_Label& theLab2); /**\class Model_Document * \ingroup DataModel @@ -28,9 +28,9 @@ static Standard_Boolean IsEqual(const TDF_Label& theLab1,const TDF_Label& theLa * Document contains all data that must be stored/retrived in the file. * Also it provides acces to this data: open/save, transactions management etc. */ -class Model_Document: public ModelAPI_Document +class Model_Document : public ModelAPI_Document { -public: + public: //! Loads the OCAF document from the file. //! \param theFileName full name of the file to load @@ -86,7 +86,10 @@ public: MODEL_EXPORT virtual boost::shared_ptr subDocument(std::string theDocID); ///! Returns the id of hte document - MODEL_EXPORT virtual const std::string& id() const {return myID;} + MODEL_EXPORT virtual const std::string& id() const + { + return myID; + } //! Returns the feature in the group by the index (started from zero) //! \param theGroupID group that contains a feature @@ -94,7 +97,7 @@ public: //! \param isOperation if it is true, returns feature (not Object) //! \param theHidden if it is true, it counts also the features that are not in tree MODEL_EXPORT virtual ObjectPtr object(const std::string& theGroupID, const int theIndex, - const bool theHidden = false); + const bool theHidden = false); //! Returns the number of features in the group //! If theHidden is true, it counts also the features that are not in tree @@ -102,20 +105,19 @@ public: /// Creates a construction cresults MODEL_EXPORT virtual boost::shared_ptr createConstruction( - const boost::shared_ptr& theFeatureData, const int theIndex = 0); + const boost::shared_ptr& theFeatureData, const int theIndex = 0); /// Creates a body results MODEL_EXPORT virtual boost::shared_ptr createBody( - const boost::shared_ptr& theFeatureData, const int theIndex = 0); + const boost::shared_ptr& theFeatureData, const int theIndex = 0); /// Creates a part results MODEL_EXPORT virtual boost::shared_ptr createPart( - const boost::shared_ptr& theFeatureData, const int theIndex = 0); + const boost::shared_ptr& theFeatureData, const int theIndex = 0); //! Returns a feature by result (owner of result) - MODEL_EXPORT virtual boost::shared_ptr - feature(const boost::shared_ptr& theResult); + MODEL_EXPORT virtual boost::shared_ptr + feature(const boost::shared_ptr& theResult); - -protected: + protected: //! Returns (creates if needed) the features label TDF_Label featuresLabel(); @@ -130,7 +132,10 @@ protected: //! Creates new document with binary file format Model_Document(const std::string theID); - Handle_TDocStd_Document document() {return myDoc;} + Handle_TDocStd_Document document() + { + return myDoc; + } //! performas compactification of all nested operations into one void compactNested(); @@ -140,16 +145,16 @@ protected: //! Allows to store the result in the data tree of the document (attaches 'data' of result to tree) MODEL_EXPORT virtual void storeResult(boost::shared_ptr theFeatureData, - boost::shared_ptr theResult, const int theResultIndex = 0); - + boost::shared_ptr theResult, + const int theResultIndex = 0); friend class Model_Application; friend class Model_PluginManager; friend class DFBrowser; -private: - std::string myID; ///< identifier of the document in the application - Handle_TDocStd_Document myDoc; ///< OCAF document + private: + std::string myID; ///< identifier of the document in the application + Handle_TDocStd_Document myDoc; ///< OCAF document /// number of transactions after the last "save" call, used for "IsModified" method int myTransactionsAfterSave; /// number of nested transactions performed (or -1 if not nested) diff --git a/src/Model/Model_Events.cpp b/src/Model/Model_Events.cpp index 4096dd65e..ae785563c 100644 --- a/src/Model/Model_Events.cpp +++ b/src/Model/Model_Events.cpp @@ -9,15 +9,15 @@ Model_EventCreator MY_CREATOR; /////////////////////// CREATOR ///////////////////////////// -void Model_EventCreator::sendUpdated( - const ObjectPtr& theObject, const Events_ID& theEvent, const bool isGroupped) const +void Model_EventCreator::sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent, + const bool isGroupped) const { Model_ObjectUpdatedMessage aMsg(theObject, theEvent); Events_Loop::loop()->send(aMsg, isGroupped); } -void Model_EventCreator::sendDeleted( - const boost::shared_ptr& theDoc, const std::string& theGroup) const +void Model_EventCreator::sendDeleted(const boost::shared_ptr& theDoc, + const std::string& theGroup) const { Model_ObjectDeletedMessage aMsg(theDoc, theGroup); Events_Loop::loop()->send(aMsg, true); @@ -29,43 +29,45 @@ Model_EventCreator::Model_EventCreator() } /////////////////////// UPDATED MESSAGE ///////////////////////////// -Model_ObjectUpdatedMessage::Model_ObjectUpdatedMessage( - const ObjectPtr& theObject, - const Events_ID& theEvent) : ModelAPI_ObjectUpdatedMessage(theEvent, 0) +Model_ObjectUpdatedMessage::Model_ObjectUpdatedMessage(const ObjectPtr& theObject, + const Events_ID& theEvent) + : ModelAPI_ObjectUpdatedMessage(theEvent, 0) { - if (theObject) myObjects.insert(theObject); + if (theObject) + myObjects.insert(theObject); } -std::set Model_ObjectUpdatedMessage::objects() const +std::set Model_ObjectUpdatedMessage::objects() const { return myObjects; } -Events_MessageGroup* Model_ObjectUpdatedMessage::newEmpty() +Events_MessageGroup* Model_ObjectUpdatedMessage::newEmpty() { ObjectPtr anEmptyObject; return new Model_ObjectUpdatedMessage(anEmptyObject, eventID()); } -void Model_ObjectUpdatedMessage::Join(Events_MessageGroup& theJoined) +void Model_ObjectUpdatedMessage::Join(Events_MessageGroup& theJoined) { Model_ObjectUpdatedMessage* aJoined = dynamic_cast(&theJoined); - std::set::iterator aFIter = aJoined->myObjects.begin(); - for(; aFIter != aJoined->myObjects.end(); aFIter++) { + std::set::iterator aFIter = aJoined->myObjects.begin(); + for (; aFIter != aJoined->myObjects.end(); aFIter++) { myObjects.insert(*aFIter); } } /////////////////////// DELETED MESSAGE ///////////////////////////// Model_ObjectDeletedMessage::Model_ObjectDeletedMessage( - const boost::shared_ptr& theDoc, const std::string& theGroup) - : ModelAPI_ObjectDeletedMessage(messageId(), 0), myDoc(theDoc) + const boost::shared_ptr& theDoc, const std::string& theGroup) + : ModelAPI_ObjectDeletedMessage(messageId(), 0), + myDoc(theDoc) { if (!theGroup.empty()) myGroups.insert(theGroup); } -Events_MessageGroup* Model_ObjectDeletedMessage::newEmpty() +Events_MessageGroup* Model_ObjectDeletedMessage::newEmpty() { return new Model_ObjectDeletedMessage(myDoc, ""); } @@ -80,7 +82,7 @@ void Model_ObjectDeletedMessage::Join(Events_MessageGroup& theJoined) { Model_ObjectDeletedMessage* aJoined = dynamic_cast(&theJoined); std::set::iterator aGIter = aJoined->myGroups.begin(); - for(; aGIter != aJoined->myGroups.end(); aGIter++) { + for (; aGIter != aJoined->myGroups.end(); aGIter++) { myGroups.insert(*aGIter); } } diff --git a/src/Model/Model_Events.h b/src/Model/Model_Events.h index f0031e1a8..c9b59c3c6 100644 --- a/src/Model/Model_Events.h +++ b/src/Model/Model_Events.h @@ -9,31 +9,31 @@ #include /// Allovs to create ModelAPI messages -class Model_EventCreator : public ModelAPI_EventCreator { -public: +class Model_EventCreator : public ModelAPI_EventCreator +{ + public: /// creates created, updated or moved messages and sends to the loop - virtual void sendUpdated( - const ObjectPtr& theObject, const Events_ID& theEvent, const bool isGroupped = true) const; + virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent, + const bool isGroupped = true) const; /// creates deleted message and sends to the loop - virtual void sendDeleted( - const boost::shared_ptr& theDoc, const std::string& theGroup) const; + virtual void sendDeleted(const boost::shared_ptr& theDoc, + const std::string& theGroup) const; /// must be one per application, the constructor for internal usage only Model_EventCreator(); }; /// Message that feature was changed (used for Object Browser update): moved, updated and deleted -class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage { - std::set myObjects; ///< which feature is changed +class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage +{ + std::set myObjects; ///< which feature is changed /// Sender is not important, all information is located in the feature. /// Use ModelAPI for creation of this event. Used for creation, movement and edition events. - Model_ObjectUpdatedMessage( - const ObjectPtr& theObject, - const Events_ID& theEvent); + Model_ObjectUpdatedMessage(const ObjectPtr& theObject, const Events_ID& theEvent); friend class Model_EventCreator; -public: + public: /// Returns the feature that has been updated virtual std::set objects() const; @@ -46,25 +46,31 @@ public: }; /// Message that feature was deleted (used for Object Browser update) -class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage { - boost::shared_ptr myDoc; ///< document owner of the feature - std::set myGroups; ///< group identifiers that contained the deleted feature +class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage +{ + boost::shared_ptr myDoc; ///< document owner of the feature + std::set myGroups; ///< group identifiers that contained the deleted feature /// Use ModelAPI for creation of this event. - Model_ObjectDeletedMessage( - const boost::shared_ptr& theDoc, const std::string& theGroup); + Model_ObjectDeletedMessage(const boost::shared_ptr& theDoc, + const std::string& theGroup); friend class Model_EventCreator; -public: + public: /// Returns the feature that has been updated - virtual boost::shared_ptr document() const {return myDoc;} + virtual boost::shared_ptr document() const + { + return myDoc; + } /// Returns the group where the feature was deleted - virtual const std::set& groups() const {return myGroups;} + virtual const std::set& groups() const + { + return myGroups; + } virtual Events_MessageGroup* newEmpty(); - virtual const Events_ID messageId(); virtual void Join(Events_MessageGroup& theJoined); diff --git a/src/Model/Model_FeatureValidator.cpp b/src/Model/Model_FeatureValidator.cpp index 5490a3819..f311e54db 100644 --- a/src/Model/Model_FeatureValidator.cpp +++ b/src/Model/Model_FeatureValidator.cpp @@ -12,17 +12,18 @@ #include bool Model_FeatureValidator::isValid(const boost::shared_ptr& theFeature - /*, const std::string theAttr*/ - /*, std::list theArguments*/) const +/*, const std::string theAttr*/ +/*, std::list theArguments*/) const { boost::shared_ptr aData = theFeature->data(); - if(!aData->isValid()) + if (!aData->isValid()) return false; const std::string kAllTypes = ""; std::list aLtAttributes = aData->attributes(kAllTypes); std::list::iterator it = aLtAttributes.begin(); - for( ; it != aLtAttributes.end(); it++) { - if(!(*it)->isInitialized()) return false; + for (; it != aLtAttributes.end(); it++) { + if (!(*it)->isInitialized()) + return false; } return true; } diff --git a/src/Model/Model_FeatureValidator.h b/src/Model/Model_FeatureValidator.h index 6ba52fd24..042621b28 100644 --- a/src/Model/Model_FeatureValidator.h +++ b/src/Model/Model_FeatureValidator.h @@ -11,9 +11,9 @@ #include -class Model_FeatureValidator: public ModelAPI_FeatureValidator +class Model_FeatureValidator : public ModelAPI_FeatureValidator { -public: + public: /// Returns true if feature and/or attributes are valid /// \param theFeature the validated feature MODEL_EXPORT virtual bool isValid(const boost::shared_ptr& theFeature) const; diff --git a/src/Model/Model_PluginManager.cpp b/src/Model/Model_PluginManager.cpp index cd262dcc7..c41d3922c 100644 --- a/src/Model/Model_PluginManager.cpp +++ b/src/Model/Model_PluginManager.cpp @@ -21,14 +21,14 @@ #include #include - using namespace std; static Model_PluginManager* myImpl = new Model_PluginManager(); FeaturePtr Model_PluginManager::createFeature(string theFeatureID) { - if (this != myImpl) return myImpl->createFeature(theFeatureID); + if (this != myImpl) + return myImpl->createFeature(theFeatureID); LoadPluginsInfo(); if (myPlugins.find(theFeatureID) != myPlugins.end()) { @@ -38,27 +38,27 @@ FeaturePtr Model_PluginManager::createFeature(string theFeatureID) Config_ModuleReader::loadLibrary(myCurrentPluginName); } if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) { - FeaturePtr aCreated = - myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID); + FeaturePtr aCreated = myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID); if (!aCreated) { - Events_Error::send(string("Can not initialize feature '") + theFeatureID + - "' in plugin '" + myCurrentPluginName + "'"); + Events_Error::send( + string("Can not initialize feature '") + theFeatureID + "' in plugin '" + + myCurrentPluginName + "'"); } return aCreated; } else { Events_Error::send(string("Can not load plugin '") + myCurrentPluginName + "'"); } } else { - Events_Error::send(string("Feature '") + theFeatureID + "' not found in any plugin"); + Events_Error::send(string("Feature '") + theFeatureID + "' not found in any plugin"); } - return FeaturePtr(); // return nothing + return FeaturePtr(); // return nothing } boost::shared_ptr Model_PluginManager::rootDocument() { return boost::shared_ptr( - Model_Application::getApplication()->getDocument("root")); + Model_Application::getApplication()->getDocument("root")); } bool Model_PluginManager::hasRootDocument() @@ -81,14 +81,14 @@ void Model_PluginManager::setCurrentDocument(boost::shared_ptr Model_PluginManager::copy( - boost::shared_ptr theSource, std::string theID) + boost::shared_ptr theSource, std::string theID) { // create a new document boost::shared_ptr aNew = boost::dynamic_pointer_cast( - Model_Application::getApplication()->getDocument(theID)); + Model_Application::getApplication()->getDocument(theID)); // make a copy of all labels - TDF_Label aSourceRoot = - boost::dynamic_pointer_cast(theSource)->document()->Main().Father(); + TDF_Label aSourceRoot = boost::dynamic_pointer_cast(theSource)->document()->Main() + .Father(); TDF_Label aTargetRoot = aNew->document()->Main().Father(); Handle(TDF_DataSet) aDS = new TDF_DataSet; aDS->AddLabel(aSourceRoot); @@ -121,8 +121,7 @@ void Model_PluginManager::processEvent(const Events_Message* theMessage) static const Events_ID kFeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent"); static const Events_ID kValidatorEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED); if (theMessage->eventID() == kFeatureEvent) { - const Config_FeatureMessage* aMsg = - dynamic_cast(theMessage); + const Config_FeatureMessage* aMsg = dynamic_cast(theMessage); if (aMsg) { // proccess the plugin info, load plugin if (myPlugins.find(aMsg->id()) == myPlugins.end()) { @@ -134,14 +133,14 @@ void Model_PluginManager::processEvent(const Events_Message* theMessage) } else if (theMessage->eventID() == kValidatorEvent) { const Config_ValidatorMessage* aMsg = dynamic_cast(theMessage); if (aMsg) { - if (aMsg->attributeId().empty()) { // feature validator + if (aMsg->attributeId().empty()) { // feature validator validators()->assignValidator(aMsg->validatorId(), aMsg->featureId()); - } else { // attribute validator - validators()->assignValidator(aMsg->validatorId(), aMsg->featureId(), - aMsg->attributeId(), aMsg->parameters()); + } else { // attribute validator + validators()->assignValidator(aMsg->validatorId(), aMsg->featureId(), aMsg->attributeId(), + aMsg->parameters()); } } - } else { // create/update/delete + } else { // create/update/delete if (myCheckTransactions && !rootDocument()->isOperation()) Events_Error::send("Modification of data structure outside of the transaction"); } @@ -149,7 +148,7 @@ void Model_PluginManager::processEvent(const Events_Message* theMessage) void Model_PluginManager::LoadPluginsInfo() { - if (myPluginsInfoLoaded) // nothing to do + if (myPluginsInfoLoaded) // nothing to do return; // Read plugins information from XML files diff --git a/src/Model/Model_PluginManager.h b/src/Model/Model_PluginManager.h index 3ae74bfc1..a1187a10b 100644 --- a/src/Model/Model_PluginManager.h +++ b/src/Model/Model_PluginManager.h @@ -22,14 +22,14 @@ class Model_Document; */ class Model_PluginManager : public ModelAPI_PluginManager, public Events_Listener { - bool myPluginsInfoLoaded; ///< it true if plugins information is loaded + bool myPluginsInfoLoaded; ///< it true if plugins information is loaded /// map of feature IDs to plugin name std::map myPlugins; - std::map myPluginObjs; ///< instances of the already plugins - std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently - boost::shared_ptr myCurrentDoc; ///< current working document - bool myCheckTransactions; ///< if true, generates error if document is updated outside of transaction -public: + std::map myPluginObjs; ///< instances of the already plugins + std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently + boost::shared_ptr myCurrentDoc; ///< current working document + bool myCheckTransactions; ///< if true, generates error if document is updated outside of transaction + public: /// Returns the root document of the application (that may contains sub-documents) MODEL_EXPORT virtual boost::shared_ptr rootDocument(); @@ -52,17 +52,20 @@ public: /// Copies the document to the new one wit hthe given id MODEL_EXPORT virtual boost::shared_ptr copy( - boost::shared_ptr theSource, std::string theID); + boost::shared_ptr theSource, std::string theID); /// Returns the validators factory: the only one instance per application MODEL_EXPORT virtual ModelAPI_ValidatorsFactory* validators(); - void setCheckTransactions(const bool theCheck) {myCheckTransactions = theCheck;} + void setCheckTransactions(const bool theCheck) + { + myCheckTransactions = theCheck; + } /// Is called only once, on startup of the application Model_PluginManager(); -protected: + protected: /// Loads (if not done yet) the information about the features and plugins void LoadPluginsInfo(); diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index fda4b4d8b..967265f83 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -15,14 +15,16 @@ Model_ResultBody::Model_ResultBody() void Model_ResultBody::store(const boost::shared_ptr& theShape) { - boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); + boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); if (aData) { TDF_Label& aShapeLab = aData->shapeLab(); // TODO: to add the naming mechanism for shape storage in the next iteration TNaming_Builder aBuilder(aShapeLab); - if (!theShape) return; // bad shape + if (!theShape) + return; // bad shape TopoDS_Shape aShape = theShape->impl(); - if (aShape.IsNull()) return; // null shape inside + if (aShape.IsNull()) + return; // null shape inside aBuilder.Generated(aShape); } @@ -30,7 +32,7 @@ void Model_ResultBody::store(const boost::shared_ptr& theShape) boost::shared_ptr Model_ResultBody::shape() { - boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); + boost::shared_ptr aData = boost::dynamic_pointer_cast(data()); if (aData) { TDF_Label& aShapeLab = aData->shapeLab(); Handle(TNaming_NamedShape) aName; diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h index 22a9b561c..08ce28ab0 100644 --- a/src/Model/Model_ResultBody.h +++ b/src/Model/Model_ResultBody.h @@ -18,8 +18,8 @@ */ class Model_ResultBody : public ModelAPI_ResultBody { - boost::shared_ptr myOwner; ///< owner of this result -public: + boost::shared_ptr myOwner; ///< owner of this result + public: /// Stores the shape (called by the execution method). MODEL_EXPORT virtual void store(const boost::shared_ptr& theShape); /// Returns the shape-result produced by this feature @@ -27,7 +27,7 @@ public: /// Returns the source feature of this result MODEL_EXPORT virtual boost::shared_ptr owner(); -protected: + protected: /// Makes a body on the given feature Model_ResultBody(); diff --git a/src/Model/Model_ResultConstruction.h b/src/Model/Model_ResultConstruction.h index 5c37e9961..5b6e9b472 100644 --- a/src/Model/Model_ResultConstruction.h +++ b/src/Model/Model_ResultConstruction.h @@ -17,13 +17,16 @@ */ class Model_ResultConstruction : public ModelAPI_ResultConstruction { - boost::shared_ptr myOwner; ///< owner of this result - boost::shared_ptr myShape; ///< shape of this result created "on the fly" + boost::shared_ptr myOwner; ///< owner of this result + boost::shared_ptr myShape; ///< shape of this result created "on the fly" bool myIsInHistory; -public: - /// By default object is displayed in the object browser. - MODEL_EXPORT virtual bool isInHistory() {return myIsInHistory;} - + public: + /// By default object is displayed in the object browser. + MODEL_EXPORT virtual bool isInHistory() + { + return myIsInHistory; + } + /// Sets the result MODEL_EXPORT virtual void setShape(boost::shared_ptr theShape); /// Returns the shape-result produced by this feature @@ -32,7 +35,7 @@ public: /// Sets the flag that it must be displayed in history (default is true) MODEL_EXPORT virtual void setIsInHistory(const bool myIsInHistory); -protected: + protected: /// Makes a body on the given feature Model_ResultConstruction(); diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index 75b2f8b41..aecaac06f 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -13,7 +13,7 @@ boost::shared_ptr Model_ResultPart::partDoc() boost::shared_ptr Model_ResultPart::owner() { - return boost::shared_ptr(); // return empty pointer + return boost::shared_ptr(); // return empty pointer } Model_ResultPart::Model_ResultPart() diff --git a/src/Model/Model_ResultPart.h b/src/Model/Model_ResultPart.h index 4123d69e3..af0f385e8 100644 --- a/src/Model/Model_ResultPart.h +++ b/src/Model/Model_ResultPart.h @@ -17,13 +17,13 @@ */ class Model_ResultPart : public ModelAPI_ResultPart { -public: + public: /// Returns the part-document of this result MODEL_EXPORT virtual boost::shared_ptr partDoc(); /// Part has no stored feature: this method returns NULL MODEL_EXPORT virtual boost::shared_ptr owner(); -protected: + protected: /// makes a result on a temporary feature (an action) Model_ResultPart(); diff --git a/src/Model/Model_ResultValidators.cpp b/src/Model/Model_ResultValidators.cpp index 75b603fc7..66840d450 100644 --- a/src/Model/Model_ResultValidators.cpp +++ b/src/Model/Model_ResultValidators.cpp @@ -14,7 +14,6 @@ #include #include - ResultPtr result(const ObjectPtr theObject) { return boost::dynamic_pointer_cast(theObject); @@ -28,7 +27,6 @@ TopoDS_Shape shape(ResultPtr theResult) return TopoDS_Shape(); } - bool Model_ResultPointValidator::isValid(const ObjectPtr theObject) const { ResultPtr aResult = result(theObject); @@ -41,7 +39,6 @@ bool Model_ResultPointValidator::isValid(const ObjectPtr theObject) const return aShape.ShapeType() == TopAbs_VERTEX; } - bool Model_ResultLineValidator::isValid(const ObjectPtr theObject) const { ResultPtr aResult = result(theObject); @@ -61,7 +58,6 @@ bool Model_ResultLineValidator::isValid(const ObjectPtr theObject) const return false; } - bool Model_ResultArcValidator::isValid(const ObjectPtr theObject) const { ResultPtr aResult = result(theObject); diff --git a/src/Model/Model_ResultValidators.h b/src/Model/Model_ResultValidators.h index c76cd3056..dbbf60dd4 100644 --- a/src/Model/Model_ResultValidators.h +++ b/src/Model/Model_ResultValidators.h @@ -9,22 +9,22 @@ #include #include -class Model_ResultPointValidator: public ModelAPI_ResultValidator +class Model_ResultPointValidator : public ModelAPI_ResultValidator { -public: + public: MODEL_EXPORT virtual bool isValid(const ObjectPtr theObject) const; }; -class Model_ResultLineValidator: public ModelAPI_ResultValidator +class Model_ResultLineValidator : public ModelAPI_ResultValidator { -public: + public: MODEL_EXPORT virtual bool isValid(const ObjectPtr theObject) const; }; -class Model_ResultArcValidator: public ModelAPI_ResultValidator +class Model_ResultArcValidator : public ModelAPI_ResultValidator { -public: + public: MODEL_EXPORT virtual bool isValid(const ObjectPtr theObject) const; }; -#endif \ No newline at end of file +#endif diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index f728bb60e..7a4050335 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -15,7 +15,7 @@ using namespace std; -Model_Update MY_INSTANCE; /// the only one instance initialized on load of the library +Model_Update MY_INSTANCE; /// the only one instance initialized on load of the library Model_Update::Model_Update() { @@ -25,25 +25,26 @@ Model_Update::Model_Update() void Model_Update::processEvent(const Events_Message* theMessage) { - if (isExecuted) return; // nothing to do: it is executed now + if (isExecuted) + return; // nothing to do: it is executed now //Events_LongOp::start(this); isExecuted = true; - const ModelAPI_ObjectUpdatedMessage* aMsg = - dynamic_cast(theMessage); + const ModelAPI_ObjectUpdatedMessage* aMsg = + dynamic_cast(theMessage); myInitial = aMsg->objects(); // collect all documents involved into the update set > aDocs; set >::iterator aFIter = myInitial.begin(); - for(; aFIter != myInitial.end(); aFIter++) { + for (; aFIter != myInitial.end(); aFIter++) { aDocs.insert((*aFIter)->document()); } // iterate all features of features-documents to update them (including hidden) set >::iterator aDIter = aDocs.begin(); - for(; aDIter != aDocs.end(); aDIter++) { + for (; aDIter != aDocs.end(); aDIter++) { int aNbFeatures = (*aDIter)->size(ModelAPI_Feature::group(), true); - for(int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) { - FeaturePtr aFeature = boost::dynamic_pointer_cast - ((*aDIter)->object(ModelAPI_Feature::group(), aFIndex, true)); + for (int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) { + FeaturePtr aFeature = boost::dynamic_pointer_cast( + (*aDIter)->object(ModelAPI_Feature::group(), aFIndex, true)); if (aFeature) updateFeature(aFeature); } @@ -63,25 +64,25 @@ bool Model_Update::updateFeature(FeaturePtr theFeature) return myUpdated[theFeature]; // check all features this feature depended on (recursive call of updateFeature) bool aMustbeUpdated = myInitial.find(theFeature) != myInitial.end(); - if (theFeature) { // only real feature contains references to other objects + if (theFeature) { // only real feature contains references to other objects // references - list > aRefs = - theFeature->data()->attributes(ModelAPI_AttributeReference::type()); + list > aRefs = theFeature->data()->attributes( + ModelAPI_AttributeReference::type()); list >::iterator aRefsIter = aRefs.begin(); - for(; aRefsIter != aRefs.end(); aRefsIter++) { - boost::shared_ptr aSub = - boost::dynamic_pointer_cast(*aRefsIter)->value(); + for (; aRefsIter != aRefs.end(); aRefsIter++) { + boost::shared_ptr aSub = boost::dynamic_pointer_cast< + ModelAPI_AttributeReference>(*aRefsIter)->value(); if (updateObject(aSub)) { aMustbeUpdated = true; } } // lists of references aRefs = theFeature->data()->attributes(ModelAPI_AttributeRefList::type()); - for(aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) { - list aListRef = - boost::dynamic_pointer_cast(*aRefsIter)->list(); + for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) { + list aListRef = boost::dynamic_pointer_cast(*aRefsIter) + ->list(); list::iterator aListIter = aListRef.begin(); - for(; aListIter != aListRef.end(); aListIter++) { + for (; aListIter != aListRef.end(); aListIter++) { boost::shared_ptr aSub = *aListIter; if (updateObject(aSub)) { aMustbeUpdated = true; @@ -95,17 +96,17 @@ bool Model_Update::updateFeature(FeaturePtr theFeature) static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); const std::list >& aResults = theFeature->results(); std::list >::const_iterator aRIter = aResults.begin(); - for(; aRIter != aResults.cend(); aRIter++) { + for (; aRIter != aResults.cend(); aRIter++) { boost::shared_ptr aRes = *aRIter; myUpdated[aRes] = true; ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP); } // to redisplay "presentable" feature (for ex. distance constraint) ModelAPI_EventCreator::get()->sendUpdated(theFeature, EVENT_DISP); - } else { // returns also true is results were updated: for sketch that refers to sub-features but results of sub-features were changed + } else { // returns also true is results were updated: for sketch that refers to sub-features but results of sub-features were changed const std::list >& aResults = theFeature->results(); std::list >::const_iterator aRIter = aResults.begin(); - for(; aRIter != aResults.cend(); aRIter++) { + for (; aRIter != aResults.cend(); aRIter++) { if (myInitial.find(*aRIter) != myInitial.end()) { aMustbeUpdated = true; break; @@ -119,15 +120,15 @@ bool Model_Update::updateFeature(FeaturePtr theFeature) bool Model_Update::updateObject(boost::shared_ptr theObject) { - if (!theObject) + if (!theObject) return false; FeaturePtr aFeature = boost::dynamic_pointer_cast(theObject); - if (aFeature) { // for feature just call update Feature + if (aFeature) { // for feature just call update Feature return updateFeature(aFeature); } // check general object, possible just a result if (myUpdated.find(theObject) != myUpdated.end()) - return myUpdated[theObject]; // already processed + return myUpdated[theObject]; // already processed // check the feature of this object must be executed ResultPtr aResult = boost::dynamic_pointer_cast(theObject); if (aResult) { @@ -138,5 +139,5 @@ bool Model_Update::updateObject(boost::shared_ptr theObject) } if (myInitial.find(theObject) != myInitial.end()) return true; - return false; // nothing is known + return false; // nothing is known } diff --git a/src/Model/Model_Update.h b/src/Model/Model_Update.h index 803dd6056..ee3efc79c 100644 --- a/src/Model/Model_Update.h +++ b/src/Model/Model_Update.h @@ -26,14 +26,14 @@ class Model_Update : public Events_Listener std::map, bool> myUpdated; ///< to know that all next updates are caused by this execution bool isExecuted; -public: + public: /// Is called only once, on startup of the application Model_Update(); /// Processes the feature argument update: executes the results MODEL_EXPORT virtual void processEvent(const Events_Message* theMessage); -protected: + protected: /// Recoursively checks and updates the feature if needed (calls the execute method) /// Returns true if feature was updated. bool updateFeature(boost::shared_ptr theFeature); diff --git a/src/Model/Model_Validator.cpp b/src/Model/Model_Validator.cpp index bda76e29c..90a281c86 100644 --- a/src/Model/Model_Validator.cpp +++ b/src/Model/Model_Validator.cpp @@ -8,8 +8,8 @@ #include #include -void Model_ValidatorsFactory::registerValidator( - const std::string& theID, ModelAPI_Validator* theValidator) +void Model_ValidatorsFactory::registerValidator(const std::string& theID, + ModelAPI_Validator* theValidator) { if (myIDs.find(theID) != myIDs.end()) { Events_Error::send(std::string("Validator ") + theID + " is already registered"); @@ -18,8 +18,8 @@ void Model_ValidatorsFactory::registerValidator( } } -void Model_ValidatorsFactory::assignValidator( - const std::string& theID, const std::string& theFeatureID) +void Model_ValidatorsFactory::assignValidator(const std::string& theID, + const std::string& theFeatureID) { if (myFeatures.find(theFeatureID) == myFeatures.end()) { myFeatures[theFeatureID] = std::set(); @@ -27,13 +27,14 @@ void Model_ValidatorsFactory::assignValidator( myFeatures[theFeatureID].insert(theID); } -void Model_ValidatorsFactory::assignValidator(const std::string& theID, - const std::string& theFeatureID, const std::string& theAttrID, - const std::list& theArguments) +void Model_ValidatorsFactory::assignValidator(const std::string& theID, + const std::string& theFeatureID, + const std::string& theAttrID, + const std::list& theArguments) { // create feature-structures if not exist - std::map >::iterator aFeature = - myAttrs.find(theFeatureID); + std::map >::iterator aFeature = myAttrs.find( + theFeatureID); if (aFeature == myAttrs.end()) { myAttrs[theFeatureID] = std::map(); aFeature = myAttrs.find(theFeatureID); @@ -44,17 +45,17 @@ void Model_ValidatorsFactory::assignValidator(const std::string& theID, aFeature->second[theAttrID] = AttrValidators(); } aFeature->second[theAttrID].insert( - std::pair >(theID, theArguments)); + std::pair >(theID, theArguments)); } -void Model_ValidatorsFactory::validators( - const std::string& theFeatureID, std::list& theResult ) const +void Model_ValidatorsFactory::validators(const std::string& theFeatureID, + std::list& theResult) const { - std::map >::const_iterator aFeature = - myFeatures.find(theFeatureID); + std::map >::const_iterator aFeature = myFeatures.find( + theFeatureID); if (aFeature != myFeatures.cend()) { std::set::const_iterator aValIter = aFeature->second.cbegin(); - for(; aValIter != aFeature->second.cend(); aValIter++) { + for (; aValIter != aFeature->second.cend(); aValIter++) { std::map::const_iterator aFound = myIDs.find(*aValIter); if (aFound == myIDs.end()) { Events_Error::send(std::string("Validator ") + *aValIter + " was not registered"); @@ -65,20 +66,20 @@ void Model_ValidatorsFactory::validators( } } -void Model_ValidatorsFactory::validators(const std::string& theFeatureID, - const std::string& theAttrID, std::list& theValidators, - std::list >& theArguments) const +void Model_ValidatorsFactory::validators(const std::string& theFeatureID, + const std::string& theAttrID, + std::list& theValidators, + std::list >& theArguments) const { - std::map >::const_iterator aFeature = - myAttrs.find(theFeatureID); + std::map >::const_iterator aFeature = myAttrs + .find(theFeatureID); if (aFeature != myAttrs.cend()) { - std::map::const_iterator anAttr = - aFeature->second.find(theAttrID); + std::map::const_iterator anAttr = aFeature->second.find(theAttrID); if (anAttr != aFeature->second.end()) { AttrValidators::const_iterator aValIter = anAttr->second.cbegin(); - for(; aValIter != anAttr->second.cend(); aValIter++) { - std::map::const_iterator aFound = - myIDs.find(aValIter->first); + for (; aValIter != anAttr->second.cend(); aValIter++) { + std::map::const_iterator aFound = myIDs.find( + aValIter->first); if (aFound == myIDs.end()) { Events_Error::send(std::string("Validator ") + aValIter->first + " was not registered"); } else { @@ -90,7 +91,8 @@ void Model_ValidatorsFactory::validators(const std::string& theFeatureID, } } -Model_ValidatorsFactory::Model_ValidatorsFactory() : ModelAPI_ValidatorsFactory() +Model_ValidatorsFactory::Model_ValidatorsFactory() + : ModelAPI_ValidatorsFactory() { registerValidator("Model_ResultPointValidator", new Model_ResultPointValidator); registerValidator("Model_ResultLineValidator", new Model_ResultLineValidator); @@ -98,7 +100,6 @@ Model_ValidatorsFactory::Model_ValidatorsFactory() : ModelAPI_ValidatorsFactory( registerValidator("Model_FeatureValidator", new Model_FeatureValidator); } - const ModelAPI_Validator* Model_ValidatorsFactory::validator(const std::string& theID) const { std::map::const_iterator aIt = myIDs.find(theID); diff --git a/src/Model/Model_Validator.h b/src/Model/Model_Validator.h index f748c42ca..0be3d21c8 100644 --- a/src/Model/Model_Validator.h +++ b/src/Model/Model_Validator.h @@ -22,38 +22,39 @@ * All the needed information is provided to the validator as an argument, * this allows to work with them independently from the feature specific object. */ -class Model_ValidatorsFactory: public ModelAPI_ValidatorsFactory +class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory { -private: - std::map myIDs; ///< map from ID to registered validator + private: + std::map myIDs; ///< map from ID to registered validator /// validators IDs by feature ID - std::map > myFeatures; + std::map > myFeatures; /// set of pairs: validators IDs, list of arguments typedef std::set > > AttrValidators; /// validators IDs and arguments by feature and attribute IDs std::map > myAttrs; -public: + public: /// Registers the instance of the validator by the ID - MODEL_EXPORT virtual void registerValidator( - const std::string& theID, ModelAPI_Validator* theValidator); + MODEL_EXPORT virtual void registerValidator(const std::string& theID, + ModelAPI_Validator* theValidator); /// Assigns validator to the feature - MODEL_EXPORT virtual void assignValidator( - const std::string& theID, const std::string& theFeatureID); + MODEL_EXPORT virtual void assignValidator(const std::string& theID, + const std::string& theFeatureID); /// Assigns validator to the attribute of the feature - MODEL_EXPORT virtual void assignValidator(const std::string& theID, - const std::string& theFeatureID, const std::string& theAttrID, - const std::list& theArguments); + MODEL_EXPORT virtual void assignValidator(const std::string& theID, + const std::string& theFeatureID, + const std::string& theAttrID, + const std::list& theArguments); /// Provides a validator for the feature, returns NULL if no validator - MODEL_EXPORT virtual void validators(const std::string& theFeatureID, - std::list& theResult) const; + MODEL_EXPORT virtual void validators(const std::string& theFeatureID, + std::list& theResult) const; /// Provides a validator for the attribute, returns NULL if no validator - MODEL_EXPORT virtual void validators( - const std::string& theFeatureID, const std::string& theAttrID, - std::list& theValidators, - std::list >& theArguments) const; + MODEL_EXPORT virtual void validators(const std::string& theFeatureID, + const std::string& theAttrID, + std::list& theValidators, + std::list >& theArguments) const; /// Returns registered validator by its Id virtual const ModelAPI_Validator* validator(const std::string& theID) const; @@ -63,7 +64,7 @@ public: //MODEL_EXPORT virtual bool validate( // const boost::shared_ptr& theFeature, const std::string& theAttrID) const; -protected: + protected: /// Get instance from PluginManager Model_ValidatorsFactory(); diff --git a/src/ModelAPI/ModelAPI_Attribute.h b/src/ModelAPI/ModelAPI_Attribute.h index 580f443db..8e2051ac2 100644 --- a/src/ModelAPI/ModelAPI_Attribute.h +++ b/src/ModelAPI/ModelAPI_Attribute.h @@ -19,41 +19,64 @@ class ModelAPI_Attribute { ///< needed here to emit signal that feature changed on change of the attribute boost::shared_ptr myObject; -protected: // accessible from the attributes + protected: + // accessible from the attributes bool myIsInitialized; bool myIsArgument; -public: - + public: + /// Returns the type of this class of attributes, not static method MODELAPI_EXPORT virtual std::string attributeType() = 0; /// To virtually destroy the fields of successors - MODELAPI_EXPORT virtual ~ModelAPI_Attribute() {} + MODELAPI_EXPORT virtual ~ModelAPI_Attribute() + { + } /// Sets the owner of this attribute MODELAPI_EXPORT void setObject(const boost::shared_ptr& theObject) - {myObject = theObject;} + { + myObject = theObject; + } /// Returns the owner of this attribute MODELAPI_EXPORT const boost::shared_ptr& owner() - {return myObject;} + { + return myObject; + } /// Returns true if attribute was initialized by some value - MODELAPI_EXPORT bool isInitialized() {return myIsInitialized;} + MODELAPI_EXPORT bool isInitialized() + { + return myIsInitialized; + } /// Makes attribute initialized - MODELAPI_EXPORT void setInitialized() {myIsInitialized = true;} + MODELAPI_EXPORT void setInitialized() + { + myIsInitialized = true; + } /// Set this attribute is argument for result (change of this attribute requires update of result). /// By default it is true. - MODELAPI_EXPORT void setIsArgument(const bool theFlag) {myIsArgument = theFlag;} + MODELAPI_EXPORT void setIsArgument(const bool theFlag) + { + myIsArgument = theFlag; + } /// Returns true if attribute causes the result change - MODELAPI_EXPORT bool isArgument() {return myIsArgument;} + MODELAPI_EXPORT bool isArgument() + { + return myIsArgument; + } -protected: + protected: /// Objects are created for features automatically - ModelAPI_Attribute() {myIsInitialized = false; myIsArgument = true;} + ModelAPI_Attribute() + { + myIsInitialized = false; + myIsArgument = true; + } }; diff --git a/src/ModelAPI/ModelAPI_AttributeBoolean.h b/src/ModelAPI/ModelAPI_AttributeBoolean.h index 8c5a0af8e..2612e0eed 100644 --- a/src/ModelAPI/ModelAPI_AttributeBoolean.h +++ b/src/ModelAPI/ModelAPI_AttributeBoolean.h @@ -14,7 +14,7 @@ class ModelAPI_AttributeBoolean : public ModelAPI_Attribute { -public: + public: /// Defines the double value MODELAPI_EXPORT virtual void setValue(bool theValue) = 0; @@ -22,17 +22,27 @@ public: MODELAPI_EXPORT virtual bool value() = 0; /// Returns the type of this class of attributes - MODELAPI_EXPORT static std::string type() {return "Boolean";} + MODELAPI_EXPORT static std::string type() + { + return "Boolean"; + } /// Returns the type of this class of attributes, not static method - MODELAPI_EXPORT virtual std::string attributeType() {return type();} + MODELAPI_EXPORT virtual std::string attributeType() + { + return type(); + } /// To virtually destroy the fields of successors - MODELAPI_EXPORT virtual ~ModelAPI_AttributeBoolean() {} + MODELAPI_EXPORT virtual ~ModelAPI_AttributeBoolean() + { + } -protected: + protected: /// Objects are created for features automatically - MODELAPI_EXPORT ModelAPI_AttributeBoolean() {} + MODELAPI_EXPORT ModelAPI_AttributeBoolean() + { + } }; #endif diff --git a/src/ModelAPI/ModelAPI_AttributeDocRef.h b/src/ModelAPI/ModelAPI_AttributeDocRef.h index b7f312bb1..7ee1ff1ca 100644 --- a/src/ModelAPI/ModelAPI_AttributeDocRef.h +++ b/src/ModelAPI/ModelAPI_AttributeDocRef.h @@ -15,7 +15,7 @@ class ModelAPI_AttributeDocRef : public ModelAPI_Attribute { -public: + public: /// Defines the document referenced from this attribute MODELAPI_EXPORT virtual void setValue(boost::shared_ptr theDoc) = 0; @@ -23,18 +23,27 @@ public: MODELAPI_EXPORT virtual boost::shared_ptr value() = 0; /// Returns the type of this class of attributes - MODELAPI_EXPORT static std::string type() {return "DocRef";} + MODELAPI_EXPORT static std::string type() + { + return "DocRef"; + } /// Returns the type of this class of attributes, not static method - MODELAPI_EXPORT virtual std::string attributeType() {return type();} + MODELAPI_EXPORT virtual std::string attributeType() + { + return type(); + } /// To virtually destroy the fields of successors - MODELAPI_EXPORT virtual ~ModelAPI_AttributeDocRef() {} + MODELAPI_EXPORT virtual ~ModelAPI_AttributeDocRef() + { + } -protected: + protected: /// Objects are created for features automatically MODELAPI_EXPORT ModelAPI_AttributeDocRef() - {} + { + } }; #endif diff --git a/src/ModelAPI/ModelAPI_AttributeDouble.h b/src/ModelAPI/ModelAPI_AttributeDouble.h index 163ebefe9..e61dfa060 100644 --- a/src/ModelAPI/ModelAPI_AttributeDouble.h +++ b/src/ModelAPI/ModelAPI_AttributeDouble.h @@ -14,7 +14,7 @@ class ModelAPI_AttributeDouble : public ModelAPI_Attribute { -public: + public: /// Defines the double value MODELAPI_EXPORT virtual void setValue(const double theValue) = 0; @@ -22,18 +22,27 @@ public: MODELAPI_EXPORT virtual double value() = 0; /// Returns the type of this class of attributes - MODELAPI_EXPORT static std::string type() {return "Double";} + MODELAPI_EXPORT static std::string type() + { + return "Double"; + } /// Returns the type of this class of attributes, not static method - MODELAPI_EXPORT virtual std::string attributeType() {return type();} + MODELAPI_EXPORT virtual std::string attributeType() + { + return type(); + } /// To virtually destroy the fields of successors - MODELAPI_EXPORT virtual ~ModelAPI_AttributeDouble() {} + MODELAPI_EXPORT virtual ~ModelAPI_AttributeDouble() + { + } -protected: + protected: /// Objects are created for features automatically MODELAPI_EXPORT ModelAPI_AttributeDouble() - {} + { + } }; //! Pointer on double attribute diff --git a/src/ModelAPI/ModelAPI_AttributeRefAttr.h b/src/ModelAPI/ModelAPI_AttributeRefAttr.h index be0bf6e1e..dc862f3a6 100644 --- a/src/ModelAPI/ModelAPI_AttributeRefAttr.h +++ b/src/ModelAPI/ModelAPI_AttributeRefAttr.h @@ -16,7 +16,7 @@ class ModelAPI_AttributeRefAttr : public ModelAPI_Attribute { -public: + public: /// Returns true if this attribute references to a object (not to the attribute) MODELAPI_EXPORT virtual bool isObject() = 0; @@ -33,18 +33,27 @@ public: MODELAPI_EXPORT virtual ObjectPtr object() = 0; /// Returns the type of this class of attributes - MODELAPI_EXPORT static std::string type() {return "RefAttr";} + MODELAPI_EXPORT static std::string type() + { + return "RefAttr"; + } /// Returns the type of this class of attributes, not static method - MODELAPI_EXPORT virtual std::string attributeType() {return type();} + MODELAPI_EXPORT virtual std::string attributeType() + { + return type(); + } /// To virtually destroy the fields of successors - MODELAPI_EXPORT virtual ~ModelAPI_AttributeRefAttr() {} + MODELAPI_EXPORT virtual ~ModelAPI_AttributeRefAttr() + { + } -protected: + protected: /// Objects are created for features automatically MODELAPI_EXPORT ModelAPI_AttributeRefAttr() - {} + { + } }; #endif diff --git a/src/ModelAPI/ModelAPI_AttributeRefList.h b/src/ModelAPI/ModelAPI_AttributeRefList.h index d9948dd04..b8b5c700b 100644 --- a/src/ModelAPI/ModelAPI_AttributeRefList.h +++ b/src/ModelAPI/ModelAPI_AttributeRefList.h @@ -16,12 +16,18 @@ class ModelAPI_AttributeRefList : public ModelAPI_Attribute { -public: + public: /// Returns the type of this class of attributes - MODELAPI_EXPORT static std::string type() {return "RefList";} + MODELAPI_EXPORT static std::string type() + { + return "RefList"; + } /// Returns the type of this class of attributes, not static method - MODELAPI_EXPORT virtual std::string attributeType() {return type();} + MODELAPI_EXPORT virtual std::string attributeType() + { + return type(); + } /// Appends the feature to the end of a list MODELAPI_EXPORT virtual void append(ObjectPtr theObject) = 0; @@ -35,10 +41,11 @@ public: /// Returns the list of features MODELAPI_EXPORT virtual std::list list() = 0; -protected: + protected: /// Objects are created for features automatically MODELAPI_EXPORT ModelAPI_AttributeRefList() - {} + { + } }; #endif diff --git a/src/ModelAPI/ModelAPI_AttributeReference.h b/src/ModelAPI/ModelAPI_AttributeReference.h index dd13cad06..14d63ae32 100644 --- a/src/ModelAPI/ModelAPI_AttributeReference.h +++ b/src/ModelAPI/ModelAPI_AttributeReference.h @@ -15,7 +15,7 @@ class ModelAPI_AttributeReference : public ModelAPI_Attribute { -public: + public: /// Defines the object referenced from this attribute MODELAPI_EXPORT virtual void setValue(ObjectPtr theObject) = 0; @@ -23,18 +23,27 @@ public: MODELAPI_EXPORT virtual ObjectPtr value() = 0; /// Returns the type of this class of attributes - MODELAPI_EXPORT static std::string type() {return "Reference";} + MODELAPI_EXPORT static std::string type() + { + return "Reference"; + } /// Returns the type of this class of attributes, not static method - MODELAPI_EXPORT virtual std::string attributeType() {return type();} + MODELAPI_EXPORT virtual std::string attributeType() + { + return type(); + } /// To virtually destroy the fields of successors - MODELAPI_EXPORT virtual ~ModelAPI_AttributeReference() {} + MODELAPI_EXPORT virtual ~ModelAPI_AttributeReference() + { + } -protected: + protected: /// Objects are created for features automatically MODELAPI_EXPORT ModelAPI_AttributeReference() - {} + { + } }; #endif diff --git a/src/ModelAPI/ModelAPI_AttributeValidator.h b/src/ModelAPI/ModelAPI_AttributeValidator.h index b40c145e2..15b8514ec 100644 --- a/src/ModelAPI/ModelAPI_AttributeValidator.h +++ b/src/ModelAPI/ModelAPI_AttributeValidator.h @@ -9,12 +9,10 @@ #include #include - -class ModelAPI_AttributeValidator: public ModelAPI_Validator +class ModelAPI_AttributeValidator : public ModelAPI_Validator { -public: - virtual bool isValid(const FeaturePtr& theFeature, - const std::list& theArguments, + public: + virtual bool isValid(const FeaturePtr& theFeature, const std::list& theArguments, const ObjectPtr& theObject) const = 0; }; diff --git a/src/ModelAPI/ModelAPI_Data.h b/src/ModelAPI/ModelAPI_Data.h index 0b69acb36..d07d24052 100644 --- a/src/ModelAPI/ModelAPI_Data.h +++ b/src/ModelAPI/ModelAPI_Data.h @@ -28,7 +28,7 @@ class GeomAPI_Shape; class MODELAPI_EXPORT ModelAPI_Data { -public: + public: /// Returns the name of the feature visible by the user in the object browser virtual std::string name() = 0; @@ -55,7 +55,7 @@ public: /// Returns all attributes ofthe feature of the given type /// or all attributes if "theType" is empty virtual std::list > - attributes(const std::string& theType) = 0; + attributes(const std::string& theType) = 0; /// Identifier by the id (not fast, iteration by map) /// \param theAttr attribute already created in this data virtual const std::string& id(const boost::shared_ptr& theAttr) = 0; @@ -75,15 +75,17 @@ public: virtual void sendAttributeUpdated(ModelAPI_Attribute* theAttr) = 0; /// To virtually destroy the fields of successors - virtual ~ModelAPI_Data() {} + virtual ~ModelAPI_Data() + { + } -protected: + protected: /// Objects are created for features automatically ModelAPI_Data() - {} + { + } }; typedef boost::shared_ptr DataPtr; - #endif diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 5e0d28091..5b1cfb0af 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -26,7 +26,7 @@ class ModelAPI_Data; */ class ModelAPI_Document { -public: + public: //! Loads the OCAF document from the file. //! \param theFileName full name of the file to load //! \param theStudyID identifier of the SALOME study to associate with loaded file @@ -69,8 +69,8 @@ public: virtual void removeFeature(boost::shared_ptr theFeature) = 0; ///! Adds a new sub-document by the identifier, or returns existing one if it is already exist - virtual boost::shared_ptr - subDocument(std::string theDocID) = 0; + virtual boost::shared_ptr + subDocument(std::string theDocID) = 0; ///! Returns the id of the document virtual const std::string& id() const = 0; @@ -79,39 +79,40 @@ public: //! \param theGroupID group that contains an object //! \param theIndex zero-based index of feature in the group //! \param theHidden if it is true, it counts also the features that are not in tree - virtual boost::shared_ptr - object(const std::string& theGroupID, const int theIndex, const bool theHidden = false) = 0; + virtual boost::shared_ptr + object(const std::string& theGroupID, const int theIndex, const bool theHidden = false) = 0; //! Returns the number of objects in the group of objects //! If theHidden is true, it counts also the features that are not in tree virtual int size(const std::string& theGroupID, const bool theHidden = false) = 0; /// To virtually destroy the fields of successors - virtual ~ModelAPI_Document() {} + virtual ~ModelAPI_Document() + { + } /// Creates a construction cresults virtual boost::shared_ptr createConstruction( - const boost::shared_ptr& theFeatureData, const int theIndex = 0) = 0; + const boost::shared_ptr& theFeatureData, const int theIndex = 0) = 0; /// Creates a body results virtual boost::shared_ptr createBody( - const boost::shared_ptr& theFeatureData, const int theIndex = 0) = 0; + const boost::shared_ptr& theFeatureData, const int theIndex = 0) = 0; /// Creates a part results virtual boost::shared_ptr createPart( - const boost::shared_ptr& theFeatureData, const int theIndex = 0) = 0; + const boost::shared_ptr& theFeatureData, const int theIndex = 0) = 0; //! Returns a feature by result (owner of result) virtual boost::shared_ptr feature( - const boost::shared_ptr& theResult) = 0; + const boost::shared_ptr& theResult) = 0; -protected: + protected: /// Only for SWIG wrapping it is here MODELAPI_EXPORT ModelAPI_Document() - {} + { + } }; - //! Pointer on document object typedef boost::shared_ptr DocumentPtr; - #endif diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h index 965a695af..89b1fd5b9 100644 --- a/src/ModelAPI/ModelAPI_Events.h +++ b/src/ModelAPI/ModelAPI_Events.h @@ -29,12 +29,15 @@ static const char * EVENT_OBJECT_TO_REDISPLAY = "ObjectsToRedisplay"; static const char * EVENT_OPERATION_LAUNCHED = "OperationLaunched"; /// Message that feature was changed (used for Object Browser update): moved, updated and deleted -class ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup { -protected: +class ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup +{ + protected: ModelAPI_ObjectUpdatedMessage(const Events_ID theID, const void* theSender = 0) - : Events_MessageGroup(theID, theSender) {} + : Events_MessageGroup(theID, theSender) + { + } -public: + public: /// Returns the feature that has been updated virtual std::set objects() const = 0; @@ -46,17 +49,20 @@ public: }; /// Message that feature was deleted (used for Object Browser update) -class ModelAPI_ObjectDeletedMessage : public Events_MessageGroup { -protected: +class ModelAPI_ObjectDeletedMessage : public Events_MessageGroup +{ + protected: ModelAPI_ObjectDeletedMessage(const Events_ID theID, const void* theSender = 0) - : Events_MessageGroup(theID, theSender) {} + : Events_MessageGroup(theID, theSender) + { + } -public: + public: /// Returns the feature that has been updated virtual boost::shared_ptr document() const = 0; /// Returns the group where the feature was deleted - virtual const std::set& groups() const = 0; + virtual const std::set& groups() const = 0; virtual Events_MessageGroup* newEmpty() = 0; @@ -66,18 +72,19 @@ public: }; /// Allows to create ModelAPI messages -class MODELAPI_EXPORT ModelAPI_EventCreator { -public: +class MODELAPI_EXPORT ModelAPI_EventCreator +{ + public: /// creates created, updated or moved messages and sends to the loop virtual void sendUpdated(const ObjectPtr& theObject, const Events_ID& theEvent, const bool isGroupped = true) const = 0; /// creates deleted message and sends to the loop - virtual void sendDeleted( - const boost::shared_ptr& theDoc, const std::string& theGroup) const = 0; + virtual void sendDeleted(const boost::shared_ptr& theDoc, + const std::string& theGroup) const = 0; /// returns the creator instance static const ModelAPI_EventCreator* get(); - + /// sets the creator instance static void set(const ModelAPI_EventCreator* theCreator); }; diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp index 028f17385..07079fe14 100644 --- a/src/ModelAPI/ModelAPI_Feature.cpp +++ b/src/ModelAPI/ModelAPI_Feature.cpp @@ -8,25 +8,25 @@ #include #include -const std::list >& ModelAPI_Feature::results() +const std::list >& ModelAPI_Feature::results() { return myResults; } -boost::shared_ptr ModelAPI_Feature::firstResult() +boost::shared_ptr ModelAPI_Feature::firstResult() { return myResults.empty() ? boost::shared_ptr() : *(myResults.begin()); } -void ModelAPI_Feature::setResult(const boost::shared_ptr& theResult) +void ModelAPI_Feature::setResult(const boost::shared_ptr& theResult) { - if (firstResult() == theResult) { // just updated + if (firstResult() == theResult) { // just updated static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent); return; } // created - while(!myResults.empty()) { // remove one by one with messages + while (!myResults.empty()) { // remove one by one with messages boost::shared_ptr aRes = *(myResults.begin()); myResults.erase(myResults.begin()); ModelAPI_EventCreator::get()->sendDeleted(aRes->document(), aRes->groupName()); @@ -38,20 +38,20 @@ void ModelAPI_Feature::setResult(const boost::shared_ptr& theRe Events_Loop::loop()->flush(anEvent); } -void ModelAPI_Feature::setResult( - const boost::shared_ptr& theResult, const int theIndex) +void ModelAPI_Feature::setResult(const boost::shared_ptr& theResult, + const int theIndex) { std::list >::iterator aResIter = myResults.begin(); - for(int anIndex = 0; anIndex < theIndex; anIndex++) { + for (int anIndex = 0; anIndex < theIndex; anIndex++) { aResIter++; } - if (aResIter == myResults.end()) { // append + if (aResIter == myResults.end()) { // append myResults.push_back(theResult); static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent); // Create event for first Feature, send it to make "created" earlier than "updated" Events_Loop::loop()->flush(anEvent); - } else { // update + } else { // update *aResIter = theResult; static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent); @@ -65,7 +65,7 @@ boost::shared_ptr ModelAPI_Feature::documentToAdd() ModelAPI_Feature::~ModelAPI_Feature() { - while(!myResults.empty()) { // remove one by one with messages + while (!myResults.empty()) { // remove one by one with messages boost::shared_ptr aRes = *(myResults.begin()); myResults.erase(myResults.begin()); ModelAPI_EventCreator::get()->sendDeleted(aRes->document(), aRes->groupName()); diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index 9f989074b..5b35b7e50 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -25,16 +25,22 @@ class ModelAPI_Feature : public ModelAPI_Object { ///< list of current results of this feature std::list > myResults; -public: + public: /// Returns the unique kind of a feature (like "Point") virtual const std::string& getKind() = 0; /// Returns the group identifier of all features static std::string group() - {static std::string MY_GROUP = "Features"; return MY_GROUP;} + { + static std::string MY_GROUP = "Features"; + return MY_GROUP; + } /// Returns the group identifier of this result - virtual std::string groupName() { return group(); } + virtual std::string groupName() + { + return group(); + } /// Request for initialization of data model of the feature: adding all attributes virtual void initAttributes() = 0; @@ -49,12 +55,15 @@ public: /// sets the alone result MODELAPI_EXPORT void setResult(const boost::shared_ptr& theResult); /// sets the result by index (zero based), results before this must be set before - MODELAPI_EXPORT void setResult( - const boost::shared_ptr& theResult, const int theIndex); + MODELAPI_EXPORT void setResult(const boost::shared_ptr& theResult, + const int theIndex); /// Returns true if this feature must not be created: this is just an action /// that is not stored in the features history and data model (like "delete part"). - virtual bool isAction() {return false;} + virtual bool isAction() + { + return false; + } /// Must return document where the new feature must be added to /// By default it is current document diff --git a/src/ModelAPI/ModelAPI_FeatureValidator.h b/src/ModelAPI/ModelAPI_FeatureValidator.h index d2378a0de..7508c7ad3 100644 --- a/src/ModelAPI/ModelAPI_FeatureValidator.h +++ b/src/ModelAPI/ModelAPI_FeatureValidator.h @@ -8,9 +8,9 @@ #include "ModelAPI.h" #include "ModelAPI_Validator.h" -class ModelAPI_FeatureValidator: public ModelAPI_Validator +class ModelAPI_FeatureValidator : public ModelAPI_Validator { -public: + public: /// Returns true if feature and/or attributes are valid /// \param theFeature the validated feature /// \param theAttr the validated attribute ID, empty string of feature is validated diff --git a/src/ModelAPI/ModelAPI_Object.h b/src/ModelAPI/ModelAPI_Object.h index d46fb7623..91167b871 100644 --- a/src/ModelAPI/ModelAPI_Object.h +++ b/src/ModelAPI/ModelAPI_Object.h @@ -23,33 +23,48 @@ class ModelAPI_Document; */ class ModelAPI_Object { - boost::shared_ptr myData; ///< manager of the data model of a feature - boost::shared_ptr myDoc; ///< document this feature belongs to -public: + boost::shared_ptr myData; ///< manager of the data model of a feature + boost::shared_ptr myDoc; ///< document this feature belongs to + public: /// By default object is displayed in the object browser. - virtual bool isInHistory() {return true;} + virtual bool isInHistory() + { + return true; + } /// Returns the data manager of this object: attributes - virtual boost::shared_ptr data() {return myData;} + virtual boost::shared_ptr data() + { + return myData; + } /// Returns true if object refers to the same data model instance virtual bool isSame(const boost::shared_ptr& theObject) - {return theObject.get() == this;} + { + return theObject.get() == this; + } /// Returns document this feature belongs to virtual boost::shared_ptr document() - {return myDoc;} + { + return myDoc; + } /// Returns the group identifier of this object virtual std::string groupName() = 0; -protected: + protected: /// Sets the data manager of an object (document does) - virtual void setData(boost::shared_ptr theData) - {myData = theData;} + virtual void setData(boost::shared_ptr theData) + { + myData = theData; + } /// Sets the data manager of an object (document does) - virtual void setDoc(boost::shared_ptr theDoc) {myDoc = theDoc;} + virtual void setDoc(boost::shared_ptr theDoc) + { + myDoc = theDoc; + } friend class Model_Document; }; diff --git a/src/ModelAPI/ModelAPI_Plugin.h b/src/ModelAPI/ModelAPI_Plugin.h index 31795c3f1..5222b4c7b 100644 --- a/src/ModelAPI/ModelAPI_Plugin.h +++ b/src/ModelAPI/ModelAPI_Plugin.h @@ -18,16 +18,21 @@ class ModelAPI_Feature; class MODELAPI_EXPORT ModelAPI_Plugin { -public: + public: /// Creates the feature object of this plugin by the feature string ID virtual boost::shared_ptr createFeature(std::string theFeatureID) = 0; /// To virtually destroy the fields of successors - virtual ~ModelAPI_Plugin() {} + virtual ~ModelAPI_Plugin() + { + } -protected: + protected: /// Is needed for python wrapping by swig - ModelAPI_Plugin() {}; + ModelAPI_Plugin() + { + } + ; }; #endif diff --git a/src/ModelAPI/ModelAPI_PluginManager.cpp b/src/ModelAPI/ModelAPI_PluginManager.cpp index 72deaba2c..2b83d0aed 100644 --- a/src/ModelAPI/ModelAPI_PluginManager.cpp +++ b/src/ModelAPI/ModelAPI_PluginManager.cpp @@ -43,30 +43,29 @@ ModelAPI_PluginManager::ModelAPI_PluginManager() { } -void ModelAPI_PluginManager::setPluginManager( - boost::shared_ptr theManager) +void ModelAPI_PluginManager::setPluginManager(boost::shared_ptr theManager) { MY_MANAGER = theManager; } boost::shared_ptr ModelAPI_PluginManager::get() { - if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI + if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI Config_ModuleReader::loadLibrary("Model"); } return MY_MANAGER; } -const ModelAPI_EventCreator* MY_CREATOR = 0; ///< instance of the events creator, one pre application +const ModelAPI_EventCreator* MY_CREATOR = 0; ///< instance of the events creator, one pre application const ModelAPI_EventCreator* ModelAPI_EventCreator::get() { - if (!MY_CREATOR) { // import Model library that implements this interface of ModelAPI + if (!MY_CREATOR) { // import Model library that implements this interface of ModelAPI Config_ModuleReader::loadLibrary("Model"); } return MY_CREATOR; } - + void ModelAPI_EventCreator::set(const ModelAPI_EventCreator* theCreator) { MY_CREATOR = theCreator; diff --git a/src/ModelAPI/ModelAPI_PluginManager.h b/src/ModelAPI/ModelAPI_PluginManager.h index 355e9814f..90a59a9ef 100644 --- a/src/ModelAPI/ModelAPI_PluginManager.h +++ b/src/ModelAPI/ModelAPI_PluginManager.h @@ -23,7 +23,7 @@ class ModelAPI_ValidatorsFactory; class MODELAPI_EXPORT ModelAPI_PluginManager { -public: + public: /// Returns the real implementation (the alone instance per application) of the plugin manager static boost::shared_ptr get(); @@ -45,8 +45,8 @@ public: virtual void setCurrentDocument(boost::shared_ptr theDoc) = 0; /// Copies the document to the new one wit hthe given id - virtual boost::shared_ptr copy( - boost::shared_ptr theSource, std::string theID) = 0; + virtual boost::shared_ptr copy(boost::shared_ptr theSource, + std::string theID) = 0; /// Returns the validators factory: the only one instance per application virtual ModelAPI_ValidatorsFactory* validators() = 0; @@ -55,9 +55,11 @@ public: ModelAPI_PluginManager(); /// To virtually destroy the fields of successors - virtual ~ModelAPI_PluginManager() {} + virtual ~ModelAPI_PluginManager() + { + } -protected: + protected: /// Creates the feature object using plugins functionality virtual boost::shared_ptr createFeature(std::string theFeatureID) = 0; diff --git a/src/ModelAPI/ModelAPI_Result.h b/src/ModelAPI/ModelAPI_Result.h index 4a3adbd76..af9e7ce87 100644 --- a/src/ModelAPI/ModelAPI_Result.h +++ b/src/ModelAPI/ModelAPI_Result.h @@ -17,7 +17,7 @@ class ModelAPI_Feature; */ class ModelAPI_Result : public ModelAPI_Object { -public: + public: /// Returns the source feature of this result //virtual boost::shared_ptr owner() = 0; diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h index cd484031a..c2eff7efc 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.h +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -20,15 +20,19 @@ */ class ModelAPI_ResultBody : public ModelAPI_Result { -public: + public: /// Returns the group identifier of this result - virtual std::string groupName() { + virtual std::string groupName() + { return group(); } /// Returns the group identifier of this result static std::string group() - {static std::string MY_GROUP = "Bodies"; return MY_GROUP;} + { + static std::string MY_GROUP = "Bodies"; + return MY_GROUP; + } /// Stores the shape (called by the execution method). virtual void store(const boost::shared_ptr& theShape) = 0; @@ -36,13 +40,16 @@ public: virtual boost::shared_ptr shape() = 0; /// To virtually destroy the fields of successors - virtual ~ModelAPI_ResultBody() {} + virtual ~ModelAPI_ResultBody() + { + } -protected: + protected: /// Use plugin manager for features creation: this method is /// defined here only for SWIG-wrapping ModelAPI_ResultBody() - {} + { + } }; //! Pointer on feature object diff --git a/src/ModelAPI/ModelAPI_ResultConstruction.h b/src/ModelAPI/ModelAPI_ResultConstruction.h index 0a7cf17b6..972b3a965 100644 --- a/src/ModelAPI/ModelAPI_ResultConstruction.h +++ b/src/ModelAPI/ModelAPI_ResultConstruction.h @@ -19,15 +19,19 @@ */ class ModelAPI_ResultConstruction : public ModelAPI_Result { -public: + public: /// Returns the group identifier of this result virtual std::string groupName() - { return group(); } + { + return group(); + } /// Returns the group identifier of this result static std::string group() - {static std::string MY_GROUP = "Construction"; return MY_GROUP;} - + { + static std::string MY_GROUP = "Construction"; + return MY_GROUP; + } /// Returns the shape-result produced by this feature virtual boost::shared_ptr& shape() = 0; diff --git a/src/ModelAPI/ModelAPI_ResultParameters.h b/src/ModelAPI/ModelAPI_ResultParameters.h index 509e064ea..5c67cbcc0 100644 --- a/src/ModelAPI/ModelAPI_ResultParameters.h +++ b/src/ModelAPI/ModelAPI_ResultParameters.h @@ -16,14 +16,19 @@ */ class ModelAPI_ResultParameters : public ModelAPI_Result { -public: + public: /// Returns the group identifier of this result virtual std::string groupName() - { return group(); } + { + return group(); + } /// Returns the group identifier of this result static std::string group() - {static std::string MY_GROUP = "Parameters"; return MY_GROUP;} + { + static std::string MY_GROUP = "Parameters"; + return MY_GROUP; + } }; //! Pointer on feature object diff --git a/src/ModelAPI/ModelAPI_ResultPart.h b/src/ModelAPI/ModelAPI_ResultPart.h index 73bfd1ca3..ca52304cc 100644 --- a/src/ModelAPI/ModelAPI_ResultPart.h +++ b/src/ModelAPI/ModelAPI_ResultPart.h @@ -18,14 +18,19 @@ */ class ModelAPI_ResultPart : public ModelAPI_Result { -public: + public: /// Returns the group identifier of this result virtual std::string groupName() - { return group(); } + { + return group(); + } /// Returns the group identifier of this result static std::string group() - {static std::string MY_GROUP = "Parts"; return MY_GROUP;} + { + static std::string MY_GROUP = "Parts"; + return MY_GROUP; + } /// part document reference attribute inline static const std::string& DOC_REF() diff --git a/src/ModelAPI/ModelAPI_ResultValidator.h b/src/ModelAPI/ModelAPI_ResultValidator.h index 7484246d1..b18709a14 100644 --- a/src/ModelAPI/ModelAPI_ResultValidator.h +++ b/src/ModelAPI/ModelAPI_ResultValidator.h @@ -8,11 +8,10 @@ #include "ModelAPI_Validator.h" #include "ModelAPI_Object.h" -class ModelAPI_ResultValidator: public ModelAPI_Validator +class ModelAPI_ResultValidator : public ModelAPI_Validator { -public: + public: virtual bool isValid(const ObjectPtr theObject) const = 0; }; - -#endif \ No newline at end of file +#endif diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp index 1c49c6779..52b88b5b0 100644 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -6,16 +6,18 @@ #include #include - namespace ModelAPI_Tools { boost::shared_ptr shape(const ResultPtr& theResult) { ResultBodyPtr aBody = boost::dynamic_pointer_cast(theResult); - if (aBody) return aBody->shape(); - ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast(theResult); - if (aConstruct) return aConstruct->shape(); + if (aBody) + return aBody->shape(); + ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast( + theResult); + if (aConstruct) + return aConstruct->shape(); return boost::shared_ptr(); } -} \ No newline at end of file +} diff --git a/src/ModelAPI/ModelAPI_Tools.h b/src/ModelAPI/ModelAPI_Tools.h index f4fc0ebf0..bec1b9da1 100644 --- a/src/ModelAPI/ModelAPI_Tools.h +++ b/src/ModelAPI/ModelAPI_Tools.h @@ -9,10 +9,10 @@ #include #include -namespace ModelAPI_Tools -{ - /// Returns shape from the given Result object - MODELAPI_EXPORT boost::shared_ptr shape(const ResultPtr& theResult); -}; +namespace ModelAPI_Tools { +/// Returns shape from the given Result object +MODELAPI_EXPORT boost::shared_ptr shape(const ResultPtr& theResult); +} +; -#endif \ No newline at end of file +#endif diff --git a/src/ModelAPI/ModelAPI_Validator.h b/src/ModelAPI/ModelAPI_Validator.h index bd53ecc24..c1c5f37fb 100644 --- a/src/ModelAPI/ModelAPI_Validator.h +++ b/src/ModelAPI/ModelAPI_Validator.h @@ -24,9 +24,12 @@ class ModelAPI_Feature; */ class MODELAPI_EXPORT ModelAPI_Validator { -public: + public: // Make virtual destructor in order to make the class polymorphic - virtual ~ModelAPI_Validator() {}; + virtual ~ModelAPI_Validator() + { + } + ; /// Returns true if feature and/or attributes are valid /// \param theFeature the validated feature @@ -52,7 +55,7 @@ typedef boost::shared_ptr ValidatorPtr; */ class MODELAPI_EXPORT ModelAPI_ValidatorsFactory { -public: + public: /// Registers the instance of the validator by the ID virtual void registerValidator(const std::string& theID, ModelAPI_Validator* theValidator) = 0; @@ -60,18 +63,17 @@ public: virtual void assignValidator(const std::string& theID, const std::string& theFeatureID) = 0; /// Assigns validator to the attribute of the feature - virtual void assignValidator(const std::string& theID, - const std::string& theFeatureID, const std::string& theAttrID, - const std::list& theArguments) = 0; + virtual void assignValidator(const std::string& theID, const std::string& theFeatureID, + const std::string& theAttrID, + const std::list& theArguments) = 0; /// Provides a validator for the feature, returns NULL if no validator - virtual void validators(const std::string& theFeatureID, - std::list& theResult) const = 0; + virtual void validators(const std::string& theFeatureID, + std::list& theResult) const = 0; /// Provides a validator for the attribute, returns NULL if no validator - virtual void validators( - const std::string& theFeatureID, const std::string& theAttrID, - std::list& theValidators, - std::list >& theArguments) const = 0; + virtual void validators(const std::string& theFeatureID, const std::string& theAttrID, + std::list& theValidators, + std::list >& theArguments) const = 0; /// Returns registered validator by its Id virtual const ModelAPI_Validator* validator(const std::string& theID) const = 0; @@ -81,9 +83,11 @@ public: //virtual bool validate( // const boost::shared_ptr& theFeature, const std::string& theAttrID) const = 0; -protected: + protected: /// Get instance from PluginManager - ModelAPI_ValidatorsFactory() {} + ModelAPI_ValidatorsFactory() + { + } }; #endif diff --git a/src/ModuleBase/ModuleBase.h b/src/ModuleBase/ModuleBase.h index e4a58e3d7..54ee50427 100644 --- a/src/ModuleBase/ModuleBase.h +++ b/src/ModuleBase/ModuleBase.h @@ -1,18 +1,18 @@ -#ifndef MODULEBASE_H -#define MODULEBASE_H - -#if defined MODULEBASE_EXPORTS -#if defined WIN32 -#define MODULEBASE_EXPORT __declspec( dllexport ) -#else -#define MODULEBASE_EXPORT -#endif -#else -#if defined WIN32 -#define MODULEBASE_EXPORT __declspec( dllimport ) -#else -#define MODULEBASE_EXPORT -#endif -#endif - -#endif //MODULEBASE_H +#ifndef MODULEBASE_H +#define MODULEBASE_H + +#if defined MODULEBASE_EXPORTS +#if defined WIN32 +#define MODULEBASE_EXPORT __declspec( dllexport ) +#else +#define MODULEBASE_EXPORT +#endif +#else +#if defined WIN32 +#define MODULEBASE_EXPORT __declspec( dllimport ) +#else +#define MODULEBASE_EXPORT +#endif +#endif + +#endif //MODULEBASE_H \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_Definitions.h b/src/ModuleBase/ModuleBase_Definitions.h index 9e4bfbc02..56049acec 100644 --- a/src/ModuleBase/ModuleBase_Definitions.h +++ b/src/ModuleBase/ModuleBase_Definitions.h @@ -1,4 +1,3 @@ - #ifndef ModuleBase_Definitions_H #define ModuleBase_Definitions_H @@ -9,8 +8,7 @@ typedef QList QIntList; //!< list of int values typedef QList QShortList; //!< list of short int values typedef QList QDoubleList; //!< list of double values -typedef QList QFeatureList; //!< List of features -typedef QList QResultList; //!< List of results - +typedef QList QFeatureList; //!< List of features +typedef QList QResultList; //!< List of results -#endif \ No newline at end of file +#endif diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index ae652617e..640484927 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -1,49 +1,52 @@ -#ifndef ModuleBase_IModule_H -#define ModuleBase_IModule_H - -#include -#include - -class QAction; -class XGUI_Workshop; -class Config_WidgetAPI; -class ModuleBase_ModelWidget; - -/** -* Interface to a module -*/ -class ModuleBase_IModule: public QObject -{ -public: - /// Reads description of features from XML file - virtual void createFeatures() = 0; - - /// Called on creation of menu item in desktop - virtual void featureCreated(QAction*) = 0; - - /// Creates an operation and send it to loop - /// \param theCmdId the operation name - virtual void launchOperation(const QString& theCmdId) = 0; - - /// Called when it is necessary to update a command state (enable or disable it) - //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0; - - /// Creates custom widgets for property panel - virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent, - Config_WidgetAPI* theWidgetApi, QList& theModelWidgets) - { - return 0; - } - - virtual ~ModuleBase_IModule() {}; -}; - -//! This function must return a new module instance. -extern "C" -{ -typedef ModuleBase_IModule* (*CREATE_FUNC)(XGUI_Workshop*); -} - -#define CREATE_MODULE "createModule" - -#endif //ModuleBase_IModule +#ifndef ModuleBase_IModule_H +#define ModuleBase_IModule_H + +#include +#include + +class QAction; +class XGUI_Workshop; +class Config_WidgetAPI; +class ModuleBase_ModelWidget; + +/** + * Interface to a module + */ +class ModuleBase_IModule : public QObject +{ + public: + /// Reads description of features from XML file + virtual void createFeatures() = 0; + + /// Called on creation of menu item in desktop + virtual void featureCreated(QAction*) = 0; + + /// Creates an operation and send it to loop + /// \param theCmdId the operation name + virtual void launchOperation(const QString& theCmdId) = 0; + + /// Called when it is necessary to update a command state (enable or disable it) + //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0; + + /// Creates custom widgets for property panel + virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent, + Config_WidgetAPI* theWidgetApi, + QList& theModelWidgets) + { + return 0; + } + + virtual ~ModuleBase_IModule() + { + } + ; +}; + +//! This function must return a new module instance. +extern "C" { +typedef ModuleBase_IModule* (*CREATE_FUNC)(XGUI_Workshop*); +} + +#define CREATE_MODULE "createModule" + +#endif //ModuleBase_IModule \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_IOperation.cpp b/src/ModuleBase/ModuleBase_IOperation.cpp index cee8fbc2b..f8aacb9c1 100644 --- a/src/ModuleBase/ModuleBase_IOperation.cpp +++ b/src/ModuleBase/ModuleBase_IOperation.cpp @@ -17,7 +17,9 @@ #endif ModuleBase_IOperation::ModuleBase_IOperation(const QString& theId, QObject* theParent) - : QObject(theParent), myIsEditing(false), myIsModified(false) + : QObject(theParent), + myIsEditing(false), + myIsModified(false) { myDescription = new ModuleBase_OperationDescription(theId); } @@ -43,14 +45,14 @@ bool ModuleBase_IOperation::isGranted(ModuleBase_IOperation* /*theOperation*/) c } /*void ModuleBase_IOperation::setModelWidgets(const std::string& theXmlRepresentation, - QList theWidgets) -{ - QList::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end(); - for (; anIt != aLast; anIt++) { - QObject::connect(*anIt, SIGNAL(valuesChanged()), this, SLOT(storeCustomValue())); - } - getDescription()->setModelWidgets(theXmlRepresentation, theWidgets); -}*/ + QList theWidgets) + { + QList::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end(); + for (; anIt != aLast; anIt++) { + QObject::connect(*anIt, SIGNAL(valuesChanged()), this, SLOT(storeCustomValue())); + } + getDescription()->setModelWidgets(theXmlRepresentation, theWidgets); + }*/ boost::shared_ptr ModuleBase_IOperation::document() const { @@ -91,7 +93,7 @@ bool ModuleBase_IOperation::commit() document()->finishOperation(); emit stopped(); - + afterCommitOperation(); return true; } diff --git a/src/ModuleBase/ModuleBase_IOperation.h b/src/ModuleBase/ModuleBase_IOperation.h index c9510192f..8d738763e 100644 --- a/src/ModuleBase/ModuleBase_IOperation.h +++ b/src/ModuleBase/ModuleBase_IOperation.h @@ -5,7 +5,6 @@ * Author: nds */ - #ifndef ModuleBase_IOperation_H #define ModuleBase_IOperation_H @@ -37,11 +36,11 @@ class ModuleBase_OperationDescription; * - virtual void commitOperation(); */ -class MODULEBASE_EXPORT ModuleBase_IOperation: public QObject +class MODULEBASE_EXPORT ModuleBase_IOperation : public QObject { Q_OBJECT -public: + public: /// Constructor /// Constructs an empty operation. Constructor should work very fast because many /// operators may be created after starting workshop but only several from them @@ -73,19 +72,25 @@ public: // QList theWidgets); /// Returns True if data of its feature was modified during operation - virtual bool isModified() const { return myIsModified; } + virtual bool isModified() const + { + return myIsModified; + } /// Returns True id the current operation is launched in editing mode - bool isEditOperation() const { return myIsEditing; } + bool isEditOperation() const + { + return myIsEditing; + } signals: - void started(); /// the operation is started - void aborted(); /// the operation is aborted - void committed(); /// the operation is committed - void stopped(); /// the operation is aborted or committed - void resumed(); /// the operation is resumed + void started(); /// the operation is started + void aborted(); /// the operation is aborted + void committed(); /// the operation is committed + void stopped(); /// the operation is aborted or committed + void resumed(); /// the operation is resumed -public slots: + public slots: /// Starts operation /// Public slot. Verifies whether operation can be started and starts operation. /// This slot is not virtual and cannot be redefined. Redefine startOperation method @@ -119,7 +124,7 @@ public slots: /// Stores a custom value in model. virtual void storeCustomValue() = 0; -protected: + protected: /// Virtual method called when operation started (see start() method for more description) /// Default impl calls corresponding slot and commits immediately. virtual void startOperation() = 0; @@ -150,8 +155,8 @@ protected: /// Modified feature flag bool myIsModified; -private: - ModuleBase_OperationDescription* myDescription; /// the container to have the operation description + private: + ModuleBase_OperationDescription* myDescription; /// the container to have the operation description }; #endif diff --git a/src/ModuleBase/ModuleBase_ISelection.h b/src/ModuleBase/ModuleBase_ISelection.h index 33d617de9..43bd0ea86 100644 --- a/src/ModuleBase/ModuleBase_ISelection.h +++ b/src/ModuleBase/ModuleBase_ISelection.h @@ -18,7 +18,7 @@ class ModuleBase_ISelection { -public: + public: /// Returns a list of viewer selected presentations /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build @@ -31,15 +31,15 @@ public: virtual std::list getHighlighted(int theShapeTypeToSkip = -1) const = 0; /** - * Returns list of features currently selected in 3d viewer - */ + * Returns list of features currently selected in 3d viewer + */ virtual QList selectedObjects() const = 0; /** - * Returns list of currently selected results - */ + * Returns list of currently selected results + */ virtual QList selectedPresentations() const = 0; - + //! Returns list of currently selected QModelIndexes virtual QModelIndexList selectedIndexes() const = 0; @@ -51,4 +51,4 @@ public: }; -#endif \ No newline at end of file +#endif diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h index 134274398..b05e2d629 100644 --- a/src/ModuleBase/ModuleBase_IWorkshop.h +++ b/src/ModuleBase/ModuleBase_IWorkshop.h @@ -16,21 +16,27 @@ class ModuleBase_IModule; /** -* Class which provides access to Workshop object serveces -*/ -class MODULEBASE_EXPORT ModuleBase_IWorkshop: public QObject + * Class which provides access to Workshop object serveces + */ +class MODULEBASE_EXPORT ModuleBase_IWorkshop : public QObject { Q_OBJECT -public: - ModuleBase_IWorkshop(QObject* theParent):QObject(theParent) {} + public: + ModuleBase_IWorkshop(QObject* theParent) + : QObject(theParent) + { + } - virtual ~ModuleBase_IWorkshop() {}; + virtual ~ModuleBase_IWorkshop() + { + } + ; //! Returns AIS_InteractiveContext from current OCCViewer virtual Handle(AIS_InteractiveContext) AISContext() const = 0; //! Returns list of currently selected data objects - virtual QList selectedObjects() const = 0; + virtual QList selectedObjects() const = 0; //! Returns instance of loaded module virtual ModuleBase_IModule* module() const = 0; @@ -39,4 +45,4 @@ signals: void selectionChanged(); }; -#endif \ No newline at end of file +#endif diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 86a8a8e0f..80c4cb856 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -14,10 +14,11 @@ #include -ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, - const Config_WidgetAPI* theData, - const std::string& theParentId) - : QObject(theParent), myHasDefaultValue(false), myParentId(theParentId) +ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData, + const std::string& theParentId) + : QObject(theParent), + myHasDefaultValue(false), + myParentId(theParentId) { myAttributeID = theData ? theData->widgetId() : ""; } @@ -41,7 +42,6 @@ bool ModuleBase_ModelWidget::focusTo() return true; } - void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const { Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index c150d01b3..d11c21d0f 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -27,19 +27,27 @@ class QKeyEvent; */ class MODULEBASE_EXPORT ModuleBase_ModelWidget : public QObject { - Q_OBJECT -public: +Q_OBJECT + public: /// Constructor /// \theParent the parent object /// \theData the widget configuation. The attribute of the model widget is obtained from - ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData, const std::string& theParentId); + ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData, + const std::string& theParentId); /// Destructor - virtual ~ModuleBase_ModelWidget() {}; + virtual ~ModuleBase_ModelWidget() + { + } + ; /// Set the given wrapped value to the current widget /// This value should be processed in the widget according to the needs /// \param theValue the wrapped widget value - virtual bool setValue(ModuleBase_WidgetValue* theValue) { return false; }; + virtual bool setValue(ModuleBase_WidgetValue* theValue) + { + return false; + } + ; /// Returns the state whether the attribute of the feature is initialized /// \param theObject a model feature to be checked @@ -63,18 +71,33 @@ public: /// Returns whether the control has a default value /// \return a boolean value - bool hasDefaultValue() const { return myHasDefaultValue; } + bool hasDefaultValue() const + { + return myHasDefaultValue; + } /// Returns the attribute name /// \returns the string value - std::string attributeID() const { return myAttributeID; } + std::string attributeID() const + { + return myAttributeID; + } /// Returns the parent of the attribute /// \returns the string value - std::string parentID() const { return myParentId; } - - FeaturePtr feature() const { return myFeature;} - void setFeature(const FeaturePtr& theFeature) { myFeature = theFeature; } + std::string parentID() const + { + return myParentId; + } + + FeaturePtr feature() const + { + return myFeature; + } + void setFeature(const FeaturePtr& theFeature) + { + myFeature = theFeature; + } signals: /// The signal about widget values changed @@ -87,17 +110,19 @@ signals: /// \param theWidget the model base widget void focusOutWidget(ModuleBase_ModelWidget* theWidget); -protected: + protected: /// Returns the attribute name /// \returns the string value - void setAttributeID(const std::string& theAttribute) { myAttributeID = theAttribute; } + void setAttributeID(const std::string& theAttribute) + { + myAttributeID = theAttribute; + } void updateObject(ObjectPtr theObj) const; - bool myHasDefaultValue; /// the boolean state whether the control has a default value - + bool myHasDefaultValue; /// the boolean state whether the control has a default value - std::string myAttributeID; /// the attribute name of the model feature + std::string myAttributeID; /// the attribute name of the model feature std::string myParentId; /// name of parent FeaturePtr myFeature; }; diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 4a980a1dc..305b810c6 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -26,7 +26,7 @@ #endif ModuleBase_Operation::ModuleBase_Operation(const QString& theId, QObject* theParent) -: ModuleBase_IOperation(theId, theParent) + : ModuleBase_IOperation(theId, theParent) { } @@ -51,11 +51,11 @@ bool ModuleBase_Operation::isNestedOperationsEnabled() const void ModuleBase_Operation::storeCustomValue() { - if(!myFeature){ - #ifdef _DEBUG + if (!myFeature) { +#ifdef _DEBUG qDebug() << "ModuleBase_Operation::storeCustom: " << - "trying to store value without opening a transaction."; - #endif + "trying to store value without opening a transaction."; +#endif return; } @@ -86,7 +86,8 @@ void ModuleBase_Operation::abortOperation() void ModuleBase_Operation::commitOperation() { - if (myFeature) myFeature->execute(); + if (myFeature) + myFeature->execute(); } void ModuleBase_Operation::afterCommitOperation() @@ -96,22 +97,22 @@ void ModuleBase_Operation::afterCommitOperation() bool ModuleBase_Operation::canBeCommitted() const { if (ModuleBase_IOperation::canBeCommitted()) { -/* FeaturePtr aFeature = feature(); - std::string aId = aFeature->getKind(); - - PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); - ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - std::list aValidators; - aFactory->validators(aId, aValidators); - std::list::const_iterator aIt; - for (aIt = aValidators.cbegin(); aIt != aValidators.cend(); ++aIt) { - const ModuleBase_FeatureValidator* aFValidator = - dynamic_cast(*aIt); - if (aFValidator) { - if (!aFValidator->isValid(aFeature)) - return false; - } - }*/ + /* FeaturePtr aFeature = feature(); + std::string aId = aFeature->getKind(); + + PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); + std::list aValidators; + aFactory->validators(aId, aValidators); + std::list::const_iterator aIt; + for (aIt = aValidators.cbegin(); aIt != aValidators.cend(); ++aIt) { + const ModuleBase_FeatureValidator* aFValidator = + dynamic_cast(*aIt); + if (aFValidator) { + if (!aFValidator->isValid(aFeature)) + return false; + } + }*/ return true; } return false; @@ -131,15 +132,15 @@ FeaturePtr ModuleBase_Operation::createFeature(const bool theFlushMessage) { boost::shared_ptr aDoc = document(); myFeature = aDoc->addFeature(getDescription()->operationId().toStdString()); - if (myFeature) { // TODO: generate an error if feature was not created + if (myFeature) { // TODO: generate an error if feature was not created myIsModified = true; myFeature->execute(); // Init default values /*QList aWidgets = getDescription()->modelWidgets(); - QList::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end(); - for (; anIt != aLast; anIt++) { - (*anIt)->storeValue(aFeature); - }*/ + QList::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end(); + for (; anIt != aLast; anIt++) { + (*anIt)->storeValue(aFeature); + }*/ } if (theFlushMessage) @@ -172,4 +173,4 @@ bool ModuleBase_Operation::hasObject(ObjectPtr theObj) const } } return false; -} \ No newline at end of file +} diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index c9693d3f6..15e157bae 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -5,7 +5,6 @@ * Author: sbh */ - #ifndef ModuleBase_Operation_H #define ModuleBase_Operation_H @@ -40,11 +39,11 @@ class QKeyEvent; * - virtual void commitOperation(); */ -class MODULEBASE_EXPORT ModuleBase_Operation: public ModuleBase_IOperation +class MODULEBASE_EXPORT ModuleBase_Operation : public ModuleBase_IOperation { Q_OBJECT -public: + public: /// Constructor /// \param theId the operation identifier /// \param theParent the QObject parent @@ -67,7 +66,10 @@ public: /// Stores a custom value in model. void storeCustomValue(); - virtual void keyReleased(std::string theName, QKeyEvent* theEvent) {}; + virtual void keyReleased(std::string theName, QKeyEvent* theEvent) + { + } + ; /// Sets the operation feature void setEditingFeature(FeaturePtr theFeature); @@ -75,7 +77,7 @@ public: /// Returns True if the current operation works with the given object (feature or result) virtual bool hasObject(ObjectPtr theObj) const; -public slots: + public slots: /// Slots which listen the mode widget activation /// \param theWidget the model widget virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget); @@ -85,7 +87,7 @@ signals: /// \param theWidget the previous active widget void activateNextWidget(ModuleBase_ModelWidget* theWidget); -protected: + protected: /// Virtual method called when operation started (see start() method for more description) /// Default impl calls corresponding slot and commits immediately. virtual void startOperation(); @@ -108,7 +110,7 @@ protected: /// \returns the created feature virtual FeaturePtr createFeature(const bool theFlushMessage = true); -protected: + protected: /// Sets the operation feature void setFeature(FeaturePtr theFeature); @@ -116,8 +118,8 @@ protected: /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled virtual bool canBeCommitted() const; -protected: - FeaturePtr myFeature; /// the operation feature to be handled + protected: + FeaturePtr myFeature; /// the operation feature to be handled }; #endif diff --git a/src/ModuleBase/ModuleBase_OperationDescription.cpp b/src/ModuleBase/ModuleBase_OperationDescription.cpp index ffffe6922..e69e39218 100644 --- a/src/ModuleBase/ModuleBase_OperationDescription.cpp +++ b/src/ModuleBase/ModuleBase_OperationDescription.cpp @@ -9,7 +9,7 @@ #include ModuleBase_OperationDescription::ModuleBase_OperationDescription(const QString& theId) -: myOperationId(theId) + : myOperationId(theId) { } @@ -33,19 +33,19 @@ void ModuleBase_OperationDescription::setDescription(const QString& theDescripti } /*void ModuleBase_OperationDescription::setModelWidgets(const std::string& theXmlRepresentation, - const QList& theWidgets) -{ - myWidgets.clear(); - QList::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end(); - for (; anIt != aLast; anIt++) - myWidgets.push_back(*anIt); - myXmlRepresentation = theXmlRepresentation; -}*/ + const QList& theWidgets) + { + myWidgets.clear(); + QList::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end(); + for (; anIt != aLast; anIt++) + myWidgets.push_back(*anIt); + myXmlRepresentation = theXmlRepresentation; + }*/ /*const QList& ModuleBase_OperationDescription::modelWidgets() const -{ - return myWidgets; -}*/ + { + return myWidgets; + }*/ const QString& ModuleBase_OperationDescription::xmlRepresentation() const { diff --git a/src/ModuleBase/ModuleBase_OperationDescription.h b/src/ModuleBase/ModuleBase_OperationDescription.h index 79a730110..fdcd0b3fb 100644 --- a/src/ModuleBase/ModuleBase_OperationDescription.h +++ b/src/ModuleBase/ModuleBase_OperationDescription.h @@ -1,80 +1,80 @@ -/* - * ModuleBase_OperationDescription.h - * - * Created on: Apr 2, 2014 - * Author: sbh - */ - -#ifndef MODULEBASE_OPERATIONDESCRIPTION_H -#define MODULEBASE_OPERATIONDESCRIPTION_H - -#include -#include - -#include -#include -#include - -#include - -//class ModuleBase_ModelWidget; - -/*! - * \class ModuleBase_OperationDescription - * - */ -class MODULEBASE_EXPORT ModuleBase_OperationDescription -{ -public: - /// Constructor - /// \param theId - the operation identifier - ModuleBase_OperationDescription(const QString& theId = ""); - /// Destructor - virtual ~ModuleBase_OperationDescription(); - - /// Unique name of the operation - /// \return string name of the operation. - const QString& operationId() const; - - /// Returns XML representation of the operation's widget. - /// \return XML QString - //const QString& xmlRepresentation() const; - - /// Returns a short description of operation (will be - /// inserted in title of property panel) - const QString& description() const; - - /// Sets a short description of operation (will be - /// inserted in title of property panel) - void setDescription(const QString& theDescription); - - /// Sets a list of model widgets, according to the operation feature xml definition - /// \param theWidgets a list of widgets - //void setModelWidgets(const std::string& theXmlRepresentation, - // const QList& theWidgets); - - /// Sets a list of model widgets, according to the operation feature xml definition - /// \param theWidgets a list of widgets - //const QList& modelWidgets() const; - - /// Returns XML representation of the operation's widget. - /// \return XML QString - const QString& xmlRepresentation() const; - - /// Sets XML representation of the operation's widget. - /// \param theXMLRepresentation - XML QString - void setXmlRepresentation(const QString& theXMLRepresentation); - - /// Returns true if there are no model widgets - /// \return the boolean value - bool hasXmlRepresentation() const; - -private: - //!< Next fields could be extracted into a subclass; - QString myOperationId; /// the operation identifier - QString myDescription; /// the short description of the opertaion - QString myXmlRepresentation; /// the xml definition - //QList myWidgets; /// the list of operation widgets -}; - -#endif //ModuleBase_OperationDescription_H +/* + * ModuleBase_OperationDescription.h + * + * Created on: Apr 2, 2014 + * Author: sbh + */ + +#ifndef MODULEBASE_OPERATIONDESCRIPTION_H +#define MODULEBASE_OPERATIONDESCRIPTION_H + +#include +#include + +#include +#include +#include + +#include + +//class ModuleBase_ModelWidget; + +/*! + * \class ModuleBase_OperationDescription + * + */ +class MODULEBASE_EXPORT ModuleBase_OperationDescription +{ + public: + /// Constructor + /// \param theId - the operation identifier + ModuleBase_OperationDescription(const QString& theId = ""); + /// Destructor + virtual ~ModuleBase_OperationDescription(); + + /// Unique name of the operation + /// \return string name of the operation. + const QString& operationId() const; + + /// Returns XML representation of the operation's widget. + /// \return XML QString + //const QString& xmlRepresentation() const; + + /// Returns a short description of operation (will be + /// inserted in title of property panel) + const QString& description() const; + + /// Sets a short description of operation (will be + /// inserted in title of property panel) + void setDescription(const QString& theDescription); + + /// Sets a list of model widgets, according to the operation feature xml definition + /// \param theWidgets a list of widgets + //void setModelWidgets(const std::string& theXmlRepresentation, + // const QList& theWidgets); + + /// Sets a list of model widgets, according to the operation feature xml definition + /// \param theWidgets a list of widgets + //const QList& modelWidgets() const; + + /// Returns XML representation of the operation's widget. + /// \return XML QString + const QString& xmlRepresentation() const; + + /// Sets XML representation of the operation's widget. + /// \param theXMLRepresentation - XML QString + void setXmlRepresentation(const QString& theXMLRepresentation); + + /// Returns true if there are no model widgets + /// \return the boolean value + bool hasXmlRepresentation() const; + + private: + //!< Next fields could be extracted into a subclass; + QString myOperationId; /// the operation identifier + QString myDescription; /// the short description of the opertaion + QString myXmlRepresentation; /// the xml definition + //QList myWidgets; /// the list of operation widgets +}; + +#endif //ModuleBase_OperationDescription_H \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_ResultValidators.cpp b/src/ModuleBase/ModuleBase_ResultValidators.cpp index 67a9ca5a9..4fde0437b 100644 --- a/src/ModuleBase/ModuleBase_ResultValidators.cpp +++ b/src/ModuleBase/ModuleBase_ResultValidators.cpp @@ -14,7 +14,6 @@ #include #include - ResultPtr result(const ObjectPtr theObject) { return boost::dynamic_pointer_cast(theObject); @@ -28,7 +27,6 @@ TopoDS_Shape shape(ResultPtr theResult) return TopoDS_Shape(); } - bool ModuleBase_ResultPointValidator::isValid(const ObjectPtr theObject) const { ResultPtr aResult = result(theObject); @@ -41,7 +39,6 @@ bool ModuleBase_ResultPointValidator::isValid(const ObjectPtr theObject) const return aShape.ShapeType() == TopAbs_VERTEX; } - bool ModuleBase_ResultLineValidator::isValid(const ObjectPtr theObject) const { ResultPtr aResult = result(theObject); @@ -61,7 +58,6 @@ bool ModuleBase_ResultLineValidator::isValid(const ObjectPtr theObject) const return false; } - bool ModuleBase_ResultArcValidator::isValid(const ObjectPtr theObject) const { ResultPtr aResult = result(theObject); diff --git a/src/ModuleBase/ModuleBase_ResultValidators.h b/src/ModuleBase/ModuleBase_ResultValidators.h index 1b55460e0..ee4b23ded 100644 --- a/src/ModuleBase/ModuleBase_ResultValidators.h +++ b/src/ModuleBase/ModuleBase_ResultValidators.h @@ -9,28 +9,28 @@ #include #include -class ModuleBase_ResultValidator: public ModelAPI_Validator +class ModuleBase_ResultValidator : public ModelAPI_Validator { -public: + public: virtual bool isValid(const ObjectPtr theObject) const = 0; }; -class ModuleBase_ResultPointValidator: public ModuleBase_ResultValidator +class ModuleBase_ResultPointValidator : public ModuleBase_ResultValidator { -public: + public: MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const; }; -class ModuleBase_ResultLineValidator: public ModuleBase_ResultValidator +class ModuleBase_ResultLineValidator : public ModuleBase_ResultValidator { -public: + public: MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const; }; -class ModuleBase_ResultArcValidator: public ModuleBase_ResultValidator +class ModuleBase_ResultArcValidator : public ModuleBase_ResultValidator { -public: + public: MODULEBASE_EXPORT virtual bool isValid(const ObjectPtr theObject) const; }; -#endif \ No newline at end of file +#endif diff --git a/src/ModuleBase/ModuleBase_SelectionValidator.h b/src/ModuleBase/ModuleBase_SelectionValidator.h index 1dd380139..f4bf04e7e 100644 --- a/src/ModuleBase/ModuleBase_SelectionValidator.h +++ b/src/ModuleBase/ModuleBase_SelectionValidator.h @@ -10,10 +10,9 @@ #include - -class ModuleBase_SelectionValidator: public ModelAPI_Validator +class ModuleBase_SelectionValidator : public ModelAPI_Validator { -public: + public: virtual bool isValid(const ModuleBase_ISelection* theSelection) const = 0; }; diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 87f636360..f68de8da5 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -7,8 +7,7 @@ #include #include -namespace ModuleBase_Tools -{ +namespace ModuleBase_Tools { //****************************************************************** diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index 3a2dbacff..e2a09c546 100644 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -2,7 +2,6 @@ // Created: 11 July 2014 // Author: Vitaly Smetannikov - #ifndef ModuleBase_Tools_H #define ModuleBase_Tools_H @@ -13,16 +12,16 @@ class GeomAPI_Shape; -namespace ModuleBase_Tools -{ +namespace ModuleBase_Tools { - /** - * Returns returns a shape if the result has a shape method. Otherwise returns NULL pointer - */ - MODULEBASE_EXPORT boost::shared_ptr shape(ResultPtr theResult); +/** + * Returns returns a shape if the result has a shape method. Otherwise returns NULL pointer + */ +MODULEBASE_EXPORT boost::shared_ptr shape(ResultPtr theResult); - MODULEBASE_EXPORT FeaturePtr feature(ObjectPtr theObject); +MODULEBASE_EXPORT FeaturePtr feature(ObjectPtr theObject); -}; +} +; -#endif \ No newline at end of file +#endif diff --git a/src/ModuleBase/ModuleBase_ViewerPrs.h b/src/ModuleBase/ModuleBase_ViewerPrs.h index 40ec66613..c67c2312b 100644 --- a/src/ModuleBase/ModuleBase_ViewerPrs.h +++ b/src/ModuleBase/ModuleBase_ViewerPrs.h @@ -20,49 +20,80 @@ */ class ModuleBase_ViewerPrs { -public: + public: /// Constructor - ModuleBase_ViewerPrs() {} - + ModuleBase_ViewerPrs() + { + } + /// Constructor /// \param theFeature a model feature /// \param theShape a viewer shape /// \param theOwner a selection owner - ModuleBase_ViewerPrs(ObjectPtr theResult, - const TopoDS_Shape& theShape, - Handle_SelectMgr_EntityOwner theOwner) - : myResult(theResult), myShape(theShape), myOwner(theOwner) {} - + ModuleBase_ViewerPrs(ObjectPtr theResult, const TopoDS_Shape& theShape, + Handle_SelectMgr_EntityOwner theOwner) + : myResult(theResult), + myShape(theShape), + myOwner(theOwner) + { + } + /// Destructor - virtual ~ModuleBase_ViewerPrs() {} + virtual ~ModuleBase_ViewerPrs() + { + } /// Sets the feature. /// \param theFeature a feature instance - void setFeature(ObjectPtr theResult) { myResult = theResult; } + void setFeature(ObjectPtr theResult) + { + myResult = theResult; + } /// Returns the feature. /// \return a feature instance - ObjectPtr object() const { return myResult; } + ObjectPtr object() const + { + return myResult; + } /// Returns the presentation owner /// \param the owner - void setOwner(Handle_SelectMgr_EntityOwner theOwner) { myOwner = theOwner; } + void setOwner(Handle_SelectMgr_EntityOwner theOwner) + { + myOwner = theOwner; + } /// Returns the presentation owner /// \return an owner - Handle_SelectMgr_EntityOwner owner() const { return myOwner; } + Handle_SelectMgr_EntityOwner owner() const + { + return myOwner; + } /// Sets the shape /// \param theShape a shape instance - void setShape(const TopoDS_Shape& theShape) { myShape = theShape; } + void setShape(const TopoDS_Shape& theShape) + { + myShape = theShape; + } /// Returns the shape /// \return a shape instance - const TopoDS_Shape& shape() const { return myShape; } + const TopoDS_Shape& shape() const + { + return myShape; + } - void setInteractive(const Handle(AIS_InteractiveObject)& theIO) { myInteractive = theIO; } + void setInteractive(const Handle(AIS_InteractiveObject)& theIO) + { + myInteractive = theIO; + } - Handle(AIS_InteractiveObject) interactive() const { return myInteractive; } + Handle(AIS_InteractiveObject) interactive() const + { + return myInteractive; + } bool operator==(const ModuleBase_ViewerPrs& thePrs) { @@ -73,10 +104,10 @@ public: return aResult && aOwner && aShape && aIO; } -private: - ObjectPtr myResult; /// the feature - Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner - TopoDS_Shape myShape; /// the shape + private: + ObjectPtr myResult; /// the feature + Handle(SelectMgr_EntityOwner) myOwner; /// the selection owner + TopoDS_Shape myShape; /// the shape Handle(AIS_InteractiveObject) myInteractive; }; diff --git a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp index 07a8eb000..e6bbdad25 100644 --- a/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetBoolValue.cpp @@ -17,10 +17,10 @@ #include #include -ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent, - const Config_WidgetAPI* theData, - const std::string& theParentId) - : ModuleBase_ModelWidget(theParent, theData, theParentId) +ModuleBase_WidgetBoolValue::ModuleBase_WidgetBoolValue(QWidget* theParent, + const Config_WidgetAPI* theData, + const std::string& theParentId) + : ModuleBase_ModelWidget(theParent, theData, theParentId) { QString aText = QString::fromStdString(theData->widgetLabel()); QString aToolTip = QString::fromStdString(theData->widgetTooltip()); @@ -37,9 +37,9 @@ ModuleBase_WidgetBoolValue::~ModuleBase_WidgetBoolValue() { } -QWidget* ModuleBase_WidgetBoolValue::getControl() const -{ - return myCheckBox; +QWidget* ModuleBase_WidgetBoolValue::getControl() const +{ + return myCheckBox; } bool ModuleBase_WidgetBoolValue::storeValue() const diff --git a/src/ModuleBase/ModuleBase_WidgetBoolValue.h b/src/ModuleBase/ModuleBase_WidgetBoolValue.h index 7f6c822a8..9d0246c11 100644 --- a/src/ModuleBase/ModuleBase_WidgetBoolValue.h +++ b/src/ModuleBase/ModuleBase_WidgetBoolValue.h @@ -12,14 +12,15 @@ class Config_WidgetAPI; class QWidget; class QCheckBox; -class MODULEBASE_EXPORT ModuleBase_WidgetBoolValue: public ModuleBase_ModelWidget +class MODULEBASE_EXPORT ModuleBase_WidgetBoolValue : public ModuleBase_ModelWidget { - Q_OBJECT -public: +Q_OBJECT + public: /// Constructor /// \theParent the parent object /// \theData the widget configuation. The attribute of the model widget is obtained from - ModuleBase_WidgetBoolValue(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId); + ModuleBase_WidgetBoolValue(QWidget* theParent, const Config_WidgetAPI* theData, + const std::string& theParentId); virtual ~ModuleBase_WidgetBoolValue(); @@ -37,8 +38,8 @@ public: /// \returns the widget QWidget* getControl() const; -private: + private: QCheckBox* myCheckBox; }; -#endif \ No newline at end of file +#endif diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp index beb384bcd..361c07cfc 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp @@ -24,11 +24,10 @@ #define DBL_MAX 1.7976931348623158e+308 #endif - -ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, - const Config_WidgetAPI* theData, - const std::string& theParentId) - : ModuleBase_ModelWidget(theParent, theData, theParentId) +ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent, + const Config_WidgetAPI* theData, + const std::string& theParentId) + : ModuleBase_ModelWidget(theParent, theData, theParentId) { myContainer = new QWidget(theParent); QHBoxLayout* aControlLay = new QHBoxLayout(myContainer); @@ -125,7 +124,7 @@ bool ModuleBase_WidgetDoubleValue::eventFilter(QObject *theObject, QEvent *theEv { if (theObject == mySpinBox) { if (theEvent->type() == QEvent::KeyRelease) { - QKeyEvent* aKeyEvent = (QKeyEvent*)theEvent; + QKeyEvent* aKeyEvent = (QKeyEvent*) theEvent; if (aKeyEvent && aKeyEvent->key() == Qt::Key_Return) { emit focusOutWidget(this); } diff --git a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h index 15b9063b3..6c819866e 100644 --- a/src/ModuleBase/ModuleBase_WidgetDoubleValue.h +++ b/src/ModuleBase/ModuleBase_WidgetDoubleValue.h @@ -13,14 +13,15 @@ class QWidget; class QLabel; class QDoubleSpinBox; -class MODULEBASE_EXPORT ModuleBase_WidgetDoubleValue: public ModuleBase_ModelWidget +class MODULEBASE_EXPORT ModuleBase_WidgetDoubleValue : public ModuleBase_ModelWidget { - Q_OBJECT -public: +Q_OBJECT + public: /// Constructor /// \theParent the parent object /// \theData the widget configuation. The attribute of the model widget is obtained from - ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId); + ModuleBase_WidgetDoubleValue(QWidget* theParent, const Config_WidgetAPI* theData, + const std::string& theParentId); virtual ~ModuleBase_WidgetDoubleValue(); @@ -36,17 +37,20 @@ public: /// Returns the internal parent wiget control, that can be shown anywhere /// \returns the widget - QWidget* getControl() const { return myContainer; } + QWidget* getControl() const + { + return myContainer; + } /// Process key release envent on the widget spin box controls /// \param theObject the object where the event happens /// \param theEvent the processed event virtual bool eventFilter(QObject *theObject, QEvent *theEvent); -protected: - QWidget* myContainer; - QLabel* myLabel; + protected: + QWidget* myContainer; + QLabel* myLabel; QDoubleSpinBox* mySpinBox; }; -#endif \ No newline at end of file +#endif diff --git a/src/ModuleBase/ModuleBase_WidgetEditor.cpp b/src/ModuleBase/ModuleBase_WidgetEditor.cpp index 9774a52bb..b42e84017 100644 --- a/src/ModuleBase/ModuleBase_WidgetEditor.cpp +++ b/src/ModuleBase/ModuleBase_WidgetEditor.cpp @@ -25,14 +25,15 @@ #include ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent, - const Config_WidgetAPI* theData, + const Config_WidgetAPI* theData, const std::string& theParentId) -: ModuleBase_WidgetDoubleValue(theParent, theData, theParentId) + : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId) { } -ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent, const std::string& theAttribute) -: ModuleBase_WidgetDoubleValue(theParent, 0, "") +ModuleBase_WidgetEditor::ModuleBase_WidgetEditor(QWidget* theParent, + const std::string& theAttribute) + : ModuleBase_WidgetDoubleValue(theParent, 0, "") { setAttributeID(theAttribute); } @@ -46,7 +47,7 @@ double editedValue(double theValue, bool& isDone) QDialog aDlg; aDlg.setWindowFlags(Qt::FramelessWindowHint); QHBoxLayout* aLay = new QHBoxLayout(&aDlg); - aLay->setContentsMargins(0,0,0,0); + aLay->setContentsMargins(0, 0, 0, 0); QLineEdit* aEditor = new QLineEdit(QString::number(theValue), &aDlg); aEditor->setValidator(new QDoubleValidator(aEditor)); @@ -80,7 +81,8 @@ bool ModuleBase_WidgetEditor::focusTo() return false; } -void ModuleBase_WidgetEditor::editFeatureValue(FeaturePtr theFeature, const std::string theAttribute) +void ModuleBase_WidgetEditor::editFeatureValue(FeaturePtr theFeature, + const std::string theAttribute) { DataPtr aData = theFeature->data(); AttributeDoublePtr aRef = aData->real(theAttribute); diff --git a/src/ModuleBase/ModuleBase_WidgetEditor.h b/src/ModuleBase/ModuleBase_WidgetEditor.h index 9c567bfcc..508e5ee53 100644 --- a/src/ModuleBase/ModuleBase_WidgetEditor.h +++ b/src/ModuleBase/ModuleBase_WidgetEditor.h @@ -20,13 +20,14 @@ class QLineEdit; */ class MODULEBASE_EXPORT ModuleBase_WidgetEditor : public ModuleBase_WidgetDoubleValue { - Q_OBJECT -public: +Q_OBJECT + public: /// Constructor /// \theParent the parent object /// \theParent the parent object /// \theData the widget configuation. The attribute of the model widget is obtained from - ModuleBase_WidgetEditor(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId); + ModuleBase_WidgetEditor(QWidget* theParent, const Config_WidgetAPI* theData, + const std::string& theParentId); /// Constructor /// \theParent the parent object /// \theParent the parent object @@ -46,9 +47,9 @@ public: /// \param theAttribute the feature attribute static void editFeatureValue(FeaturePtr theFeature, const std::string theAttribute); -private: - FeaturePtr myFeature; ///< the current widget feature - QStringList myFeatureKinds; ///< the kinds of possible features + private: + FeaturePtr myFeature; ///< the current widget feature + QStringList myFeatureKinds; ///< the kinds of possible features }; #endif diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 6f292f3a6..d75479e74 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -43,7 +43,7 @@ ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(const std::string& theXmlRepresentation, ModuleBase_IWorkshop* theWorkshop) - : myWorkshop(theWorkshop) + : myWorkshop(theWorkshop) { myWidgetApi = new Config_WidgetAPI(theXmlRepresentation); } @@ -60,15 +60,14 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent) QVBoxLayout* aWidgetLay = new QVBoxLayout(theParent); aWidgetLay->setContentsMargins(2, 2, 2, 2); - do { //Iterate over each node + do { //Iterate over each node std::string aWdgType = myWidgetApi->widgetType(); //Create a widget (doublevalue, groupbox, toolbox, etc. QWidget* aWidget = createWidgetByType(aWdgType, theParent); if (aWidget) { if (!isInternalWidget(aWdgType)) { aWidgetLay->addWidget(aWidget); - } - else { + } else { aWidget->setVisible(false); } } @@ -90,13 +89,13 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent) if (aWdgType == WDG_SWITCH) { ModuleBase_WidgetSwitch* aSwitch = qobject_cast(aWidget); aSwitch->addPage(aPage, aPageName); - } else if (aWdgType == WDG_TOOLBOX){ + } else if (aWdgType == WDG_TOOLBOX) { QToolBox* aToolbox = qobject_cast(aWidget); aToolbox->addItem(aPage, aPageName); } - } while(myWidgetApi->toNextWidget()); + } while (myWidgetApi->toNextWidget()); } - } while(myWidgetApi->toNextWidget()); + } while (myWidgetApi->toNextWidget()); theParent->setLayout(aWidgetLay); } @@ -114,7 +113,8 @@ QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent) return result; } -QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType, QWidget* theParent) +QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType, + QWidget* theParent) { QWidget* result = NULL; if (theType == WDG_DOUBLEVALUE) { @@ -140,17 +140,17 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType } else if (theType == WDG_DOUBLEVALUE_EDITOR) { result = doubleValueEditor(theParent); - + } else if (theType == WDG_POINT2D_DISTANCE) { result = point2dDistanceControl(theParent); - } - else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) { + } else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) { result = createContainer(theType, theParent); } else { - result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi, myModelWidgets); + result = myWorkshop->module()->createWidgetByType(theType, theParent, myWidgetApi, + myModelWidgets); #ifdef _DEBUG - if (!result) { qDebug("ModuleBase_WidgetFactory::fillWidget: find bad widget type"); } + if (!result) {qDebug("ModuleBase_WidgetFactory::fillWidget: find bad widget type");} #endif } return result; @@ -171,15 +171,15 @@ QWidget* ModuleBase_WidgetFactory::createContainer(const std::string& theType, Q result = NULL; } #ifdef _DEBUG - else { qDebug() << "ModuleBase_WidgetFactory::fillWidget: find bad container type"; } + else {qDebug() << "ModuleBase_WidgetFactory::fillWidget: find bad container type";} #endif return result; } QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent) { - ModuleBase_WidgetDoubleValue* aDblWgt = - new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, myParentId); + ModuleBase_WidgetDoubleValue* aDblWgt = new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, + myParentId); myModelWidgets.append(aDblWgt); return aDblWgt->getControl(); @@ -187,32 +187,32 @@ QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent) QWidget* ModuleBase_WidgetFactory::pointSelectorControl(QWidget* theParent) { - ModuleBase_WidgetPoint2D* aWidget = - new ModuleBase_WidgetPoint2D(theParent, myWidgetApi, myParentId); + ModuleBase_WidgetPoint2D* aWidget = new ModuleBase_WidgetPoint2D(theParent, myWidgetApi, + myParentId); myModelWidgets.append(aWidget); return aWidget->getControl(); } QWidget* ModuleBase_WidgetFactory::featureSelectorControl(QWidget* theParent) { - ModuleBase_WidgetFeature* aWidget = - new ModuleBase_WidgetFeature(theParent, myWidgetApi, myParentId); + ModuleBase_WidgetFeature* aWidget = new ModuleBase_WidgetFeature(theParent, myWidgetApi, + myParentId); myModelWidgets.append(aWidget); return aWidget->getControl(); } QWidget* ModuleBase_WidgetFactory::featureOrAttributeSelectorControl(QWidget* theParent) { - ModuleBase_WidgetFeatureOrAttribute* aWidget = - new ModuleBase_WidgetFeatureOrAttribute(theParent, myWidgetApi, myParentId); + ModuleBase_WidgetFeatureOrAttribute* aWidget = new ModuleBase_WidgetFeatureOrAttribute( + theParent, myWidgetApi, myParentId); myModelWidgets.append(aWidget); return aWidget->getControl(); } QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent) { - ModuleBase_WidgetEditor* aWidget = - new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId); + ModuleBase_WidgetEditor* aWidget = new ModuleBase_WidgetEditor(theParent, myWidgetApi, + myParentId); myModelWidgets.append(aWidget); return aWidget->getControl(); } @@ -227,36 +227,35 @@ bool ModuleBase_WidgetFactory::isInternalWidget(const std::string& theType) std::string prop = myWidgetApi->getProperty(FEATURE_INTERNAL); std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower); - if(prop.empty() || prop == "false" || prop == "0") { + if (prop.empty() || prop == "false" || prop == "0") { return false; } - return true; + return true; } QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent) { - ModuleBase_WidgetSelector* aSelector = - new ModuleBase_WidgetSelector(theParent, myWorkshop, myWidgetApi, myParentId); + ModuleBase_WidgetSelector* aSelector = new ModuleBase_WidgetSelector(theParent, myWorkshop, + myWidgetApi, myParentId); myModelWidgets.append(aSelector); return aSelector->getControl(); } - QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent) { - ModuleBase_WidgetBoolValue* aBoolWgt = - new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId); + ModuleBase_WidgetBoolValue* aBoolWgt = new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, + myParentId); myModelWidgets.append(aBoolWgt); return aBoolWgt->getControl(); } - QWidget* ModuleBase_WidgetFactory::point2dDistanceControl(QWidget* theParent) { - ModuleBase_WidgetPoint2dDistance* aDistWgt = - new ModuleBase_WidgetPoint2dDistance(theParent, myWidgetApi, myParentId); + ModuleBase_WidgetPoint2dDistance* aDistWgt = new ModuleBase_WidgetPoint2dDistance(theParent, + myWidgetApi, + myParentId); myModelWidgets.append(aDistWgt); return aDistWgt->getControl(); -} \ No newline at end of file +} diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.h b/src/ModuleBase/ModuleBase_WidgetFactory.h index 5360f35db..81be16e71 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.h +++ b/src/ModuleBase/ModuleBase_WidgetFactory.h @@ -21,8 +21,9 @@ class ModuleBase_IWorkshop; class MODULEBASE_EXPORT ModuleBase_WidgetFactory { -public: - ModuleBase_WidgetFactory(const std::string& theXmlRepresentation, ModuleBase_IWorkshop* theWorkshop); + public: + ModuleBase_WidgetFactory(const std::string& theXmlRepresentation, + ModuleBase_IWorkshop* theWorkshop); virtual ~ModuleBase_WidgetFactory(); void createWidget(QWidget* theParent); @@ -32,7 +33,7 @@ public: return myModelWidgets; } -protected: + protected: //Widgets QWidget* createWidgetByType(const std::string& theType, QWidget* theParent = NULL); QWidget* labelControl(QWidget* theParent); @@ -53,9 +54,9 @@ protected: QString qs(const std::string& theStdString) const; -private: + private: Config_WidgetAPI* myWidgetApi; - ModuleBase_IWorkshop* myWorkshop; + ModuleBase_IWorkshop* myWorkshop; QList myModelWidgets; std::string myParentId; diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp index 983329b53..dd8fb9493 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeature.cpp @@ -27,9 +27,9 @@ #include ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent, - const Config_WidgetAPI* theData, + const Config_WidgetAPI* theData, const std::string& theParentId) -: ModuleBase_ModelWidget(theParent, theData, theParentId) + : ModuleBase_ModelWidget(theParent, theData, theParentId) { myContainer = new QWidget(theParent); QHBoxLayout* aControlLay = new QHBoxLayout(myContainer); @@ -61,8 +61,8 @@ bool ModuleBase_WidgetFeature::setValue(ModuleBase_WidgetValue* theValue) bool isDone = false; if (theValue) { - ModuleBase_WidgetValueFeature* aFeatureValue = - dynamic_cast(theValue); + ModuleBase_WidgetValueFeature* aFeatureValue = + dynamic_cast(theValue); if (aFeatureValue) isDone = setObject(aFeatureValue->object()); } @@ -80,9 +80,9 @@ bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject, bool theSen // Check the type of selected object std::list::iterator aValidator = aValidators.begin(); bool isValid = true; - for(; aValidator != aValidators.end(); aValidator++) { - const ModelAPI_ResultValidator* aResValidator = - dynamic_cast(*aValidator); + for (; aValidator != aValidators.end(); aValidator++) { + const ModelAPI_ResultValidator* aResValidator = + dynamic_cast(*aValidator); if (aResValidator) { isValid = false; if (aResValidator->isValid(theObject)) { @@ -97,9 +97,9 @@ bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject, bool theSen // Check the acceptability of the object as attribute aValidator = aValidators.begin(); std::list >::iterator aArgs = anArguments.begin(); - for(; aValidator != aValidators.end(); aValidator++, aArgs++) { - const ModelAPI_AttributeValidator* aAttrValidator = - dynamic_cast(*aValidator); + for (; aValidator != aValidators.end(); aValidator++, aArgs++) { + const ModelAPI_AttributeValidator* aAttrValidator = + dynamic_cast(*aValidator); if (aAttrValidator) { if (!aAttrValidator->isValid(myFeature, *aArgs, theObject)) { return false; @@ -120,8 +120,8 @@ bool ModuleBase_WidgetFeature::storeValue() const //if (!aFeature) // return false; boost::shared_ptr aData = myFeature->data(); - boost::shared_ptr aRef = - boost::dynamic_pointer_cast(aData->attribute(attributeID())); + boost::shared_ptr aRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(attributeID())); ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this; aRef->setObject(myObject); @@ -133,8 +133,8 @@ bool ModuleBase_WidgetFeature::storeValue() const bool ModuleBase_WidgetFeature::restoreValue() { boost::shared_ptr aData = myFeature->data(); - boost::shared_ptr aRef = - boost::dynamic_pointer_cast(aData->attribute(attributeID())); + boost::shared_ptr aRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(attributeID())); ObjectPtr aObj = aRef->object(); FeaturePtr aFeature = boost::dynamic_pointer_cast(aRef->object()); diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.h b/src/ModuleBase/ModuleBase_WidgetFeature.h index fee570d64..9320fb696 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.h +++ b/src/ModuleBase/ModuleBase_WidgetFeature.h @@ -23,13 +23,14 @@ class QLineEdit; */ class MODULEBASE_EXPORT ModuleBase_WidgetFeature : public ModuleBase_ModelWidget { - Q_OBJECT -public: +Q_OBJECT + public: /// Constructor /// \theParent the parent object /// \theParent the parent object /// \theData the widget configuation. The attribute of the model widget is obtained from - ModuleBase_WidgetFeature(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId); + ModuleBase_WidgetFeature(QWidget* theParent, const Config_WidgetAPI* theData, + const std::string& theParentId); /// Destructor virtual ~ModuleBase_WidgetFeature(); @@ -52,7 +53,7 @@ public: /// \return a control list virtual QList getControls() const; -protected: + protected: /// Fill the widget values by given point /// \param thePoint the point /// \return the boolean result of the feature set @@ -60,22 +61,31 @@ protected: /// Returns current widget feature /// \return the feature - const ObjectPtr object() const { return myObject; } + const ObjectPtr object() const + { + return myObject; + } /// Returns the widget editor /// \return the editor - QLineEdit* editor() const { return myEditor; } + QLineEdit* editor() const + { + return myEditor; + } /// Returns the possible feature kinds /// \return the list of kinds - const QStringList& featureKinds() const { return myObjectKinds; } + const QStringList& featureKinds() const + { + return myObjectKinds; + } - ObjectPtr myObject; ///< the current widget feature - QStringList myObjectKinds; ///< the kinds of possible features + ObjectPtr myObject; ///< the current widget feature + QStringList myObjectKinds; ///< the kinds of possible features - QWidget* myContainer; /// the parent top control - QLabel* myLabel; /// the editor information label - QLineEdit* myEditor; ///< the feature editor to visualize the feature name + QWidget* myContainer; /// the parent top control + QLabel* myLabel; /// the editor information label + QLineEdit* myEditor; ///< the feature editor to visualize the feature name }; #endif diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp index 40fb3a52f..4481c2034 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp @@ -30,10 +30,9 @@ #include #include -ModuleBase_WidgetFeatureOrAttribute::ModuleBase_WidgetFeatureOrAttribute(QWidget* theParent, - const Config_WidgetAPI* theData, - const std::string& theParentId) -: ModuleBase_WidgetFeature(theParent, theData, theParentId) +ModuleBase_WidgetFeatureOrAttribute::ModuleBase_WidgetFeatureOrAttribute( + QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId) + : ModuleBase_WidgetFeature(theParent, theData, theParentId) { } @@ -46,8 +45,8 @@ bool ModuleBase_WidgetFeatureOrAttribute::setValue(ModuleBase_WidgetValue* theVa bool isDone = false; if (theValue) { - ModuleBase_WidgetValueFeature* aFeatureValue = - dynamic_cast(theValue); + ModuleBase_WidgetValueFeature* aFeatureValue = + dynamic_cast(theValue); if (aFeatureValue) { boost::shared_ptr aValuePoint = aFeatureValue->point(); ObjectPtr aObject = aFeatureValue->object(); @@ -58,14 +57,14 @@ bool ModuleBase_WidgetFeatureOrAttribute::setValue(ModuleBase_WidgetValue* theVa FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); if (aFeature) { // find the given point in the feature attributes - std::list > anAttiributes = - aFeature->data()->attributes(GeomDataAPI_Point2D::type()); - std::list >::const_iterator anIt = anAttiributes.begin(), - aLast = anAttiributes.end(); + std::list > anAttiributes = aFeature->data() + ->attributes(GeomDataAPI_Point2D::type()); + std::list >::const_iterator anIt = anAttiributes + .begin(), aLast = anAttiributes.end(); boost::shared_ptr aFPoint; - for (;anIt!=aLast && !aFPoint; anIt++) { - boost::shared_ptr aCurPoint = - boost::dynamic_pointer_cast(*anIt); + for (; anIt != aLast && !aFPoint; anIt++) { + boost::shared_ptr aCurPoint = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(*anIt); if (aCurPoint && aCurPoint->pnt()->distance(aValuePoint) < Precision::Confusion()) aFPoint = aCurPoint; } @@ -87,8 +86,8 @@ bool ModuleBase_WidgetFeatureOrAttribute::storeValue() const // return false; boost::shared_ptr aData = myFeature->data(); - boost::shared_ptr aRef = - boost::dynamic_pointer_cast(aData->attribute(attributeID())); + boost::shared_ptr aRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(attributeID())); if (myObject) aRef->setObject(myObject); @@ -104,8 +103,8 @@ bool ModuleBase_WidgetFeatureOrAttribute::storeValue() const bool ModuleBase_WidgetFeatureOrAttribute::restoreValue() { boost::shared_ptr aData = myFeature->data(); - boost::shared_ptr aRef = - boost::dynamic_pointer_cast(aData->attribute(attributeID())); + boost::shared_ptr aRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(attributeID())); ObjectPtr aObj = aRef->object(); FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object()); @@ -126,10 +125,9 @@ bool ModuleBase_WidgetFeatureOrAttribute::restoreValue() } bool ModuleBase_WidgetFeatureOrAttribute::setAttribute( - const boost::shared_ptr& theAttribute, - bool theSendEvent) + const boost::shared_ptr& theAttribute, bool theSendEvent) { - if (!theAttribute)// || !featureKinds().contains(theAttribute->attributeType().c_str())) + if (!theAttribute) // || !featureKinds().contains(theAttribute->attributeType().c_str())) return false; myAttribute = theAttribute; diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h index 0518409bd..8ba8d352c 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h +++ b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h @@ -19,13 +19,14 @@ class ModelAPI_Attribute; */ class MODULEBASE_EXPORT ModuleBase_WidgetFeatureOrAttribute : public ModuleBase_WidgetFeature { - Q_OBJECT -public: +Q_OBJECT + public: /// Constructor /// \theParent the parent object /// \theParent the parent object /// \theData the widget configuation. The attribute of the model widget is obtained from - ModuleBase_WidgetFeatureOrAttribute(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId); + ModuleBase_WidgetFeatureOrAttribute(QWidget* theParent, const Config_WidgetAPI* theData, + const std::string& theParentId); /// Destructor virtual ~ModuleBase_WidgetFeatureOrAttribute(); @@ -40,15 +41,15 @@ public: virtual bool restoreValue(); -protected: + protected: /// Set the attribute /// \param theAttribute value /// \return the boolean result of the attribute set - bool setAttribute(const boost::shared_ptr& theAttribute, - bool theSendEvent = true); + bool setAttribute(const boost::shared_ptr& theAttribute, bool theSendEvent = + true); -protected: - boost::shared_ptr myAttribute; /// < the attribute + protected: + boost::shared_ptr myAttribute; /// < the attribute }; #endif diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp index cd88c57b7..5e447ef1d 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp @@ -28,9 +28,9 @@ #include ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent, - const Config_WidgetAPI* theData, + const Config_WidgetAPI* theData, const std::string& theParentId) -: ModuleBase_ModelWidget(theParent, theData, theParentId) + : ModuleBase_ModelWidget(theParent, theData, theParentId) { myOptionParam = theData->getProperty(PREVIOUS_FEATURE_PARAM); myGroupBox = new QGroupBox(QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME)), @@ -49,7 +49,7 @@ ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent, myXSpin->setMaximum(DBL_MAX); myXSpin->setToolTip("X"); aGroupLay->addWidget(myXSpin, 0, 1); - + connect(myXSpin, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged())); } { @@ -78,8 +78,8 @@ bool ModuleBase_WidgetPoint2D::setValue(ModuleBase_WidgetValue* theValue) { bool isDone = false; if (theValue) { - ModuleBase_WidgetValueFeature* aFeatureValue = - dynamic_cast(theValue); + ModuleBase_WidgetValueFeature* aFeatureValue = + dynamic_cast(theValue); if (aFeatureValue) { boost::shared_ptr aPoint = aFeatureValue->point(); if (aPoint) { @@ -105,8 +105,8 @@ void ModuleBase_WidgetPoint2D::setPoint(const boost::shared_ptr& bool ModuleBase_WidgetPoint2D::storeValue() const { boost::shared_ptr aData = myFeature->data(); - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(aData->attribute(attributeID())); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + aData->attribute(attributeID())); ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this; bool isBlocked = that->blockSignals(true); @@ -120,8 +120,8 @@ bool ModuleBase_WidgetPoint2D::storeValue() const bool ModuleBase_WidgetPoint2D::restoreValue() { boost::shared_ptr aData = myFeature->data(); - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(aData->attribute(attributeID())); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + aData->attribute(attributeID())); bool isBlocked = this->blockSignals(true); myXSpin->setValue(aPoint->x()); @@ -148,7 +148,7 @@ bool ModuleBase_WidgetPoint2D::eventFilter(QObject *theObject, QEvent *theEvent) { if (theObject == myXSpin || theObject == myYSpin) { if (theEvent->type() == QEvent::KeyRelease) { - QKeyEvent* aKeyEvent = (QKeyEvent*)theEvent; + QKeyEvent* aKeyEvent = (QKeyEvent*) theEvent; if (aKeyEvent && aKeyEvent->key() == Qt::Key_Return) { emit focusOutWidget(this); } @@ -164,8 +164,8 @@ bool ModuleBase_WidgetPoint2D::initFromPrevious(ObjectPtr theObject) if (myOptionParam.length() == 0) return false; boost::shared_ptr aData = theObject->data(); - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(aData->attribute(myOptionParam)); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + aData->attribute(myOptionParam)); if (aPoint) { bool isBlocked = this->blockSignals(true); myXSpin->setValue(aPoint->x()); diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.h b/src/ModuleBase/ModuleBase_WidgetPoint2D.h index 77fbd74ee..e5d324a83 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.h +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.h @@ -23,13 +23,14 @@ class QDoubleSpinBox; */ class MODULEBASE_EXPORT ModuleBase_WidgetPoint2D : public ModuleBase_ModelWidget { - Q_OBJECT -public: +Q_OBJECT + public: /// Constructor /// \theParent the parent object /// \theParent the parent object /// \theData the widget configuation. The attribute of the model widget is obtained from - ModuleBase_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId); + ModuleBase_WidgetPoint2D(QWidget* theParent, const Config_WidgetAPI* theData, + const std::string& theParentId); /// Destructor virtual ~ModuleBase_WidgetPoint2D(); @@ -65,17 +66,17 @@ signals: /// \param the attribute of the feature void storedPoint2D(ObjectPtr theObject, const std::string& theAttribute); -protected: + protected: /// Fill the widget values by given point /// \param thePoint the point void setPoint(const boost::shared_ptr& thePoint); -private: - QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets - QDoubleSpinBox* myXSpin; ///< the spin box for the X coordinate - QDoubleSpinBox* myYSpin; ///< the spin box for the Y coordinate + private: + QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets + QDoubleSpinBox* myXSpin; ///< the spin box for the X coordinate + QDoubleSpinBox* myYSpin; ///< the spin box for the Y coordinate - std::string myOptionParam; /// Parameter name which has to be taken from previous feature + std::string myOptionParam; /// Parameter name which has to be taken from previous feature }; #endif diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp index ef5cf3207..1a100c57b 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp @@ -14,9 +14,10 @@ #include -ModuleBase_WidgetPoint2dDistance::ModuleBase_WidgetPoint2dDistance(QWidget* theParent, - const Config_WidgetAPI* theData, const std::string& theParentId) - : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId) +ModuleBase_WidgetPoint2dDistance::ModuleBase_WidgetPoint2dDistance(QWidget* theParent, + const Config_WidgetAPI* theData, + const std::string& theParentId) + : ModuleBase_WidgetDoubleValue(theParent, theData, theParentId) { myFirstPntName = theData->getProperty("first_point"); } @@ -30,8 +31,8 @@ bool ModuleBase_WidgetPoint2dDistance::setValue(ModuleBase_WidgetValue* theValue bool isDone = false; if (theValue) { - ModuleBase_WidgetValueFeature* aFeatureValue = - dynamic_cast(theValue); + ModuleBase_WidgetValueFeature* aFeatureValue = + dynamic_cast(theValue); if (aFeatureValue) { boost::shared_ptr aPnt = aFeatureValue->point(); ObjectPtr aObject = aFeatureValue->object(); @@ -45,12 +46,14 @@ bool ModuleBase_WidgetPoint2dDistance::setValue(ModuleBase_WidgetValue* theValue return isDone; } -void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, const boost::shared_ptr& thePnt) +void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, + const boost::shared_ptr& thePnt) { boost::shared_ptr aData = theFeature->data(); - boost::shared_ptr aPoint = boost::dynamic_pointer_cast - (aData->attribute(myFirstPntName)); - if (!aPoint) return; + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + aData->attribute(myFirstPntName)); + if (!aPoint) + return; double aRadius = thePnt->distance(aPoint->pnt()); AttributeDoublePtr aReal = aData->real(attributeID()); @@ -58,4 +61,4 @@ void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, const boo aReal->setValue(aRadius); mySpinBox->setValue(aRadius); } -} \ No newline at end of file +} diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.h b/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.h index 3ab47c62c..164e78bac 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.h +++ b/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.h @@ -2,7 +2,6 @@ // Created: 23 June 2014 // Author: Vitaly Smetannikov - #ifndef ModuleBase_WidgetPoint2dDistance_H #define ModuleBase_WidgetPoint2dDistance_H @@ -12,14 +11,15 @@ class ModuleBase_WidgetValue; class GeomAPI_Pnt2d; -class MODULEBASE_EXPORT ModuleBase_WidgetPoint2dDistance: public ModuleBase_WidgetDoubleValue +class MODULEBASE_EXPORT ModuleBase_WidgetPoint2dDistance : public ModuleBase_WidgetDoubleValue { - Q_OBJECT -public: +Q_OBJECT + public: /// Constructor /// \theParent the parent object /// \theData the widget configuation. The attribute of the model widget is obtained from - ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId); + ModuleBase_WidgetPoint2dDistance(QWidget* theParent, const Config_WidgetAPI* theData, + const std::string& theParentId); virtual ~ModuleBase_WidgetPoint2dDistance(); @@ -28,13 +28,12 @@ public: /// \param theValue the wrapped widget value virtual bool setValue(ModuleBase_WidgetValue* theValue); -protected: + protected: /// Set the second point which defines a value in the widget as a distance with a first point defined by feature void setPoint(FeaturePtr theFeature, const boost::shared_ptr& thePnt); -private: + private: std::string myFirstPntName; }; - -#endif \ No newline at end of file +#endif diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.cpp b/src/ModuleBase/ModuleBase_WidgetSelector.cpp index c0933f566..ff187372c 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelector.cpp @@ -2,7 +2,6 @@ // Created: 2 June 2014 // Author: Vitaly Smetannikov - #include "ModuleBase_WidgetSelector.h" #include "ModuleBase_IWorkshop.h" @@ -32,7 +31,6 @@ #include - typedef QMap ShapeTypes; static ShapeTypes MyShapeTypes; @@ -46,19 +44,18 @@ TopAbs_ShapeEnum ModuleBase_WidgetSelector::shapeType(const QString& theType) MyShapeTypes["shell"] = TopAbs_SHELL; MyShapeTypes["solid"] = TopAbs_SOLID; } - if (MyShapeTypes.contains(theType)) + if (MyShapeTypes.contains(theType)) return MyShapeTypes[theType]; throw std::invalid_argument("Shape type defined in XML is not implemented!"); } - - - -ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent, - ModuleBase_IWorkshop* theWorkshop, +ModuleBase_WidgetSelector::ModuleBase_WidgetSelector(QWidget* theParent, + ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, const std::string& theParentId) -: ModuleBase_ModelWidget(theParent, theData, theParentId), myWorkshop(theWorkshop), myActivateOnStart(false) + : ModuleBase_ModelWidget(theParent, theData, theParentId), + myWorkshop(theWorkshop), + myActivateOnStart(false) { myContainer = new QWidget(theParent); QHBoxLayout* aLayout = new QHBoxLayout(myContainer); @@ -105,12 +102,12 @@ ModuleBase_WidgetSelector::~ModuleBase_WidgetSelector() bool ModuleBase_WidgetSelector::storeValue() const { FeaturePtr aSelectedFeature = ModelAPI_Feature::feature(mySelectedObject); - if (aSelectedFeature == myFeature) // In order to avoid selection of the same object + if (aSelectedFeature == myFeature) // In order to avoid selection of the same object return false; DataPtr aData = myFeature->data(); - boost::shared_ptr aRef = - boost::dynamic_pointer_cast(aData->attribute(attributeID())); + boost::shared_ptr aRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeReference>(aData->attribute(attributeID())); ObjectPtr aObject = aRef->value(); if (!(aObject && aObject->isSame(mySelectedObject))) { @@ -128,7 +125,7 @@ bool ModuleBase_WidgetSelector::restoreValue() bool isBlocked = this->blockSignals(true); mySelectedObject = aRef->value(); - updateSelectionName(); + updateSelectionName(); this->blockSignals(isBlocked); return true; @@ -156,7 +153,8 @@ void ModuleBase_WidgetSelector::onSelectionChanged() return; // Check that the selection corresponds to selection type - if (!isAccepted(aObject)) return; + if (!isAccepted(aObject)) + return; mySelectedObject = aObject; if (mySelectedObject) { @@ -175,19 +173,23 @@ bool ModuleBase_WidgetSelector::isAccepted(const ObjectPtr theResult) const { ResultPtr aResult = boost::dynamic_pointer_cast(theResult); boost::shared_ptr aShapePtr = ModelAPI_Tools::shape(aResult); - if (!aShapePtr) return false; + if (!aShapePtr) + return false; TopoDS_Shape aShape = aShapePtr->impl(); - if (aShape.IsNull()) return false; + if (aShape.IsNull()) + return false; TopAbs_ShapeEnum aShapeType = aShape.ShapeType(); if (aShapeType == TopAbs_COMPOUND) { - foreach (QString aType, myShapeTypes) { + foreach (QString aType, myShapeTypes) + { TopExp_Explorer aEx(aShape, shapeType(aType)); if (aEx.More()) return true; } } else { - foreach (QString aType, myShapeTypes) { + foreach (QString aType, myShapeTypes) + { if (shapeType(aType) == aShapeType) return true; } @@ -200,9 +202,9 @@ void ModuleBase_WidgetSelector::updateSelectionName() { if (mySelectedObject) { std::string aName = mySelectedObject->data()->name(); - + myTextLine->setText(QString::fromStdString(aName)); - } else + } else myTextLine->setText(""); } @@ -223,8 +225,10 @@ void ModuleBase_WidgetSelector::enableOthersControls(bool toEnable) const { QWidget* aParent = myContainer->parentWidget(); QList aChldList = aParent->findChildren(); - foreach(QWidget* aWgt, aChldList) { - if ((aWgt != myLabel) && (aWgt != myActivateBtn) && (aWgt != myTextLine) && (aWgt != myContainer)) + foreach(QWidget* aWgt, aChldList) + { + if ((aWgt != myLabel) && (aWgt != myActivateBtn) && (aWgt != myTextLine) + && (aWgt != myContainer)) aWgt->setEnabled(toEnable); } } @@ -251,7 +255,8 @@ void ModuleBase_WidgetSelector::raisePanel() const while (!aParent->inherits("QDockWidget")) { aLastPanel = aParent; aParent = aParent->parentWidget(); - if (!aParent) return; + if (!aParent) + return; } if (aParent->inherits("QDockWidget")) { QDockWidget* aTabWgt = (QDockWidget*) aParent; diff --git a/src/ModuleBase/ModuleBase_WidgetSelector.h b/src/ModuleBase/ModuleBase_WidgetSelector.h index 9d7180848..574ae0e8b 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetSelector.h @@ -14,7 +14,6 @@ #include - class Config_WidgetAPI; class QWidget; class QLabel; @@ -22,12 +21,11 @@ class QLineEdit; class QToolButton; class ModuleBase_IWorkshop; -class MODULEBASE_EXPORT ModuleBase_WidgetSelector: public ModuleBase_ModelWidget +class MODULEBASE_EXPORT ModuleBase_WidgetSelector : public ModuleBase_ModelWidget { - Q_OBJECT -public: - ModuleBase_WidgetSelector(QWidget* theParent, - ModuleBase_IWorkshop* theWorkshop, +Q_OBJECT + public: + ModuleBase_WidgetSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, const std::string& theParentId); virtual ~ModuleBase_WidgetSelector(); @@ -40,29 +38,41 @@ public: /// Returns the internal parent wiget control, that can be shown anywhere /// \returns the widget - QWidget* getControl() const { return myContainer; } + QWidget* getControl() const + { + return myContainer; + } /// Returns list of widget controls /// \return a control list virtual QList getControls() const; - void setActivationOnStart(bool toActivate) { myActivateOnStart = toActivate; } - bool activateOnStart() const { return myActivateOnStart; } + void setActivationOnStart(bool toActivate) + { + myActivateOnStart = toActivate; + } + bool activateOnStart() const + { + return myActivateOnStart; + } - ObjectPtr selectedFeature() const { return mySelectedObject; } + ObjectPtr selectedFeature() const + { + return mySelectedObject; + } -public slots: + public slots: /// Activate or deactivate selection void activateSelection(bool toActivate); -protected: + protected: bool eventFilter(QObject* theObj, QEvent* theEvent); -private slots: + private slots: void onSelectionChanged(); -private: + private: void enableOthersControls(bool toEnable) const; void updateSelectionName(); void raisePanel() const; @@ -70,9 +80,9 @@ private: static TopAbs_ShapeEnum shapeType(const QString& theType); - QWidget* myContainer; - QLabel* myLabel; - QLineEdit* myTextLine; + QWidget* myContainer; + QLabel* myLabel; + QLineEdit* myTextLine; QToolButton* myActivateBtn; ModuleBase_IWorkshop* myWorkshop; @@ -83,4 +93,4 @@ private: QStringList myShapeTypes; }; -#endif \ No newline at end of file +#endif diff --git a/src/ModuleBase/ModuleBase_WidgetSwitch.cpp b/src/ModuleBase/ModuleBase_WidgetSwitch.cpp index 3024f1166..a6e20a8cf 100644 --- a/src/ModuleBase/ModuleBase_WidgetSwitch.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSwitch.cpp @@ -12,7 +12,7 @@ #include ModuleBase_WidgetSwitch::ModuleBase_WidgetSwitch(QWidget* parent) -: QFrame(parent) + : QFrame(parent) { myMainLay = new QVBoxLayout(this); myMainLay->setContentsMargins(2, 4, 2, 2); @@ -20,10 +20,8 @@ ModuleBase_WidgetSwitch::ModuleBase_WidgetSwitch(QWidget* parent) myCombo->hide(); myMainLay->addWidget(myCombo); this->setFrameShape(QFrame::StyledPanel); - connect(myCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(setCurrentIndex(int))); - connect(myCombo, SIGNAL(currentIndexChanged(int)), - this, SIGNAL(currentPageChanged(int))); + connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentIndex(int))); + connect(myCombo, SIGNAL(currentIndexChanged(int)), this, SIGNAL(currentPageChanged(int))); } @@ -60,7 +58,7 @@ int ModuleBase_WidgetSwitch::indexOf(QWidget* theWidget) const int ModuleBase_WidgetSwitch::insertPage(int theIndex, QWidget* theWidget, const QString& theName) { int index = theIndex < count() ? theIndex : count(); - if(count() == 0) + if (count() == 0) myCombo->show(); myCombo->insertItem(index, theName); myCases.insert(index, theWidget); @@ -116,10 +114,11 @@ void ModuleBase_WidgetSwitch::setCurrentIndex(int index) void ModuleBase_WidgetSwitch::refresh() { - foreach(QWidget* eachWidget, myCases) { + foreach(QWidget* eachWidget, myCases) + { eachWidget->setVisible(false); } - if(currentIndex() >= myCases.count()) + if (currentIndex() >= myCases.count()) return; myCases[currentIndex()]->setVisible(true); } diff --git a/src/ModuleBase/ModuleBase_WidgetSwitch.h b/src/ModuleBase/ModuleBase_WidgetSwitch.h index 08ce3bc71..f7a442e41 100644 --- a/src/ModuleBase/ModuleBase_WidgetSwitch.h +++ b/src/ModuleBase/ModuleBase_WidgetSwitch.h @@ -14,10 +14,10 @@ class QComboBox; class QVBoxLayout; -class MODULEBASE_EXPORT ModuleBase_WidgetSwitch: public QFrame +class MODULEBASE_EXPORT ModuleBase_WidgetSwitch : public QFrame { - Q_OBJECT -public: +Q_OBJECT + public: ModuleBase_WidgetSwitch(QWidget* parent = NULL); virtual ~ModuleBase_WidgetSwitch(); @@ -35,16 +35,16 @@ public: void setPageName(int index, const QString & text); void setPageToolTip(int index, const QString & toolTip); -public slots: + public slots: void setCurrentIndex(int index); signals: void currentPageChanged(int); -protected: + protected: void refresh(); -private: + private: QVBoxLayout* myMainLay; QComboBox* myCombo; QWidgetList myCases; diff --git a/src/ModuleBase/ModuleBase_WidgetValue.h b/src/ModuleBase/ModuleBase_WidgetValue.h index 983d39d76..38b8e51b3 100644 --- a/src/ModuleBase/ModuleBase_WidgetValue.h +++ b/src/ModuleBase/ModuleBase_WidgetValue.h @@ -13,7 +13,7 @@ */ class MODULEBASE_EXPORT ModuleBase_WidgetValue { -public: + public: /// Constructor ModuleBase_WidgetValue(); /// Destructor diff --git a/src/ModuleBase/ModuleBase_WidgetValueFeature.h b/src/ModuleBase/ModuleBase_WidgetValueFeature.h index 1a1f10164..a40cbd06d 100644 --- a/src/ModuleBase/ModuleBase_WidgetValueFeature.h +++ b/src/ModuleBase/ModuleBase_WidgetValueFeature.h @@ -20,7 +20,7 @@ class GeomAPI_Pnt2d; */ class MODULEBASE_EXPORT ModuleBase_WidgetValueFeature : public ModuleBase_WidgetValue { -public: + public: /// Constructor ModuleBase_WidgetValueFeature(); /// Destructor @@ -42,7 +42,7 @@ public: /// \return the current point const boost::shared_ptr& point() const; -private: + private: ObjectPtr myResult; boost::shared_ptr myPoint; }; diff --git a/src/NewGeom/NewGeom.h b/src/NewGeom/NewGeom.h index 78f0f9930..4490c442b 100644 --- a/src/NewGeom/NewGeom.h +++ b/src/NewGeom/NewGeom.h @@ -17,5 +17,3 @@ #endif - - diff --git a/src/NewGeom/NewGeom_DataModel.cpp b/src/NewGeom/NewGeom_DataModel.cpp index 371fe7a4b..99327c50c 100644 --- a/src/NewGeom/NewGeom_DataModel.cpp +++ b/src/NewGeom/NewGeom_DataModel.cpp @@ -1,30 +1,28 @@ - #include "NewGeom_DataModel.h" - -NewGeom_DataModel::NewGeom_DataModel( CAM_Module* theModule ) - : LightApp_DataModel(theModule) +NewGeom_DataModel::NewGeom_DataModel(CAM_Module* theModule) + : LightApp_DataModel(theModule) { } - + NewGeom_DataModel::~NewGeom_DataModel() { } -bool NewGeom_DataModel::open( const QString& thePath, CAM_Study* theStudy, QStringList theFiles ) +bool NewGeom_DataModel::open(const QString& thePath, CAM_Study* theStudy, QStringList theFiles) { return true; } -bool NewGeom_DataModel::save( QStringList& theFiles ) +bool NewGeom_DataModel::save(QStringList& theFiles) { return true; } -bool NewGeom_DataModel::saveAs( const QString& thePath, CAM_Study* theStudy, QStringList& theFiles ) +bool NewGeom_DataModel::saveAs(const QString& thePath, CAM_Study* theStudy, QStringList& theFiles) { myStudyPath = thePath; - return save( theFiles ); + return save(theFiles); } bool NewGeom_DataModel::close() @@ -32,7 +30,7 @@ bool NewGeom_DataModel::close() return LightApp_DataModel::close(); } -bool NewGeom_DataModel::create( CAM_Study* theStudy ) +bool NewGeom_DataModel::create(CAM_Study* theStudy) { return true; } @@ -47,6 +45,6 @@ bool NewGeom_DataModel::isSaved() const return true; } -void NewGeom_DataModel::update( LightApp_DataObject* theObj, LightApp_Study* theStudy ) +void NewGeom_DataModel::update(LightApp_DataObject* theObj, LightApp_Study* theStudy) { } diff --git a/src/NewGeom/NewGeom_DataModel.h b/src/NewGeom/NewGeom_DataModel.h index 66c6bf84d..7beaf392f 100644 --- a/src/NewGeom/NewGeom_DataModel.h +++ b/src/NewGeom/NewGeom_DataModel.h @@ -1,5 +1,4 @@ - #ifndef NEWGEOM_DATAMODEL_H #define NEWGEOM_DATAMODEL_H @@ -9,24 +8,24 @@ class NewGeom_EXPORT NewGeom_DataModel : public LightApp_DataModel { Q_OBJECT -public: - NewGeom_DataModel( CAM_Module* theModule ); + public: + NewGeom_DataModel(CAM_Module* theModule); virtual ~NewGeom_DataModel(); - virtual bool open( const QString& thePath, CAM_Study* theStudy, QStringList theFiles ); - virtual bool save( QStringList& theFiles ); - virtual bool saveAs( const QString& thePath, CAM_Study* theStudy, QStringList& theFiles ); + virtual bool open(const QString& thePath, CAM_Study* theStudy, QStringList theFiles); + virtual bool save(QStringList& theFiles); + virtual bool saveAs(const QString& thePath, CAM_Study* theStudy, QStringList& theFiles); virtual bool close(); - virtual bool create( CAM_Study* theStudy ); + virtual bool create(CAM_Study* theStudy); virtual bool isModified() const; virtual bool isSaved() const; - virtual void update( LightApp_DataObject* theObj = 0, LightApp_Study* theStudy = 0 ); + virtual void update(LightApp_DataObject* theObj = 0, LightApp_Study* theStudy = 0); -private: + private: QString myStudyPath; }; -#endif \ No newline at end of file +#endif diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index fc07f5d55..a4caf653c 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -1,5 +1,4 @@ - #include "NewGeom_Module.h" #include "NewGeom_DataModel.h" #include "NewGeom_OCCSelector.h" @@ -24,19 +23,21 @@ #include extern "C" { - NewGeom_EXPORT CAM_Module* createModule() { - return new NewGeom_Module(); - } - - NewGeom_EXPORT char* getModuleVersion() { - return "0.0"; - } +NewGeom_EXPORT CAM_Module* createModule() +{ + return new NewGeom_Module(); } +NewGeom_EXPORT char* getModuleVersion() +{ + return "0.0"; +} +} //****************************************************** NewGeom_Module::NewGeom_Module() -: LightApp_Module( "NewGeom" ), mySelector(0) + : LightApp_Module("NewGeom"), + mySelector(0) { myWorkshop = new XGUI_Workshop(this); myProxyViewer = new NewGeom_SalomeViewer(this); @@ -51,20 +52,20 @@ NewGeom_Module::~NewGeom_Module() void NewGeom_Module::initialize(CAM_Application* theApp) { LightApp_Module::initialize(theApp); - + myWorkshop->startApplication(); } //****************************************************** void NewGeom_Module::windows(QMap& theWndMap) const { - theWndMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea ); + theWndMap.insert(LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea); } //****************************************************** void NewGeom_Module::viewManagers(QStringList& theList) const { - theList.append( OCCViewer_Viewer::Type() ); + theList.append(OCCViewer_Viewer::Type()); } //****************************************************** @@ -72,8 +73,8 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy) { bool isDone = LightApp_Module::activateModule(theStudy); if (isDone) { - setMenuShown( true ); - setToolShown( true ); + setMenuShown(true); + setToolShown(true); if (!mySelector) { ViewManagerList OCCViewManagers; @@ -83,7 +84,7 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy) } } myWorkshop->propertyPanel()->hide(); - QtxPopupMgr* aMgr = popupMgr(); // Create popup manager + QtxPopupMgr* aMgr = popupMgr(); // Create popup manager action(myEraseAll)->setEnabled(false); } return isDone; @@ -92,14 +93,14 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy) //****************************************************** bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy) { - setMenuShown( false ); - setToolShown( false ); + setMenuShown(false); + setToolShown(false); //myWorkshop->contextMenuMgr()->disconnectViewer(); return LightApp_Module::deactivateModule(theStudy); } //****************************************************** -void NewGeom_Module::onViewManagerAdded( SUIT_ViewManager* theMgr ) +void NewGeom_Module::onViewManagerAdded(SUIT_ViewManager* theMgr) { if ((!mySelector)) { mySelector = createSelector(theMgr); @@ -111,12 +112,12 @@ NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr) { if (theMgr->getType() == OCCViewer_Viewer::Type()) { OCCViewer_Viewer* aViewer = static_cast(theMgr->getViewModel()); - NewGeom_OCCSelector* aSelector = new NewGeom_OCCSelector(aViewer, - getApp()->selectionMgr()); + NewGeom_OCCSelector* aSelector = new NewGeom_OCCSelector(aViewer, getApp()->selectionMgr()); LightApp_SelectionMgr* aMgr = getApp()->selectionMgr(); QList aList; aMgr->selectors(aList); - foreach(SUIT_Selector* aSel, aList) { + foreach(SUIT_Selector* aSel, aList) + { aSel->setEnabled(aSel == aSelector); } myProxyViewer->setSelector(aSelector); @@ -128,16 +129,13 @@ NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr) //****************************************************** CAM_DataModel* NewGeom_Module::createDataModel() { - return new NewGeom_DataModel( this ); + return new NewGeom_DataModel(this); } //****************************************************** -QAction* NewGeom_Module::addFeature(const QString& theWBName, - const QString& theId, - const QString& theTitle, - const QString& theTip, - const QIcon& theIcon, - const QKeySequence& theKeys, +QAction* NewGeom_Module::addFeature(const QString& theWBName, const QString& theId, + const QString& theTitle, const QString& theTip, + const QIcon& theIcon, const QKeySequence& theKeys, bool isCheckable) { int aMenu = createMenu(theWBName, -1, -1, 50); @@ -147,44 +145,41 @@ QAction* NewGeom_Module::addFeature(const QString& theWBName, myActionsList.append(theId); SUIT_Desktop* aDesk = application()->desktop(); int aKeys = 0; - for (int i = 0; i < theKeys.count(); i++) + for (int i = 0; i < theKeys.count(); i++) aKeys += theKeys[i]; - QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk, + QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk, isCheckable); aAction->setData(theId); - int aItemId = createMenu( aId, aMenu, -1, 10 ); - int aToolId = createTool( aId, aTool ); + int aItemId = createMenu(aId, aMenu, -1, 10); + int aToolId = createTool(aId, aTool); return aAction; } //****************************************************** -QAction* NewGeom_Module::addEditCommand(const QString& theId, - const QString& theTitle, - const QString& theTip, - const QIcon& theIcon, - const QKeySequence& theKeys, - bool isCheckable) +QAction* NewGeom_Module::addEditCommand(const QString& theId, const QString& theTitle, + const QString& theTip, const QIcon& theIcon, + const QKeySequence& theKeys, bool isCheckable) { - int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1); + int aMenu = createMenu(tr("MEN_DESK_EDIT"), -1, -1); int aId = myActionsList.size(); myActionsList.append(theId); SUIT_Desktop* aDesk = application()->desktop(); int aKeys = 0; - for (int i = 0; i < theKeys.count(); i++) + for (int i = 0; i < theKeys.count(); i++) aKeys += theKeys[i]; - QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk, + QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk, isCheckable); aAction->setData(theId); - createMenu( aId, aMenu, 10 ); + createMenu(aId, aMenu, 10); return aAction; } //****************************************************** void NewGeom_Module::addEditMenuSeparator() { - int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1); - createMenu( separator(), aMenu, -1, 10 ); + int aMenu = createMenu(tr("MEN_DESK_EDIT"), -1, -1); + createMenu(separator(), aMenu, -1, 10); } //****************************************************** @@ -253,4 +248,4 @@ void NewGeom_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, { myWorkshop->contextMenuMgr()->addViewerItems(theMenu); LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle); -} \ No newline at end of file +} diff --git a/src/NewGeom/NewGeom_Module.h b/src/NewGeom/NewGeom_Module.h index 78cc95fba..d300655a3 100644 --- a/src/NewGeom/NewGeom_Module.h +++ b/src/NewGeom/NewGeom_Module.h @@ -1,5 +1,4 @@ - #ifndef NewGeom_Module_H #define NewGeom_Module_H @@ -12,42 +11,36 @@ #include #include -class XGUI_Workshop; +class XGUI_Workshop; class NewGeom_OCCSelector; class OCCViewer_Viewer; /** -* An implementation of SALOME connector class for implementation of -* XGUI functionality as a module of SALOME -*/ -class NewGeom_EXPORT NewGeom_Module: public LightApp_Module, public XGUI_SalomeConnector + * An implementation of SALOME connector class for implementation of + * XGUI functionality as a module of SALOME + */ +class NewGeom_EXPORT NewGeom_Module : public LightApp_Module, public XGUI_SalomeConnector { - Q_OBJECT -public: +Q_OBJECT + public: NewGeom_Module(); virtual ~NewGeom_Module(); //----- LightAPP_Module interface --------------- - virtual void initialize( CAM_Application* theApp); - virtual void windows( QMap& theWndMap) const; - virtual void viewManagers( QStringList& theList) const; + virtual void initialize(CAM_Application* theApp); + virtual void windows(QMap& theWndMap) const; + virtual void viewManagers(QStringList& theList) const; virtual void selectionChanged(); //--- XGUI connector interface ----- - virtual QAction* addFeature(const QString& theWBName, - const QString& theId, - const QString& theTitle, - const QString& theTip, - const QIcon& theIcon, + virtual QAction* addFeature(const QString& theWBName, const QString& theId, + const QString& theTitle, const QString& theTip, const QIcon& theIcon, const QKeySequence& theKeys = QKeySequence(), bool isCheckable = false); - virtual QAction* addEditCommand(const QString& theId, - const QString& theTitle, - const QString& theTip, - const QIcon& theIcon, - const QKeySequence& theKeys, - bool isCheckable); + virtual QAction* addEditCommand(const QString& theId, const QString& theTitle, + const QString& theTip, const QIcon& theIcon, + const QKeySequence& theKeys, bool isCheckable); virtual void addEditMenuSeparator(); @@ -66,7 +59,10 @@ public: virtual QStringList nestedActions(const QString& theId) const; //! Returns interface to Salome viewer - virtual XGUI_SalomeViewer* viewer() const { return myProxyViewer; } + virtual XGUI_SalomeViewer* viewer() const + { + return myProxyViewer; + } //! Returns list of defined actions (just by NewGeom module) virtual QList commandList() const; @@ -76,18 +72,17 @@ public: virtual void contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle); -public slots: - virtual bool activateModule( SUIT_Study* theStudy); - virtual bool deactivateModule( SUIT_Study* theStudy); + public slots: + virtual bool activateModule(SUIT_Study* theStudy); + virtual bool deactivateModule(SUIT_Study* theStudy); -protected slots: - virtual void onViewManagerAdded( SUIT_ViewManager* theMgr ); + protected slots: + virtual void onViewManagerAdded(SUIT_ViewManager* theMgr); -protected: + protected: CAM_DataModel* createDataModel(); - -private: + private: NewGeom_OCCSelector* createSelector(SUIT_ViewManager* theMgr); QStringList myActionsList; diff --git a/src/NewGeom/NewGeom_OCCSelector.cpp b/src/NewGeom/NewGeom_OCCSelector.cpp index b7442acb4..a5c39b12b 100644 --- a/src/NewGeom/NewGeom_OCCSelector.cpp +++ b/src/NewGeom/NewGeom_OCCSelector.cpp @@ -1,8 +1,7 @@ #include "NewGeom_OCCSelector.h" -NewGeom_OCCSelector::NewGeom_OCCSelector( OCCViewer_Viewer* theViewer, - SUIT_SelectionMgr* theMgr) -: LightApp_OCCSelector(theViewer, theMgr) +NewGeom_OCCSelector::NewGeom_OCCSelector(OCCViewer_Viewer* theViewer, SUIT_SelectionMgr* theMgr) + : LightApp_OCCSelector(theViewer, theMgr) { } @@ -10,14 +9,14 @@ NewGeom_OCCSelector::~NewGeom_OCCSelector() { } -void NewGeom_OCCSelector::getSelection( SUIT_DataOwnerPtrList& thePtrList ) const +void NewGeom_OCCSelector::getSelection(SUIT_DataOwnerPtrList& thePtrList) const { OCCViewer_Viewer* vw = viewer(); if (!vw) return; } -void NewGeom_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& thePtrList ) +void NewGeom_OCCSelector::setSelection(const SUIT_DataOwnerPtrList& thePtrList) { OCCViewer_Viewer* vw = viewer(); if (!vw) diff --git a/src/NewGeom/NewGeom_OCCSelector.h b/src/NewGeom/NewGeom_OCCSelector.h index ae6b1cbea..ce9a84615 100644 --- a/src/NewGeom/NewGeom_OCCSelector.h +++ b/src/NewGeom/NewGeom_OCCSelector.h @@ -7,13 +7,13 @@ class NewGeom_EXPORT NewGeom_OCCSelector : public LightApp_OCCSelector { -public: - NewGeom_OCCSelector( OCCViewer_Viewer* theViewer, SUIT_SelectionMgr* theMgr ); + public: + NewGeom_OCCSelector(OCCViewer_Viewer* theViewer, SUIT_SelectionMgr* theMgr); virtual ~NewGeom_OCCSelector(); -protected: - virtual void getSelection( SUIT_DataOwnerPtrList& theList ) const; - virtual void setSelection( const SUIT_DataOwnerPtrList& theList ); + protected: + virtual void getSelection(SUIT_DataOwnerPtrList& theList) const; + virtual void setSelection(const SUIT_DataOwnerPtrList& theList); }; -#endif \ No newline at end of file +#endif diff --git a/src/NewGeom/NewGeom_SalomeViewer.cpp b/src/NewGeom/NewGeom_SalomeViewer.cpp index 99a99d328..f63b3d77c 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.cpp +++ b/src/NewGeom/NewGeom_SalomeViewer.cpp @@ -1,4 +1,3 @@ - #include "NewGeom_SalomeViewer.h" #include "NewGeom_OCCSelector.h" @@ -11,9 +10,9 @@ #include #include - NewGeom_SalomeViewer::NewGeom_SalomeViewer(QObject* theParent) -: XGUI_SalomeViewer(theParent), mySelector(0) + : XGUI_SalomeViewer(theParent), + mySelector(0) { } @@ -52,32 +51,26 @@ void NewGeom_SalomeViewer::setSelector(NewGeom_OCCSelector* theSel) OCCViewer_Viewer* aViewer = mySelector->viewer(); SUIT_ViewManager* aMgr = aViewer->getViewManager(); - connect(aMgr, SIGNAL(lastViewClosed(SUIT_ViewManager*)), - this, SIGNAL(lastViewClosed())); - connect(aMgr, SIGNAL(tryCloseView(SUIT_ViewManager*)), - this, SIGNAL(tryCloseView())); - connect(aMgr, SIGNAL(deleteView(SUIT_ViewManager*)), - this, SIGNAL(deleteView())); - connect(aMgr, SIGNAL(viewCreated(SUIT_ViewManager*)), - this, SIGNAL(viewCreated())); - connect(aMgr, SIGNAL(activated(SUIT_ViewManager*)), - this, SIGNAL(activated())); - - connect(aMgr, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); - connect(aMgr, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); - connect(aMgr, SIGNAL(mouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*))); - connect(aMgr, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*))); - connect(aMgr, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)), - this, SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*))); - connect(aMgr, SIGNAL(keyRelease(SUIT_ViewWindow*, QKeyEvent*)), - this, SLOT(onKeyRelease(SUIT_ViewWindow*, QKeyEvent*))); - - connect(aViewer, SIGNAL(selectionChanged()), - this, SIGNAL(selectionChanged())); + connect(aMgr, SIGNAL(lastViewClosed(SUIT_ViewManager*)), this, SIGNAL(lastViewClosed())); + connect(aMgr, SIGNAL(tryCloseView(SUIT_ViewManager*)), this, SIGNAL(tryCloseView())); + connect(aMgr, SIGNAL(deleteView(SUIT_ViewManager*)), this, SIGNAL(deleteView())); + connect(aMgr, SIGNAL(viewCreated(SUIT_ViewManager*)), this, SIGNAL(viewCreated())); + connect(aMgr, SIGNAL(activated(SUIT_ViewManager*)), this, SIGNAL(activated())); + + connect(aMgr, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), this, + SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + connect(aMgr, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), this, + SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); + connect(aMgr, SIGNAL(mouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)), this, + SLOT(onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*))); + connect(aMgr, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), this, + SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*))); + connect(aMgr, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)), this, + SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*))); + connect(aMgr, SIGNAL(keyRelease(SUIT_ViewWindow*, QKeyEvent*)), this, + SLOT(onKeyRelease(SUIT_ViewWindow*, QKeyEvent*))); + + connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); } //********************************************** @@ -153,4 +146,4 @@ void NewGeom_SalomeViewer::fitAll() if (aVFrame) { aVFrame->onFitAll(); } -} \ No newline at end of file +} diff --git a/src/NewGeom/NewGeom_SalomeViewer.h b/src/NewGeom/NewGeom_SalomeViewer.h index 8217e0146..7f638ac86 100644 --- a/src/NewGeom/NewGeom_SalomeViewer.h +++ b/src/NewGeom/NewGeom_SalomeViewer.h @@ -1,5 +1,4 @@ - #ifndef NewGeom_SalomeViewer_H #define NewGeom_SalomeViewer_H @@ -13,10 +12,10 @@ class QKeyEvent; class NewGeom_OCCSelector; -class NewGeom_SalomeViewer: public XGUI_SalomeViewer +class NewGeom_SalomeViewer : public XGUI_SalomeViewer { - Q_OBJECT -public: +Q_OBJECT + public: NewGeom_SalomeViewer(QObject* theParent); //! Returns AIS_InteractiveContext from current OCCViewer @@ -45,9 +44,12 @@ public: void setSelector(NewGeom_OCCSelector* theSel); - NewGeom_OCCSelector* selector() const { return mySelector; } + NewGeom_OCCSelector* selector() const + { + return mySelector; + } -private slots: + private slots: void onMousePress(SUIT_ViewWindow*, QMouseEvent*); void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*); void onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*); @@ -55,8 +57,7 @@ private slots: void onKeyPress(SUIT_ViewWindow*, QKeyEvent*); void onKeyRelease(SUIT_ViewWindow*, QKeyEvent*); - -private: + private: NewGeom_OCCSelector* mySelector; }; diff --git a/src/PartSet/PartSet.h b/src/PartSet/PartSet.h index 6579536fe..4e9f59f46 100644 --- a/src/PartSet/PartSet.h +++ b/src/PartSet/PartSet.h @@ -1,18 +1,18 @@ -#ifndef PARTSET_H -#define PARTSET_H - -#if defined PARTSET_EXPORTS -#if defined WIN32 -#define PARTSET_EXPORT __declspec( dllexport ) -#else -#define PARTSET_EXPORT -#endif -#else -#if defined WIN32 -#define PARTSET_EXPORT __declspec( dllimport ) -#else -#define PARTSET_EXPORT -#endif -#endif - -#endif //PARTSET_H +#ifndef PARTSET_H +#define PARTSET_H + +#if defined PARTSET_EXPORTS +#if defined WIN32 +#define PARTSET_EXPORT __declspec( dllexport ) +#else +#define PARTSET_EXPORT +#endif +#else +#if defined WIN32 +#define PARTSET_EXPORT __declspec( dllimport ) +#else +#define PARTSET_EXPORT +#endif +#endif + +#endif //PARTSET_H \ No newline at end of file diff --git a/src/PartSet/PartSet_EditLine.cpp b/src/PartSet/PartSet_EditLine.cpp index a8bccebaf..a7b2ecccb 100644 --- a/src/PartSet/PartSet_EditLine.cpp +++ b/src/PartSet/PartSet_EditLine.cpp @@ -7,7 +7,7 @@ #include PartSet_EditLine::PartSet_EditLine(QWidget* theParent) -: QObject(theParent) + : QObject(theParent) { myEditor = new QLineEdit(theParent); myEditor->setWindowFlags(Qt::ToolTip); diff --git a/src/PartSet/PartSet_EditLine.h b/src/PartSet/PartSet_EditLine.h index f389a45f9..c043dc08a 100644 --- a/src/PartSet/PartSet_EditLine.h +++ b/src/PartSet/PartSet_EditLine.h @@ -16,15 +16,18 @@ class QWidget; /*! \class PartSet_EditLine * \brief The class to give an editor to modify a real value -*/ + */ class PARTSET_EXPORT PartSet_EditLine : public QObject { - Q_OBJECT -public: +Q_OBJECT + public: /// Constructor PartSet_EditLine(QWidget* theParent); /// Destructor - virtual ~PartSet_EditLine() {}; + virtual ~PartSet_EditLine() + { + } + ; /// Show the editor in the given global position /// \param thePoint a position @@ -43,17 +46,17 @@ signals: /// \param theValue the editor value void stopped(double theValue); -protected: + protected: /// Returns the editor value /// \return the real value double getValue() const; -protected slots: + protected slots: /// Slot to check the editing stop void onStopEditing(); -protected: - QLineEdit* myEditor; /// the value editor + protected: + QLineEdit* myEditor; /// the value editor }; #endif diff --git a/src/PartSet/PartSet_Listener.cpp b/src/PartSet/PartSet_Listener.cpp index de5345666..d6a1edca8 100644 --- a/src/PartSet/PartSet_Listener.cpp +++ b/src/PartSet/PartSet_Listener.cpp @@ -25,7 +25,7 @@ using namespace std; PartSet_Listener::PartSet_Listener(PartSet_Module* theModule) -: myModule(theModule) + : myModule(theModule) { Events_Loop* aLoop = Events_Loop::loop(); //aLoop->registerListener(this, aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY)); @@ -42,16 +42,16 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage) { ModuleBase_Operation* anOperation = myModule->workshop()->operationMgr()->currentOperation(); PartSet_OperationSketchBase* aSketchOp = dynamic_cast(anOperation); - if (!aSketchOp) + if (!aSketchOp) return; XGUI_Displayer* aDisplayer = myModule->workshop()->displayer(); QString aType = QString(theMessage->eventID().eventText()); if (aType == EVENT_OBJECT_CREATED) { - const ModelAPI_ObjectUpdatedMessage* aUpdMsg = - dynamic_cast(theMessage); - std::set aFeatures = aUpdMsg->objects(); - std::set::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); + const ModelAPI_ObjectUpdatedMessage* aUpdMsg = + dynamic_cast(theMessage); + std::set aFeatures = aUpdMsg->objects(); + std::set::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); for (; anIt != aLast; anIt++) { aDisplayer->deactivate(*anIt); FeaturePtr aFeature = boost::dynamic_pointer_cast(*anIt); @@ -60,15 +60,15 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage) } } else if (aType == EVENT_OBJECT_DELETED) { - const ModelAPI_ObjectDeletedMessage* aDelMsg = - dynamic_cast(theMessage); + const ModelAPI_ObjectDeletedMessage* aDelMsg = + dynamic_cast(theMessage); boost::shared_ptr aDoc = aDelMsg->document(); std::set aGroups = aDelMsg->groups(); std::set::const_iterator anIt = aGroups.begin(), aLast = aGroups.end(); for (; anIt != aLast; anIt++) { std::string aGroup = *anIt; - if (aGroup.compare(SketchPlugin_Sketch::ID()) == 0) { // Update only Sketch group + if (aGroup.compare(SketchPlugin_Sketch::ID()) == 0) { // Update only Sketch group myModule->workshop()->displayer()->eraseDeletedResults(); myModule->updateCurrentPreview(aGroup); } diff --git a/src/PartSet/PartSet_Listener.h b/src/PartSet/PartSet_Listener.h index 051224554..a0ae4d742 100644 --- a/src/PartSet/PartSet_Listener.h +++ b/src/PartSet/PartSet_Listener.h @@ -14,10 +14,10 @@ class PartSet_Module; /*! \class PartSet_Listener * \brief The operation for the sketch feature creation -*/ + */ class PARTSET_EXPORT PartSet_Listener : public Events_Listener { -public: + public: /// Constructor /// \param theId the feature identifier /// \param theParent the operation parent @@ -28,8 +28,8 @@ public: /// This method is called by loop when the event is started to process. virtual void processEvent(const Events_Message* theMessage); -private: - PartSet_Module* myModule; ///< the current module + private: + PartSet_Module* myModule; ///< the current module }; #endif diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index ecace8c28..ec21e0266 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -60,7 +60,6 @@ #include #endif - /*!Create and return new instance of XGUI_Module*/ extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(XGUI_Workshop* theWshop) { @@ -74,26 +73,25 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop) XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr(); - connect(anOperationMgr, SIGNAL(operationStarted()), - this, SLOT(onOperationStarted())); + connect(anOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted())); - connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), - this, SLOT(onOperationStopped(ModuleBase_Operation*))); + connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), this, + SLOT(onOperationStopped(ModuleBase_Operation*))); XGUI_ContextMenuMgr* aContextMenuMgr = myWorkshop->contextMenuMgr(); - connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), - this, SLOT(onContextMenuCommand(const QString&, bool))); + connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this, + SLOT(onContextMenuCommand(const QString&, bool))); - connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)), - this, SLOT(onMousePressed(QMouseEvent*))); - connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)), - this, SLOT(onMouseReleased(QMouseEvent*))); - connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)), - this, SLOT(onMouseMoved(QMouseEvent*))); - connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)), - this, SLOT(onKeyRelease(QKeyEvent*))); - connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), - this, SLOT(onMouseDoubleClick(QMouseEvent*))); + connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)), this, + SLOT(onMousePressed(QMouseEvent*))); + connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)), this, + SLOT(onMouseReleased(QMouseEvent*))); + connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)), this, + SLOT(onMouseMoved(QMouseEvent*))); + connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)), this, + SLOT(onKeyRelease(QKeyEvent*))); + connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), this, + SLOT(onMouseDoubleClick(QMouseEvent*))); } PartSet_Module::~PartSet_Module() @@ -148,11 +146,11 @@ void PartSet_Module::onFeatureTriggered() // myWorkshop->viewer()->activeView()); QAction* aCmd = dynamic_cast(sender()); //Do nothing on uncheck - if(aCmd->isCheckable() && !aCmd->isChecked()) + if (aCmd->isCheckable() && !aCmd->isChecked()) return; launchOperation(aCmd->data().toString()); } - + void PartSet_Module::launchOperation(const QString& theCmdId) { ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString()); @@ -163,18 +161,18 @@ void PartSet_Module::launchOperation(const QString& theCmdId) std::list aSelected = aSelection->getSelected(); std::list aHighlighted = aSelection->getHighlighted(); aPreviewOp->initSelection(aSelected, aHighlighted); - } + } sendOperation(anOperation); } void PartSet_Module::onOperationStarted() { - PartSet_OperationSketchBase* aPreviewOp = dynamic_cast( - myWorkshop->operationMgr()->currentOperation()); + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(myWorkshop + ->operationMgr()->currentOperation()); if (aPreviewOp) { XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel(); - connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), - this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection); + connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this, + SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection); } } @@ -211,8 +209,8 @@ void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked) void PartSet_Module::onMousePressed(QMouseEvent* theEvent) { - PartSet_OperationSketchBase* aPreviewOp = dynamic_cast( - myWorkshop->operationMgr()->currentOperation()); + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(myWorkshop + ->operationMgr()->currentOperation()); Handle(V3d_View) aView = myWorkshop->viewer()->activeView(); if (aPreviewOp && (!aView.IsNull())) { XGUI_Selection* aSelection = myWorkshop->selector()->selection(); @@ -226,8 +224,8 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent) void PartSet_Module::onMouseReleased(QMouseEvent* theEvent) { - PartSet_OperationSketchBase* aPreviewOp = dynamic_cast( - myWorkshop->operationMgr()->currentOperation()); + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(myWorkshop + ->operationMgr()->currentOperation()); Handle(V3d_View) aView = myWorkshop->viewer()->activeView(); if (aPreviewOp && (!aView.IsNull())) { XGUI_Selection* aSelection = myWorkshop->selector()->selection(); @@ -241,8 +239,8 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent) void PartSet_Module::onMouseMoved(QMouseEvent* theEvent) { - PartSet_OperationSketchBase* aPreviewOp = dynamic_cast( - myWorkshop->operationMgr()->currentOperation()); + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(myWorkshop + ->operationMgr()->currentOperation()); Handle(V3d_View) aView = myWorkshop->viewer()->activeView(); if (aPreviewOp && (!aView.IsNull())) aPreviewOp->mouseMoved(theEvent, aView); @@ -259,8 +257,8 @@ void PartSet_Module::onKeyRelease(QKeyEvent* theEvent) void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent) { - PartSet_OperationSketchBase* aPreviewOp = dynamic_cast( - myWorkshop->operationMgr()->currentOperation()); + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(myWorkshop + ->operationMgr()->currentOperation()); Handle(V3d_View) aView = myWorkshop->viewer()->activeView(); if (aPreviewOp && (!aView.IsNull())) { XGUI_Selection* aSelection = myWorkshop->selector()->selection(); @@ -326,7 +324,8 @@ void PartSet_Module::onStopSelection(const QList& theFeatures, const { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); if (!isStop) { - foreach(ObjectPtr aObject, theFeatures) { + foreach(ObjectPtr aObject, theFeatures) + { activateFeature(aObject, false); } } @@ -360,7 +359,7 @@ void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode) std::list aList = aPrevOp->subFeatures(); XGUI_Displayer* aDisplayer = myWorkshop->displayer(); std::list aModes = aPrevOp->getSelectionModes(aPrevOp->feature()); - std::list::iterator aSFIt; + std::list::iterator aSFIt; for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) { std::list aResults = (*aSFIt)->results(); std::list::iterator aIt; @@ -375,30 +374,30 @@ void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode) } } if (isDisplay) - ModelAPI_EventCreator::get()->sendUpdated(theFeature, - Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); -/* bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide; - // TODO visualizePreview(theFeature, isDisplay, false); - if (!isDisplay) { - ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation(); - FeaturePtr aSketch; - PartSet_OperationSketchBase* aPrevOp = dynamic_cast(aCurOperation); - if (aPrevOp) { - std::list aList = aPrevOp->subFeatures(); - XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - std::list aModes = aPrevOp->getSelectionModes(aPrevOp->feature()); - - std::list::const_iterator anIt = aList.begin(), - aLast = aList.end(); - //TODO for (; anIt != aLast; anIt++) - // visualizePreview((*anIt), false, false); - //aDisplayer->updateViewer(); - } - } - - if (theMode == PartSet_OperationSketchBase::FM_Activation || - theMode == PartSet_OperationSketchBase::FM_Deactivation) - activateFeature(theFeature, true);*/ + ModelAPI_EventCreator::get()->sendUpdated( + theFeature, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); + /* bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide; + // TODO visualizePreview(theFeature, isDisplay, false); + if (!isDisplay) { + ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation(); + FeaturePtr aSketch; + PartSet_OperationSketchBase* aPrevOp = dynamic_cast(aCurOperation); + if (aPrevOp) { + std::list aList = aPrevOp->subFeatures(); + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + std::list aModes = aPrevOp->getSelectionModes(aPrevOp->feature()); + + std::list::const_iterator anIt = aList.begin(), + aLast = aList.end(); + //TODO for (; anIt != aLast; anIt++) + // visualizePreview((*anIt), false, false); + //aDisplayer->updateViewer(); + } + } + + if (theMode == PartSet_OperationSketchBase::FM_Activation || + theMode == PartSet_OperationSketchBase::FM_Deactivation) + activateFeature(theFeature, true);*/ } ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdId, @@ -408,8 +407,7 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI ModuleBase_Operation* anOperation = 0; if (theCmdId == PartSet_OperationSketch::Type()) { anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this); - } - else { + } else { ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation(); FeaturePtr aSketch; PartSet_OperationSketchBase* aPrevOp = dynamic_cast(aCurOperation); @@ -418,7 +416,7 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId)) anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch); else if (theCmdId == PartSet_OperationFeatureEditMulti::Type()) - anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch); + anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch); else if (theCmdId == PartSet_OperationFeatureEdit::Type()) anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch); } @@ -451,27 +449,25 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI // connect the operation PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); if (aPreviewOp) { - connect(aPreviewOp, SIGNAL(featureConstructed(ObjectPtr, int)), - this, SLOT(onFeatureConstructed(ObjectPtr, int))); - connect(aPreviewOp, SIGNAL(launchOperation(std::string, ObjectPtr)), - this, SLOT(onLaunchOperation(std::string, ObjectPtr))); - connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), - this, SLOT(onMultiSelectionEnabled(bool))); + connect(aPreviewOp, SIGNAL(featureConstructed(ObjectPtr, int)), this, + SLOT(onFeatureConstructed(ObjectPtr, int))); + connect(aPreviewOp, SIGNAL(launchOperation(std::string, ObjectPtr)), this, + SLOT(onLaunchOperation(std::string, ObjectPtr))); + connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this, + SLOT(onMultiSelectionEnabled(bool))); - connect(aPreviewOp, SIGNAL(stopSelection(const QList&, const bool)), - this, SLOT(onStopSelection(const QList&, const bool))); - connect(aPreviewOp, SIGNAL(setSelection(const QList&)), - this, SLOT(onSetSelection(const QList&))); + connect(aPreviewOp, SIGNAL(stopSelection(const QList&, const bool)), this, + SLOT(onStopSelection(const QList&, const bool))); + connect(aPreviewOp, SIGNAL(setSelection(const QList&)), this, + SLOT(onSetSelection(const QList&))); - connect(aPreviewOp, SIGNAL(closeLocalContext()), - this, SLOT(onCloseLocalContext())); + connect(aPreviewOp, SIGNAL(closeLocalContext()), this, SLOT(onCloseLocalContext())); PartSet_OperationSketch* aSketchOp = dynamic_cast(aPreviewOp); if (aSketchOp) { - connect(aSketchOp, SIGNAL(planeSelected(double, double, double)), - this, SLOT(onPlaneSelected(double, double, double))); - connect(aSketchOp, SIGNAL(fitAllView()), - this, SLOT(onFitAllView())); + connect(aSketchOp, SIGNAL(planeSelected(double, double, double)), this, + SLOT(onPlaneSelected(double, double, double))); + connect(aSketchOp, SIGNAL(fitAllView()), this, SLOT(onFitAllView())); } } @@ -486,35 +482,34 @@ void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation) Events_Loop::loop()->send(aMessage); } - /*void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay, - const bool isUpdateViewer) -{ - ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); - if (!anOperation) - return; - - PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); - if (!aPreviewOp) - return; - - ResultPtr aResult = theFeature->firstResult(); - XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - if (isDisplay) { - boost::shared_ptr aSPFeature = - boost::dynamic_pointer_cast(theFeature); - if (aSPFeature) { - PartSet_OperationSketch* aSketchOp = dynamic_cast(aPreviewOp); - if (aSketchOp && !aSketchOp->hasSketchPlane()) - showPlanes(); - } - } - else - aDisplayer->erase(aResult, false); - - if (isUpdateViewer) - aDisplayer->updateViewer(); -}*/ + const bool isUpdateViewer) + { + ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); + if (!anOperation) + return; + + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); + if (!aPreviewOp) + return; + + ResultPtr aResult = theFeature->firstResult(); + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + if (isDisplay) { + boost::shared_ptr aSPFeature = + boost::dynamic_pointer_cast(theFeature); + if (aSPFeature) { + PartSet_OperationSketch* aSketchOp = dynamic_cast(aPreviewOp); + if (aSketchOp && !aSketchOp->hasSketchPlane()) + showPlanes(); + } + } + else + aDisplayer->erase(aResult, false); + + if (isUpdateViewer) + aDisplayer->updateViewer(); + }*/ void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer) { @@ -551,11 +546,10 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId) std::list aList = aPreviewOp->subFeatures(); std::list aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature()); - std::list::const_iterator anIt = aList.begin(), - aLast = aList.end(); + std::list::const_iterator anIt = aList.begin(), aLast = aList.end(); for (; anIt != aLast; anIt++) { - boost::shared_ptr aSPFeature = - boost::dynamic_pointer_cast(*anIt); + boost::shared_ptr aSPFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(*anIt); if (!aSPFeature) continue; std::list aResults = aSPFeature->results(); @@ -576,16 +570,16 @@ void PartSet_Module::editFeature(FeaturePtr theFeature) return; // if (theFeature->getKind() == SKETCH_KIND) { - //FeaturePtr aFeature = theFeature; - //if (XGUI_Tools::isModelObject(aFeature)) { - // ObjectPtr aObject = boost::dynamic_pointer_cast(aFeature); - // aFeature = aObject->featureRef(); - //} - - //if (aFeature) { - onLaunchOperation(theFeature->getKind(), theFeature); - updateCurrentPreview(theFeature->getKind()); - //} + //FeaturePtr aFeature = theFeature; + //if (XGUI_Tools::isModelObject(aFeature)) { + // ObjectPtr aObject = boost::dynamic_pointer_cast(aFeature); + // aFeature = aObject->featureRef(); + //} + + //if (aFeature) { + onLaunchOperation(theFeature->getKind(), theFeature); + updateCurrentPreview(theFeature->getKind()); + //} // } } @@ -593,40 +587,41 @@ void PartSet_Module::onStorePoint2D(ObjectPtr theFeature, const std::string& the { FeaturePtr aFeature = boost::dynamic_pointer_cast(theFeature); - PartSet_OperationSketchBase* aPreviewOp = dynamic_cast( - myWorkshop->operationMgr()->currentOperation()); + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(myWorkshop + ->operationMgr()->currentOperation()); if (!aPreviewOp) return; - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(aFeature->data()->attribute(theAttribute)); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + aFeature->data()->attribute(theAttribute)); - PartSet_Tools::setConstraints(aPreviewOp->sketch(), aFeature, theAttribute, - aPoint->x(), aPoint->y()); + PartSet_Tools::setConstraints(aPreviewOp->sketch(), aFeature, theAttribute, aPoint->x(), + aPoint->y()); } /*bool PartSet_Module::isFeatureEnabled(const QString& theCmdId) const -{ - XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr(); - XGUI_ActionsMgr* aActMgr = myWorkshop->actionsMgr(); - - ModuleBase_Operation* aOperation = aOpMgr->currentOperation(); - if (!aOperation) - return !aActMgr->isNested(theCmdId); - - PartSet_OperationFeatureEdit* aSketchEdtOp = dynamic_cast(aOperation); - if (aSketchEdtOp) { - QStringList aConstraintList; - aConstraintList<<"SketchConstraintDistance"<<"SketchConstraintLength" - <<"SketchConstraintRadius"<<"SketchConstraintParallel"<<"SketchConstraintPerpendicular"; - return aConstraintList.contains(theCmdId); - } - QStringList aList = aActMgr->nestedCommands(aOperation->id()); - return aList.contains(theCmdId); -}*/ - -QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent, - Config_WidgetAPI* theWidgetApi, QList& theModelWidgets) + { + XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr(); + XGUI_ActionsMgr* aActMgr = myWorkshop->actionsMgr(); + + ModuleBase_Operation* aOperation = aOpMgr->currentOperation(); + if (!aOperation) + return !aActMgr->isNested(theCmdId); + + PartSet_OperationFeatureEdit* aSketchEdtOp = dynamic_cast(aOperation); + if (aSketchEdtOp) { + QStringList aConstraintList; + aConstraintList<<"SketchConstraintDistance"<<"SketchConstraintLength" + <<"SketchConstraintRadius"<<"SketchConstraintParallel"<<"SketchConstraintPerpendicular"; + return aConstraintList.contains(theCmdId); + } + QStringList aList = aActMgr->nestedCommands(aOperation->id()); + return aList.contains(theCmdId); + }*/ + +QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget* theParent, + Config_WidgetAPI* theWidgetApi, + QList& theModelWidgets) { if (theType == "sketch-start-label") { PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, ""); diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 58e099579..797e55c74 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -23,11 +23,11 @@ class XGUI_ViewerPrs; class ModuleBase_Operation; class GeomAPI_AISObject; -class PARTSET_EXPORT PartSet_Module: public ModuleBase_IModule +class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule { Q_OBJECT -public: + public: PartSet_Module(XGUI_Workshop* theWshop); virtual ~PartSet_Module(); @@ -62,19 +62,18 @@ public: /// Activates the feature in the displayer /// \param theFeature the feature instance to be displayed /// \param isUpdateViewer the flag whether the viewer should be updated - void activateFeature(ObjectPtr theFeature, - const bool isUpdateViewer); + void activateFeature(ObjectPtr theFeature, const bool isUpdateViewer); /// Updates current operation preview, if it has it. /// \param theCmdId the operation name void updateCurrentPreview(const std::string& theCmdId); /// Creates custom widgets for property panel - virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent, - Config_WidgetAPI* theWidgetApi, QList& theModelWidgets); + virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent, + Config_WidgetAPI* theWidgetApi, + QList& theModelWidgets); - -public slots: + public slots: void onFeatureTriggered(); /// SLOT, that is called after the operation is started. Connect on the focus activated signal void onOperationStarted(); @@ -141,7 +140,7 @@ public slots: /// \param the attribute of the feature void onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute); -protected: + protected: /// Creates a new operation /// \param theCmdId the operation name /// \param theFeatureKind a kind of feature to get the feature xml description @@ -152,11 +151,11 @@ protected: /// \param theOperation the operation void sendOperation(ModuleBase_Operation* theOperation); -protected: + protected: //! Edits the feature void editFeature(FeaturePtr theFeature); -private: + private: XGUI_Workshop* myWorkshop; PartSet_Listener* myListener; diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index f8b2dddf1..a67347689 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -43,8 +43,10 @@ using namespace std; PartSet_OperationFeatureCreate::PartSet_OperationFeatureCreate(const QString& theId, QObject* theParent, - FeaturePtr theFeature) -: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myActiveWidget(0) + FeaturePtr theFeature) + : PartSet_OperationSketchBase(theId, theParent), + mySketch(theFeature), + myActiveWidget(0) { } @@ -54,15 +56,14 @@ PartSet_OperationFeatureCreate::~PartSet_OperationFeatureCreate() bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId) { - return theId == SketchPlugin_Line::ID() || theId == SketchPlugin_Point::ID() || - theId == SketchPlugin_Circle::ID() || - theId == SketchPlugin_Arc::ID() || - theId == SketchPlugin_ConstraintDistance::ID() || - theId == SketchPlugin_ConstraintLength::ID() || - theId == SketchPlugin_ConstraintRadius::ID() || - theId == SketchPlugin_ConstraintParallel::ID() || - theId == SketchPlugin_ConstraintPerpendicular::ID() || - theId == SketchPlugin_ConstraintCoincidence::ID(); + return theId == SketchPlugin_Line::ID() || theId == SketchPlugin_Point::ID() + || theId == SketchPlugin_Circle::ID() || theId == SketchPlugin_Arc::ID() + || theId == SketchPlugin_ConstraintDistance::ID() + || theId == SketchPlugin_ConstraintLength::ID() + || theId == SketchPlugin_ConstraintRadius::ID() + || theId == SketchPlugin_ConstraintParallel::ID() + || theId == SketchPlugin_ConstraintPerpendicular::ID() + || theId == SketchPlugin_ConstraintCoincidence::ID(); } bool PartSet_OperationFeatureCreate::canBeCommitted() const @@ -74,7 +75,8 @@ bool PartSet_OperationFeatureCreate::canBeCommitted() const bool PartSet_OperationFeatureCreate::isGranted(ModuleBase_IOperation* theOperation) const { - return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type(); + return theOperation->getDescription()->operationId().toStdString() + == PartSet_OperationSketch::Type(); } std::list PartSet_OperationFeatureCreate::getSelectionModes(ObjectPtr theFeature) const @@ -85,8 +87,9 @@ std::list PartSet_OperationFeatureCreate::getSelectionModes(ObjectPtr theFe return aModes; } -void PartSet_OperationFeatureCreate::initSelection(const std::list& theSelected, - const std::list& /*theHighlighted*/) +void PartSet_OperationFeatureCreate::initSelection( + const std::list& theSelected, + const std::list& /*theHighlighted*/) { myPreSelection = theSelected; } @@ -96,15 +99,15 @@ void PartSet_OperationFeatureCreate::initFeature(FeaturePtr theFeature) myInitFeature = theFeature; } - FeaturePtr PartSet_OperationFeatureCreate::sketch() const { return mySketch; } -void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& theSelected, - const std::list& /*theHighlighted*/) +void PartSet_OperationFeatureCreate::mouseReleased( + QMouseEvent* theEvent, Handle(V3d_View) theView, + const std::list& theSelected, + const std::list& /*theHighlighted*/) { if (commit()) { // if the point creation is finished, the next mouse release should commit the modification @@ -118,11 +121,10 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle if (theSelected.empty()) { PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); - } - else { + } else { ModuleBase_ViewerPrs aPrs = theSelected.front(); const TopoDS_Shape& aShape = aPrs.shape(); - if (!aShape.IsNull()) // the point is selected + if (!aShape.IsNull()) // the point is selected { if (aShape.ShapeType() == TopAbs_VERTEX) { const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape); @@ -130,12 +132,11 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle aPoint = BRep_Tool::Pnt(aVertex); PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); - PartSet_Tools::setConstraints(sketch(), feature(), myActiveWidget->attributeID(), - aX, anY); + PartSet_Tools::setConstraints(sketch(), feature(), myActiveWidget->attributeID(), aX, + anY); } - } - else if (aShape.ShapeType() == TopAbs_EDGE) // the line is selected - { + } else if (aShape.ShapeType() == TopAbs_EDGE) // the line is selected + { PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); // move to selected line if (feature()->getKind() == SketchPlugin_Line::ID()) { @@ -150,7 +151,7 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle ModuleBase_ViewerPrs aPrs = theSelected.front(); aFeature = aPrs.object(); } else - aFeature = feature(); // for the widget distance only + aFeature = feature(); // for the widget distance only bool isApplyed = setWidgetValue(aFeature, aX, anY); if (isApplyed) { @@ -163,8 +164,7 @@ void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, Handle(V3 { if (commit()) { restartOperation(feature()->getKind(), feature()); - } - else { + } else { double aX, anY; gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView); PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); @@ -177,8 +177,7 @@ void PartSet_OperationFeatureCreate::keyReleased(std::string theName, QKeyEvent* { int aKeyType = theEvent->key(); // the second point should be activated by any modification in the property panel - if (!theName.empty()) - { + if (!theName.empty()) { //setPointSelectionMode(myFeaturePrs->getNextMode(theName), false); } keyReleased(theEvent->key()); @@ -195,10 +194,10 @@ void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* t myPreSelection.remove(aPrs); emit activateNextWidget(myActiveWidget); } - } + } if (myInitFeature && myActiveWidget) { ModuleBase_WidgetPoint2D* aWgt = dynamic_cast(myActiveWidget); - if (aWgt && aWgt->initFromPrevious(myInitFeature)) { + if (aWgt && aWgt->initFromPrevious(myInitFeature)) { myInitFeature = FeaturePtr(); emit activateNextWidget(myActiveWidget); } @@ -214,14 +213,14 @@ void PartSet_OperationFeatureCreate::keyReleased(const int theKey) restartOperation(feature()->getKind(), FeaturePtr()); } } - break; + break; case Qt::Key_Escape: { if (!commit()) { abort(); } } default: - break; + break; } } @@ -247,7 +246,7 @@ void PartSet_OperationFeatureCreate::stopOperation() void PartSet_OperationFeatureCreate::afterCommitOperation() { - PartSet_OperationSketchBase::afterCommitOperation(); + PartSet_OperationSketchBase::afterCommitOperation(); emit featureConstructed(feature(), FM_Deactivation); } @@ -255,8 +254,8 @@ FeaturePtr PartSet_OperationFeatureCreate::createFeature(const bool theFlushMess { FeaturePtr aNewFeature = ModuleBase_Operation::createFeature(false); if (sketch()) { - boost::shared_ptr aFeature = - boost::dynamic_pointer_cast(sketch()); + boost::shared_ptr aFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(sketch()); aFeature->addSub(aNewFeature); } diff --git a/src/PartSet/PartSet_OperationFeatureCreate.h b/src/PartSet/PartSet_OperationFeatureCreate.h index 5ba2e7428..cedf301a7 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.h +++ b/src/PartSet/PartSet_OperationFeatureCreate.h @@ -19,29 +19,28 @@ class QKeyEvent; /*! \class PartSet_OperationFeatureCreate * \brief The operation for the sketch feature creation -*/ + */ class PARTSET_EXPORT PartSet_OperationFeatureCreate : public PartSet_OperationSketchBase { - Q_OBJECT +Q_OBJECT -public: + public: /// Returns true if the feature with the given kind can be created by this operation /// \param theId the feature kind /// \return the boolean result static bool canProcessKind(const std::string& theId); -public: + public: /// Constructor /// \param theId the feature identifier /// \param theParent the operation parent /// \param theSketch the parent feature - PartSet_OperationFeatureCreate(const QString& theId, QObject* theParent, - FeaturePtr theSketch); + PartSet_OperationFeatureCreate(const QString& theId, QObject* theParent, FeaturePtr theSketch); /// Destructor virtual ~PartSet_OperationFeatureCreate(); /// Returns that this operator can be started above already running one. - /// The runned operation should be the sketch feature modified operation + /// The runned operation should be the sketch feature modified operation /// \param theOperation the previous running operation virtual bool isGranted(ModuleBase_IOperation* theOperation) const; @@ -57,7 +56,7 @@ public: /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations virtual void initSelection(const std::list& theSelected, - const std::list& theHighlighted); + const std::list& theHighlighted); /// Returns the operation sketch feature /// \returns the sketch instance @@ -68,9 +67,9 @@ public: /// \param theView a viewer to have the viewer the eye position /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted); /// Gives the current mouse point in the viewer /// \param thePoint a point clicked in the viewer /// \param theEvent the mouse event @@ -81,12 +80,12 @@ public: virtual void keyReleased(std::string theName, QKeyEvent* theEvent); -public slots: + public slots: /// Slots which listen the mode widget activation /// \param theWidget the model widget virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget); -protected: + protected: /// \brief Virtual method called when operation is started /// Virtual method called when operation started (see start() method for more description) /// After the parent operation body perform, set sketch feature to the created line feature @@ -114,7 +113,7 @@ protected: /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled virtual bool canBeCommitted() const; -protected: + protected: /// Set value to the active widget /// \param theFeature the feature /// \param theX the horizontal coordinate @@ -122,11 +121,11 @@ protected: /// \return true if the point is set bool setWidgetValue(ObjectPtr theFeature, double theX, double theY); -private: - FeaturePtr myInitFeature; ///< the initial feature - FeaturePtr mySketch; ///< the sketch of the feature + private: + FeaturePtr myInitFeature; ///< the initial feature + FeaturePtr mySketch; ///< the sketch of the feature - ModuleBase_ModelWidget* myActiveWidget; ///< the active widget + ModuleBase_ModelWidget* myActiveWidget; ///< the active widget std::list myPreSelection; }; diff --git a/src/PartSet/PartSet_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp index 887ec4f9c..b17524725 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.cpp +++ b/src/PartSet/PartSet_OperationFeatureEdit.cpp @@ -37,10 +37,11 @@ using namespace std; -PartSet_OperationFeatureEdit::PartSet_OperationFeatureEdit(const QString& theId, - QObject* theParent, - FeaturePtr theFeature) -: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myIsBlockedSelection(false) +PartSet_OperationFeatureEdit::PartSet_OperationFeatureEdit(const QString& theId, QObject* theParent, + FeaturePtr theFeature) + : PartSet_OperationSketchBase(theId, theParent), + mySketch(theFeature), + myIsBlockedSelection(false) { } @@ -50,7 +51,8 @@ PartSet_OperationFeatureEdit::~PartSet_OperationFeatureEdit() bool PartSet_OperationFeatureEdit::isGranted(ModuleBase_IOperation* theOperation) const { - return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type(); + return theOperation->getDescription()->operationId().toStdString() + == PartSet_OperationSketch::Type(); } std::list PartSet_OperationFeatureEdit::getSelectionModes(ObjectPtr theFeature) const @@ -63,20 +65,20 @@ void PartSet_OperationFeatureEdit::initFeature(FeaturePtr theFeature) setEditingFeature(theFeature); } - FeaturePtr PartSet_OperationFeatureEdit::sketch() const { return mySketch; } -void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationFeatureEdit::mousePressed( + QMouseEvent* theEvent, Handle(V3d_View) theView, + const std::list& theSelected, + const std::list& theHighlighted) { ObjectPtr aObject; if (!theHighlighted.empty()) aObject = theHighlighted.front().object(); - if (!aObject && !theSelected.empty()) // changed for a constrain + if (!aObject && !theSelected.empty()) // changed for a constrain aObject = theSelected.front().object(); FeaturePtr aFeature = ModelAPI_Feature::feature(aObject); @@ -85,20 +87,19 @@ void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3 emit featureConstructed(feature(), FM_Deactivation); bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); - if(aHasShift && !theHighlighted.empty()) { + if (aHasShift && !theHighlighted.empty()) { QList aSelected; std::list::const_iterator aIt; for (aIt = theSelected.cbegin(); aIt != theSelected.cend(); ++aIt) aSelected.append((*aIt).object()); /*for (aIt = theHighlighted.cbegin(); aIt != theHighlighted.cend(); ++aIt) { - if (!aSelected.contains((*aIt).object())) - aSelected.append((*aIt).object()); - }*/ + if (!aSelected.contains((*aIt).object())) + aSelected.append((*aIt).object()); + }*/ //aSelected.push_back(feature()); //aSelected.push_back(theHighlighted.front().object()); emit setSelection(aSelected); - } - else if (aFeature) { + } else if (aFeature) { restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature); } } @@ -107,7 +108,7 @@ void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3 void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) { - if (!(theEvent->buttons() & Qt::LeftButton)) + if (!(theEvent->buttons() & Qt::LeftButton)) return; gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView); @@ -123,8 +124,8 @@ void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, Handle(V3d_ double aDeltaX = aX - aCurX; double aDeltaY = anY - aCurY; - boost::shared_ptr aSketchFeature = - boost::dynamic_pointer_cast(feature()); + boost::shared_ptr aSketchFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(feature()); aSketchFeature->move(aDeltaX, aDeltaY); static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); ModelAPI_EventCreator::get()->sendUpdated(feature(), anEvent); @@ -134,25 +135,29 @@ void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, Handle(V3d_ myCurPoint.setPoint(aPoint); } -void PartSet_OperationFeatureEdit::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& /*theSelected*/, - const std::list& /*theHighlighted*/) +void PartSet_OperationFeatureEdit::mouseReleased( + QMouseEvent* theEvent, Handle(V3d_View) theView, + const std::list& /*theSelected*/, + const std::list& /*theHighlighted*/) { blockSelection(false); } -void PartSet_OperationFeatureEdit::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationFeatureEdit::mouseDoubleClick( + QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted) { // TODO the functionality is important only for constraint feature. Should be moved in another place if (!theSelected.empty()) { ModuleBase_ViewerPrs aFeaturePrs = theSelected.front(); if (!aFeaturePrs.owner().IsNull()) { - Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast(aFeaturePrs.owner()); + Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast( + aFeaturePrs.owner()); if (!anOwner.IsNull() && anOwner->SelectionMode() == AIS_DSM_Text) { bool isValid; - double aValue = PartSet_Tools::featureValue(feature(), SketchPlugin_Constraint::VALUE(), isValid); + double aValue = PartSet_Tools::featureValue(feature(), SketchPlugin_Constraint::VALUE(), + isValid); if (isValid) { ModuleBase_WidgetEditor::editFeatureValue(feature(), SketchPlugin_Constraint::VALUE()); flushUpdated(); @@ -162,12 +167,11 @@ void PartSet_OperationFeatureEdit::mouseDoubleClick(QMouseEvent* theEvent, Handl } } - void PartSet_OperationFeatureEdit::keyReleased(const int theKey) { if (theKey == Qt::Key_Return) { commit(); - } else + } else PartSet_OperationSketchBase::keyReleased(theKey); } @@ -198,8 +202,7 @@ void PartSet_OperationFeatureEdit::blockSelection(bool isBlocked, const bool isR if (isBlocked) { emit setSelection(QList()); emit stopSelection(aFeatureList, true); - } - else { + } else { emit stopSelection(aFeatureList, false); if (isRestoreSelection) emit setSelection(aFeatureList); diff --git a/src/PartSet/PartSet_OperationFeatureEdit.h b/src/PartSet/PartSet_OperationFeatureEdit.h index ac607e47f..eadd73f10 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.h +++ b/src/PartSet/PartSet_OperationFeatureEdit.h @@ -15,25 +15,32 @@ class QMouseEvent; /*! \class PartSet_OperationFeatureEdit * \brief The operation for the sketch feature creation -*/ -class PARTSET_EXPORT PartSet_OperationFeatureEdit : public PartSet_OperationSketchBase + */ +class PARTSET_EXPORT PartSet_OperationFeatureEdit : public PartSet_OperationSketchBase { - Q_OBJECT +Q_OBJECT /// Struct to define gp point, with the state is the point is initialized struct Point { /// Constructor - Point() {} + Point() + { + } /// Constructor /// \param thePoint the point Point(gp_Pnt thePoint) { setPoint(thePoint); } - ~Point() {} + ~Point() + { + } /// clear the initialized flag. - void clear() { myIsInitialized = false; } + void clear() + { + myIsInitialized = false; + } /// set the point and switch on the initialized flag /// \param thePoint the point void setPoint(const gp_Pnt& thePoint) @@ -42,21 +49,23 @@ class PARTSET_EXPORT PartSet_OperationFeatureEdit : public PartSet_OperationSket myPoint = thePoint; } - bool myIsInitialized; /// the state whether the point is set - gp_Pnt myPoint; /// the point + bool myIsInitialized; /// the state whether the point is set + gp_Pnt myPoint; /// the point }; -public: + public: /// Returns the operation type key - static std::string Type() { return "EditLine"; } + static std::string Type() + { + return "EditLine"; + } -public: + public: /// Constructor /// \param theId the feature identifier /// \param theParent the operation parent /// \param theFeature the parent feature - PartSet_OperationFeatureEdit(const QString& theId, QObject* theParent, - FeaturePtr theFeature); + PartSet_OperationFeatureEdit(const QString& theId, QObject* theParent, FeaturePtr theFeature); /// Destructor virtual ~PartSet_OperationFeatureEdit(); @@ -94,9 +103,9 @@ public: /// \param theEvent the mouse event /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted); /// Processes the mouse double click in the point /// \param theEvent the mouse event @@ -111,7 +120,7 @@ public: /// \param theKey a key value virtual void keyReleased(const int theKey); -protected: + protected: /// \brief Virtual method called when operation is started /// Virtual method called when operation started (see start() method for more description) /// Switch off the multi selection state @@ -127,7 +136,7 @@ protected: /// \returns the created feature virtual FeaturePtr createFeature(const bool theFlushMessage = true); -protected: + protected: /// Emits a signal about the selection blocking. Emits a signal to change the selection. /// If the block is true, the signal clear selection, otherwise if restore selection flag allows, /// the internal operation features are to be selected @@ -138,10 +147,10 @@ protected: /// Sends the features void sendFeatures(); -private: - FeaturePtr mySketch; ///< the sketch feature - Point myCurPoint; ///< the current 3D point clicked or moved - bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal + private: + FeaturePtr mySketch; ///< the sketch feature + Point myCurPoint; ///< the current 3D point clicked or moved + bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal }; #endif diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp index 83d2a04b5..0c4a71697 100644 --- a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp +++ b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp @@ -33,9 +33,11 @@ using namespace std; PartSet_OperationFeatureEditMulti::PartSet_OperationFeatureEditMulti(const QString& theId, - QObject* theParent, - FeaturePtr theFeature) -: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myIsBlockedSelection(false) + QObject* theParent, + FeaturePtr theFeature) + : PartSet_OperationSketchBase(theId, theParent), + mySketch(theFeature), + myIsBlockedSelection(false) { } @@ -45,11 +47,13 @@ PartSet_OperationFeatureEditMulti::~PartSet_OperationFeatureEditMulti() bool PartSet_OperationFeatureEditMulti::isGranted(ModuleBase_IOperation* theOperation) const { - return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type(); + return theOperation->getDescription()->operationId().toStdString() + == PartSet_OperationSketch::Type(); } -void PartSet_OperationFeatureEditMulti::initSelection(const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationFeatureEditMulti::initSelection( + const std::list& theSelected, + const std::list& theHighlighted) { if (!theHighlighted.empty()) { // if there is highlighted object, we check whether it is in the list of selected objects @@ -57,7 +61,8 @@ void PartSet_OperationFeatureEditMulti::initSelection(const std::list::const_iterator anIt = theSelected.begin(), aLast = theSelected.end(); + std::list::const_iterator anIt = theSelected.begin(), aLast = theSelected + .end(); for (; anIt != aLast && !isSelected; anIt++) { isSelected = ModelAPI_Feature::feature((*anIt).object()) == feature(); } @@ -65,8 +70,7 @@ void PartSet_OperationFeatureEditMulti::initSelection(const std::list& /*theSelected*/, - const std::list& theHighlighted) +void PartSet_OperationFeatureEditMulti::mousePressed( + QMouseEvent* theEvent, Handle(V3d_View) theView, + const std::list& /*theSelected*/, + const std::list& theHighlighted) { } void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) { - if (!(theEvent->buttons() & Qt::LeftButton)) + if (!(theEvent->buttons() & Qt::LeftButton)) return; gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView); @@ -104,11 +109,12 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle double aDeltaX = aX - aCurX; double aDeltaY = anY - aCurY; - boost::shared_ptr aSketchFeature = - boost::dynamic_pointer_cast(feature()); + boost::shared_ptr aSketchFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(feature()); aSketchFeature->move(aDeltaX, aDeltaY); - std::list::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end(); + std::list::const_iterator anIt = myFeatures.begin(), aLast = myFeatures + .end(); for (; anIt != aLast; anIt++) { ObjectPtr aObject = (*anIt).object(); if (!aObject || aObject == feature()) @@ -126,18 +132,20 @@ void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, Handle myCurPoint.setPoint(aPoint); } -void PartSet_OperationFeatureEditMulti::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView, - const std::list& /*theSelected*/, - const std::list& /*theHighlighted*/) +void PartSet_OperationFeatureEditMulti::mouseReleased( + QMouseEvent* theEvent, Handle(V3d_View) theView, + const std::list& /*theSelected*/, + const std::list& /*theHighlighted*/) { if (commit()) { std::list aFeatures = myFeatures; - std::list::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); + std::list::const_iterator anIt = aFeatures.begin(), aLast = + aFeatures.end(); for (; anIt != aLast; anIt++) { ObjectPtr aFeature = (*anIt).object(); if (aFeature) { emit featureConstructed(aFeature, FM_Deactivation); - } + } } } } @@ -161,22 +169,22 @@ void PartSet_OperationFeatureEditMulti::stopOperation() myFeatures.clear(); } -void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, const bool isRestoreSelection) +void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, + const bool isRestoreSelection) { if (myIsBlockedSelection == isBlocked) return; myIsBlockedSelection = isBlocked; QList aFeatureList; - std::list::const_iterator anIt = myFeatures.begin(), - aLast = myFeatures.end(); + std::list::const_iterator anIt = myFeatures.begin(), aLast = + myFeatures.end(); /*for(; anIt != aLast; anIt++) - aFeatureList.append((*anIt).feature());*/ + aFeatureList.append((*anIt).feature());*/ if (isBlocked) { emit setSelection(QList()); emit stopSelection(aFeatureList, true); - } - else { + } else { emit stopSelection(aFeatureList, false); if (isRestoreSelection) { emit setSelection(aFeatureList); @@ -188,8 +196,9 @@ void PartSet_OperationFeatureEditMulti::sendFeatures() { static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED); - std::list aFeatures; - std::list::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end(); + std::list aFeatures; + std::list::const_iterator anIt = myFeatures.begin(), aLast = + myFeatures.end(); for (; anIt != aLast; anIt++) { ObjectPtr aFeature = (*anIt).object(); if (!aFeature) diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.h b/src/PartSet/PartSet_OperationFeatureEditMulti.h index 7f018618b..f49d0480b 100644 --- a/src/PartSet/PartSet_OperationFeatureEditMulti.h +++ b/src/PartSet/PartSet_OperationFeatureEditMulti.h @@ -15,25 +15,32 @@ class QMouseEvent; /*! \class PartSet_OperationFeatureEditMulti * \brief The operation for the sketch feature creation -*/ -class PARTSET_EXPORT PartSet_OperationFeatureEditMulti : public PartSet_OperationSketchBase + */ +class PARTSET_EXPORT PartSet_OperationFeatureEditMulti : public PartSet_OperationSketchBase { - Q_OBJECT +Q_OBJECT /// Struct to define gp point, with the state is the point is initialized struct Point { /// Constructor - Point() {} + Point() + { + } /// Constructor /// \param thePoint the point Point(gp_Pnt thePoint) { setPoint(thePoint); } - ~Point() {} + ~Point() + { + } /// clear the initialized flag. - void clear() { myIsInitialized = false; } + void clear() + { + myIsInitialized = false; + } /// set the point and switch on the initialized flag /// \param thePoint the point void setPoint(const gp_Pnt& thePoint) @@ -42,21 +49,24 @@ class PARTSET_EXPORT PartSet_OperationFeatureEditMulti : public PartSet_Operatio myPoint = thePoint; } - bool myIsInitialized; /// the state whether the point is set - gp_Pnt myPoint; /// the point + bool myIsInitialized; /// the state whether the point is set + gp_Pnt myPoint; /// the point }; -public: + public: /// Returns the operation type key - static std::string Type() { return "EditMulti"; } + static std::string Type() + { + return "EditMulti"; + } -public: + public: /// Constructor /// \param theId the feature identifier /// \param theParent the operation parent /// \param theFeature the parent feature PartSet_OperationFeatureEditMulti(const QString& theId, QObject* theParent, - FeaturePtr theFeature); + FeaturePtr theFeature); /// Destructor virtual ~PartSet_OperationFeatureEditMulti(); @@ -72,7 +82,7 @@ public: /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations virtual void initSelection(const std::list& theSelected, - const std::list& theHighlighted); + const std::list& theHighlighted); /// Returns the operation sketch feature /// \returns the sketch instance @@ -95,10 +105,10 @@ public: /// \param theEvent the mouse event /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations - virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); -protected: + virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted); + protected: /// \brief Virtual method called when operation is started /// Virtual method called when operation started (see start() method for more description) /// Switch off the multi selection state @@ -108,7 +118,7 @@ protected: /// Restore the multi selection state virtual void stopOperation(); -protected: + protected: /// Emits a signal about the selection blocking. Emits a signal to change the selection. /// If the block is true, the signal clear selection, otherwise if restore selection flag allows, /// the internal operation features are to be selected @@ -119,11 +129,11 @@ protected: /// Sends the features void sendFeatures(); -private: - FeaturePtr mySketch; ///< the sketch feature - std::list myFeatures; ///< the features to apply the edit operation - Point myCurPoint; ///< the current 3D point clicked or moved - bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal + private: + FeaturePtr mySketch; ///< the sketch feature + std::list myFeatures; ///< the features to apply the edit operation + Point myCurPoint; ///< the current 3D point clicked or moved + bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal }; #endif diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 81ba69a07..4ff87cae1 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -39,10 +39,8 @@ using namespace std; - -PartSet_OperationSketch::PartSet_OperationSketch(const QString& theId, - QObject* theParent) -: PartSet_OperationSketchBase(theId, theParent) +PartSet_OperationSketch::PartSet_OperationSketch(const QString& theId, QObject* theParent) + : PartSet_OperationSketchBase(theId, theParent) { } @@ -61,7 +59,6 @@ std::list PartSet_OperationSketch::getSelectionModes(ObjectPtr theFeature) return aModes; } - /// Initializes the operation with previously created feature. It is used in sequental operations void PartSet_OperationSketch::initFeature(FeaturePtr theFeature) { @@ -78,7 +75,7 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie const std::list& theSelected, const std::list& theHighlighted) { - if (hasSketchPlane()){ + if (hasSketchPlane()) { // if shift button is pressed and there are some already selected objects, the operation should // not be started. We just want to combine some selected objects. bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); @@ -88,13 +85,12 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie if (theHighlighted.size() == 1) { ObjectPtr aFeature = theHighlighted.front().object(); if (aFeature) { - std::string anOperationType = (theSelected.size() > 1)? - PartSet_OperationFeatureEditMulti::Type() : - PartSet_OperationFeatureEdit::Type(); + std::string anOperationType = + (theSelected.size() > 1) ? + PartSet_OperationFeatureEditMulti::Type() : PartSet_OperationFeatureEdit::Type(); restartOperation(anOperationType, aFeature); } - } - else + } else myFeatures = theHighlighted; } else { @@ -126,14 +122,14 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) { - if (!hasSketchPlane() || !(theEvent->buttons() & Qt::LeftButton) || myFeatures.empty()) + if (!hasSketchPlane() || !(theEvent->buttons() & Qt::LeftButton) || myFeatures.empty()) return; if (myFeatures.size() != 1) { FeaturePtr aFeature = PartSet_Tools::nearestFeature(theEvent->pos(), theView, feature(), myFeatures); if (aFeature) - restartOperation(PartSet_OperationFeatureEditMulti::Type(), aFeature); + restartOperation(PartSet_OperationFeatureEditMulti::Type(), aFeature); } } @@ -147,8 +143,8 @@ std::list PartSet_OperationSketch::subFeatures() const boost::shared_ptr aData = aFeature->data(); if (!aData->isValid()) return std::list(); - boost::shared_ptr aRefList = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::FEATURES_ID())); + boost::shared_ptr aRefList = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID())); std::list aList = aRefList->list(); std::list::iterator aIt; @@ -170,8 +166,8 @@ void PartSet_OperationSketch::stopOperation() std::list aResults = aFeature->results(); std::list::const_iterator aIt; for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) { - ModelAPI_EventCreator::get()->sendUpdated(*aIt, - Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); + ModelAPI_EventCreator::get()->sendUpdated( + *aIt, Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); } //ModelAPI_EventCreator::get()->sendUpdated(aFeature, // Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); @@ -182,7 +178,6 @@ bool PartSet_OperationSketch::isNestedOperationsEnabled() const return hasSketchPlane(); } - void PartSet_OperationSketch::startOperation() { PartSet_OperationSketchBase::startOperation(); @@ -197,8 +192,8 @@ bool PartSet_OperationSketch::hasSketchPlane() const if (feature()) { boost::shared_ptr aData = feature()->data(); AttributeDoublePtr anAttr; - boost::shared_ptr aNormal = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::NORM_ID())); + boost::shared_ptr aNormal = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::NORM_ID())); aHasPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0); } return aHasPlane; @@ -230,26 +225,27 @@ void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape) // X axis is preferable to be dirX on the sketch const double tol = Precision::Confusion(); bool isX = fabs(anA - 1.0) < tol && fabs(aB) < tol && fabs(aC) < tol; - boost::shared_ptr aTempDir(isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0)); + boost::shared_ptr aTempDir( + isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0)); boost::shared_ptr aYDir(new GeomAPI_Dir(aNormDir->cross(aTempDir))); boost::shared_ptr aXDir(new GeomAPI_Dir(aYDir->cross(aNormDir))); - boost::shared_ptr anOrigin = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + boost::shared_ptr anOrigin = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); anOrigin->setValue(anOrigPnt); - boost::shared_ptr aNormal = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::NORM_ID())); + boost::shared_ptr aNormal = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::NORM_ID())); aNormal->setValue(aNormDir); - boost::shared_ptr aDirX = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::DIRX_ID())); + boost::shared_ptr aDirX = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::DIRX_ID())); aDirX->setValue(aXDir); - boost::shared_ptr aDirY = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::DIRY_ID())); + boost::shared_ptr aDirY = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::DIRY_ID())); aDirY->setValue(aYDir); boost::shared_ptr aDir = aPlane->direction(); flushUpdated(); - + emit featureConstructed(feature(), FM_Hide); emit closeLocalContext(); emit planeSelected(aDir->x(), aDir->y(), aDir->z()); diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index 1cd920158..04604ef0c 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -18,15 +18,18 @@ class Handle_AIS_InteractiveObject; /*! \class PartSet_OperationSketch * \brief The operation for the sketch feature creation -*/ + */ class PARTSET_EXPORT PartSet_OperationSketch : public PartSet_OperationSketchBase { - Q_OBJECT -public: +Q_OBJECT + public: /// Returns the operation type key - static std::string Type() { return SketchPlugin_Sketch::ID(); } + static std::string Type() + { + return SketchPlugin_Sketch::ID(); + } -public: + public: /// Constructor /// \param theId the feature identifier /// \param theParent the operation parent @@ -99,13 +102,13 @@ signals: // signal about the viewer fit all perform void fitAllView(); -protected: + protected: /// Virtual method called when operation started (see start() method for more description) /// Default impl calls corresponding slot and commits immediately. virtual void startOperation(); -private: - std::list myFeatures; ///< the features to apply the edit operation + private: + std::list myFeatures; ///< the features to apply the edit operation }; #endif diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index c606e919d..d90de1d29 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -21,9 +21,8 @@ using namespace std; -PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId, - QObject* theParent) -: ModuleBase_Operation(theId, theParent) +PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId, QObject* theParent) + : ModuleBase_Operation(theId, theParent) { } @@ -31,11 +30,10 @@ PartSet_OperationSketchBase::~PartSet_OperationSketchBase() { } -boost::shared_ptr PartSet_OperationSketchBase::preview( - FeaturePtr theFeature) +boost::shared_ptr PartSet_OperationSketchBase::preview(FeaturePtr theFeature) { - boost::shared_ptr aFeature = - boost::dynamic_pointer_cast(theFeature); + boost::shared_ptr aFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(theFeature); if (aFeature) { ResultPtr aRes = aFeature->firstResult(); ResultBodyPtr aBody = boost::dynamic_pointer_cast(aRes); @@ -62,8 +60,8 @@ std::list PartSet_OperationSketchBase::getSelectionModes(ObjectPtr theFeatu // return aModes; // } //} - aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_VERTEX)); - aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_EDGE)); + aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX)); + aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE)); aModes.push_back(AIS_DSM_Text); aModes.push_back(AIS_DSM_Line); return aModes; @@ -76,23 +74,25 @@ FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage return myFeature; } - -void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationSketchBase::mousePressed( + QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted) { } -void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationSketchBase::mouseReleased( + QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted) { } void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) { } -void PartSet_OperationSketchBase::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted) +void PartSet_OperationSketchBase::mouseDoubleClick( + QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted) { } @@ -102,17 +102,18 @@ void PartSet_OperationSketchBase::keyReleased(const int theKey) case Qt::Key_Escape: { bool toAbort = true; if (isModified()) { - int anAnswer = QMessageBox::question(qApp->activeWindow(), tr("Cancel operation"), - tr("Operation %1 will be cancelled. Continue?").arg(id()), - QMessageBox::Yes, QMessageBox::No); + int anAnswer = QMessageBox::question( + qApp->activeWindow(), tr("Cancel operation"), + tr("Operation %1 will be cancelled. Continue?").arg(id()), QMessageBox::Yes, + QMessageBox::No); toAbort = (anAnswer == QMessageBox::Yes); } if (toAbort) abort(); } - break; + break; default: - break; + break; } } @@ -121,8 +122,7 @@ void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* th keyReleased(theEvent->key()); } -void PartSet_OperationSketchBase::restartOperation(const std::string& theType, - ObjectPtr theFeature) +void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature) { emit launchOperation(theType, theFeature); } diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index caae337a7..66e3cd004 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -29,17 +29,22 @@ class GeomAPI_Shape; class ModuleBase_ViewerPrs; /*! - \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_Operation { - Q_OBJECT -public: - enum FeatureActionMode { FM_Activation, FM_Deactivation, FM_Hide }; - -public: +Q_OBJECT + public: + enum FeatureActionMode + { + FM_Activation, + FM_Deactivation, + FM_Hide + }; + + public: /// Constructor /// \param theId an feature index /// \param theParent the object parent @@ -61,13 +66,17 @@ public: virtual std::list getSelectionModes(ObjectPtr theFeature) const; /// Initializes the operation with previously created feature. It is used in sequental operations - virtual void initFeature(FeaturePtr theFeature) {} + virtual void initFeature(FeaturePtr theFeature) + { + } /// Initialisation of operation with preliminary selection /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations virtual void initSelection(const std::list& theSelected, - const std::list& theHighlighted) {} + const std::list& theHighlighted) + { + } /// Returns the operation sketch feature /// \returns the sketch instance @@ -102,8 +111,8 @@ public: /// \param theSelected the list of selected presentations /// \param theHighlighted the list of highlighted presentations virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView, - const std::list& theSelected, - const std::list& theHighlighted); + const std::list& theSelected, + const std::list& theHighlighted); /// Processes the key pressed in the view /// \param theKey a key value @@ -115,15 +124,14 @@ public: /// If the provided feature is empty, the current operation feature is used. /// \param theType a type of an operation started /// theFeature the operation argument - void restartOperation(const std::string& theType, - ObjectPtr theFeature = ObjectPtr()); + void restartOperation(const std::string& theType, ObjectPtr theFeature = ObjectPtr()); signals: /// signal about the request to launch operation /// theName the operation name /// theFeature the operation argument void launchOperation(std::string theName, ObjectPtr theFeature); - + /// Signal about the feature construing is finished /// \param theFeature the result feature /// \param theMode the mode of the feature modification @@ -132,7 +140,7 @@ signals: /// Signal about the features should be selected /// \param theSelected the list of selected presentations void featureSelected(const std::list& theSelected); - + /// signal to enable/disable multi selection in the viewer /// \param theEnabled the boolean state void multiSelectionEnabled(bool theEnabled); @@ -141,7 +149,7 @@ signals: /// \param theFeatures a list of features to be disabled /// \param theToStop the boolean state whether it it stopped or non stopped void stopSelection(const QList& theFeatures, const bool theToStop); - + /// signal to set selection in the viewer /// \param theFeatures a list of features to be disabled void setSelection(const QList& theFeatures); @@ -149,7 +157,7 @@ signals: /// signal to close the operation local context if it is opened void closeLocalContext(); -protected: + protected: /// Creates an operation new feature /// In addition to the default realization it appends the created line feature to /// the sketch feature diff --git a/src/PartSet/PartSet_TestOCC.cpp b/src/PartSet/PartSet_TestOCC.cpp index fbf819b15..727a97915 100644 --- a/src/PartSet/PartSet_TestOCC.cpp +++ b/src/PartSet/PartSet_TestOCC.cpp @@ -40,7 +40,8 @@ void PartSet_TestOCC::testSelection(XGUI_Workshop* theWorkshop) boost::shared_ptr anIO = theWorkshop->displayer()->getAISObject(myTestObject); if (!anIO->empty()) { theWorkshop->viewer()->AISContext()->MoveTo(0, 0, theWorkshop->viewer()->activeView()); - theWorkshop->viewer()->AISContext()->Select(0, 0, 2500, 2500, theWorkshop->viewer()->activeView()); + theWorkshop->viewer()->AISContext()->Select(0, 0, 2500, 2500, + theWorkshop->viewer()->activeView()); } } @@ -96,7 +97,7 @@ void PartSet_TestOCC::local_selection_change_shape(Handle_AIS_InteractiveContext } void PartSet_TestOCC::local_selection_erase(Handle_AIS_InteractiveContext theContext, - Handle_V3d_View theView) + Handle_V3d_View theView) { // 1. Create shape gp_Pnt aPnt1(100, 100, 0); @@ -127,17 +128,17 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop) ModuleBase_Operation* anOperation = theWorkshop->operationMgr()->currentOperation(); PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); - FeaturePtr aSketch; + FeaturePtr aSketch; if (aPreviewOp) { // create a line boost::shared_ptr aDoc = ModelAPI_PluginManager::get()->rootDocument(); FeaturePtr aFeature = aDoc->addFeature(SketchPlugin_Line::ID()); - if (aFeature) // TODO: generate an error if feature was not created + if (aFeature) // TODO: generate an error if feature was not created aFeature->execute(); - boost::shared_ptr aSketch = - boost::dynamic_pointer_cast(aPreviewOp->sketch()); + boost::shared_ptr aSketch = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(aPreviewOp->sketch()); aSketch->addSub(aFeature); PartSet_Tools::setFeaturePoint(aFeature, 100, 100, SketchPlugin_Line::START_ID()); @@ -148,12 +149,12 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop) XGUI_Displayer* aDisplayer = theWorkshop->displayer(); boost::shared_ptr aPrevAIS; - boost::shared_ptr aSPFeature = - boost::dynamic_pointer_cast(aFeature); + boost::shared_ptr aSPFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(aFeature); //boost::shared_ptr anAIS = aSPFeature->getAISObject(aPrevAIS); //if (!anAIS->empty()) aDisplayer->display(aFeature, false); - //aDisplayer->redisplay(aFeature->firstResult(), anAIS, false); + //aDisplayer->redisplay(aFeature->firstResult(), anAIS, false); std::list aModes; aModes.push_back(TopAbs_VERTEX); @@ -162,22 +163,22 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop) // change the line /*double aDelta = -200; - for (int i = 0; i < 20; i++) { - aDelta = aDelta - i*2; - PartSet_Tools::setFeaturePoint(aFeature, 100+aDelta, 200+aDelta, SketchPlugin_Line::START_ID()); - PartSet_Tools::setFeaturePoint(aFeature, 300+aDelta, 500+aDelta, SketchPlugin_Line::END_ID()); - - boost::shared_ptr aPreview = PartSet_OperationSketchBase::preview(aFeature); - Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation( - aFeature, aSketch, - aPreview ? aPreview->impl() : TopoDS_Shape(), NULL); - if (!anAIS.IsNull()) - aDisplayer->redisplay(aFeature, anAIS, true); - - int aVal = 90; - for (int j = 0; j < 10000000; j++) - aVal = aVal/aVal+aVal*2; - }*/ + for (int i = 0; i < 20; i++) { + aDelta = aDelta - i*2; + PartSet_Tools::setFeaturePoint(aFeature, 100+aDelta, 200+aDelta, SketchPlugin_Line::START_ID()); + PartSet_Tools::setFeaturePoint(aFeature, 300+aDelta, 500+aDelta, SketchPlugin_Line::END_ID()); + + boost::shared_ptr aPreview = PartSet_OperationSketchBase::preview(aFeature); + Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation( + aFeature, aSketch, + aPreview ? aPreview->impl() : TopoDS_Shape(), NULL); + if (!anAIS.IsNull()) + aDisplayer->redisplay(aFeature, anAIS, true); + + int aVal = 90; + for (int j = 0; j < 10000000; j++) + aVal = aVal/aVal+aVal*2; + }*/ //std::list aModes; //aModes.clear(); //aModes.push_back(TopAbs_VERTEX); @@ -206,8 +207,8 @@ void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop) //boost::shared_ptr aPreview = PartSet_OperationSketchBase::preview(aFeature); boost::shared_ptr aPrevAIS; - boost::shared_ptr aSPFeature = - boost::dynamic_pointer_cast(aFeature); + boost::shared_ptr aSPFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(aFeature); //boost::shared_ptr anAIS = aSPFeature->getAISObject(aPrevAIS); //if (!anAIS->empty()) theWorkshop->displayer()->display(aFeature, true); @@ -219,8 +220,8 @@ void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop) //aDisplayer->activateInLocalContext(aFeature, aModes, true); /*QFeatureList aFeatureList; - aFeatureList.append(myTestObject); - theWorkshop->displayer()->setSelected(aFeatureList, true);*/ + aFeatureList.append(myTestObject); + theWorkshop->displayer()->setSelected(aFeatureList, true);*/ theWorkshop->displayer()->updateViewer(); } diff --git a/src/PartSet/PartSet_TestOCC.h b/src/PartSet/PartSet_TestOCC.h index e4b8dd005..757b344cd 100644 --- a/src/PartSet/PartSet_TestOCC.h +++ b/src/PartSet/PartSet_TestOCC.h @@ -14,11 +14,14 @@ class Handle_V3d_View; /*! \class PartSet_TestOCC * \brief The operation to test OCC viewer work -*/ + */ class PARTSET_EXPORT PartSet_TestOCC { -public: - PartSet_TestOCC() {}; + public: + PartSet_TestOCC() + { + } + ; /// Creates a line feature, select it, modify the line. Check whether the highlight is correct. /// \param the workshop to provide an access to the application information @@ -38,7 +41,7 @@ public: static void local_selection_erase(Handle_AIS_InteractiveContext theContext, Handle_V3d_View theView); -private: + private: /// Creates a temporary line /// \param the workshop to get the operation manager and the displayer diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 08c362a43..92c66ffbe 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -63,12 +63,14 @@ gp_Pnt PartSet_Tools::convertClickToPoint(QPoint thePoint, Handle(V3d_View) theV gp_Pnt ConvertedPoint(X, Y, Z); gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project(PlaneOfTheView, ConvertedPoint); - gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView); + gp_Pnt ResultPoint = ElSLib::Value(ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), + PlaneOfTheView); return ResultPoint; } void PartSet_Tools::convertTo2D(const gp_Pnt& thePoint, FeaturePtr theSketch, - Handle(V3d_View) theView, double& theX, double& theY) +Handle(V3d_View) theView, + double& theX, double& theY) { if (!theSketch) return; @@ -76,19 +78,18 @@ void PartSet_Tools::convertTo2D(const gp_Pnt& thePoint, FeaturePtr theSketch, AttributeDoublePtr anAttr; boost::shared_ptr aData = theSketch->data(); - boost::shared_ptr anOrigin = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + boost::shared_ptr anOrigin = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); - boost::shared_ptr aX = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::DIRX_ID())); - boost::shared_ptr anY = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::DIRY_ID())); + boost::shared_ptr aX = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::DIRX_ID())); + boost::shared_ptr anY = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::DIRY_ID())); gp_Pnt anOriginPnt(anOrigin->x(), anOrigin->y(), anOrigin->z()); gp_Vec aVec(anOriginPnt, thePoint); - if (!theView.IsNull()) - { + if (!theView.IsNull()) { V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt; theView->Eye(XEye, YEye, ZEye); @@ -99,22 +100,21 @@ void PartSet_Tools::convertTo2D(const gp_Pnt& thePoint, FeaturePtr theSketch, gp_Vec anEyeVec(EyePoint, AtPoint); anEyeVec.Normalize(); - boost::shared_ptr aNormal = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::NORM_ID())); + boost::shared_ptr aNormal = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::NORM_ID())); gp_Vec aNormalVec(aNormal->x(), aNormal->y(), aNormal->z()); double aDen = anEyeVec * aNormalVec; double aLVec = aDen != 0 ? aVec * aNormalVec / aDen : DBL_MAX; - gp_Vec aDeltaVec = anEyeVec*aLVec; + gp_Vec aDeltaVec = anEyeVec * aLVec; aVec = aVec - aDeltaVec; } theX = aVec.X() * aX->x() + aVec.Y() * aX->y() + aVec.Z() * aX->z(); theY = aVec.X() * anY->x() + aVec.Y() * anY->y() + aVec.Z() * anY->z(); } -void PartSet_Tools::convertTo3D(const double theX, const double theY, - FeaturePtr theSketch, +void PartSet_Tools::convertTo3D(const double theX, const double theY, FeaturePtr theSketch, gp_Pnt& thePoint) { if (!theSketch) @@ -122,15 +122,15 @@ void PartSet_Tools::convertTo3D(const double theX, const double theY, boost::shared_ptr aData = theSketch->data(); - boost::shared_ptr aC = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); - boost::shared_ptr aX = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::DIRX_ID())); - boost::shared_ptr aY = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::DIRY_ID())); + boost::shared_ptr aC = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + boost::shared_ptr aX = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::DIRX_ID())); + boost::shared_ptr aY = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::DIRY_ID())); - boost::shared_ptr aSum = aC->pnt()->xyz()->added( - aX->dir()->xyz()->multiplied(theX))->added(aY->dir()->xyz()->multiplied(theY)); + boost::shared_ptr aSum = aC->pnt()->xyz()->added(aX->dir()->xyz()->multiplied(theX)) + ->added(aY->dir()->xyz()->multiplied(theY)); boost::shared_ptr aPoint = boost::shared_ptr(new GeomAPI_Pnt(aSum)); thePoint = gp_Pnt(aPoint->x(), aPoint->y(), aPoint->z()); @@ -145,21 +145,22 @@ FeaturePtr PartSet_Tools::nearestFeature(QPoint thePoint, Handle_V3d_View theVie PartSet_Tools::convertTo2D(aPoint, theSketch, theView, aX, anY); FeaturePtr aFeature; - std::list::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end(); + std::list::const_iterator anIt = theFeatures.begin(), aLast = theFeatures + .end(); - FeaturePtr aDeltaFeature; + FeaturePtr aDeltaFeature; double aMinDelta = -1; ModuleBase_ViewerPrs aPrs; for (; anIt != aLast; anIt++) { aPrs = *anIt; if (!aPrs.object()) continue; - boost::shared_ptr aSketchFeature = - boost::dynamic_pointer_cast(aPrs.object()); + boost::shared_ptr aSketchFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(aPrs.object()); if (!aSketchFeature) continue; double aDelta = aSketchFeature->distanceToPoint( - boost::shared_ptr(new GeomAPI_Pnt2d(aX, anY))); + boost::shared_ptr(new GeomAPI_Pnt2d(aX, anY))); if (aMinDelta < 0 || aMinDelta > aDelta) { aMinDelta = aDelta; // TODO aDeltaFeature = aPrs.result(); @@ -179,8 +180,8 @@ void PartSet_Tools::setFeaturePoint(FeaturePtr theFeature, double theX, double t if (!theFeature) return; boost::shared_ptr aData = theFeature->data(); - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(aData->attribute(theAttribute)); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + aData->attribute(theAttribute)); if (aPoint) aPoint->setValue(theX, theY); } @@ -191,8 +192,8 @@ void PartSet_Tools::setFeatureValue(FeaturePtr theFeature, double theValue, if (!theFeature) return; boost::shared_ptr aData = theFeature->data(); - AttributeDoublePtr anAttribute = - boost::dynamic_pointer_cast(aData->attribute(theAttribute)); + AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast( + aData->attribute(theAttribute)); if (anAttribute) anAttribute->setValue(theValue); } @@ -204,8 +205,8 @@ double PartSet_Tools::featureValue(FeaturePtr theFeature, const std::string& the double aValue; if (theFeature) { boost::shared_ptr aData = theFeature->data(); - AttributeDoublePtr anAttribute = - boost::dynamic_pointer_cast(aData->attribute(theAttribute)); + AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast( + aData->attribute(theAttribute)); if (anAttribute) { aValue = anAttribute->value(); isValid = true; @@ -222,8 +223,8 @@ FeaturePtr PartSet_Tools::feature(FeaturePtr theFeature, const std::string& theA return aFeature; boost::shared_ptr aData = theFeature->data(); - boost::shared_ptr anAttr = - boost::dynamic_pointer_cast(aData->attribute(theAttribute)); + boost::shared_ptr anAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(theAttribute)); if (anAttr) { aFeature = boost::dynamic_pointer_cast(anAttr->object()); if (!theKind.empty() && aFeature && aFeature->getKind() != theKind) { @@ -241,58 +242,57 @@ void PartSet_Tools::createConstraint(FeaturePtr theSketch, FeaturePtr aFeature = aDoc->addFeature(SketchPlugin_ConstraintCoincidence::ID()); if (theSketch) { - boost::shared_ptr aSketch = - boost::dynamic_pointer_cast(theSketch); + boost::shared_ptr aSketch = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(theSketch); aSketch->addSub(aFeature); } boost::shared_ptr aData = aFeature->data(); - boost::shared_ptr aRef1 = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); + boost::shared_ptr aRef1 = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); aRef1->setAttr(thePoint1); - boost::shared_ptr aRef2 = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::ENTITY_B())); + boost::shared_ptr aRef2 = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B())); aRef2->setAttr(thePoint2); - if (aFeature) // TODO: generate an error if feature was not created + if (aFeature) // TODO: generate an error if feature was not created aFeature->execute(); } void PartSet_Tools::setConstraints(FeaturePtr theSketch, FeaturePtr theFeature, - const std::string& theAttribute, - double theClickedX, double theClickedY) + const std::string& theAttribute, double theClickedX, + double theClickedY) { // find a feature point by the selection mode //boost::shared_ptr aPoint = featurePoint(theMode); - boost::shared_ptr aFeaturePoint = - boost::dynamic_pointer_cast(theFeature->data()->attribute(theAttribute)); + boost::shared_ptr aFeaturePoint = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(theFeature->data()->attribute(theAttribute)); if (!aFeaturePoint) return; // get all sketch features. If the point with the given coordinates belong to any sketch feature, // the constraint is created between the feature point and the found sketch point boost::shared_ptr aData = theSketch->data(); - boost::shared_ptr aRefList = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::FEATURES_ID())); + boost::shared_ptr aRefList = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID())); - std::list aFeatures = aRefList->list(); - std::list::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); + std::list aFeatures = aRefList->list(); + std::list::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); std::list > anAttiributes; - boost::shared_ptr aClickedPoint = boost::shared_ptr - (new GeomAPI_Pnt2d(theClickedX, theClickedY)); - for (; anIt != aLast; anIt++) - { + boost::shared_ptr aClickedPoint = boost::shared_ptr( + new GeomAPI_Pnt2d(theClickedX, theClickedY)); + for (; anIt != aLast; anIt++) { FeaturePtr aFeature = boost::dynamic_pointer_cast(*anIt); // find the given point in the feature attributes anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::type()); std::list >::const_iterator anIt = anAttiributes.begin(), - aLast = anAttiributes.end(); + aLast = anAttiributes.end(); boost::shared_ptr aFPoint; - for (;anIt!=aLast && !aFPoint; anIt++) { - boost::shared_ptr aCurPoint = - boost::dynamic_pointer_cast(*anIt); + for (; anIt != aLast && !aFPoint; anIt++) { + boost::shared_ptr aCurPoint = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(*anIt); if (aCurPoint && aCurPoint->pnt()->distance(aClickedPoint) < Precision::Confusion()) aFPoint = aCurPoint; } @@ -307,10 +307,10 @@ boost::shared_ptr PartSet_Tools::sketchPlane(FeaturePtr theSketch) double aA, aB, aC, aD; boost::shared_ptr aData = theSketch->data(); - boost::shared_ptr anOrigin = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); - boost::shared_ptr aNormal = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::NORM_ID())); + boost::shared_ptr anOrigin = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + boost::shared_ptr aNormal = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::NORM_ID())); aA = aNormal->x(); aB = aNormal->y(); aC = aNormal->z(); @@ -320,27 +320,26 @@ boost::shared_ptr PartSet_Tools::sketchPlane(FeaturePtr theSketch) return aPlane; } -boost::shared_ptr PartSet_Tools::point3D( - boost::shared_ptr thePoint2D, - FeaturePtr theSketch) +boost::shared_ptr PartSet_Tools::point3D(boost::shared_ptr thePoint2D, + FeaturePtr theSketch) { boost::shared_ptr aPoint; if (!theSketch || !thePoint2D) return aPoint; - boost::shared_ptr aC = - boost::dynamic_pointer_cast(theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); - boost::shared_ptr aX = - boost::dynamic_pointer_cast(theSketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - boost::shared_ptr aY = - boost::dynamic_pointer_cast(theSketch->data()->attribute(SketchPlugin_Sketch::DIRY_ID())); + boost::shared_ptr aC = boost::dynamic_pointer_cast( + theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + boost::shared_ptr aX = boost::dynamic_pointer_cast( + theSketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID())); + boost::shared_ptr aY = boost::dynamic_pointer_cast( + theSketch->data()->attribute(SketchPlugin_Sketch::DIRY_ID())); return thePoint2D->to3D(aC->pnt(), aX->dir(), aY->dir()); } bool PartSet_Tools::isConstraintFeature(const std::string& theKind) { - return theKind == SketchPlugin_ConstraintDistance::ID() || - theKind == SketchPlugin_ConstraintLength::ID() || - theKind == SketchPlugin_ConstraintRadius::ID(); + return theKind == SketchPlugin_ConstraintDistance::ID() + || theKind == SketchPlugin_ConstraintLength::ID() + || theKind == SketchPlugin_ConstraintRadius::ID(); } diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h index 1cd763ca0..d1b5b4d5c 100644 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -27,10 +27,10 @@ class GeomAPI_Pnt; /*! \class PartSet_Tools * \brief The operation for the sketch feature creation -*/ + */ class PARTSET_EXPORT PartSet_Tools { -public: + public: /// Converts the 2D screen point to the 3D point on the view according to the point of view /// \param thePoint a screen point /// \param theView a 3D view @@ -42,7 +42,8 @@ public: /// \param theX the X coordinate /// \param theY the Y coordinate static void convertTo2D(const gp_Pnt& thePoint, FeaturePtr theSketch, - Handle(V3d_View) theView, double& theX, double& theY); + Handle(V3d_View) theView, + double& theX, double& theY); /// \brief Converts the 2D projected coodinates on the sketch plane to the 3D point. /// \param theX the X coordinate @@ -82,8 +83,7 @@ public: /// \param theAttribute the feature attribute /// \param isValid an output parameter whether the value is valid /// \returns the feature value - static double featureValue(FeaturePtr theFeature, const std::string& theAttribute, - bool& isValid); + static double featureValue(FeaturePtr theFeature, const std::string& theAttribute, bool& isValid); /// Find a feature in the attribute of the given feature. If the kind is not empty, /// the return feature should be this type. Otherwise it is null @@ -92,7 +92,7 @@ public: /// \param theKind an output feature kind /// \return the feature static FeaturePtr feature(FeaturePtr theFeature, const std::string& theAttribute, - const std::string& theKind); + const std::string& theKind); /// Creates a constraint on two points /// \param thePoint1 the first point @@ -108,7 +108,8 @@ public: /// \param theClickedX the horizontal coordnate of the point /// \param theClickedY the vertical coordnate of the point static void setConstraints(FeaturePtr theSketch, FeaturePtr theFeature, - const std::string& theAttribute, double theClickedX, double theClickedY); + const std::string& theAttribute, double theClickedX, + double theClickedY); /// Create a sketch plane instance /// \param theSketch a sketch feature diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index 7a3d43fe7..d464e85ab 100644 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -12,7 +12,6 @@ #include - int shapesNbPoints(const ModuleBase_ISelection* theSelection) { std::list aList = theSelection->getSelected(); diff --git a/src/PartSet/PartSet_Validators.h b/src/PartSet/PartSet_Validators.h index 94bab7756..02f7d21e6 100644 --- a/src/PartSet/PartSet_Validators.h +++ b/src/PartSet/PartSet_Validators.h @@ -11,43 +11,42 @@ #include /* -* Selector validators -*/ + * Selector validators + */ //! A class to validate a selection for Distance constraint operation -class PartSet_DistanceValidator: public ModuleBase_SelectionValidator +class PartSet_DistanceValidator : public ModuleBase_SelectionValidator { -public: + public: PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; }; //! A class to validate a selection for Length constraint operation -class PartSet_LengthValidator: public ModuleBase_SelectionValidator +class PartSet_LengthValidator : public ModuleBase_SelectionValidator { -public: + public: PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; }; //! A class to validate a selection for Perpendicular constraint operation -class PartSet_PerpendicularValidator: public ModuleBase_SelectionValidator +class PartSet_PerpendicularValidator : public ModuleBase_SelectionValidator { -public: + public: PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; }; //! A class to validate a selection for Perpendicular constraint operation -class PartSet_ParallelValidator: public ModuleBase_SelectionValidator +class PartSet_ParallelValidator : public ModuleBase_SelectionValidator { -public: + public: PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; }; //! A class to validate a selection for Perpendicular constraint operation -class PartSet_RadiusValidator: public ModuleBase_SelectionValidator +class PartSet_RadiusValidator : public ModuleBase_SelectionValidator { -public: + public: PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const; }; - #endif diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 6089ab850..bbcd7c177 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -12,10 +12,10 @@ #include -PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent, - const Config_WidgetAPI* theData, - const std::string& theParentId) -: ModuleBase_ModelWidget(theParent, theData, theParentId) +PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent, + const Config_WidgetAPI* theData, + const std::string& theParentId) + : ModuleBase_ModelWidget(theParent, theData, theParentId) { myText = QString::fromStdString(theData->getProperty("title")); myLabel = new QLabel(myText, theParent); @@ -27,7 +27,7 @@ PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent, QList PartSet_WidgetSketchLabel::getControls() const { QList aLst; - aLst<currentOperation(); if (aOperation->inherits("PartSet_OperationSketch")) { PartSet_OperationSketch* aSketchOpe = static_cast(aOperation); updateLabel(aSketchOpe); - connect(aSketchOpe, SIGNAL(planeSelected(double, double, double)), - this, SLOT(onPlaneSelected())); + connect(aSketchOpe, SIGNAL(planeSelected(double, double, double)), this, + SLOT(onPlaneSelected())); } } @@ -64,4 +62,4 @@ void PartSet_WidgetSketchLabel::updateLabel(PartSet_OperationSketch* theSketchOp myLabel->setText(myText); myLabel->setToolTip(myTooltip); } -} \ No newline at end of file +} diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 98cae8a48..442f31907 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -10,24 +10,32 @@ #include class QLabel; -class XGUI_OperationMgr; +class XGUI_OperationMgr; class PartSet_OperationSketch; class PARTSET_EXPORT PartSet_WidgetSketchLabel : public ModuleBase_ModelWidget { - Q_OBJECT -public: - PartSet_WidgetSketchLabel(QWidget* theParent, - const Config_WidgetAPI* theData, - const std::string& theParentId); +Q_OBJECT + public: + PartSet_WidgetSketchLabel(QWidget* theParent, const Config_WidgetAPI* theData, + const std::string& theParentId); - virtual ~PartSet_WidgetSketchLabel() {}; + virtual ~PartSet_WidgetSketchLabel() + { + } + ; /// Saves the internal parameters to the given feature /// \param theFeature a model feature to be changed - virtual bool storeValue() const { return true;} + virtual bool storeValue() const + { + return true; + } - virtual bool restoreValue() { return true;} + virtual bool restoreValue() + { + return true; + } /// Returns list of widget controls /// \return a control list @@ -37,10 +45,10 @@ public: void setOperationsMgr(XGUI_OperationMgr* theMgr); -private slots: + private slots: void onPlaneSelected(); -private: + private: void updateLabel(PartSet_OperationSketch* theSketchOpe); QLabel* myLabel; @@ -48,4 +56,4 @@ private: QString myTooltip; }; -#endif \ No newline at end of file +#endif diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp index 28c8ce3de..7f94e6943 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp @@ -22,19 +22,18 @@ void PartSetPlugin_Duplicate::initAttributes() boost::shared_ptr aPManager = ModelAPI_PluginManager::get(); boost::shared_ptr aRoot = aPManager->rootDocument(); - boost::shared_ptr aSource; // searching for source document attribute - for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) { + boost::shared_ptr aSource; // searching for source document attribute + for (int a = aRoot->size(getGroup()) - 1; a >= 0; a--) { aSource = boost::dynamic_pointer_cast(aRoot->object(getGroup(), a)); - if (aSource && aSource->data() && - aSource->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value() == - aPManager->currentDocument()) + if (aSource && aSource->data() + && aSource->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value() + == aPManager->currentDocument()) break; aSource.reset(); } if (aSource) { boost::shared_ptr aCopy = aPManager->copy( - aSource->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value(), - data()->name()); + aSource->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value(), data()->name()); data()->refattr(ORIGIN_REF())->setObject(aSource); } } diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.h b/src/PartSetPlugin/PartSetPlugin_Duplicate.h index 446b6f325..b5e48183f 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.h +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.h @@ -11,9 +11,9 @@ * \ingroup DataModel * \brief Duplicates the active part (not root). Creates a new "part" feature. */ -class PartSetPlugin_Duplicate: public PartSetPlugin_Part +class PartSetPlugin_Duplicate : public PartSetPlugin_Part { -public: + public: /// the reference to copy: reference to the attribute inline static const std::string& ORIGIN_REF() { diff --git a/src/PartSetPlugin/PartSetPlugin_Part.cpp b/src/PartSetPlugin/PartSetPlugin_Part.cpp index e2b47f4ce..edb6ddac3 100644 --- a/src/PartSetPlugin/PartSetPlugin_Part.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Part.cpp @@ -16,26 +16,27 @@ PartSetPlugin_Part::PartSetPlugin_Part() } void PartSetPlugin_Part::initAttributes() -{// all is in part result +{ // all is in part result } -void PartSetPlugin_Part::execute() +void PartSetPlugin_Part::execute() { ResultPartPtr aResult = boost::dynamic_pointer_cast(firstResult()); if (!aResult) { aResult = document()->createPart(data()); setResult(aResult); } - boost::shared_ptr aDocRef = - aResult->data()->docRef(ModelAPI_ResultPart::DOC_REF()); + boost::shared_ptr aDocRef = aResult->data()->docRef( + ModelAPI_ResultPart::DOC_REF()); - if (!aDocRef->value()) { // create a document if not yet created - boost::shared_ptr aPartSetDoc = - ModelAPI_PluginManager::get()->rootDocument(); + if (!aDocRef->value()) { // create a document if not yet created + boost::shared_ptr aPartSetDoc = + ModelAPI_PluginManager::get()->rootDocument(); aDocRef->setValue(aPartSetDoc->subDocument(data()->name())); } } -boost::shared_ptr PartSetPlugin_Part::documentToAdd() { +boost::shared_ptr PartSetPlugin_Part::documentToAdd() +{ return ModelAPI_PluginManager::get()->rootDocument(); } diff --git a/src/PartSetPlugin/PartSetPlugin_Part.h b/src/PartSetPlugin/PartSetPlugin_Part.h index 10cdebb85..ef1dd528c 100644 --- a/src/PartSetPlugin/PartSetPlugin_Part.h +++ b/src/PartSetPlugin/PartSetPlugin_Part.h @@ -12,9 +12,9 @@ * \ingroup DataModel * \brief Feature for creation of the new part in PartSet. */ -class PartSetPlugin_Part: public ModelAPI_Feature +class PartSetPlugin_Part : public ModelAPI_Feature { -public: + public: /// Part kind inline static const std::string& ID() { @@ -22,12 +22,18 @@ public: return MY_PART_KIND; } /// Returns the kind of a feature - PARTSETPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = PartSetPlugin_Part::ID(); return MY_KIND;} + PARTSETPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = PartSetPlugin_Part::ID(); + return MY_KIND; + } /// Returns to which group in the document must be added feature - PARTSETPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = "Parts"; return MY_GROUP;} + PARTSETPLUGIN_EXPORT virtual const std::string& getGroup() + { + static std::string MY_GROUP = "Parts"; + return MY_GROUP; + } /// Creates a new part document if needed PARTSETPLUGIN_EXPORT virtual void execute(); @@ -38,7 +44,10 @@ public: PARTSETPLUGIN_EXPORT virtual boost::shared_ptr documentToAdd(); /// Returns true if this feature must be displayed in the history (top level of Part tree) - PARTSETPLUGIN_EXPORT virtual bool isInHistory() {return false;} + PARTSETPLUGIN_EXPORT virtual bool isInHistory() + { + return false; + } /// Use plugin manager for features creation PartSetPlugin_Part(); diff --git a/src/PartSetPlugin/PartSetPlugin_Plugin.cpp b/src/PartSetPlugin/PartSetPlugin_Plugin.cpp index dc384608e..6dfc43704 100644 --- a/src/PartSetPlugin/PartSetPlugin_Plugin.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Plugin.cpp @@ -10,7 +10,7 @@ using namespace std; // the only created instance of this plugin static PartSetPlugin_Plugin* MY_INSTANCE = new PartSetPlugin_Plugin(); -PartSetPlugin_Plugin::PartSetPlugin_Plugin() +PartSetPlugin_Plugin::PartSetPlugin_Plugin() { // register this plugin ModelAPI_PluginManager::get()->registerPlugin(this); @@ -27,6 +27,6 @@ FeaturePtr PartSetPlugin_Plugin::createFeature(string theFeatureID) if (theFeatureID == "remove") { return FeaturePtr(new PartSetPlugin_Remove); } - // feature of such kind is not found + // feature of such kind is not found return FeaturePtr(); } diff --git a/src/PartSetPlugin/PartSetPlugin_Plugin.h b/src/PartSetPlugin/PartSetPlugin_Plugin.h index 1ffda8a72..e8e9e702b 100644 --- a/src/PartSetPlugin/PartSetPlugin_Plugin.h +++ b/src/PartSetPlugin/PartSetPlugin_Plugin.h @@ -5,18 +5,17 @@ #ifndef PartSetPlugin_Plugin_H_ #define PartSetPlugin_Plugin_H_ - #include "PartSetPlugin.h" #include "ModelAPI_Plugin.h" #include "ModelAPI_Feature.h" -class PARTSETPLUGIN_EXPORT PartSetPlugin_Plugin: public ModelAPI_Plugin +class PARTSETPLUGIN_EXPORT PartSetPlugin_Plugin : public ModelAPI_Plugin { -public: + public: /// Creates the feature object of this plugin by the feature string ID virtual FeaturePtr createFeature(std::string theFeatureID); -public: + public: /// Is needed for python wrapping by swig PartSetPlugin_Plugin(); }; diff --git a/src/PartSetPlugin/PartSetPlugin_Remove.cpp b/src/PartSetPlugin/PartSetPlugin_Remove.cpp index d7dbf434c..28ee6b797 100644 --- a/src/PartSetPlugin/PartSetPlugin_Remove.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Remove.cpp @@ -15,12 +15,12 @@ void PartSetPlugin_Remove::execute() boost::shared_ptr aRoot = aPManager->rootDocument(); boost::shared_ptr aCurrent; boost::shared_ptr a; - for(int a = aRoot->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) { + for (int a = aRoot->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) { ResultPartPtr aPart = boost::dynamic_pointer_cast( - aRoot->object(ModelAPI_ResultPart::group(), a)); - if (aPart && aPart->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value() == - aPManager->currentDocument()) - { + aRoot->object(ModelAPI_ResultPart::group(), a)); + if (aPart + && aPart->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value() + == aPManager->currentDocument()) { FeaturePtr aFeature = aRoot->feature(aPart); if (aFeature) { // do remove diff --git a/src/PartSetPlugin/PartSetPlugin_Remove.h b/src/PartSetPlugin/PartSetPlugin_Remove.h index 20ccef4a0..bbb23be03 100644 --- a/src/PartSetPlugin/PartSetPlugin_Remove.h +++ b/src/PartSetPlugin/PartSetPlugin_Remove.h @@ -12,9 +12,9 @@ * \ingroup DataModel * \brief Feature for creation of the new part in PartSet. */ -class PartSetPlugin_Remove: public ModelAPI_Feature +class PartSetPlugin_Remove : public ModelAPI_Feature { -public: + public: /// Remove kind inline static const std::string& ID() { @@ -22,24 +22,37 @@ public: return MY_REMOVE_KIND; } /// Returns the kind of a feature - PARTSETPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = PartSetPlugin_Remove::ID(); return MY_KIND;} + PARTSETPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = PartSetPlugin_Remove::ID(); + return MY_KIND; + } /// Returns to which group in the document must be added feature - PARTSETPLUGIN_EXPORT virtual const std::string& getGroup() - {static std::string MY_GROUP = "Parts"; return MY_GROUP;} + PARTSETPLUGIN_EXPORT virtual const std::string& getGroup() + { + static std::string MY_GROUP = "Parts"; + return MY_GROUP; + } /// Request for initialization of data model of the feature: adding all attributes - PARTSETPLUGIN_EXPORT virtual void initAttributes() {} + PARTSETPLUGIN_EXPORT virtual void initAttributes() + { + } /// Not normal feature that stored in the tree - PARTSETPLUGIN_EXPORT virtual bool isAction() {return true;} + PARTSETPLUGIN_EXPORT virtual bool isAction() + { + return true; + } /// Performs the "remove" PARTSETPLUGIN_EXPORT virtual void execute(); /// Use plugin manager for features creation - PartSetPlugin_Remove() {} + PartSetPlugin_Remove() + { + } }; #endif diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index 542ed47c5..21e616aef 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -18,72 +18,65 @@ const double tolerance = 1e-7; SketchPlugin_Arc::SketchPlugin_Arc() - : SketchPlugin_Feature() + : SketchPlugin_Feature() { } void SketchPlugin_Arc::initAttributes() { data()->addAttribute(SketchPlugin_Arc::CENTER_ID(), GeomDataAPI_Point2D::type()); - data()->addAttribute(SketchPlugin_Arc::START_ID(), GeomDataAPI_Point2D::type()); - data()->addAttribute(SketchPlugin_Arc::END_ID(), GeomDataAPI_Point2D::type()); + data()->addAttribute(SketchPlugin_Arc::START_ID(), GeomDataAPI_Point2D::type()); + data()->addAttribute(SketchPlugin_Arc::END_ID(), GeomDataAPI_Point2D::type()); } -void SketchPlugin_Arc::execute() +void SketchPlugin_Arc::execute() { SketchPlugin_Sketch* aSketch = sketch(); if (aSketch) { std::list > aShapes; // compute a circle point in 3D view - boost::shared_ptr aCenterAttr = - boost::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Arc::CENTER_ID())); - // compute the arc start point - boost::shared_ptr aStartAttr = - boost::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Arc::START_ID())); - if (aCenterAttr->isInitialized() && aStartAttr->isInitialized()) { - boost::shared_ptr aCenter( - aSketch->to3D(aCenterAttr->x(), aCenterAttr->y())); + boost::shared_ptr aCenterAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::CENTER_ID())); + // compute the arc start point + boost::shared_ptr aStartAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::START_ID())); + if (aCenterAttr->isInitialized() && aStartAttr->isInitialized()) { + boost::shared_ptr aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y())); // make a visible point boost::shared_ptr aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter); //aShapes.push_back(aCenterPointShape); - boost::shared_ptr aConstr1 = - document()->createConstruction(data(), 0); + boost::shared_ptr aConstr1 = document()->createConstruction( + data(), 0); aConstr1->setShape(aCenterPointShape); aConstr1->setIsInHistory(false); setResult(aConstr1, 0); - // make a visible circle - boost::shared_ptr aNDir = - boost::dynamic_pointer_cast( - aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); + boost::shared_ptr aNDir = boost::dynamic_pointer_cast( + aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0); if (aHasPlane) { boost::shared_ptr aNormal = aNDir->dir(); boost::shared_ptr aStartPoint(aSketch->to3D(aStartAttr->x(), aStartAttr->y())); // compute and change the arc end point - boost::shared_ptr anEndAttr = - boost::dynamic_pointer_cast(data()->attribute( - SketchPlugin_Arc::END_ID())); - if (anEndAttr->isInitialized()) - { + boost::shared_ptr anEndAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::END_ID())); + if (anEndAttr->isInitialized()) { boost::shared_ptr aCircleForArc( - new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt())); + new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt())); boost::shared_ptr aProjection = aCircleForArc->project(anEndAttr->pnt()); if (aProjection && anEndAttr->pnt()->distance(aProjection) > tolerance) anEndAttr->setValue(aProjection); } boost::shared_ptr aEndPoint(aSketch->to3D(anEndAttr->x(), anEndAttr->y())); - boost::shared_ptr aCircleShape = - GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStartPoint, aEndPoint, aNormal); + boost::shared_ptr aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircleArc( + aCenter, aStartPoint, aEndPoint, aNormal); if (aCircleShape) { - boost::shared_ptr aConstr2 = - document()->createConstruction(data(), 1); + boost::shared_ptr aConstr2 = document()->createConstruction( + data(), 1); aConstr2->setShape(aCircleShape); aConstr2->setIsInHistory(false); setResult(aConstr2, 1); @@ -91,14 +84,14 @@ void SketchPlugin_Arc::execute() } } /* - boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); - // store the result - boost::shared_ptr aConstr = - document()->createConstruction(data()); - aConstr->setShape(aCompound); - aConstr->setIsInHistory(false); - setResult(aConstr); - */ + boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); + // store the result + boost::shared_ptr aConstr = + document()->createConstruction(data()); + aConstr->setShape(aCompound); + aConstr->setIsInHistory(false); + setResult(aConstr); + */ } } } @@ -109,19 +102,16 @@ void SketchPlugin_Arc::move(double theDeltaX, double theDeltaY) if (!aData->isValid()) return; - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Arc::CENTER_ID())); + boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Arc::CENTER_ID())); aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); - boost::shared_ptr aPoint2 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Arc::START_ID())); + boost::shared_ptr aPoint2 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Arc::START_ID())); aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY); - boost::shared_ptr aPoint3 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Arc::END_ID())); + boost::shared_ptr aPoint3 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Arc::END_ID())); aPoint3->setValue(aPoint3->x() + theDeltaX, aPoint3->y() + theDeltaY); } @@ -130,21 +120,18 @@ double SketchPlugin_Arc::distanceToPoint(const boost::shared_ptr& double aDelta = 0; boost::shared_ptr aData = data(); - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Arc::CENTER_ID())); + boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Arc::CENTER_ID())); aDelta = aPoint1->pnt()->distance(thePoint); - boost::shared_ptr aPoint2 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Arc::START_ID())); + boost::shared_ptr aPoint2 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Arc::START_ID())); double aDistance = aPoint2->pnt()->distance(thePoint); if (aDelta < aDistance) aDelta = aDistance; - boost::shared_ptr aPoint3 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Arc::END_ID())); + boost::shared_ptr aPoint3 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Arc::END_ID())); aDistance = aPoint3->pnt()->distance(thePoint); if (aDelta < aDistance) aDelta = aDistance; diff --git a/src/SketchPlugin/SketchPlugin_Arc.h b/src/SketchPlugin/SketchPlugin_Arc.h index 26815bc9e..00ada99b0 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.h +++ b/src/SketchPlugin/SketchPlugin_Arc.h @@ -14,9 +14,9 @@ * \ingroup DataModel * \brief Feature for creation of the new arc of circle in PartSet. */ -class SketchPlugin_Arc: public SketchPlugin_Feature//, public GeomAPI_IPresentable +class SketchPlugin_Arc : public SketchPlugin_Feature //, public GeomAPI_IPresentable { -public: + public: /// Arc feature kind inline static const std::string& ID() { @@ -45,7 +45,10 @@ public: /// Returns the kind of a feature SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SketchPlugin_Arc::ID(); return MY_KIND;} + { + static std::string MY_KIND = SketchPlugin_Arc::ID(); + return MY_KIND; + } /// Creates an arc-shape SKETCHPLUGIN_EXPORT virtual void execute(); @@ -55,7 +58,9 @@ public: /// Returns the AIS preview virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious) - {return simpleAISObject(firstResult(), thePrevious);} + { + return simpleAISObject(firstResult(), thePrevious); + } /// Moves the feature /// \param theDeltaX the delta for X coordinate is moved diff --git a/src/SketchPlugin/SketchPlugin_Circle.cpp b/src/SketchPlugin/SketchPlugin_Circle.cpp index 7dd1d3f60..635214f42 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.cpp +++ b/src/SketchPlugin/SketchPlugin_Circle.cpp @@ -16,7 +16,7 @@ #include SketchPlugin_Circle::SketchPlugin_Circle() - : SketchPlugin_Feature() + : SketchPlugin_Feature() { } @@ -33,52 +33,49 @@ void SketchPlugin_Circle::execute() std::list > aShapes; // compute a circle point in 3D view - boost::shared_ptr aCenterAttr = - boost::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Circle::CENTER_ID())); - AttributeDoublePtr aRadiusAttr = - boost::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Circle::RADIUS_ID())); + boost::shared_ptr aCenterAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Circle::CENTER_ID())); + AttributeDoublePtr aRadiusAttr = boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Circle::RADIUS_ID())); if (aCenterAttr->isInitialized() && aRadiusAttr->isInitialized()) { boost::shared_ptr aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y())); // make a visible point boost::shared_ptr aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter); //aShapes.push_back(aCenterPointShape); - boost::shared_ptr aConstr1 = - document()->createConstruction(data(), 0); + boost::shared_ptr aConstr1 = document()->createConstruction( + data(), 0); aConstr1->setShape(aCenterPointShape); aConstr1->setIsInHistory(false); setResult(aConstr1, 0); // make a visible circle - boost::shared_ptr aNDir = - boost::dynamic_pointer_cast(aSketch->data()->attribute( - SketchPlugin_Sketch::NORM_ID())); + boost::shared_ptr aNDir = boost::dynamic_pointer_cast( + aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0); if (aHasPlane) { boost::shared_ptr aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z())); // compute the circle radius double aRadius = aRadiusAttr->value(); - boost::shared_ptr aCircleShape = - GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius); + boost::shared_ptr aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircle( + aCenter, aNormal, aRadius); aShapes.push_back(aCircleShape); - boost::shared_ptr aConstr2 = - document()->createConstruction(data(), 1); + boost::shared_ptr aConstr2 = document()->createConstruction( + data(), 1); aConstr2->setShape(aCircleShape); aConstr2->setIsInHistory(false); setResult(aConstr2, 1); } } /* - boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); - // store the result - boost::shared_ptr aConstr = - document()->createConstruction(data()); - aConstr->setShape(aCompound); - aConstr->setIsInHistory(false); - setResult(aConstr); - */ + boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); + // store the result + boost::shared_ptr aConstr = + document()->createConstruction(data()); + aConstr->setShape(aCompound); + aConstr->setIsInHistory(false); + setResult(aConstr); + */ } } @@ -88,18 +85,16 @@ void SketchPlugin_Circle::move(double theDeltaX, double theDeltaY) if (!aData->isValid()) return; - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Circle::CENTER_ID())); + boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Circle::CENTER_ID())); aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); } double SketchPlugin_Circle::distanceToPoint(const boost::shared_ptr& thePoint) { boost::shared_ptr aData = data(); - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Circle::CENTER_ID())); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Circle::CENTER_ID())); return aPoint->pnt()->distance(thePoint); } diff --git a/src/SketchPlugin/SketchPlugin_Circle.h b/src/SketchPlugin/SketchPlugin_Circle.h index 5c7cc7aa7..c489f1014 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.h +++ b/src/SketchPlugin/SketchPlugin_Circle.h @@ -14,9 +14,9 @@ * \ingroup DataModel * \brief Feature for creation of the new circle in PartSet. */ -class SketchPlugin_Circle: public SketchPlugin_Feature//, public GeomAPI_IPresentable +class SketchPlugin_Circle : public SketchPlugin_Feature //, public GeomAPI_IPresentable { -public: + public: /// Circle feature kind inline static const std::string& ID() { @@ -39,8 +39,11 @@ public: } /// Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SketchPlugin_Circle::ID(); return MY_KIND;} + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = SketchPlugin_Circle::ID(); + return MY_KIND; + } /// Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); @@ -50,12 +53,16 @@ public: /// Returns the AIS preview virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious) - {return simpleAISObject(firstResult(), thePrevious);} + { + return simpleAISObject(firstResult(), thePrevious); + } /// Adds sub-feature of the higher level feature (sub-element of the sketch) /// \param theFeature sub-feature - SKETCHPLUGIN_EXPORT virtual const void addSub( - const FeaturePtr& theFeature) {}; + SKETCHPLUGIN_EXPORT virtual const void addSub(const FeaturePtr& theFeature) + { + } + ; /// Moves the feature /// \param theDeltaX the delta for X coordinate is moved diff --git a/src/SketchPlugin/SketchPlugin_Constraint.h b/src/SketchPlugin/SketchPlugin_Constraint.h index 01fbe230f..c621c58f5 100644 --- a/src/SketchPlugin/SketchPlugin_Constraint.h +++ b/src/SketchPlugin/SketchPlugin_Constraint.h @@ -16,9 +16,9 @@ const unsigned int CONSTRAINT_ATTR_SIZE = 4; * \brief Abstract interface to the SketchPlugin_ConstraintBase * For more info see: SketchPlugin_ConstraintBase.h */ -class SketchPlugin_Constraint: public SketchPlugin_Feature +class SketchPlugin_Constraint : public SketchPlugin_Feature { -public: + public: /// The value parameter for the constraint inline static const std::string& VALUE() { @@ -57,21 +57,29 @@ public: } /// List of constraint attributes - inline static const std::string& ATTRIBUTE(const int theNumber) { + inline static const std::string& ATTRIBUTE(const int theNumber) + { switch (theNumber) { - case 0: return ENTITY_A(); - case 1: return ENTITY_B(); - case 2: return ENTITY_C(); - case 3: return ENTITY_D(); - default: break; + case 0: + return ENTITY_A(); + case 1: + return ENTITY_B(); + case 2: + return ENTITY_C(); + case 3: + return ENTITY_D(); + default: + break; } static const std::string EMPTY_STRING(""); return EMPTY_STRING; } -protected: + protected: /// \brief Use plugin manager for features creation - SketchPlugin_Constraint() {} + SketchPlugin_Constraint() + { + } }; #endif diff --git a/src/SketchPlugin/SketchPlugin_ConstraintBase.cpp b/src/SketchPlugin/SketchPlugin_ConstraintBase.cpp index b743c0be3..f8ecab365 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintBase.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintBase.cpp @@ -5,7 +5,7 @@ #include "SketchPlugin_ConstraintBase.h" AISObjectPtr SketchPlugin_ConstraintBase::getAISObject(AISObjectPtr thePrevious) -{ +{ return thePrevious; } @@ -19,7 +19,8 @@ void SketchPlugin_ConstraintBase::move(const double theDeltaX, const double theD } -double SketchPlugin_ConstraintBase::distanceToPoint(const boost::shared_ptr& thePoint) +double SketchPlugin_ConstraintBase::distanceToPoint( + const boost::shared_ptr& thePoint) { return 0; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintBase.h b/src/SketchPlugin/SketchPlugin_ConstraintBase.h index e08bf7682..b027076cc 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintBase.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintBase.h @@ -15,7 +15,6 @@ #include - /* Description: * Each constraint uses a set of parameters. In the SolveSpace library * these parameters are named "valA", "ptA", "ptB", "entityA", "entityB". @@ -35,10 +34,9 @@ * Some feature's methods implemented here as dummy to * Base class for all constraints. */ -class SketchPlugin_ConstraintBase: public SketchPlugin_Constraint, - public GeomAPI_IPresentable +class SketchPlugin_ConstraintBase : public SketchPlugin_Constraint, public GeomAPI_IPresentable { -public: + public: /// Returns the AIS preview SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious); @@ -55,9 +53,11 @@ public: /// \param thePoint the point virtual double distanceToPoint(const boost::shared_ptr& thePoint); -protected: + protected: /// \brief Use plugin manager for features creation - SketchPlugin_ConstraintBase() {} + SketchPlugin_ConstraintBase() + { + } }; #endif diff --git a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h index e6595af30..78c580426 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.h @@ -17,9 +17,9 @@ * These constraint has two attributes: * SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() */ -class SketchPlugin_ConstraintCoincidence: public SketchPlugin_ConstraintBase +class SketchPlugin_ConstraintCoincidence : public SketchPlugin_ConstraintBase { -public: + public: /// Parallel constraint kind inline static const std::string& ID() { @@ -27,8 +27,11 @@ public: return MY_CONSTRAINT_COINCIDENCE_ID; } /// \brief Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SketchPlugin_ConstraintCoincidence::ID(); return MY_KIND;} + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = SketchPlugin_ConstraintCoincidence::ID(); + return MY_KIND; + } /// \brief Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index ab8bba036..e8ea4bfbe 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -23,7 +23,7 @@ SketchPlugin_ConstraintDistance::SketchPlugin_ConstraintDistance() //************************************************************************************* void SketchPlugin_ConstraintDistance::initAttributes() { - data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type()); + data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type()); data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type()); @@ -33,28 +33,27 @@ void SketchPlugin_ConstraintDistance::initAttributes() void SketchPlugin_ConstraintDistance::execute() { boost::shared_ptr aData = data(); - AttributeDoublePtr anAttr_Value = - boost::dynamic_pointer_cast( + AttributeDoublePtr anAttr_Value = boost::dynamic_pointer_cast( aData->attribute(SketchPlugin_Constraint::VALUE())); if (!anAttr_Value->isInitialized()) { - boost::shared_ptr aPoint_A = - getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_A()); - boost::shared_ptr aPoint_B = - getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_B()); - - if (aPoint_A && aPoint_B) { // both points - anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt())); + boost::shared_ptr aPoint_A = getFeaturePoint( + aData, SketchPlugin_Constraint::ENTITY_A()); + boost::shared_ptr aPoint_B = getFeaturePoint( + aData, SketchPlugin_Constraint::ENTITY_B()); + + if (aPoint_A && aPoint_B) { // both points + anAttr_Value->setValue(aPoint_A->pnt()->distance(aPoint_B->pnt())); } else { - if (!aPoint_A && aPoint_B) { //Line and point - boost::shared_ptr aLine = - getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A()); + if (!aPoint_A && aPoint_B) { //Line and point + boost::shared_ptr aLine = getFeatureLine( + aData, SketchPlugin_Constraint::ENTITY_A()); if (aLine) anAttr_Value->setValue(aLine->distanceToPoint(aPoint_B->pnt())); - } else if (aPoint_A && !aPoint_B) { // Point and line - boost::shared_ptr aLine = - getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B()); - if(aLine) + } else if (aPoint_A && !aPoint_B) { // Point and line + boost::shared_ptr aLine = getFeatureLine( + aData, SketchPlugin_Constraint::ENTITY_B()); + if (aLine) anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt())); } } @@ -70,8 +69,10 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi boost::shared_ptr aPlane = sketch()->plane(); DataPtr aData = data(); - boost::shared_ptr aPoint_A = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_A()); - boost::shared_ptr aPoint_B = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_B()); + boost::shared_ptr aPoint_A = getFeaturePoint( + aData, SketchPlugin_Constraint::ENTITY_A()); + boost::shared_ptr aPoint_B = getFeaturePoint( + aData, SketchPlugin_Constraint::ENTITY_B()); boost::shared_ptr aPnt_A; boost::shared_ptr aPnt_B; @@ -80,15 +81,15 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi aPnt_A = aPoint_A->pnt(); aPnt_B = aPoint_B->pnt(); } else if (!aPoint_A && aPoint_B) { - boost::shared_ptr aLine = - getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A()); + boost::shared_ptr aLine = getFeatureLine( + aData, SketchPlugin_Constraint::ENTITY_A()); if (aLine) { aPnt_B = aPoint_B->pnt(); aPnt_A = getProjectionPoint(aLine, aPnt_B); } } else if (aPoint_A && !aPoint_B) { - boost::shared_ptr aLine = - getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B()); + boost::shared_ptr aLine = getFeatureLine( + aData, SketchPlugin_Constraint::ENTITY_B()); if (aLine) { aPnt_A = aPoint_A->pnt(); aPnt_B = getProjectionPoint(aLine, aPnt_A); @@ -97,18 +98,18 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi if (!aPnt_A || !aPnt_B) return thePrevious; - boost::shared_ptr aFlyOutAttr = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); + boost::shared_ptr aFlyOutAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); boost::shared_ptr aPoint1 = sketch()->to3D(aPnt_A->x(), aPnt_A->y()); boost::shared_ptr aPoint2 = sketch()->to3D(aPnt_B->x(), aPnt_B->y()); - boost::shared_ptr aFlyoutPnt = aFlyOutAttr->isInitialized() ? - sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()) : - boost::shared_ptr(); + boost::shared_ptr aFlyoutPnt = + aFlyOutAttr->isInitialized() ? + sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()) : boost::shared_ptr(); // value calculation - boost::shared_ptr aValueAttr = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::VALUE())); + boost::shared_ptr aValueAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE())); double aValue = aValueAttr->value(); AISObjectPtr anAIS = thePrevious; @@ -117,7 +118,8 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue); // Set color from preferences - std::vector aRGB = Config_PropManager::color("Visualization", "distance_color", DISTANCE_COLOR); + std::vector aRGB = Config_PropManager::color("Visualization", "distance_color", + DISTANCE_COLOR); anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); return anAIS; } @@ -129,8 +131,8 @@ void SketchPlugin_ConstraintDistance::move(double theDeltaX, double theDeltaY) if (!aData->isValid()) return; - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); + boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); } @@ -144,32 +146,33 @@ boost::shared_ptr getFeaturePoint(DataPtr theData, return aPointAttr; FeaturePtr aFeature; - boost::shared_ptr anAttr = - boost::dynamic_pointer_cast(theData->attribute(theAttribute)); + boost::shared_ptr anAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute)); if (anAttr) aFeature = ModelAPI_Feature::feature(anAttr->object()); if (aFeature && aFeature->getKind() == SketchPlugin_Point::ID()) - aPointAttr = boost::dynamic_pointer_cast - (aFeature->data()->attribute(SketchPlugin_Point::COORD_ID())); + aPointAttr = boost::dynamic_pointer_cast( + aFeature->data()->attribute(SketchPlugin_Point::COORD_ID())); else if (aFeature && aFeature->getKind() == SketchPlugin_Circle::ID()) - aPointAttr = boost::dynamic_pointer_cast - (aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID())); + aPointAttr = boost::dynamic_pointer_cast( + aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID())); else if (anAttr->attr()) { - aPointAttr = boost::dynamic_pointer_cast(anAttr->attr()); + aPointAttr = boost::dynamic_pointer_cast(anAttr->attr()); } return aPointAttr; } //************************************************************************************* -boost::shared_ptr getFeatureLine(DataPtr theData, const std::string& theAttribute) +boost::shared_ptr getFeatureLine(DataPtr theData, + const std::string& theAttribute) { boost::shared_ptr aLine; if (!theData) return aLine; - boost::shared_ptr anAttr = - boost::dynamic_pointer_cast(theData->attribute(theAttribute)); + boost::shared_ptr anAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute)); if (anAttr) { FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object()); if (aFeature && aFeature->getKind() == SketchPlugin_Line::ID()) { @@ -180,16 +183,15 @@ boost::shared_ptr getFeatureLine(DataPtr theData, const std:: } //************************************************************************************* -boost::shared_ptr getProjectionPoint(const boost::shared_ptr& theLine, - const boost::shared_ptr& thePoint) +boost::shared_ptr getProjectionPoint( + const boost::shared_ptr& theLine, + const boost::shared_ptr& thePoint) { boost::shared_ptr aData = theLine->data(); - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Line::START_ID())); - boost::shared_ptr aPoint2 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Line::END_ID())); + boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Line::START_ID())); + boost::shared_ptr aPoint2 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Line::END_ID())); GeomAPI_Lin2d aLin2d(aPoint1->x(), aPoint1->y(), aPoint2->x(), aPoint2->y()); return aLin2d.project(thePoint); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h index 17d795a89..69ff19762 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.h @@ -25,9 +25,9 @@ class GeomDataAPI_Point2D; * These constraint has three attributes: * SketchPlugin_Constraint::VALUE(), SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() */ -class SketchPlugin_ConstraintDistance: public SketchPlugin_ConstraintBase +class SketchPlugin_ConstraintDistance : public SketchPlugin_ConstraintBase { -public: + public: /// Distance constraint kind inline static const std::string& ID() { @@ -36,8 +36,11 @@ public: } /// \brief Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SketchPlugin_ConstraintDistance::ID(); return MY_KIND;} + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = SketchPlugin_ConstraintDistance::ID(); + return MY_KIND; + } /// \brief Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); @@ -57,15 +60,15 @@ public: SketchPlugin_ConstraintDistance(); }; - /// Obtain the point object from specified constraint parameter boost::shared_ptr getFeaturePoint(DataPtr theData, - const std::string& theAttribute); - -boost::shared_ptr getFeatureLine(DataPtr theData, const std::string& theAttribute); + const std::string& theAttribute); -boost::shared_ptr getProjectionPoint(const boost::shared_ptr& theLine, - const boost::shared_ptr& thePoint); +boost::shared_ptr getFeatureLine(DataPtr theData, + const std::string& theAttribute); +boost::shared_ptr getProjectionPoint( + const boost::shared_ptr& theLine, + const boost::shared_ptr& thePoint); #endif diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index 248a9d2c0..94f23ae87 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -18,37 +18,36 @@ #include - SketchPlugin_ConstraintLength::SketchPlugin_ConstraintLength() { } void SketchPlugin_ConstraintLength::initAttributes() { - data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type()); + data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type()); data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type()); } void SketchPlugin_ConstraintLength::execute() { - if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized() && - !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) { + if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized() + && !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) { - boost::shared_ptr aRef = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); + boost::shared_ptr aRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object()); if (aFeature) { // set length value - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast(aFeature->data()->attribute(SketchPlugin_Line::START_ID())); - boost::shared_ptr aPoint2 = - boost::dynamic_pointer_cast(aFeature->data()->attribute(SketchPlugin_Line::END_ID())); + boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID())); + boost::shared_ptr aPoint2 = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID())); double aLenght = aPoint1->pnt()->distance(aPoint2->pnt()); - boost::shared_ptr aValueAttr = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Constraint::VALUE())); + boost::shared_ptr aValueAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE())); aValueAttr->setValue(aLenght); } } @@ -61,32 +60,32 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou boost::shared_ptr aPlane = sketch()->plane(); - boost::shared_ptr anAttr = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); + boost::shared_ptr anAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); if (!anAttr) return thePrevious; FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object()); if (!aFeature || aFeature->getKind() != SketchPlugin_Line::ID()) return thePrevious; - boost::shared_ptr aFlyOutAttr = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); + boost::shared_ptr aFlyOutAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); DataPtr aData = aFeature->data(); - boost::shared_ptr aStartPoint = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Line::START_ID())); - boost::shared_ptr anEndPoint = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Line::END_ID())); + boost::shared_ptr aStartPoint = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::START_ID())); + boost::shared_ptr anEndPoint = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID())); boost::shared_ptr aPoint1 = sketch()->to3D(aStartPoint->x(), aStartPoint->y()); - boost::shared_ptr aPoint2 = sketch()->to3D(anEndPoint->x(), anEndPoint->y()); - boost::shared_ptr aFlyoutPnt = aFlyOutAttr->isInitialized() ? - sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()) : - boost::shared_ptr(); + boost::shared_ptr aPoint2 = sketch()->to3D(anEndPoint->x(), anEndPoint->y()); + boost::shared_ptr aFlyoutPnt = + aFlyOutAttr->isInitialized() ? + sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()) : boost::shared_ptr(); // value calculation - boost::shared_ptr aValueAttr = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Constraint::VALUE())); + boost::shared_ptr aValueAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE())); double aValue = aValueAttr->value(); AISObjectPtr anAIS = thePrevious; @@ -106,8 +105,8 @@ void SketchPlugin_ConstraintLength::move(double theDeltaX, double theDeltaY) if (!aData->isValid()) return; - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); + boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.h b/src/SketchPlugin/SketchPlugin_ConstraintLength.h index 33afa8814..456c0c27c 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.h @@ -20,9 +20,9 @@ * SketchPlugin_Constraint::VALUE() (length) and SketchPlugin_Constraint::ENTITY_A() (segment), * SketchPlugin_Constraint::FLYOUT_VALUE_PNT() (distance of a constraints handle) */ -class SketchPlugin_ConstraintLength: public SketchPlugin_ConstraintBase +class SketchPlugin_ConstraintLength : public SketchPlugin_ConstraintBase { -public: + public: /// Length constraint kind inline static const std::string& ID() { @@ -30,8 +30,11 @@ public: return MY_CONSTRAINT_LENGTH_ID; } /// \brief Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SketchPlugin_ConstraintLength::ID(); return MY_KIND;} + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = SketchPlugin_ConstraintLength::ID(); + return MY_KIND; + } /// \brief Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp index c39b4b3db..3503ff45d 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp @@ -38,40 +38,41 @@ AISObjectPtr SketchPlugin_ConstraintParallel::getAISObject(AISObjectPtr thePrevi return thePrevious; boost::shared_ptr aData = data(); - boost::shared_ptr anAttr1 = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); - boost::shared_ptr anAttr2 = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::ENTITY_B())); - if (!anAttr1 || !anAttr1->isObject() || - !anAttr2 || !anAttr2->isObject()) + boost::shared_ptr anAttr1 = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); + boost::shared_ptr anAttr2 = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B())); + if (!anAttr1 || !anAttr1->isObject() || !anAttr2 || !anAttr2->isObject()) return thePrevious; FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr1->object()); if (!aFeature) return thePrevious; - boost::shared_ptr aLine1Feature = - boost::dynamic_pointer_cast(aFeature); + boost::shared_ptr aLine1Feature = + boost::dynamic_pointer_cast(aFeature); aFeature = ModelAPI_Feature::feature(anAttr2->object()); if (!aFeature) return thePrevious; - boost::shared_ptr aLine2Feature = - boost::dynamic_pointer_cast(aFeature); + boost::shared_ptr aLine2Feature = + boost::dynamic_pointer_cast(aFeature); if (!aLine1Feature || !aLine2Feature) return thePrevious; boost::shared_ptr aPlane = sketch()->plane(); boost::shared_ptr aLine1, aLine2; - boost::shared_ptr aConst1 = - boost::dynamic_pointer_cast(anAttr1->object()); - if (aConst1) aLine1 = aConst1->shape(); - boost::shared_ptr aConst2 = - boost::dynamic_pointer_cast(anAttr2->object()); - if (aConst2) aLine2 = aConst2->shape(); - - boost::shared_ptr aFlyoutAttr = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); + boost::shared_ptr aConst1 = boost::dynamic_pointer_cast< + ModelAPI_ResultConstruction>(anAttr1->object()); + if (aConst1) + aLine1 = aConst1->shape(); + boost::shared_ptr aConst2 = boost::dynamic_pointer_cast< + ModelAPI_ResultConstruction>(anAttr2->object()); + if (aConst2) + aLine2 = aConst2->shape(); + + boost::shared_ptr aFlyoutAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); boost::shared_ptr aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y()); AISObjectPtr anAIS = thePrevious; @@ -80,7 +81,8 @@ AISObjectPtr SketchPlugin_ConstraintParallel::getAISObject(AISObjectPtr thePrevi anAIS->createParallel(aLine1, aLine2, aFlyoutPnt, aPlane); // Set color from preferences - std::vector aRGB = Config_PropManager::color("Visualization", "parallel_color", PARALLEL_COLOR); + std::vector aRGB = Config_PropManager::color("Visualization", "parallel_color", + PARALLEL_COLOR); anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); return anAIS; } @@ -91,8 +93,8 @@ void SketchPlugin_ConstraintParallel::move(double theDeltaX, double theDeltaY) if (!aData->isValid()) return; - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); aPoint->setValue(aPoint->x() + theDeltaX, aPoint->y() + theDeltaY); } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.h b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h index 9a77a7a7b..053fe5f36 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.h @@ -9,7 +9,6 @@ #include #include "SketchPlugin_ConstraintBase.h" - #define PARALLEL_COLOR "#ffff00" /** \class SketchPlugin_ConstraintParallel @@ -19,9 +18,9 @@ * These constraint has two attributes: * SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() */ -class SketchPlugin_ConstraintParallel: public SketchPlugin_ConstraintBase +class SketchPlugin_ConstraintParallel : public SketchPlugin_ConstraintBase { -public: + public: /// Parallel constraint kind inline static const std::string& ID() { @@ -29,8 +28,11 @@ public: return MY_CONSTRAINT_PARALLEL_ID; } /// \brief Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SketchPlugin_ConstraintParallel::ID(); return MY_KIND;} + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = SketchPlugin_ConstraintParallel::ID(); + return MY_KIND; + } /// \brief Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp index 826fc50b8..c21920928 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp @@ -38,37 +38,38 @@ AISObjectPtr SketchPlugin_ConstraintPerpendicular::getAISObject(AISObjectPtr the return thePrevious; boost::shared_ptr aData = data(); - boost::shared_ptr anAttr1 = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); - boost::shared_ptr anAttr2 = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::ENTITY_B())); - if (!anAttr1 || !anAttr1->isObject() || - !anAttr2 || !anAttr2->isObject()) + boost::shared_ptr anAttr1 = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); + boost::shared_ptr anAttr2 = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B())); + if (!anAttr1 || !anAttr1->isObject() || !anAttr2 || !anAttr2->isObject()) return thePrevious; FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr1->object()); if (!aFeature) return thePrevious; - boost::shared_ptr aLine1Feature = - boost::dynamic_pointer_cast(aFeature); + boost::shared_ptr aLine1Feature = + boost::dynamic_pointer_cast(aFeature); aFeature = ModelAPI_Feature::feature(anAttr2->object()); if (!aFeature) return thePrevious; - boost::shared_ptr aLine2Feature = - boost::dynamic_pointer_cast(aFeature); + boost::shared_ptr aLine2Feature = + boost::dynamic_pointer_cast(aFeature); if (!aLine1Feature || !aLine2Feature) return thePrevious; boost::shared_ptr aPlane = sketch()->plane(); boost::shared_ptr aLine1, aLine2; - boost::shared_ptr aConst1 = - boost::dynamic_pointer_cast(anAttr1->object()); - if (aConst1) aLine1 = aConst1->shape(); - boost::shared_ptr aConst2 = - boost::dynamic_pointer_cast(anAttr2->object()); - if (aConst2) aLine2 = aConst2->shape(); + boost::shared_ptr aConst1 = boost::dynamic_pointer_cast< + ModelAPI_ResultConstruction>(anAttr1->object()); + if (aConst1) + aLine1 = aConst1->shape(); + boost::shared_ptr aConst2 = boost::dynamic_pointer_cast< + ModelAPI_ResultConstruction>(anAttr2->object()); + if (aConst2) + aLine2 = aConst2->shape(); AISObjectPtr anAIS = thePrevious; if (!anAIS) @@ -76,7 +77,8 @@ AISObjectPtr SketchPlugin_ConstraintPerpendicular::getAISObject(AISObjectPtr the anAIS->createPerpendicular(aLine1, aLine2, aPlane); // Set color from preferences - std::vector aRGB = Config_PropManager::color("Visualization", "perpendicular_color", PERPENDICULAR_COLOR); + std::vector aRGB = Config_PropManager::color("Visualization", "perpendicular_color", + PERPENDICULAR_COLOR); anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); return anAIS; } @@ -87,8 +89,8 @@ void SketchPlugin_ConstraintPerpendicular::move(double theDeltaX, double theDelt if (!aData->isValid()) return; - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); aPoint->setValue(aPoint->x() + theDeltaX, aPoint->y() + theDeltaY); } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h index b0bc7ff9e..9b304c8d4 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.h @@ -18,9 +18,9 @@ * These constraint has two attributes: * SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() */ -class SketchPlugin_ConstraintPerpendicular: public SketchPlugin_ConstraintBase +class SketchPlugin_ConstraintPerpendicular : public SketchPlugin_ConstraintBase { -public: + public: /// Perpendicular constraint kind inline static const std::string& ID() { @@ -28,8 +28,11 @@ public: return MY_CONSTRAINT_PERPENDICULAR_ID; } /// \brief Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SketchPlugin_ConstraintPerpendicular::ID(); return MY_KIND;} + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = SketchPlugin_ConstraintPerpendicular::ID(); + return MY_KIND; + } /// \brief Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp index c4ab146e2..dcbd7c9ae 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp @@ -27,38 +27,37 @@ SketchPlugin_ConstraintRadius::SketchPlugin_ConstraintRadius() void SketchPlugin_ConstraintRadius::initAttributes() { - data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type()); + data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::type()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type()); data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type()); } void SketchPlugin_ConstraintRadius::execute() { - if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized() && - !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) { + if (data()->attribute(SketchPlugin_Constraint::ENTITY_A())->isInitialized() + && !data()->attribute(SketchPlugin_Constraint::VALUE())->isInitialized()) { - boost::shared_ptr aRef = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); + boost::shared_ptr aRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object()); if (aFeature) { double aRadius = 0; boost::shared_ptr aData = aFeature->data(); if (aFeature->getKind() == SketchPlugin_Circle::ID()) { - AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast - (aData->attribute(SketchPlugin_Circle::RADIUS_ID())); + AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Circle::RADIUS_ID())); if (anAttribute) aRadius = anAttribute->value(); - } - else if (aFeature->getKind() == SketchPlugin_Arc::ID()) { - boost::shared_ptr aCenterAttr = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Arc::CENTER_ID())); - boost::shared_ptr aStartAttr = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Arc::START_ID())); + } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) { + boost::shared_ptr aCenterAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID())); + boost::shared_ptr aStartAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID())); if (aCenterAttr && aStartAttr) aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt()); } - boost::shared_ptr aValueAttr = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Constraint::VALUE())); + boost::shared_ptr aValueAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE())); aValueAttr->setValue(aRadius); } } @@ -70,8 +69,8 @@ AISObjectPtr SketchPlugin_ConstraintRadius::getAISObject(AISObjectPtr thePreviou return thePrevious; boost::shared_ptr aData = data(); - boost::shared_ptr anAttr = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); + boost::shared_ptr anAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); if (!anAttr) return thePrevious; FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object()); @@ -80,8 +79,8 @@ AISObjectPtr SketchPlugin_ConstraintRadius::getAISObject(AISObjectPtr thePreviou return thePrevious; // Flyout point - boost::shared_ptr aFlyoutAttr = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); + boost::shared_ptr aFlyoutAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); if (!aFlyoutAttr->isInitialized()) return thePrevious; boost::shared_ptr aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y()); @@ -91,30 +90,31 @@ AISObjectPtr SketchPlugin_ConstraintRadius::getAISObject(AISObjectPtr thePreviou boost::shared_ptr aCenterAttr; double aRadius; if (aKind == SketchPlugin_Circle::ID()) { - aCenterAttr = boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Circle::CENTER_ID())); - AttributeDoublePtr aCircRadius = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Circle::RADIUS_ID())); + aCenterAttr = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Circle::CENTER_ID())); + AttributeDoublePtr aCircRadius = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Circle::RADIUS_ID())); aRadius = aCircRadius->value(); - } - else if (aKind == SketchPlugin_Arc::ID()) { - aCenterAttr = boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Arc::CENTER_ID())); - boost::shared_ptr aStartAttr = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Arc::START_ID())); + } else if (aKind == SketchPlugin_Arc::ID()) { + aCenterAttr = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Arc::CENTER_ID())); + boost::shared_ptr aStartAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID())); aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt()); } boost::shared_ptr aCenter = sketch()->to3D(aCenterAttr->x(), aCenterAttr->y()); - boost::shared_ptr aNDir = - boost::dynamic_pointer_cast(sketch()->data()->attribute(SketchPlugin_Sketch::NORM_ID())); + boost::shared_ptr aNDir = boost::dynamic_pointer_cast( + sketch()->data()->attribute(SketchPlugin_Sketch::NORM_ID())); boost::shared_ptr aNormal = aNDir->dir(); boost::shared_ptr aCircle(new GeomAPI_Circ(aCenter, aNormal, aRadius)); // Value - boost::shared_ptr aValueAttr = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::VALUE())); + boost::shared_ptr aValueAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE())); double aValue = aRadius; if (aValueAttr && aValueAttr->isInitialized()) - aValue = aValueAttr->value(); + aValue = aValueAttr->value(); AISObjectPtr anAIS = thePrevious; if (!anAIS) @@ -133,8 +133,8 @@ void SketchPlugin_ConstraintRadius::move(double theDeltaX, double theDeltaY) if (!aData->isValid()) return; - boost::shared_ptr aRef = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); + boost::shared_ptr aRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object()); if (!aFeature) return; @@ -143,18 +143,18 @@ void SketchPlugin_ConstraintRadius::move(double theDeltaX, double theDeltaY) aCenterAttrName = SketchPlugin_Circle::CENTER_ID(); else if (aFeature->getKind() == SketchPlugin_Arc::ID()) aCenterAttrName = SketchPlugin_Arc::CENTER_ID(); - boost::shared_ptr aCenterAttr = - boost::dynamic_pointer_cast(aFeature->data()->attribute(aCenterAttrName)); + boost::shared_ptr aCenterAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aFeature->data()->attribute(aCenterAttrName)); boost::shared_ptr aCenter = aCenterAttr->pnt(); // The specified delta applied on the circle curve, // so it will be scaled due to distance between flyout and center points - boost::shared_ptr aFlyoutAttr = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); + boost::shared_ptr aFlyoutAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); boost::shared_ptr aFlyout = aFlyoutAttr->pnt(); - boost::shared_ptr aRadius = - boost::dynamic_pointer_cast(aData->attribute(SketchPlugin_Constraint::VALUE())); + boost::shared_ptr aRadius = boost::dynamic_pointer_cast< + ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE())); double aScale = aFlyout->distance(aCenter) / aRadius->value(); boost::shared_ptr aCircle(new GeomAPI_Circ2d(aCenter, aFlyout)); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.h b/src/SketchPlugin/SketchPlugin_ConstraintRadius.h index f330a31ec..eb96ef93d 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.h @@ -19,17 +19,21 @@ * These constraint has two attributes: * SketchPlugin_Constraint::VALUE() (radius), SketchPlugin_Constraint::ENTITY_A() (a circle) */ -class SketchPlugin_ConstraintRadius: public SketchPlugin_ConstraintBase +class SketchPlugin_ConstraintRadius : public SketchPlugin_ConstraintBase { -public: + public: /// Radius constraint kind - inline static const std::string& ID() { + inline static const std::string& ID() + { static const std::string MY_CONSTRAINT_RADIUS_ID("SketchConstraintRadius"); return MY_CONSTRAINT_RADIUS_ID; } /// \brief Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SketchPlugin_ConstraintRadius::ID(); return MY_KIND;} + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = SketchPlugin_ConstraintRadius::ID(); + return MY_KIND; + } /// \brief Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); diff --git a/src/SketchPlugin/SketchPlugin_Feature.cpp b/src/SketchPlugin/SketchPlugin_Feature.cpp index 4edfeb8f9..c3c800bd9 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.cpp +++ b/src/SketchPlugin/SketchPlugin_Feature.cpp @@ -16,14 +16,14 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch() if (!mySketch) { // find sketch that references to this feature int aSketches = document()->size(ModelAPI_Feature::group()); - for(int a = 0; a < aSketches && !mySketch; a++) { - boost::shared_ptr aSketch = boost:: - dynamic_pointer_cast(document()->object(ModelAPI_Feature::group(), a)); + for (int a = 0; a < aSketches && !mySketch; a++) { + boost::shared_ptr aSketch = boost::dynamic_pointer_cast< + SketchPlugin_Sketch>(document()->object(ModelAPI_Feature::group(), a)); if (aSketch) { - std::list aList = - aSketch->data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list(); + std::list aList = aSketch->data()->reflist(SketchPlugin_Sketch::FEATURES_ID()) + ->list(); std::list::iterator aSub = aList.begin(); - for(; aSub != aList.end(); aSub++) { + for (; aSub != aList.end(); aSub++) { if ((*aSub)->data()->isEqual(data())) { mySketch = aSketch.get(); break; @@ -35,14 +35,15 @@ SketchPlugin_Sketch* SketchPlugin_Feature::sketch() return mySketch; } -AISObjectPtr SketchPlugin_Feature::simpleAISObject( - boost::shared_ptr theRes, AISObjectPtr thePrevious) +AISObjectPtr SketchPlugin_Feature::simpleAISObject(boost::shared_ptr theRes, + AISObjectPtr thePrevious) { - boost::shared_ptr aConstr = - boost::dynamic_pointer_cast(theRes); + boost::shared_ptr aConstr = boost::dynamic_pointer_cast< + ModelAPI_ResultConstruction>(theRes); boost::shared_ptr aPreview; - if (aConstr) aPreview = aConstr->shape(); + if (aConstr) + aPreview = aConstr->shape(); AISObjectPtr aResult = thePrevious; if (!aResult) diff --git a/src/SketchPlugin/SketchPlugin_Feature.h b/src/SketchPlugin/SketchPlugin_Feature.h index 439f1b4f0..9deef3f09 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.h +++ b/src/SketchPlugin/SketchPlugin_Feature.h @@ -20,20 +20,25 @@ class Handle_AIS_InteractiveObject; * \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 +class SketchPlugin_Feature : public ModelAPI_Feature { -public: + public: /// Simple creation of interactive object by the result of the object - static AISObjectPtr simpleAISObject( - boost::shared_ptr theRes, AISObjectPtr thePrevious); + static AISObjectPtr simpleAISObject(boost::shared_ptr theRes, + AISObjectPtr thePrevious); /// Adds sub-feature of the higher level feature (sub-element of the sketch) /// \param theFeature sub-feature - SKETCHPLUGIN_EXPORT virtual const void addSub( - const FeaturePtr& theFeature) {}; + SKETCHPLUGIN_EXPORT virtual const void addSub(const FeaturePtr& theFeature) + { + } + ; /// Returns true if this feature must be displayed in the history (top level of Part tree) - SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return false;} + SKETCHPLUGIN_EXPORT virtual bool isInHistory() + { + return false; + } /// Moves the feature /// \param theDeltaX the delta for X coordinate is moved @@ -44,9 +49,12 @@ public: /// \param thePoint the point virtual double distanceToPoint(const boost::shared_ptr& thePoint) = 0; -protected: + protected: /// Sets the higher-level feature for the sub-feature (sketch for line) - void setSketch(SketchPlugin_Sketch* theSketch) {mySketch = theSketch;} + void setSketch(SketchPlugin_Sketch* theSketch) + { + mySketch = theSketch; + } /// Returns the sketch of this feature SketchPlugin_Sketch* sketch(); /// initializes mySketch @@ -54,9 +62,9 @@ protected: friend class SketchPlugin_Sketch; -private: - boost::shared_ptr myPreview; ///< the preview shape - SketchPlugin_Sketch* mySketch; /// sketch that contains this feature + private: + boost::shared_ptr myPreview; ///< the preview shape + SketchPlugin_Sketch* mySketch; /// sketch that contains this feature }; #endif diff --git a/src/SketchPlugin/SketchPlugin_Line.cpp b/src/SketchPlugin/SketchPlugin_Line.cpp index 8f9870134..8ae5384bb 100644 --- a/src/SketchPlugin/SketchPlugin_Line.cpp +++ b/src/SketchPlugin/SketchPlugin_Line.cpp @@ -16,9 +16,8 @@ using namespace std; - SketchPlugin_Line::SketchPlugin_Line() - : SketchPlugin_Feature() + : SketchPlugin_Feature() { } @@ -28,26 +27,24 @@ void SketchPlugin_Line::initAttributes() data()->addAttribute(SketchPlugin_Line::END_ID(), GeomDataAPI_Point2D::type()); } -void SketchPlugin_Line::execute() +void SketchPlugin_Line::execute() { SketchPlugin_Sketch* aSketch = sketch(); if (aSketch) { // compute a start point in 3D view - boost::shared_ptr aStartAttr = - boost::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Line::START_ID())); + boost::shared_ptr aStartAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Line::START_ID())); // compute an end point in 3D view - boost::shared_ptr anEndAttr = - boost::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Line::END_ID())); + boost::shared_ptr anEndAttr = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Line::END_ID())); if (aStartAttr->isInitialized() && anEndAttr->isInitialized()) { boost::shared_ptr aStart(aSketch->to3D(aStartAttr->x(), aStartAttr->y())); boost::shared_ptr anEnd(aSketch->to3D(anEndAttr->x(), anEndAttr->y())); // make linear edge boost::shared_ptr anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd); // store the result - boost::shared_ptr aConstr = - document()->createConstruction(data()); + boost::shared_ptr aConstr = document()->createConstruction( + data()); aConstr->setShape(anEdge); aConstr->setIsInHistory(false); setResult(aConstr); @@ -61,14 +58,12 @@ void SketchPlugin_Line::move(double theDeltaX, double theDeltaY) if (!aData->isValid()) return; - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Line::START_ID())); + boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Line::START_ID())); aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); - boost::shared_ptr aPoint2 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Line::END_ID())); + boost::shared_ptr aPoint2 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Line::END_ID())); aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY); } @@ -77,20 +72,17 @@ double SketchPlugin_Line::distanceToPoint(const boost::shared_ptr double aDelta = 0; boost::shared_ptr aData = data(); - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Line::START_ID())); - boost::shared_ptr aPoint2 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Line::END_ID())); + boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Line::START_ID())); + boost::shared_ptr aPoint2 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Line::END_ID())); GeomAPI_Lin2d aLin2d(aPoint1->x(), aPoint1->y(), aPoint2->x(), aPoint2->y()); - if (false/*projection*/) { // TODO: if it has not been necessary, remove this block + if (false/*projection*/) { // TODO: if it has not been necessary, remove this block boost::shared_ptr aResult = aLin2d.project(thePoint); aDelta = aResult->distance(thePoint); - } - else { // distance + } else { // distance aDelta = aLin2d.distance(thePoint); } diff --git a/src/SketchPlugin/SketchPlugin_Line.h b/src/SketchPlugin/SketchPlugin_Line.h index 636b7337d..d2656e5d8 100644 --- a/src/SketchPlugin/SketchPlugin_Line.h +++ b/src/SketchPlugin/SketchPlugin_Line.h @@ -14,9 +14,9 @@ * \ingroup DataModel * \brief Feature for creation of the new part in PartSet. */ -class SketchPlugin_Line: public SketchPlugin_Feature +class SketchPlugin_Line : public SketchPlugin_Feature { -public: + public: /// Arc feature kind inline static const std::string& ID() { @@ -29,7 +29,7 @@ public: static const std::string MY_START_ID("StartPoint"); return MY_START_ID; } - /// End 2D point of the line + /// End 2D point of the line inline static const std::string& END_ID() { static const std::string MY_END_ID("EndPoint"); @@ -37,8 +37,11 @@ public: } /// Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SketchPlugin_Line::ID(); return MY_KIND;} + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = SketchPlugin_Line::ID(); + return MY_KIND; + } /// Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); @@ -48,7 +51,9 @@ public: /// Returns the AIS preview SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious) - {return simpleAISObject(firstResult(), thePrevious);} + { + return simpleAISObject(firstResult(), thePrevious); + } /// Moves the feature /// \param theDeltaX the delta for X coordinate is moved diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index eb0b16c3f..0ac34f1f2 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -22,40 +22,34 @@ using namespace std; // the only created instance of this plugin static SketchPlugin_Plugin* MY_INSTANCE = new SketchPlugin_Plugin(); -SketchPlugin_Plugin::SketchPlugin_Plugin() +SketchPlugin_Plugin::SketchPlugin_Plugin() { PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - aFactory->registerValidator("SketchPlugin_DistanceAttrValidator", new SketchPlugin_DistanceAttrValidator); + aFactory->registerValidator("SketchPlugin_DistanceAttrValidator", + new SketchPlugin_DistanceAttrValidator); // register this plugin ModelAPI_PluginManager::get()->registerPlugin(this); // register sketcher properties - Config_PropManager::registerProp("Sketch planes", - "planes_color", "Color", - Config_Prop::Color, SKETCH_PLANE_COLOR); - Config_PropManager::registerProp("Sketch planes", - "planes_size", "Size", - Config_Prop::Double, PLANE_SIZE); - Config_PropManager::registerProp("Sketch planes", - "planes_thikness", "Thickness", + Config_PropManager::registerProp("Sketch planes", "planes_color", "Color", Config_Prop::Color, + SKETCH_PLANE_COLOR); + Config_PropManager::registerProp("Sketch planes", "planes_size", "Size", Config_Prop::Double, + PLANE_SIZE); + Config_PropManager::registerProp("Sketch planes", "planes_thikness", "Thickness", Config_Prop::Integer, SKETCH_WIDTH); - Config_PropManager::registerProp("Visualization", - "parallel_color", "Parallel constraint color", + Config_PropManager::registerProp("Visualization", "parallel_color", "Parallel constraint color", Config_Prop::Color, PARALLEL_COLOR); - Config_PropManager::registerProp("Visualization", - "perpendicular_color", "Perpendicular constraint color", - Config_Prop::Color, PERPENDICULAR_COLOR); - Config_PropManager::registerProp("Visualization", - "distance_color", "Distance color", + Config_PropManager::registerProp("Visualization", "perpendicular_color", + "Perpendicular constraint color", Config_Prop::Color, + PERPENDICULAR_COLOR); + Config_PropManager::registerProp("Visualization", "distance_color", "Distance color", Config_Prop::Color, DISTANCE_COLOR); - Config_PropManager::registerProp("Visualization", - "length_color", "Length color", + Config_PropManager::registerProp("Visualization", "length_color", "Length color", Config_Prop::Color, LENGTH_COLOR); - Config_PropManager::registerProp("Visualization", - "radius_color", "Radius color", + Config_PropManager::registerProp("Visualization", "radius_color", "Radius color", Config_Prop::Color, RADIUS_COLOR); } @@ -63,35 +57,25 @@ FeaturePtr SketchPlugin_Plugin::createFeature(string theFeatureID) { if (theFeatureID == SketchPlugin_Sketch::ID()) { return FeaturePtr(new SketchPlugin_Sketch); - } - else if (theFeatureID == SketchPlugin_Point::ID()) { + } else if (theFeatureID == SketchPlugin_Point::ID()) { return FeaturePtr(new SketchPlugin_Point); - } - else if (theFeatureID == SketchPlugin_Line::ID()) { + } else if (theFeatureID == SketchPlugin_Line::ID()) { return FeaturePtr(new SketchPlugin_Line); - } - else if (theFeatureID == SketchPlugin_Circle::ID()) { + } else if (theFeatureID == SketchPlugin_Circle::ID()) { return FeaturePtr(new SketchPlugin_Circle); - } - else if (theFeatureID == SketchPlugin_Arc::ID()) { + } else if (theFeatureID == SketchPlugin_Arc::ID()) { return FeaturePtr(new SketchPlugin_Arc); - } - else if (theFeatureID == SketchPlugin_ConstraintCoincidence::ID()) { + } else if (theFeatureID == SketchPlugin_ConstraintCoincidence::ID()) { return FeaturePtr(new SketchPlugin_ConstraintCoincidence); - } - else if (theFeatureID == SketchPlugin_ConstraintDistance::ID()) { + } else if (theFeatureID == SketchPlugin_ConstraintDistance::ID()) { return FeaturePtr(new SketchPlugin_ConstraintDistance); - } - else if (theFeatureID == SketchPlugin_ConstraintLength::ID()) { + } else if (theFeatureID == SketchPlugin_ConstraintLength::ID()) { return FeaturePtr(new SketchPlugin_ConstraintLength); - } - else if (theFeatureID == SketchPlugin_ConstraintParallel::ID()) { + } else if (theFeatureID == SketchPlugin_ConstraintParallel::ID()) { return FeaturePtr(new SketchPlugin_ConstraintParallel); - } - else if (theFeatureID == SketchPlugin_ConstraintPerpendicular::ID()) { + } else if (theFeatureID == SketchPlugin_ConstraintPerpendicular::ID()) { return FeaturePtr(new SketchPlugin_ConstraintPerpendicular); - } - else if (theFeatureID == SketchPlugin_ConstraintRadius::ID()) { + } else if (theFeatureID == SketchPlugin_ConstraintRadius::ID()) { return FeaturePtr(new SketchPlugin_ConstraintRadius); } // feature of such kind is not found diff --git a/src/SketchPlugin/SketchPlugin_Plugin.h b/src/SketchPlugin/SketchPlugin_Plugin.h index 63f488ca5..bb81ba781 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.h +++ b/src/SketchPlugin/SketchPlugin_Plugin.h @@ -5,18 +5,17 @@ #ifndef SketchPlugin_Plugin_H_ #define SketchPlugin_Plugin_H_ - #include "SketchPlugin.h" #include "ModelAPI_Plugin.h" #include "ModelAPI_Feature.h" -class SKETCHPLUGIN_EXPORT SketchPlugin_Plugin: public ModelAPI_Plugin +class SKETCHPLUGIN_EXPORT SketchPlugin_Plugin : public ModelAPI_Plugin { -public: + public: /// Creates the feature object of this plugin by the feature string ID virtual FeaturePtr createFeature(std::string theFeatureID); -public: + public: /// Is needed for python wrapping by swig SketchPlugin_Plugin(); }; diff --git a/src/SketchPlugin/SketchPlugin_Point.cpp b/src/SketchPlugin/SketchPlugin_Point.cpp index 14efc4f6a..5e8f2a65e 100644 --- a/src/SketchPlugin/SketchPlugin_Point.cpp +++ b/src/SketchPlugin/SketchPlugin_Point.cpp @@ -24,14 +24,14 @@ void SketchPlugin_Point::initAttributes() data()->addAttribute(SketchPlugin_Point::COORD_ID(), GeomDataAPI_Point2D::type()); } -void SketchPlugin_Point::execute() +void SketchPlugin_Point::execute() { SketchPlugin_Sketch* aSketch = sketch(); if (aSketch) { // compute a point in 3D view - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Point::COORD_ID())); + boost::shared_ptr aPoint = + boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Point::COORD_ID())); boost::shared_ptr aPoint3D(aSketch->to3D(aPoint->x(), aPoint->y())); // make a visible point boost::shared_ptr aPointShape = GeomAlgoAPI_PointBuilder::point(aPoint3D); @@ -48,18 +48,16 @@ void SketchPlugin_Point::move(double theDeltaX, double theDeltaY) if (!aData->isValid()) return; - boost::shared_ptr aPoint1 = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Point::COORD_ID())); + boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Point::COORD_ID())); aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY); } double SketchPlugin_Point::distanceToPoint(const boost::shared_ptr& thePoint) { boost::shared_ptr aData = data(); - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast( - aData->attribute(SketchPlugin_Point::COORD_ID())); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Point::COORD_ID())); return aPoint->pnt()->distance(thePoint); } diff --git a/src/SketchPlugin/SketchPlugin_Point.h b/src/SketchPlugin/SketchPlugin_Point.h index fddf2ef5a..14f587402 100644 --- a/src/SketchPlugin/SketchPlugin_Point.h +++ b/src/SketchPlugin/SketchPlugin_Point.h @@ -14,9 +14,9 @@ * \ingroup DataModel * \brief Feature for creation of a new point. */ -class SketchPlugin_Point: public SketchPlugin_Feature +class SketchPlugin_Point : public SketchPlugin_Feature { -public: + public: /// Point feature kind inline static const std::string& ID() { @@ -30,8 +30,11 @@ public: return MY_COORD_ID; } /// Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SketchPlugin_Point::ID(); return MY_KIND;} + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = SketchPlugin_Point::ID(); + return MY_KIND; + } /// Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); @@ -41,7 +44,9 @@ public: /// Returns the AIS preview virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious) - {return simpleAISObject(firstResult(), thePrevious);} + { + return simpleAISObject(firstResult(), thePrevious); + } /// Moves the feature /// \param theDeltaX the delta for X coordinate is moved diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 9236aa008..5342bf832 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -18,7 +18,6 @@ using namespace std; - SketchPlugin_Sketch::SketchPlugin_Sketch() { } @@ -32,39 +31,38 @@ void SketchPlugin_Sketch::initAttributes() data()->addAttribute(SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList::type()); } -void SketchPlugin_Sketch::execute() +void SketchPlugin_Sketch::execute() { if (!data()->isValid()) - return ; - boost::shared_ptr aRefList = - boost::dynamic_pointer_cast( - data()->attribute(SketchPlugin_Sketch::FEATURES_ID())); - - boost::shared_ptr anOrigin = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); - boost::shared_ptr aDirX = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - boost::shared_ptr aDirY = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::DIRY_ID())); - boost::shared_ptr aNorm = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::NORM_ID())); + return; + boost::shared_ptr aRefList = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefList>(data()->attribute(SketchPlugin_Sketch::FEATURES_ID())); + + boost::shared_ptr anOrigin = boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + boost::shared_ptr aDirX = boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::DIRX_ID())); + boost::shared_ptr aDirY = boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::DIRY_ID())); + boost::shared_ptr aNorm = boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::NORM_ID())); std::list aFeatures = aRefList->list(); if (aFeatures.empty()) - return ; + return; std::list::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end(); boost::shared_ptr aFeature; - std::list< boost::shared_ptr > aFeaturesPreview; + std::list > aFeaturesPreview; for (; anIt != aLast; anIt++) { aFeature = boost::dynamic_pointer_cast(*anIt); if (aFeature) { const std::list >& aRes = aFeature->results(); std::list >::const_iterator aResIter = aRes.cbegin(); - for(; aResIter != aRes.cend(); aResIter++) { - boost::shared_ptr aConstr = - boost::dynamic_pointer_cast(*aResIter); + for (; aResIter != aRes.cend(); aResIter++) { + boost::shared_ptr aConstr = boost::dynamic_pointer_cast< + ModelAPI_ResultConstruction>(*aResIter); if (aConstr) { boost::shared_ptr aShape = aConstr->shape(); if (aShape) @@ -75,9 +73,9 @@ void SketchPlugin_Sketch::execute() } if (aFeaturesPreview.empty()) - return ; - std::list< boost::shared_ptr > aLoops; - std::list< boost::shared_ptr > aWires; + return; + std::list > aLoops; + std::list > aWires; GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(), aFeaturesPreview, aLoops, aWires); @@ -96,33 +94,33 @@ const void SketchPlugin_Sketch::addSub(const FeaturePtr& theFeature) boost::shared_ptr SketchPlugin_Sketch::to3D(const double theX, const double theY) { - boost::shared_ptr aC = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); - boost::shared_ptr aX = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::DIRX_ID())); - boost::shared_ptr aY = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::DIRY_ID())); + boost::shared_ptr aC = boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + boost::shared_ptr aX = boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::DIRX_ID())); + boost::shared_ptr aY = boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::DIRY_ID())); - boost::shared_ptr aSum = aC->pnt()->xyz()->added( - aX->dir()->xyz()->multiplied(theX))->added(aY->dir()->xyz()->multiplied(theY)); + boost::shared_ptr aSum = aC->pnt()->xyz()->added(aX->dir()->xyz()->multiplied(theX)) + ->added(aY->dir()->xyz()->multiplied(theY)); return boost::shared_ptr(new GeomAPI_Pnt(aSum)); } bool SketchPlugin_Sketch::isPlaneSet() { - boost::shared_ptr aNormal = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::NORM_ID())); + boost::shared_ptr aNormal = boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::NORM_ID())); return aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0); } boost::shared_ptr SketchPlugin_Sketch::plane() { - boost::shared_ptr anOrigin = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); - boost::shared_ptr aNorm = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::NORM_ID())); + boost::shared_ptr anOrigin = boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::ORIGIN_ID())); + boost::shared_ptr aNorm = boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::NORM_ID())); if (!anOrigin || !aNorm) return boost::shared_ptr(); @@ -130,41 +128,40 @@ boost::shared_ptr SketchPlugin_Sketch::plane() return boost::shared_ptr(new GeomAPI_Pln(anOrigin->pnt(), aNorm->dir())); } -void addPlane(double theX, double theY, double theZ, std::list >& theShapes) +void addPlane(double theX, double theY, double theZ, + std::list >& theShapes) { boost::shared_ptr anOrigin(new GeomAPI_Pnt(0, 0, 0)); boost::shared_ptr aNormal(new GeomAPI_Dir(theX, theY, theZ)); double aSize = Config_PropManager::integer("Sketch definition", "Size of planes", PLANE_SIZE); - boost::shared_ptr aFace = - GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, aSize); + boost::shared_ptr aFace = GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, + aSize); theShapes.push_back(aFace); } AISObjectPtr SketchPlugin_Sketch::getAISObject(AISObjectPtr thePrevious) { - boost::shared_ptr aNorm = - boost::dynamic_pointer_cast(data()->attribute(SketchPlugin_Sketch::NORM_ID())); + boost::shared_ptr aNorm = boost::dynamic_pointer_cast( + data()->attribute(SketchPlugin_Sketch::NORM_ID())); if (!aNorm || (aNorm->x() == 0 && aNorm->y() == 0 && aNorm->z() == 0)) { AISObjectPtr aAIS = thePrevious; if (!aAIS) { std::list > aFaces; - addPlane(1, 0, 0, aFaces); // YZ plane - addPlane(0, 1, 0, aFaces); // XZ plane - addPlane(0, 0, 1, aFaces); // XY plane + addPlane(1, 0, 0, aFaces); // YZ plane + addPlane(0, 1, 0, aFaces); // XZ plane + addPlane(0, 0, 1, aFaces); // XY plane boost::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces); aAIS = AISObjectPtr(new GeomAPI_AISObject()); aAIS->createShape(aCompound); - std::vector aRGB = Config_PropManager::color("Sketch definition", - "planes_color", - SKETCH_PLANE_COLOR); + std::vector aRGB = Config_PropManager::color("Sketch definition", "planes_color", + SKETCH_PLANE_COLOR); aAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); - aAIS->setWidth(Config_PropManager::integer("Sketch definition", - "planes_thikness", - SKETCH_WIDTH)); + aAIS->setWidth(Config_PropManager::integer("Sketch definition", "planes_thikness", + SKETCH_WIDTH)); } return aAIS; } diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index 0d5d6ea0a..806025dd7 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -25,9 +25,9 @@ * \ingroup DataModel * \brief Feature for creation of the new part in PartSet. */ -class SketchPlugin_Sketch: public SketchPlugin_Feature, public GeomAPI_IPresentable +class SketchPlugin_Sketch : public SketchPlugin_Feature, public GeomAPI_IPresentable { -public: + public: /// Sketch feature kind inline static const std::string& ID() { @@ -66,8 +66,11 @@ public: } /// Returns the kind of a feature - SKETCHPLUGIN_EXPORT virtual const std::string& getKind() - {static std::string MY_KIND = SketchPlugin_Sketch::ID(); return MY_KIND;} + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = SketchPlugin_Sketch::ID(); + return MY_KIND; + } /// Creates a new part document if needed SKETCHPLUGIN_EXPORT virtual void execute(); @@ -77,24 +80,32 @@ public: /// Adds sub-feature of the higher level feature (sub-element of the sketch) /// \param theFeature sub-feature - SKETCHPLUGIN_EXPORT virtual const void addSub( - const FeaturePtr& theFeature); + SKETCHPLUGIN_EXPORT virtual const void addSub(const FeaturePtr& theFeature); /// Moves the feature /// \param theDeltaX the delta for X coordinate is moved /// \param theDeltaY the delta for Y coordinate is moved - SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {}; + SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) + { + } + ; /// Return the distance between the feature and the point /// \param thePoint the point - virtual double distanceToPoint(const boost::shared_ptr& thePoint) { return 0; }; + virtual double distanceToPoint(const boost::shared_ptr& thePoint) + { + return 0; + } + ; /// Converts a 2D sketch space point into point in 3D space - SKETCHPLUGIN_EXPORT boost::shared_ptr to3D( - const double theX, const double theY); + SKETCHPLUGIN_EXPORT boost::shared_ptr to3D(const double theX, const double theY); /// Returns true if this feature must be displayed in the history (top level of Part tree) - SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return true;} + SKETCHPLUGIN_EXPORT virtual bool isInHistory() + { + return true; + } /// Use plugin manager for features creation SketchPlugin_Sketch(); @@ -104,7 +115,7 @@ public: virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious); -protected: + protected: /// Creates a plane and append it to the list /// \param theX the X normal value /// \param theY the Y normal value diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 862a30344..50af2be89 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -9,8 +9,7 @@ #include #include - -bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature, +bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature, const std::list& theArguments, const ObjectPtr& theObject) const { @@ -19,8 +18,8 @@ bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature, ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); // If the object is not a line then it is accepted - const ModelAPI_ResultValidator* aLineValidator = dynamic_cast( - aFactory->validator("Model_ResultLineValidator")); + const ModelAPI_ResultValidator* aLineValidator = + dynamic_cast(aFactory->validator("Model_ResultLineValidator")); if (!aLineValidator->isValid(theObject)) return true; @@ -31,5 +30,3 @@ bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature, return false; } - - diff --git a/src/SketchPlugin/SketchPlugin_Validators.h b/src/SketchPlugin/SketchPlugin_Validators.h index 74357d1eb..38ba02916 100644 --- a/src/SketchPlugin/SketchPlugin_Validators.h +++ b/src/SketchPlugin/SketchPlugin_Validators.h @@ -9,14 +9,12 @@ //#include #include - -class SketchPlugin_DistanceAttrValidator: public ModelAPI_AttributeValidator +class SketchPlugin_DistanceAttrValidator : public ModelAPI_AttributeValidator { -public: - virtual bool isValid(const FeaturePtr& theFeature, - const std::list& theArguments, + public: + virtual bool isValid(const FeaturePtr& theFeature, const std::list& theArguments, const ObjectPtr& theObject) const; }; -#endif \ No newline at end of file +#endif diff --git a/src/SketchSolver/SketchSolver_Constraint.cpp b/src/SketchSolver/SketchSolver_Constraint.cpp index e44e1390b..d5f1e6810 100644 --- a/src/SketchSolver/SketchSolver_Constraint.cpp +++ b/src/SketchSolver/SketchSolver_Constraint.cpp @@ -30,7 +30,7 @@ /// Possible types of attributes (used to determine constraint type) enum AttrType { - UNKNOWN, // Something wrong during type determination + UNKNOWN, // Something wrong during type determination POINT2D, POINT3D, LINE, @@ -41,24 +41,23 @@ enum AttrType /// Calculate type of the attribute static AttrType typeOfAttribute(boost::shared_ptr theAttribute); - - SketchSolver_Constraint::SketchSolver_Constraint() - : myConstraint(boost::shared_ptr()), - myType(SLVS_C_UNKNOWN), - myAttributesList() + : myConstraint(boost::shared_ptr()), + myType(SLVS_C_UNKNOWN), + myAttributesList() { } SketchSolver_Constraint::SketchSolver_Constraint( - boost::shared_ptr theConstraint) - : myConstraint(theConstraint), - myAttributesList() + boost::shared_ptr theConstraint) + : myConstraint(theConstraint), + myAttributesList() { myType = getType(myConstraint); } -const int& SketchSolver_Constraint::getType(boost::shared_ptr theConstraint) +const int& SketchSolver_Constraint::getType( + boost::shared_ptr theConstraint) { myType = SLVS_C_UNKNOWN; if (!theConstraint) @@ -71,30 +70,28 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptrgetKind(); // Constraint for coincidence of two points - if (aConstraintKind.compare(SketchPlugin_ConstraintCoincidence::ID()) == 0) - { + if (aConstraintKind.compare(SketchPlugin_ConstraintCoincidence::ID()) == 0) { int anAttrPos = 0; // Verify the constraint has only two attributes and they are points - int aPt2d = 0; // bit-mapped field, each bit indicates whether the attribute is 2D point - int aPt3d = 0; // bit-mapped field, the same information for 3D points - for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) - { - boost::shared_ptr anAttr = - theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr)); - if (!anAttr) continue; - switch (typeOfAttribute(anAttr)) - { - case POINT2D: // the attribute is a 2D point - aPt2d |= (1 << indAttr); - myAttributesList[anAttrPos++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr); - break; - case POINT3D: // the attribute is a 3D point - aPt3d |= (1 << indAttr); - myAttributesList[anAttrPos++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr); - break; - default: - // Attribute neither 2D nor 3D point is not supported by this type of constraint - return getType(); + int aPt2d = 0; // bit-mapped field, each bit indicates whether the attribute is 2D point + int aPt3d = 0; // bit-mapped field, the same information for 3D points + for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) { + boost::shared_ptr anAttr = theConstraint->data()->attribute( + SketchPlugin_Constraint::ATTRIBUTE(indAttr)); + if (!anAttr) + continue; + switch (typeOfAttribute(anAttr)) { + case POINT2D: // the attribute is a 2D point + aPt2d |= (1 << indAttr); + myAttributesList[anAttrPos++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr); + break; + case POINT3D: // the attribute is a 3D point + aPt3d |= (1 << indAttr); + myAttributesList[anAttrPos++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr); + break; + default: + // Attribute neither 2D nor 3D point is not supported by this type of constraint + return getType(); } } // The constrained points should be in first and second positions, @@ -106,21 +103,18 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr anAttr = - theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr)); - switch (typeOfAttribute(anAttr)) - { - case POINT2D: - case POINT3D: + for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) { + boost::shared_ptr anAttr = theConstraint->data()->attribute( + SketchPlugin_Constraint::ATTRIBUTE(indAttr)); + switch (typeOfAttribute(anAttr)) { + case POINT2D: + case POINT3D: myAttributesList[aNbPoints++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr); break; - case LINE: + case LINE: // entities are placed starting from SketchPlugin_Constraint::ENTITY_C() attribute myAttributesList[2 + aNbEntities++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr); myType = SLVS_C_PT_LINE_DISTANCE; @@ -128,7 +122,7 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr anAttr = - theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr)); + for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) { + boost::shared_ptr anAttr = theConstraint->data()->attribute( + SketchPlugin_Constraint::ATTRIBUTE(indAttr)); if (typeOfAttribute(anAttr) == LINE) myAttributesList[aNbLines++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr); } @@ -154,13 +146,11 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr anAttr = - theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr)); + if (isParallel || isPerpendicular) { + int aNbEntities = 2; // lines in SolveSpace constraints should start from SketchPlugin_Constraint::ENTITY_C() attribute + for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) { + boost::shared_ptr anAttr = theConstraint->data()->attribute( + SketchPlugin_Constraint::ATTRIBUTE(indAttr)); if (typeOfAttribute(anAttr) == LINE) myAttributesList[aNbEntities++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr); } @@ -170,13 +160,11 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr anAttr = - theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr)); + if (aConstraintKind.compare(SketchPlugin_ConstraintRadius::ID()) == 0) { + int aNbEntities = 2; // lines in SolveSpace constraints should started from SketchPlugin_Constraint::ENTITY_C() attribute + for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) { + boost::shared_ptr anAttr = theConstraint->data()->attribute( + SketchPlugin_Constraint::ATTRIBUTE(indAttr)); AttrType aType = typeOfAttribute(anAttr); if (aType == CIRCLE || aType == ARC) myAttributesList[aNbEntities++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr); @@ -191,26 +179,25 @@ const int& SketchSolver_Constraint::getType(boost::shared_ptr theAttribute) { - boost::shared_ptr anAttrRef = - boost::dynamic_pointer_cast(theAttribute); - if (!anAttrRef) return UNKNOWN; + boost::shared_ptr anAttrRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(theAttribute); + if (!anAttrRef) + return UNKNOWN; - if (anAttrRef->isObject()) - { - ResultConstructionPtr aRC = - boost::dynamic_pointer_cast(anAttrRef->object()); - if (!aRC) return UNKNOWN; + if (anAttrRef->isObject()) { + ResultConstructionPtr aRC = boost::dynamic_pointer_cast( + anAttrRef->object()); + if (!aRC) + return UNKNOWN; if (aRC->shape()->isVertex()) return POINT3D; - else if (aRC->shape()->isEdge()) - { - boost::shared_ptr anEdge = - boost::dynamic_pointer_cast(aRC->shape()); + else if (aRC->shape()->isEdge()) { + boost::shared_ptr anEdge = boost::dynamic_pointer_cast( + aRC->shape()); if (anEdge->isLine()) return LINE; else if (anEdge->isCircle()) @@ -218,9 +205,7 @@ AttrType typeOfAttribute(boost::shared_ptr theAttribute) else if (anEdge->isArc()) return ARC; } - } - else - { + } else { const std::string aType = anAttrRef->attr()->attributeType(); if (aType == GeomDataAPI_Point2D::type()) return POINT2D; diff --git a/src/SketchSolver/SketchSolver_Constraint.h b/src/SketchSolver/SketchSolver_Constraint.h index 3f547d8d8..0d20edd38 100644 --- a/src/SketchSolver/SketchSolver_Constraint.h +++ b/src/SketchSolver/SketchSolver_Constraint.h @@ -18,7 +18,7 @@ */ class SketchSolver_Constraint { -public: + public: SketchSolver_Constraint(); SketchSolver_Constraint(boost::shared_ptr theConstraint); @@ -30,16 +30,20 @@ public: const int& getType(boost::shared_ptr theConstraint); /// \brief Returns the type of myConstraint member inline const int& getType() const - { return myType; } + { + return myType; + } /// \brief Returns list of attributes names in the correct order required by SolveSpace inline const std::vector& getAttributes() const - { return myAttributesList; } + { + return myAttributesList; + } -private: + private: boost::shared_ptr myConstraint; - int myType; - std::vector myAttributesList; + int myType; + std::vector myAttributesList; }; #endif diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index 0e5878091..0e1ad7790 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -39,8 +39,9 @@ const double tolerance = 1.e-10; * as inline static functions * TODO: Move this class into a separate file */ -class SketchSolver_Error { -public: +class SketchSolver_Error +{ + public: /// The value parameter for the constraint inline static const std::string& CONSTRAINTS() { @@ -57,28 +58,27 @@ static Slvs_hGroup myGroupIndexer = 0; * \param[in] theEntities list of elements * \return position of the found element or -1 if the element is not found */ -template +template static int Search(const uint32_t& theEntityID, const std::vector& theEntities); - // ======================================================== // ========= SketchSolver_ConstraintGroup =============== // ======================================================== -SketchSolver_ConstraintGroup:: - SketchSolver_ConstraintGroup(boost::shared_ptr theWorkplane) - : myID(++myGroupIndexer), - myParamMaxID(0), - myEntityMaxID(0), - myConstrMaxID(0), - myConstraintMap(), - myNeedToSolve(false), - myConstrSolver() +SketchSolver_ConstraintGroup::SketchSolver_ConstraintGroup( + boost::shared_ptr theWorkplane) + : myID(++myGroupIndexer), + myParamMaxID(0), + myEntityMaxID(0), + myConstrMaxID(0), + myConstraintMap(), + myNeedToSolve(false), + myConstrSolver() { myParams.clear(); myEntities.clear(); myConstraints.clear(); - + myTempConstraints.clear(); myTempPointWhereDragged.clear(); myTempPointWDrgdID = 0; @@ -112,7 +112,7 @@ SketchSolver_ConstraintGroup::~SketchSolver_ConstraintGroup() // Purpose: verify the group is based on the given workplane // ============================================================================ bool SketchSolver_ConstraintGroup::isBaseWorkplane( - boost::shared_ptr theWorkplane) const + boost::shared_ptr theWorkplane) const { return theWorkplane == mySketch; } @@ -123,38 +123,36 @@ bool SketchSolver_ConstraintGroup::isBaseWorkplane( // Purpose: verify are there any entities in the group used by given constraint // ============================================================================ bool SketchSolver_ConstraintGroup::isInteract( - boost::shared_ptr theConstraint) const + boost::shared_ptr theConstraint) const { // Check the group is empty if (myWorkplane.h != SLVS_E_UNKNOWN && myConstraints.empty()) return true; // Go through constraint entities and verify if some of them already in the group - for (int i = 0; i < CONSTRAINT_ATTR_SIZE; i++) - { - boost::shared_ptr aCAttrRef = - boost::dynamic_pointer_cast( - theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(i)) - ); - if (!aCAttrRef) continue; - if (!aCAttrRef->isObject() && - myEntityAttrMap.find(aCAttrRef->attr()) != myEntityAttrMap.end()) + for (int i = 0; i < CONSTRAINT_ATTR_SIZE; i++) { + boost::shared_ptr aCAttrRef = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>( + theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(i))); + if (!aCAttrRef) + continue; + if (!aCAttrRef->isObject() && myEntityAttrMap.find(aCAttrRef->attr()) != myEntityAttrMap.end()) return true; - if (aCAttrRef->isObject()) - { // Obtain a base feature for the object - ResultConstructionPtr aRC = - boost::dynamic_pointer_cast(aCAttrRef->object()); - if (!aRC) continue; + if (aCAttrRef->isObject()) { // Obtain a base feature for the object + ResultConstructionPtr aRC = boost::dynamic_pointer_cast( + aCAttrRef->object()); + if (!aRC) + continue; boost::shared_ptr aDoc = aRC->document(); FeaturePtr aFeature = aDoc->feature(aRC); if (myEntityFeatMap.find(aFeature) != myEntityFeatMap.end()) return true; // search attributes of a feature to be parameters of constraint - std::list< boost::shared_ptr > - aFeatAttrList = aFeature->data()->attributes(std::string()); - std::list< boost::shared_ptr >::const_iterator - aFAIter = aFeatAttrList.begin(); - for ( ; aFAIter != aFeatAttrList.end(); aFAIter++) + std::list > aFeatAttrList = + aFeature->data()->attributes(std::string()); + std::list >::const_iterator aFAIter = aFeatAttrList + .begin(); + for (; aFAIter != aFeatAttrList.end(); aFAIter++) if (myEntityAttrMap.find(*aFAIter) != myEntityAttrMap.end()) return true; } @@ -171,26 +169,25 @@ bool SketchSolver_ConstraintGroup::isInteract( // ============================================================================ void SketchSolver_ConstraintGroup::checkConstraintConsistence(Slvs_Constraint& theConstraint) { - if (theConstraint.type == SLVS_C_PT_LINE_DISTANCE) - { + if (theConstraint.type == SLVS_C_PT_LINE_DISTANCE) { // Get constraint parameters and check the sign of constraint value - + // point coordinates int aPtPos = Search(theConstraint.ptA, myEntities); int aPtParamPos = Search(myEntities[aPtPos].param[0], myParams); boost::shared_ptr aPoint( - new GeomAPI_XY(myParams[aPtParamPos].val, myParams[aPtParamPos+1].val)); + new GeomAPI_XY(myParams[aPtParamPos].val, myParams[aPtParamPos + 1].val)); // line coordinates int aLnPos = Search(theConstraint.entityA, myEntities); aPtPos = Search(myEntities[aLnPos].point[0], myEntities); aPtParamPos = Search(myEntities[aPtPos].param[0], myParams); boost::shared_ptr aStart( - new GeomAPI_XY(-myParams[aPtParamPos].val, -myParams[aPtParamPos+1].val)); + new GeomAPI_XY(-myParams[aPtParamPos].val, -myParams[aPtParamPos + 1].val)); aPtPos = Search(myEntities[aLnPos].point[1], myEntities); aPtParamPos = Search(myEntities[aPtPos].param[0], myParams); boost::shared_ptr aEnd( - new GeomAPI_XY(myParams[aPtParamPos].val, myParams[aPtParamPos+1].val)); + new GeomAPI_XY(myParams[aPtParamPos].val, myParams[aPtParamPos + 1].val)); aEnd = aEnd->added(aStart); aPoint = aPoint->added(aStart); @@ -205,18 +202,17 @@ void SketchSolver_ConstraintGroup::checkConstraintConsistence(Slvs_Constraint& t // Purpose: create/update the constraint in the group // ============================================================================ bool SketchSolver_ConstraintGroup::changeConstraint( - boost::shared_ptr theConstraint) + boost::shared_ptr theConstraint) { // There is no workplane yet, something wrong if (myWorkplane.h == SLVS_E_UNKNOWN) return false; // Search this constraint in the current group to update it - std::map, Slvs_hConstraint>::const_iterator - aConstrMapIter = myConstraintMap.find(theConstraint); + std::map, Slvs_hConstraint>::const_iterator aConstrMapIter = + myConstraintMap.find(theConstraint); std::vector::iterator aConstrIter; - if (aConstrMapIter != myConstraintMap.end()) - { + if (aConstrMapIter != myConstraintMap.end()) { int aConstrPos = Search(aConstrMapIter->second, myConstraints); aConstrIter = myConstraints.begin() + aConstrPos; } @@ -224,84 +220,78 @@ bool SketchSolver_ConstraintGroup::changeConstraint( // Get constraint type and verify the constraint parameters are correct SketchSolver_Constraint aConstraint(theConstraint); int aConstrType = aConstraint.getType(); - if (aConstrType == SLVS_C_UNKNOWN || - (aConstrMapIter != myConstraintMap.end() && aConstrIter->type != aConstrType)) + if (aConstrType == SLVS_C_UNKNOWN + || (aConstrMapIter != myConstraintMap.end() && aConstrIter->type != aConstrType)) return false; const std::vector& aConstraintAttributes = aConstraint.getAttributes(); // Create constraint parameters - double aDistance = 0.0; // scalar value of the constraint - AttributeDoublePtr aDistAttr = - boost::dynamic_pointer_cast(theConstraint->data()->attribute(SketchPlugin_Constraint::VALUE())); - if (aDistAttr) - { + double aDistance = 0.0; // scalar value of the constraint + AttributeDoublePtr aDistAttr = boost::dynamic_pointer_cast( + theConstraint->data()->attribute(SketchPlugin_Constraint::VALUE())); + if (aDistAttr) { aDistance = aDistAttr->value(); // SketchPlugin circle defined by its radius, but SolveSpace uses constraint for diameter if (aConstrType == SLVS_C_DIAMETER) aDistance *= 2.0; - if (aConstrMapIter != myConstraintMap.end() && fabs(aConstrIter->valA - aDistance) > tolerance) - { + if (aConstrMapIter != myConstraintMap.end() + && fabs(aConstrIter->valA - aDistance) > tolerance) { myNeedToSolve = true; aConstrIter->valA = aDistance; } } - Slvs_hEntity aConstrEnt[CONSTRAINT_ATTR_SIZE]; // parameters of the constraint - for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) - { + Slvs_hEntity aConstrEnt[CONSTRAINT_ATTR_SIZE]; // parameters of the constraint + for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) { aConstrEnt[indAttr] = SLVS_E_UNKNOWN; - boost::shared_ptr aConstrAttr = - boost::dynamic_pointer_cast( - theConstraint->data()->attribute(aConstraintAttributes[indAttr]) - ); - if (!aConstrAttr) continue; + boost::shared_ptr aConstrAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>( + theConstraint->data()->attribute(aConstraintAttributes[indAttr])); + if (!aConstrAttr) + continue; // Convert the object of the attribute to the feature FeaturePtr aFeature; - if (aConstrAttr->isObject() && aConstrAttr->object()) - { - ResultConstructionPtr aRC = - boost::dynamic_pointer_cast(aConstrAttr->object()); - if (!aRC) continue; + if (aConstrAttr->isObject() && aConstrAttr->object()) { + ResultConstructionPtr aRC = boost::dynamic_pointer_cast( + aConstrAttr->object()); + if (!aRC) + continue; boost::shared_ptr aDoc = aRC->document(); aFeature = aDoc->feature(aRC); } // For the length constraint the start and end points of the line should be added to the entities list instead of line - if (aConstrType == SLVS_C_PT_PT_DISTANCE && theConstraint->getKind().compare(SketchPlugin_ConstraintLength::ID()) == 0) - { + if (aConstrType == SLVS_C_PT_PT_DISTANCE + && theConstraint->getKind().compare(SketchPlugin_ConstraintLength::ID()) == 0) { boost::shared_ptr aData = aFeature->data(); - aConstrEnt[indAttr] = changeEntity(aData->attribute(SketchPlugin_Line::START_ID())); - aConstrEnt[indAttr+1] = changeEntity(aData->attribute(SketchPlugin_Line::END_ID())); + aConstrEnt[indAttr] = changeEntity(aData->attribute(SketchPlugin_Line::START_ID())); + aConstrEnt[indAttr + 1] = changeEntity(aData->attribute(SketchPlugin_Line::END_ID())); // measured object is added into the map of objects to avoid problems with interaction between constraint and group myEntityFeatMap[aFeature] = 0; - break; // there should be no other entities - } - else if (aConstrAttr->isObject()) + break; // there should be no other entities + } else if (aConstrAttr->isObject()) aConstrEnt[indAttr] = changeEntity(aFeature); else aConstrEnt[indAttr] = changeEntity(aConstrAttr->attr()); } - if (aConstrMapIter == myConstraintMap.end()) - { + if (aConstrMapIter == myConstraintMap.end()) { // Several points may be coincident, it is not necessary to store all constraints between them. // Try to find sequence of coincident points which connects the points of new constraint - if (aConstrType == SLVS_C_POINTS_COINCIDENT) - { - if (aConstrEnt[0] == aConstrEnt[1]) // no need to add self coincidence + if (aConstrType == SLVS_C_POINTS_COINCIDENT) { + if (aConstrEnt[0] == aConstrEnt[1]) // no need to add self coincidence return false; - if (!addCoincidentPoints(aConstrEnt[0], aConstrEnt[1])) - { - myExtraCoincidence.insert(theConstraint); // the constraint is stored for further purposes + if (!addCoincidentPoints(aConstrEnt[0], aConstrEnt[1])) { + myExtraCoincidence.insert(theConstraint); // the constraint is stored for further purposes return false; } } // Create SolveSpace constraint structure - Slvs_Constraint aConstraint = - Slvs_MakeConstraint(++myConstrMaxID, myID, aConstrType, myWorkplane.h, - aDistance, aConstrEnt[0], aConstrEnt[1], aConstrEnt[2], aConstrEnt[3]); + Slvs_Constraint aConstraint = Slvs_MakeConstraint(++myConstrMaxID, myID, aConstrType, + myWorkplane.h, aDistance, aConstrEnt[0], + aConstrEnt[1], aConstrEnt[2], aConstrEnt[3]); myConstraints.push_back(aConstraint); myConstraintMap[theConstraint] = aConstraint.h; int aConstrPos = Search(aConstraint.h, myConstraints); @@ -318,29 +308,27 @@ bool SketchSolver_ConstraintGroup::changeConstraint( // Purpose: create/update the element affected by any constraint // ============================================================================ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( - boost::shared_ptr theEntity) + boost::shared_ptr theEntity) { // If the entity is already in the group, try to find it - std::map, Slvs_hEntity>::const_iterator - aEntIter = myEntityAttrMap.find(theEntity); - std::vector::const_iterator aParamIter; // looks at first parameter of already existent entity or at the end of vector otherwise - if (aEntIter == myEntityAttrMap.end()) // no such entity => should be created + std::map, Slvs_hEntity>::const_iterator aEntIter = + myEntityAttrMap.find(theEntity); + std::vector::const_iterator aParamIter; // looks at first parameter of already existent entity or at the end of vector otherwise + if (aEntIter == myEntityAttrMap.end()) // no such entity => should be created aParamIter = myParams.end(); - else - { // the entity already exists + else { // the entity already exists int aEntPos = Search(aEntIter->second, myEntities); int aParamPos = Search(myEntities[aEntPos].param[0], myParams); aParamIter = myParams.begin() + aParamPos; } - const bool isEntExists = (aEntIter != myEntityAttrMap.end()); // defines that the entity already exists + const bool isEntExists = (aEntIter != myEntityAttrMap.end()); // defines that the entity already exists // Look over supported types of entities // Point in 3D - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(theEntity); - if (aPoint) - { + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + theEntity); + if (aPoint) { Slvs_hParam aX = changeParameter(aPoint->x(), aParamIter); Slvs_hParam aY = changeParameter(aPoint->y(), aParamIter); Slvs_hParam aZ = changeParameter(aPoint->z(), aParamIter); @@ -361,9 +349,8 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( // Point in 2D boost::shared_ptr aPoint2D = - boost::dynamic_pointer_cast(theEntity); - if (aPoint2D) - { + boost::dynamic_pointer_cast(theEntity); + if (aPoint2D) { Slvs_hParam aU = changeParameter(aPoint2D->x(), aParamIter); Slvs_hParam aV = changeParameter(aPoint2D->y(), aParamIter); @@ -378,10 +365,8 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( } // Scalar value (used for the distance entities) - AttributeDoublePtr aScalar = - boost::dynamic_pointer_cast(theEntity); - if (aScalar) - { + AttributeDoublePtr aScalar = boost::dynamic_pointer_cast(theEntity); + if (aScalar) { Slvs_hParam aValue = changeParameter(aScalar->value(), aParamIter); if (isEntExists) @@ -400,79 +385,77 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( return SLVS_E_UNKNOWN; } - // ============================================================================ // Function: changeEntity // Class: SketchSolver_ConstraintGroup // Purpose: create/update the element defined by the feature affected by any constraint // ============================================================================ -Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( - FeaturePtr theEntity) +Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(FeaturePtr theEntity) { // If the entity is already in the group, try to find it - std::map::const_iterator - aEntIter = myEntityFeatMap.find(theEntity); + std::map::const_iterator aEntIter = myEntityFeatMap.find(theEntity); // defines that the entity already exists const bool isEntExists = (myEntityFeatMap.find(theEntity) != myEntityFeatMap.end()); // SketchPlugin features - boost::shared_ptr aFeature = - boost::dynamic_pointer_cast(theEntity); - if (aFeature) - { // Verify the feature by its kind + boost::shared_ptr aFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(theEntity); + if (aFeature) { // Verify the feature by its kind const std::string& aFeatureKind = aFeature->getKind(); // Line - if (aFeatureKind.compare(SketchPlugin_Line::ID()) == 0) - { - Slvs_hEntity aStart = changeEntity(aFeature->data()->attribute(SketchPlugin_Line::START_ID())); - Slvs_hEntity aEnd = changeEntity(aFeature->data()->attribute(SketchPlugin_Line::END_ID())); + if (aFeatureKind.compare(SketchPlugin_Line::ID()) == 0) { + Slvs_hEntity aStart = changeEntity( + aFeature->data()->attribute(SketchPlugin_Line::START_ID())); + Slvs_hEntity aEnd = changeEntity(aFeature->data()->attribute(SketchPlugin_Line::END_ID())); if (isEntExists) return aEntIter->second; // New entity - Slvs_Entity aLineEntity = Slvs_MakeLineSegment(++myEntityMaxID, myID, myWorkplane.h, aStart, aEnd); + Slvs_Entity aLineEntity = Slvs_MakeLineSegment(++myEntityMaxID, myID, myWorkplane.h, aStart, + aEnd); myEntities.push_back(aLineEntity); myEntityFeatMap[theEntity] = aLineEntity.h; return aLineEntity.h; } // Circle - else if (aFeatureKind.compare(SketchPlugin_Circle::ID()) == 0) - { - Slvs_hEntity aCenter = changeEntity(aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID())); - Slvs_hEntity aRadius = changeEntity(aFeature->data()->attribute(SketchPlugin_Circle::RADIUS_ID())); + else if (aFeatureKind.compare(SketchPlugin_Circle::ID()) == 0) { + Slvs_hEntity aCenter = changeEntity( + aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID())); + Slvs_hEntity aRadius = changeEntity( + aFeature->data()->attribute(SketchPlugin_Circle::RADIUS_ID())); if (isEntExists) return aEntIter->second; // New entity - Slvs_Entity aCircleEntity = - Slvs_MakeCircle(++myEntityMaxID, myID, myWorkplane.h, aCenter, myWorkplane.normal, aRadius); + Slvs_Entity aCircleEntity = Slvs_MakeCircle(++myEntityMaxID, myID, myWorkplane.h, aCenter, + myWorkplane.normal, aRadius); myEntities.push_back(aCircleEntity); myEntityFeatMap[theEntity] = aCircleEntity.h; return aCircleEntity.h; } // Arc - else if (aFeatureKind.compare(SketchPlugin_Arc::ID()) == 0) - { - Slvs_hEntity aCenter = changeEntity(aFeature->data()->attribute(SketchPlugin_Arc::CENTER_ID())); - Slvs_hEntity aStart = changeEntity(aFeature->data()->attribute(SketchPlugin_Arc::START_ID())); - Slvs_hEntity aEnd = changeEntity(aFeature->data()->attribute(SketchPlugin_Arc::END_ID())); + else if (aFeatureKind.compare(SketchPlugin_Arc::ID()) == 0) { + Slvs_hEntity aCenter = changeEntity( + aFeature->data()->attribute(SketchPlugin_Arc::CENTER_ID())); + Slvs_hEntity aStart = changeEntity(aFeature->data()->attribute(SketchPlugin_Arc::START_ID())); + Slvs_hEntity aEnd = changeEntity(aFeature->data()->attribute(SketchPlugin_Arc::END_ID())); if (isEntExists) return aEntIter->second; - Slvs_Entity anArcEntity = Slvs_MakeArcOfCircle(++myEntityMaxID, myID, - myWorkplane.h, myWorkplane.normal, aCenter, aStart, aEnd); + Slvs_Entity anArcEntity = Slvs_MakeArcOfCircle(++myEntityMaxID, myID, myWorkplane.h, + myWorkplane.normal, aCenter, aStart, aEnd); myEntities.push_back(anArcEntity); myEntityFeatMap[theEntity] = anArcEntity.h; return anArcEntity.h; } // Point (it has low probability to be an attribute of constraint, so it is checked at the end) - else if (aFeatureKind.compare(SketchPlugin_Point::ID()) == 0) - { - Slvs_hEntity aPoint = changeEntity(aFeature->data()->attribute(SketchPlugin_Point::COORD_ID())); + else if (aFeatureKind.compare(SketchPlugin_Point::ID()) == 0) { + Slvs_hEntity aPoint = changeEntity( + aFeature->data()->attribute(SketchPlugin_Point::COORD_ID())); if (isEntExists) return aEntIter->second; @@ -495,34 +478,28 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( // Purpose: create/update the normal of workplane // ============================================================================ Slvs_hEntity SketchSolver_ConstraintGroup::changeNormal( - boost::shared_ptr theDirX, - boost::shared_ptr theDirY, - boost::shared_ptr theNorm) + boost::shared_ptr theDirX, boost::shared_ptr theDirY, + boost::shared_ptr theNorm) { - boost::shared_ptr aDirX = - boost::dynamic_pointer_cast(theDirX); - boost::shared_ptr aDirY = - boost::dynamic_pointer_cast(theDirY); - if (!aDirX || !aDirY || - (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance) || - (fabs(aDirY->x()) + fabs(aDirY->y()) + fabs(aDirY->z()) < tolerance)) + boost::shared_ptr aDirX = boost::dynamic_pointer_cast(theDirX); + boost::shared_ptr aDirY = boost::dynamic_pointer_cast(theDirY); + if (!aDirX || !aDirY || (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance) + || (fabs(aDirY->x()) + fabs(aDirY->y()) + fabs(aDirY->z()) < tolerance)) return SLVS_E_UNKNOWN; // quaternion parameters of normal vector double qw, qx, qy, qz; - Slvs_MakeQuaternion(aDirX->x(), aDirX->y(), aDirX->z(), - aDirY->x(), aDirY->y(), aDirY->z(), - &qw, &qx, &qy, &qz); - double aNormCoord[4] = {qw, qx, qy, qz}; + Slvs_MakeQuaternion(aDirX->x(), aDirX->y(), aDirX->z(), aDirY->x(), aDirY->y(), aDirY->z(), &qw, + &qx, &qy, &qz); + double aNormCoord[4] = { qw, qx, qy, qz }; // Try to find existent normal - std::map, Slvs_hEntity>::const_iterator - aEntIter = myEntityAttrMap.find(theNorm); - std::vector::const_iterator aParamIter; // looks to the first parameter of already existent entity or to the end of vector otherwise - if (aEntIter == myEntityAttrMap.end()) // no such entity => should be created + std::map, Slvs_hEntity>::const_iterator aEntIter = + myEntityAttrMap.find(theNorm); + std::vector::const_iterator aParamIter; // looks to the first parameter of already existent entity or to the end of vector otherwise + if (aEntIter == myEntityAttrMap.end()) // no such entity => should be created aParamIter = myParams.end(); - else - { // the entity already exists, update it + else { // the entity already exists, update it int aEntPos = Search(aEntIter->second, myEntities); int aParamPos = Search(myEntities[aEntPos].param[0], myParams); aParamIter = myParams.begin() + aParamPos; @@ -533,28 +510,26 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeNormal( for (int i = 0; i < 4; i++) aNormParams[i] = changeParameter(aNormCoord[i], aParamIter); - if (aEntIter != myEntityAttrMap.end()) // the entity already exists + if (aEntIter != myEntityAttrMap.end()) // the entity already exists return aEntIter->second; // Create a normal - Slvs_Entity aNormal = Slvs_MakeNormal3d(++myEntityMaxID, myID, - aNormParams[0], aNormParams[1], aNormParams[2], aNormParams[3]); + Slvs_Entity aNormal = Slvs_MakeNormal3d(++myEntityMaxID, myID, aNormParams[0], aNormParams[1], + aNormParams[2], aNormParams[3]); myEntities.push_back(aNormal); myEntityAttrMap[theNorm] = aNormal.h; return aNormal.h; } - // ============================================================================ // Function: addWorkplane // Class: SketchSolver_ConstraintGroup // Purpose: create workplane for the group // ============================================================================ -bool SketchSolver_ConstraintGroup::addWorkplane( - boost::shared_ptr theSketch) +bool SketchSolver_ConstraintGroup::addWorkplane(boost::shared_ptr theSketch) { if (myWorkplane.h || theSketch->getKind().compare(SketchPlugin_Sketch::ID()) != 0) - return false; // the workplane already exists or the function parameter is not Sketch + return false; // the workplane already exists or the function parameter is not Sketch mySketch = theSketch; updateWorkplane(); @@ -569,18 +544,23 @@ bool SketchSolver_ConstraintGroup::addWorkplane( bool SketchSolver_ConstraintGroup::updateWorkplane() { // Get parameters of workplane - boost::shared_ptr aDirX = mySketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID()); - boost::shared_ptr aDirY = mySketch->data()->attribute(SketchPlugin_Sketch::DIRY_ID()); - boost::shared_ptr aNorm = mySketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()); - boost::shared_ptr anOrigin = mySketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()); + boost::shared_ptr aDirX = mySketch->data()->attribute( + SketchPlugin_Sketch::DIRX_ID()); + boost::shared_ptr aDirY = mySketch->data()->attribute( + SketchPlugin_Sketch::DIRY_ID()); + boost::shared_ptr aNorm = mySketch->data()->attribute( + SketchPlugin_Sketch::NORM_ID()); + boost::shared_ptr anOrigin = mySketch->data()->attribute( + SketchPlugin_Sketch::ORIGIN_ID()); // Transform them into SolveSpace format Slvs_hEntity aNormalWP = changeNormal(aDirX, aDirY, aNorm); - if (!aNormalWP) return false; + if (!aNormalWP) + return false; Slvs_hEntity anOriginWP = changeEntity(anOrigin); - if (!anOriginWP) return false; + if (!anOriginWP) + return false; - if (!myWorkplane.h) - { + if (!myWorkplane.h) { // Create workplane myWorkplane = Slvs_MakeWorkplane(++myEntityMaxID, myID, anOriginWP, aNormalWP); // Workplane should be added to the list of entities @@ -595,15 +575,12 @@ bool SketchSolver_ConstraintGroup::updateWorkplane() // Purpose: create/update value of parameter // ============================================================================ Slvs_hParam SketchSolver_ConstraintGroup::changeParameter( - const double& theParam, - std::vector::const_iterator& thePrmIter) + const double& theParam, std::vector::const_iterator& thePrmIter) { - if (thePrmIter != myParams.end()) - { // Parameter should be updated + if (thePrmIter != myParams.end()) { // Parameter should be updated int aParamPos = thePrmIter - myParams.begin(); - if (fabs(thePrmIter->val - theParam) > tolerance) - { - myNeedToSolve = true; // parameter is changed, need to resolve constraints + if (fabs(thePrmIter->val - theParam) > tolerance) { + myNeedToSolve = true; // parameter is changed, need to resolve constraints myParams[aParamPos].val = theParam; } thePrmIter++; @@ -636,20 +613,18 @@ void SketchSolver_ConstraintGroup::resolveConstraints() myConstrSolver.setDraggedParameters(myTempPointWhereDragged); int aResult = myConstrSolver.solve(); - if (aResult == SLVS_RESULT_OKAY) - { // solution succeeded, store results into correspondent attributes - // Obtain result into the same list of parameters + if (aResult == SLVS_RESULT_OKAY) { // solution succeeded, store results into correspondent attributes + // Obtain result into the same list of parameters if (!myConstrSolver.getResult(myParams)) return; // We should go through the attributes map, because only attributes have valued parameters - std::map, Slvs_hEntity>::iterator - anEntIter = myEntityAttrMap.begin(); - for ( ; anEntIter != myEntityAttrMap.end(); anEntIter++) + std::map, Slvs_hEntity>::iterator anEntIter = + myEntityAttrMap.begin(); + for (; anEntIter != myEntityAttrMap.end(); anEntIter++) if (updateAttribute(anEntIter->first, anEntIter->second)) updateRelatedConstraints(anEntIter->first); - } - else if (!myConstraints.empty()) + } else if (!myConstraints.empty()) Events_Error::send(SketchSolver_Error::CONSTRAINTS(), this); removeTemporaryConstraints(); @@ -661,41 +636,38 @@ void SketchSolver_ConstraintGroup::resolveConstraints() // Class: SketchSolver_ConstraintGroup // Purpose: append specified group to the current group // ============================================================================ -void SketchSolver_ConstraintGroup::mergeGroups( - const SketchSolver_ConstraintGroup& theGroup) +void SketchSolver_ConstraintGroup::mergeGroups(const SketchSolver_ConstraintGroup& theGroup) { // If specified group is empty, no need to merge if (theGroup.myConstraintMap.empty()) - return ; + return; // Map between old and new indexes of SolveSpace constraints std::map aConstrMap; // Add all constraints from theGroup to the current group - std::map, Slvs_hConstraint>::const_iterator - aConstrIter = theGroup.myConstraintMap.begin(); - for ( ; aConstrIter != theGroup.myConstraintMap.end(); aConstrIter++) + std::map, Slvs_hConstraint>::const_iterator aConstrIter = + theGroup.myConstraintMap.begin(); + for (; aConstrIter != theGroup.myConstraintMap.end(); aConstrIter++) if (changeConstraint(aConstrIter->first)) - aConstrMap[aConstrIter->second] = myConstrMaxID; // the constraint was added => store its ID + aConstrMap[aConstrIter->second] = myConstrMaxID; // the constraint was added => store its ID // Add temporary constraints from theGroup std::list::const_iterator aTempConstrIter = theGroup.myTempConstraints.begin(); - for ( ; aTempConstrIter != theGroup.myTempConstraints.end(); aTempConstrIter++) - { - std::map::iterator aFind = aConstrMap.find(*aTempConstrIter); + for (; aTempConstrIter != theGroup.myTempConstraints.end(); aTempConstrIter++) { + std::map::iterator aFind = aConstrMap.find( + *aTempConstrIter); if (aFind != aConstrMap.end()) myTempConstraints.push_back(aFind->second); } if (myTempPointWhereDragged.empty()) myTempPointWhereDragged = theGroup.myTempPointWhereDragged; - else if (!theGroup.myTempPointWhereDragged.empty()) - { // Need to create additional transient constraint - std::map, Slvs_hEntity>::const_iterator - aFeatureIter = theGroup.myEntityAttrMap.begin(); + else if (!theGroup.myTempPointWhereDragged.empty()) { // Need to create additional transient constraint + std::map, Slvs_hEntity>::const_iterator aFeatureIter = + theGroup.myEntityAttrMap.begin(); for (; aFeatureIter != theGroup.myEntityAttrMap.end(); aFeatureIter++) - if (aFeatureIter->second == myTempPointWDrgdID) - { + if (aFeatureIter->second == myTempPointWDrgdID) { addTemporaryConstraintWhereDragged(aFeatureIter->first); break; } @@ -712,20 +684,17 @@ void SketchSolver_ConstraintGroup::mergeGroups( void SketchSolver_ConstraintGroup::splitGroup(std::vector& theCuts) { // Divide constraints and entities into several groups - std::vector< std::set > aGroupsEntities; - std::vector< std::set > aGroupsConstr; - int aMaxNbEntities = 0; // index of the group with maximal nuber of elements (this group will be left in the current) + std::vector > aGroupsEntities; + std::vector > aGroupsConstr; + int aMaxNbEntities = 0; // index of the group with maximal nuber of elements (this group will be left in the current) std::vector::const_iterator aConstrIter = myConstraints.begin(); - for ( ; aConstrIter != myConstraints.end(); aConstrIter++) - { - Slvs_hEntity aConstrEnt[] = { - aConstrIter->ptA, aConstrIter->ptB, - aConstrIter->entityA, aConstrIter->entityB}; + for (; aConstrIter != myConstraints.end(); aConstrIter++) { + Slvs_hEntity aConstrEnt[] = { aConstrIter->ptA, aConstrIter->ptB, aConstrIter->entityA, + aConstrIter->entityB }; std::vector anIndexes; // Go through the groupped entities and find even one of entities of current constraint - std::vector< std::set >::iterator aGrEntIter; - for (aGrEntIter = aGroupsEntities.begin(); aGrEntIter != aGroupsEntities.end(); aGrEntIter++) - { + std::vector >::iterator aGrEntIter; + for (aGrEntIter = aGroupsEntities.begin(); aGrEntIter != aGroupsEntities.end(); aGrEntIter++) { bool isFound = false; for (int i = 0; i < 4 && !isFound; i++) if (aConstrEnt[i] != 0) @@ -734,8 +703,7 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vector aNewGrEnt; for (int i = 0; i < 4; i++) if (aConstrEnt[i] != 0) @@ -747,9 +715,7 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vector aGroupsEntities[aMaxNbEntities].size()) aMaxNbEntities = aGroupsEntities.size() - 1; - } - else if (anIndexes.size() == 1) - { // Add entities indexes into the found group + } else if (anIndexes.size() == 1) { // Add entities indexes into the found group aGrEntIter = aGroupsEntities.begin() + anIndexes.front(); for (int i = 0; i < 4; i++) if (aConstrEnt[i] != 0) @@ -757,24 +723,20 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vectorh); if (aGrEntIter->size() > aGroupsEntities[aMaxNbEntities].size()) aMaxNbEntities = aGrEntIter - aGroupsEntities.begin(); - } - else - { // There are found several connected groups, merge them - std::vector< std::set >::iterator aFirstGroup = - aGroupsEntities.begin() + anIndexes.front(); - std::vector< std::set >::iterator aFirstConstr = - aGroupsConstr.begin() + anIndexes.front(); + } else { // There are found several connected groups, merge them + std::vector >::iterator aFirstGroup = aGroupsEntities.begin() + + anIndexes.front(); + std::vector >::iterator aFirstConstr = aGroupsConstr.begin() + + anIndexes.front(); std::vector::iterator anInd = anIndexes.begin(); - for (++anInd; anInd != anIndexes.end(); anInd++) - { + for (++anInd; anInd != anIndexes.end(); anInd++) { aFirstGroup->insert(aGroupsEntities[*anInd].begin(), aGroupsEntities[*anInd].end()); aFirstConstr->insert(aGroupsConstr[*anInd].begin(), aGroupsConstr[*anInd].end()); } if (aFirstGroup->size() > aGroupsEntities[aMaxNbEntities].size()) aMaxNbEntities = anIndexes.front(); // Remove merged groups - for (anInd = anIndexes.end() - 1; anInd != anIndexes.begin(); anInd--) - { + for (anInd = anIndexes.end() - 1; anInd != anIndexes.begin(); anInd--) { aGroupsEntities.erase(aGroupsEntities.begin() + (*anInd)); aGroupsConstr.erase(aGroupsConstr.begin() + (*anInd)); } @@ -782,7 +744,7 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vector aNewGroups; - for (int i = aGroupsEntities.size(); i > 0; i--) - { + for (int i = aGroupsEntities.size(); i > 0; i--) { SketchSolver_ConstraintGroup* aG = new SketchSolver_ConstraintGroup(mySketch); aNewGroups.push_back(aG); } - std::map, Slvs_hConstraint>::const_iterator - aConstrMapIter = myConstraintMap.begin(); - int aConstrMapPos = 0; // position of iterator in the map (used to restore iterator after removing constraint) - while (aConstrMapIter != myConstraintMap.end()) - { - std::vector< std::set >::const_iterator aGIter = aGroupsConstr.begin(); + std::map, Slvs_hConstraint>::const_iterator aConstrMapIter = + myConstraintMap.begin(); + int aConstrMapPos = 0; // position of iterator in the map (used to restore iterator after removing constraint) + while (aConstrMapIter != myConstraintMap.end()) { + std::vector >::const_iterator aGIter = aGroupsConstr.begin(); std::vector::iterator aGroup = aNewGroups.begin(); - for ( ; aGIter != aGroupsConstr.end(); aGIter++, aGroup++) - if (aGIter->find(aConstrMapIter->second) != aGIter->end()) - { + for (; aGIter != aGroupsConstr.end(); aGIter++, aGroup++) + if (aGIter->find(aConstrMapIter->second) != aGIter->end()) { (*aGroup)->changeConstraint(aConstrMapIter->first); removeConstraint(aConstrMapIter->first); // restore iterator @@ -813,8 +772,7 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vector, Slvs_hConstraint>::reverse_iterator - aConstrIter = myConstraintMap.rbegin(); + std::map, Slvs_hConstraint>::reverse_iterator aConstrIter = + myConstraintMap.rbegin(); bool isAllValid = true; - bool isCCRemoved = false; // indicates that at least one of coincidence constraints was removed - while (isAllValid && aConstrIter != myConstraintMap.rend()) - { - if (!aConstrIter->first->data()->isValid()) - { + bool isCCRemoved = false; // indicates that at least one of coincidence constraints was removed + while (isAllValid && aConstrIter != myConstraintMap.rend()) { + if (!aConstrIter->first->data()->isValid()) { if (aConstrIter->first->getKind().compare(SketchPlugin_ConstraintCoincidence::ID()) == 0) isCCRemoved = true; - std::map, Slvs_hConstraint>::reverse_iterator - aCopyIter = aConstrIter++; + std::map, Slvs_hConstraint>::reverse_iterator aCopyIter = + aConstrIter++; removeConstraint(aCopyIter->first); isAllValid = false; - } - else aConstrIter++; + } else + aConstrIter++; } // Probably, need to update coincidence constraints - if (isCCRemoved && !myExtraCoincidence.empty()) - { + if (isCCRemoved && !myExtraCoincidence.empty()) { // Make a copy, because the new list of unused constrtaints will be generated - std::set< boost::shared_ptr > anExtraCopy = myExtraCoincidence; + std::set > anExtraCopy = myExtraCoincidence; myExtraCoincidence.clear(); - std::set< boost::shared_ptr >::iterator - aCIter = anExtraCopy.begin(); - for ( ; aCIter != anExtraCopy.end(); aCIter++) + std::set >::iterator aCIter = anExtraCopy.begin(); + for (; aCIter != anExtraCopy.end(); aCIter++) if ((*aCIter)->data()->isValid()) changeConstraint(*aCIter); } @@ -871,8 +825,7 @@ bool SketchSolver_ConstraintGroup::updateGroup() // Purpose: update features of sketch after resolving constraints // ============================================================================ bool SketchSolver_ConstraintGroup::updateAttribute( - boost::shared_ptr theAttribute, - const Slvs_hEntity& theEntityID) + boost::shared_ptr theAttribute, const Slvs_hEntity& theEntityID) { // Search the position of the first parameter of the entity int anEntPos = Search(theEntityID, myEntities); @@ -881,17 +834,14 @@ bool SketchSolver_ConstraintGroup::updateAttribute( // Look over supported types of entities // Point in 3D - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(theAttribute); - if (aPoint) - { - if (fabs(aPoint->x() - myParams[aFirstParamPos].val) > tolerance || - fabs(aPoint->y() - myParams[aFirstParamPos+1].val) > tolerance || - fabs(aPoint->z() - myParams[aFirstParamPos+2].val) > tolerance) - { - aPoint->setValue(myParams[aFirstParamPos].val, - myParams[aFirstParamPos+1].val, - myParams[aFirstParamPos+2].val); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + theAttribute); + if (aPoint) { + if (fabs(aPoint->x() - myParams[aFirstParamPos].val) > tolerance + || fabs(aPoint->y() - myParams[aFirstParamPos + 1].val) > tolerance + || fabs(aPoint->z() - myParams[aFirstParamPos + 2].val) > tolerance) { + aPoint->setValue(myParams[aFirstParamPos].val, myParams[aFirstParamPos + 1].val, + myParams[aFirstParamPos + 2].val); return true; } return false; @@ -899,26 +849,20 @@ bool SketchSolver_ConstraintGroup::updateAttribute( // Point in 2D boost::shared_ptr aPoint2D = - boost::dynamic_pointer_cast(theAttribute); - if (aPoint2D) - { - if (fabs(aPoint2D->x() - myParams[aFirstParamPos].val) > tolerance || - fabs(aPoint2D->y() - myParams[aFirstParamPos+1].val) > tolerance) - { - aPoint2D->setValue(myParams[aFirstParamPos].val, - myParams[aFirstParamPos+1].val); + boost::dynamic_pointer_cast(theAttribute); + if (aPoint2D) { + if (fabs(aPoint2D->x() - myParams[aFirstParamPos].val) > tolerance + || fabs(aPoint2D->y() - myParams[aFirstParamPos + 1].val) > tolerance) { + aPoint2D->setValue(myParams[aFirstParamPos].val, myParams[aFirstParamPos + 1].val); return true; } return false; } // Scalar value - AttributeDoublePtr aScalar = - boost::dynamic_pointer_cast(theAttribute); - if (aScalar) - { - if (fabs(aScalar->value() - myParams[aFirstParamPos].val) > tolerance) - { + AttributeDoublePtr aScalar = boost::dynamic_pointer_cast(theAttribute); + if (aScalar) { + if (fabs(aScalar->value() - myParams[aFirstParamPos].val) > tolerance) { aScalar->setValue(myParams[aFirstParamPos].val); return true; } @@ -935,10 +879,9 @@ bool SketchSolver_ConstraintGroup::updateAttribute( // Purpose: search the entity in this group and update it // ============================================================================ void SketchSolver_ConstraintGroup::updateEntityIfPossible( - boost::shared_ptr theEntity) + boost::shared_ptr theEntity) { - if (myEntityAttrMap.find(theEntity) != myEntityAttrMap.end()) - { + if (myEntityAttrMap.find(theEntity) != myEntityAttrMap.end()) { // If the attribute is a point and it is changed (the group needs to rebuild), // probably user has dragged this point into this position, // so it is necessary to add constraint which will guarantee the point will not change @@ -949,13 +892,13 @@ void SketchSolver_ConstraintGroup::updateEntityIfPossible( changeEntity(theEntity); - if (myNeedToSolve) // the entity is changed + if (myNeedToSolve) // the entity is changed { // Verify the entity is a point and add temporary constraint of permanency - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(theEntity); - boost::shared_ptr aPoint2D = - boost::dynamic_pointer_cast(theEntity); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + theEntity); + boost::shared_ptr aPoint2D = boost::dynamic_pointer_cast< + GeomDataAPI_Point2D>(theEntity); if (aPoint || aPoint2D) addTemporaryConstraintWhereDragged(theEntity); } @@ -975,49 +918,46 @@ void SketchSolver_ConstraintGroup::updateEntityIfPossible( // which was moved by user // ============================================================================ void SketchSolver_ConstraintGroup::addTemporaryConstraintWhereDragged( - boost::shared_ptr theEntity) + boost::shared_ptr theEntity) { // Find identifier of the entity - std::map, Slvs_hEntity>::const_iterator - anEntIter = myEntityAttrMap.find(theEntity); + std::map, Slvs_hEntity>::const_iterator anEntIter = + myEntityAttrMap.find(theEntity); if (anEntIter == myEntityAttrMap.end()) - return ; + return; // If this is a first dragged point, its parameters should be placed // into Slvs_System::dragged field to avoid system inconsistense - if (myTempPointWhereDragged.empty()) - { + if (myTempPointWhereDragged.empty()) { int anEntPos = Search(anEntIter->second, myEntities); Slvs_hParam* aDraggedParam = myEntities[anEntPos].param; for (int i = 0; i < 4; i++, aDraggedParam++) if (*aDraggedParam != 0) myTempPointWhereDragged.push_back(*aDraggedParam); myTempPointWDrgdID = myEntities[anEntPos].h; - return ; + return; } // Get identifiers of all dragged points std::set aDraggedPntID; aDraggedPntID.insert(myTempPointWDrgdID); std::list::iterator aTmpCoIter = myTempConstraints.begin(); - for ( ; aTmpCoIter != myTempConstraints.end(); aTmpCoIter++) - { + for (; aTmpCoIter != myTempConstraints.end(); aTmpCoIter++) { unsigned int aConstrPos = Search(*aTmpCoIter, myConstraints); if (aConstrPos < myConstraints.size()) aDraggedPntID.insert(myConstraints[aConstrPos].ptA); } // Find whether there is a point coincident with theEntity, which already has SLVS_C_WHERE_DRAGGED - std::vector< std::set >::iterator aCoPtIter = myCoincidentPoints.begin(); - for ( ; aCoPtIter != myCoincidentPoints.end(); aCoPtIter++) - { + std::vector >::iterator aCoPtIter = myCoincidentPoints.begin(); + for (; aCoPtIter != myCoincidentPoints.end(); aCoPtIter++) { if (aCoPtIter->find(anEntIter->second) == aCoPtIter->end()) - continue; // the entity was not found in current set + continue; // the entity was not found in current set // Find one of already created SLVS_C_WHERE_DRAGGED constraints in current set of coincident points std::set::const_iterator aDrgIter = aDraggedPntID.begin(); - for ( ; aDrgIter != aDraggedPntID.end(); aDrgIter++) + for (; aDrgIter != aDraggedPntID.end(); aDrgIter++) if (aCoPtIter->find(*aDrgIter) != aCoPtIter->end()) - return ; // the SLVS_C_WHERE_DRAGGED constraint already exists + return; // the SLVS_C_WHERE_DRAGGED constraint already exists } // Create additional SLVS_C_WHERE_DRAGGED constraint if myTempPointWhereDragged field is not empty @@ -1036,8 +976,8 @@ void SketchSolver_ConstraintGroup::addTemporaryConstraintWhereDragged( void SketchSolver_ConstraintGroup::removeTemporaryConstraints() { std::list::reverse_iterator aTmpConstrIter; - for (aTmpConstrIter = myTempConstraints.rbegin(); aTmpConstrIter != myTempConstraints.rend(); aTmpConstrIter++) - { + for (aTmpConstrIter = myTempConstraints.rbegin(); aTmpConstrIter != myTempConstraints.rend(); + aTmpConstrIter++) { unsigned int aConstrPos = Search(*aTmpConstrIter, myConstraints); if (aConstrPos >= myConstraints.size()) continue; @@ -1058,12 +998,13 @@ void SketchSolver_ConstraintGroup::removeTemporaryConstraints() // Class: SketchSolver_ConstraintGroup // Purpose: remove constraint and all unused entities // ============================================================================ -void SketchSolver_ConstraintGroup::removeConstraint(boost::shared_ptr theConstraint) +void SketchSolver_ConstraintGroup::removeConstraint( + boost::shared_ptr theConstraint) { - std::map, Slvs_hConstraint>::iterator - anIterToRemove = myConstraintMap.find(theConstraint); + std::map, Slvs_hConstraint>::iterator anIterToRemove = + myConstraintMap.find(theConstraint); if (anIterToRemove == myConstraintMap.end()) - return ; + return; Slvs_hConstraint aCnstrToRemove = anIterToRemove->second; // Remove constraint from the map @@ -1072,8 +1013,8 @@ void SketchSolver_ConstraintGroup::removeConstraint(boost::shared_ptr anEntToRemove; - Slvs_hEntity aCnstEnt[] = {myConstraints[aConstrPos].ptA, myConstraints[aConstrPos].ptB, - myConstraints[aConstrPos].entityA, myConstraints[aConstrPos].entityB}; + Slvs_hEntity aCnstEnt[] = { myConstraints[aConstrPos].ptA, myConstraints[aConstrPos].ptB, + myConstraints[aConstrPos].entityA, myConstraints[aConstrPos].entityB }; for (int i = 0; i < 4; i++) if (aCnstEnt[i] != 0) anEntToRemove.insert(aCnstEnt[i]); @@ -1081,48 +1022,40 @@ void SketchSolver_ConstraintGroup::removeConstraint(boost::shared_ptr::const_iterator aConstrIter = myConstraints.begin(); - for ( ; aConstrIter != myConstraints.end(); aConstrIter++) - { - Slvs_hEntity aEnts[] = {aConstrIter->ptA, aConstrIter->ptB, - aConstrIter->entityA, aConstrIter->entityB}; + for (; aConstrIter != myConstraints.end(); aConstrIter++) { + Slvs_hEntity aEnts[] = { aConstrIter->ptA, aConstrIter->ptB, aConstrIter->entityA, aConstrIter + ->entityB }; for (int i = 0; i < 4; i++) if (aEnts[i] != 0 && anEntToRemove.find(aEnts[i]) != anEntToRemove.end()) anEntToRemove.erase(aEnts[i]); } if (anEntToRemove.empty()) - return ; + return; // Remove unused entities - std::map, Slvs_hEntity>::iterator - anEntAttrIter = myEntityAttrMap.begin(); - while (anEntAttrIter != myEntityAttrMap.end()) - { - if (anEntToRemove.find(anEntAttrIter->second) != anEntToRemove.end()) - { - std::map, Slvs_hEntity>::iterator - aRemovedIter = anEntAttrIter; + std::map, Slvs_hEntity>::iterator anEntAttrIter = + myEntityAttrMap.begin(); + while (anEntAttrIter != myEntityAttrMap.end()) { + if (anEntToRemove.find(anEntAttrIter->second) != anEntToRemove.end()) { + std::map, Slvs_hEntity>::iterator aRemovedIter = + anEntAttrIter; anEntAttrIter++; myEntityAttrMap.erase(aRemovedIter); - } - else anEntAttrIter++; + } else + anEntAttrIter++; } - std::map::iterator - anEntFeatIter = myEntityFeatMap.begin(); - while (anEntFeatIter != myEntityFeatMap.end()) - { - if (anEntToRemove.find(anEntFeatIter->second) != anEntToRemove.end()) - { - std::map::iterator - aRemovedIter = anEntFeatIter; + std::map::iterator anEntFeatIter = myEntityFeatMap.begin(); + while (anEntFeatIter != myEntityFeatMap.end()) { + if (anEntToRemove.find(anEntFeatIter->second) != anEntToRemove.end()) { + std::map::iterator aRemovedIter = anEntFeatIter; anEntFeatIter++; myEntityFeatMap.erase(aRemovedIter); - } - else anEntFeatIter++; + } else + anEntFeatIter++; } std::set::const_reverse_iterator aRemIter = anEntToRemove.rbegin(); - for ( ; aRemIter != anEntToRemove.rend(); aRemIter++) - { + for (; aRemIter != anEntToRemove.rend(); aRemIter++) { unsigned int anEntPos = Search(*aRemIter, myEntities); if (anEntPos >= myEntities.size()) continue; @@ -1130,9 +1063,9 @@ void SketchSolver_ConstraintGroup::removeConstraint(boost::shared_ptr= myParams.size()) continue; int aNbParams = 0; - while (myEntities[anEntPos].param[aNbParams] != 0) + while (myEntities[anEntPos].param[aNbParams] != 0) aNbParams++; - if (myEntities[anEntPos].param[aNbParams-1] == myParamMaxID) + if (myEntities[anEntPos].param[aNbParams - 1] == myParamMaxID) myParamMaxID -= aNbParams; myParams.erase(myParams.begin() + aParamPos, myParams.begin() + aParamPos + aNbParams); if (*aRemIter == myEntityMaxID) @@ -1140,37 +1073,32 @@ void SketchSolver_ConstraintGroup::removeConstraint(boost::shared_ptr >::iterator aCoPtIter = myCoincidentPoints.begin(); - for ( ; aCoPtIter != myCoincidentPoints.end(); aCoPtIter++) + std::vector >::iterator aCoPtIter = myCoincidentPoints.begin(); + for (; aCoPtIter != myCoincidentPoints.end(); aCoPtIter++) aCoPtIter->erase(*aRemIter); } if (myCoincidentPoints.size() == 1 && myCoincidentPoints.front().empty()) myCoincidentPoints.clear(); } - // ============================================================================ // Function: addCoincidentPoints // Class: SketchSolver_ConstraintGroup // Purpose: add coincident point the appropriate list of such points // ============================================================================ -bool SketchSolver_ConstraintGroup::addCoincidentPoints( - const Slvs_hEntity& thePoint1, const Slvs_hEntity& thePoint2) +bool SketchSolver_ConstraintGroup::addCoincidentPoints(const Slvs_hEntity& thePoint1, + const Slvs_hEntity& thePoint2) { - std::vector< std::set >::iterator aCoPtIter = myCoincidentPoints.begin(); - std::vector< std::set >::iterator aFirstFound = myCoincidentPoints.end(); - while (aCoPtIter != myCoincidentPoints.end()) - { - bool isFound[2] = { // indicate which point ID was already in coincidence constraint - aCoPtIter->find(thePoint1) != aCoPtIter->end(), - aCoPtIter->find(thePoint2) != aCoPtIter->end(), - }; - if (isFound[0] && isFound[1]) // points are already connected by coincidence constraints => no need additional one + std::vector >::iterator aCoPtIter = myCoincidentPoints.begin(); + std::vector >::iterator aFirstFound = myCoincidentPoints.end(); + while (aCoPtIter != myCoincidentPoints.end()) { + bool isFound[2] = { // indicate which point ID was already in coincidence constraint + aCoPtIter->find(thePoint1) != aCoPtIter->end(), aCoPtIter->find(thePoint2) + != aCoPtIter->end(), }; + if (isFound[0] && isFound[1]) // points are already connected by coincidence constraints => no need additional one return false; - if ((isFound[0] && !isFound[1]) || (!isFound[0] && isFound[1])) - { - if (aFirstFound != myCoincidentPoints.end()) - { // there are two groups of coincident points connected by created constraint => merge them + if ((isFound[0] && !isFound[1]) || (!isFound[0] && isFound[1])) { + if (aFirstFound != myCoincidentPoints.end()) { // there are two groups of coincident points connected by created constraint => merge them int aFirstFoundShift = aFirstFound - myCoincidentPoints.begin(); int aCurrentShift = aCoPtIter - myCoincidentPoints.begin(); aFirstFound->insert(aCoPtIter->begin(), aCoPtIter->end()); @@ -1178,9 +1106,7 @@ bool SketchSolver_ConstraintGroup::addCoincidentPoints( aFirstFound = myCoincidentPoints.begin() + aFirstFoundShift; aCoPtIter = myCoincidentPoints.begin() + aCurrentShift; continue; - } - else - { + } else { aCoPtIter->insert(isFound[0] ? thePoint2 : thePoint1); aFirstFound = aCoPtIter; } @@ -1188,8 +1114,7 @@ bool SketchSolver_ConstraintGroup::addCoincidentPoints( aCoPtIter++; } // No points were found, need to create new set - if (aFirstFound == myCoincidentPoints.end()) - { + if (aFirstFound == myCoincidentPoints.end()) { std::set aNewSet; aNewSet.insert(thePoint1); aNewSet.insert(thePoint2); @@ -1199,34 +1124,29 @@ bool SketchSolver_ConstraintGroup::addCoincidentPoints( return true; } - // ============================================================================ // Function: updateRelatedConstraints // Class: SketchSolver_ConstraintGroup // Purpose: emit the signal to update constraints // ============================================================================ void SketchSolver_ConstraintGroup::updateRelatedConstraints( - boost::shared_ptr theEntity) const + boost::shared_ptr theEntity) const { - std::map, Slvs_hConstraint>::const_iterator - aConstrIter = myConstraintMap.begin(); - for ( ; aConstrIter != myConstraintMap.end(); aConstrIter++) - { - std::list< boost::shared_ptr > anAttributes = - aConstrIter->first->data()->attributes(std::string()); - - std::list< boost::shared_ptr >::iterator - anAttrIter = anAttributes.begin(); - for ( ; anAttrIter != anAttributes.end(); anAttrIter++) - { + std::map, Slvs_hConstraint>::const_iterator aConstrIter = + myConstraintMap.begin(); + for (; aConstrIter != myConstraintMap.end(); aConstrIter++) { + std::list > anAttributes = aConstrIter->first->data() + ->attributes(std::string()); + + std::list >::iterator anAttrIter = anAttributes.begin(); + for (; anAttrIter != anAttributes.end(); anAttrIter++) { bool isUpd = (*anAttrIter == theEntity); - boost::shared_ptr aRefAttr = - boost::dynamic_pointer_cast(*anAttrIter); + boost::shared_ptr aRefAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(*anAttrIter); if (aRefAttr && !aRefAttr->isObject() && aRefAttr->attr() == theEntity) isUpd = true; - if (isUpd) - { + if (isUpd) { static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); ModelAPI_EventCreator::get()->sendUpdated(aConstrIter->first, anEvent); break; @@ -1236,23 +1156,19 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints( } void SketchSolver_ConstraintGroup::updateRelatedConstraints( - boost::shared_ptr theFeature) const + boost::shared_ptr theFeature) const { - std::map, Slvs_hConstraint>::const_iterator - aConstrIter = myConstraintMap.begin(); - for ( ; aConstrIter != myConstraintMap.end(); aConstrIter++) - { - std::list< boost::shared_ptr > anAttributes = - aConstrIter->first->data()->attributes(std::string()); - - std::list< boost::shared_ptr >::iterator - anAttrIter = anAttributes.begin(); - for ( ; anAttrIter != anAttributes.end(); anAttrIter++) - { - boost::shared_ptr aRefAttr = - boost::dynamic_pointer_cast(*anAttrIter); - if (aRefAttr && aRefAttr->isObject() && aRefAttr->object() == theFeature) - { + std::map, Slvs_hConstraint>::const_iterator aConstrIter = + myConstraintMap.begin(); + for (; aConstrIter != myConstraintMap.end(); aConstrIter++) { + std::list > anAttributes = aConstrIter->first->data() + ->attributes(std::string()); + + std::list >::iterator anAttrIter = anAttributes.begin(); + for (; anAttrIter != anAttributes.end(); anAttrIter++) { + boost::shared_ptr aRefAttr = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefAttr>(*anAttrIter); + if (aRefAttr && aRefAttr->isObject() && aRefAttr->object() == theFeature) { static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); ModelAPI_EventCreator::get()->sendUpdated(aConstrIter->first, anEvent); break; @@ -1261,13 +1177,11 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints( } } - - // ======================================================== // ========= Auxiliary functions =============== // ======================================================== -template +template int Search(const uint32_t& theEntityID, const std::vector& theEntities) { int aResIndex = theEntityID <= theEntities.size() ? theEntityID - 1 : 0; diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.h b/src/SketchSolver/SketchSolver_ConstraintGroup.h index 1ec223627..26b577201 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.h +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.h @@ -16,14 +16,13 @@ #include #include - /** \class SketchSolver_ConstraintGroup * \ingroup DataModel * \brief Keeps the group of constraints which based on the same entities */ class SketchSolver_ConstraintGroup { -public: + public: /** \brief New group based on specified workplane. * Throws an exception if theWorkplane is not an object of SketchPlugin_Sketch type * \remark Type of theSketch is not verified inside @@ -34,15 +33,21 @@ public: /// \brief Returns group's unique identifier inline const Slvs_hGroup& getId() const - {return myID;} + { + return myID; + } /// \brief Returns true if the group has no constraints yet inline bool isEmpty() const - {return myConstraints.empty();} + { + return myConstraints.empty(); + } /// \brief Check for valid sketch data inline bool isWorkplaneValid() const - {return mySketch->data()->isValid();} + { + return mySketch->data()->isValid(); + } /** \brief Adds or updates a constraint in the group * \param[in] theConstraint constraint to be changed @@ -63,7 +68,9 @@ public: bool isBaseWorkplane(boost::shared_ptr theWorkplane) const; boost::shared_ptr getWorkplane() const - { return mySketch; } + { + return mySketch; + } /** \brief Update parameters of workplane. Should be called when Update event is coming. * \return \c true if workplane updated successfully, \c false if workplane parameters are not consistent @@ -97,10 +104,10 @@ public: /** \brief Searches the constraints built on the entity and emit the signal to update them * \param[in] theEntity attribute of the constraint */ - void updateRelatedConstraints(boost::shared_ptr theEntity) const; - void updateRelatedConstraints(boost::shared_ptr theFeature) const; + void updateRelatedConstraints(boost::shared_ptr theEntity) const; + void updateRelatedConstraints(boost::shared_ptr theFeature) const; -protected: + protected: /** \brief Adds or updates an entity in the group * * The parameters of entity will be parsed and added to the list of SolveSpace parameters. @@ -110,7 +117,7 @@ protected: * \return identifier of changed entity or 0 if entity could not be changed */ Slvs_hEntity changeEntity(boost::shared_ptr theEntity); - Slvs_hEntity changeEntity(FeaturePtr theEntity); + Slvs_hEntity changeEntity(FeaturePtr theEntity); /** \brief Adds or updates a normal in the group * @@ -148,7 +155,8 @@ protected: * \param[in] theEntityID identifier of SolveSpace entity, which contains updated data * \return \c true if the attribute's value has changed */ - bool updateAttribute(boost::shared_ptr theAttribute, const Slvs_hEntity& theEntityID); + bool updateAttribute(boost::shared_ptr theAttribute, + const Slvs_hEntity& theEntityID); /** \brief Adds a constraint for a point which should not be changed during computations * \param[in] theEntity the base for the constraint @@ -159,7 +167,7 @@ protected: */ void removeTemporaryConstraints(); -private: + private: /** \brief Creates a workplane from the sketch parameters * \param[in] theSketch parameters of workplane are the attributes of this sketch * \return \c true if success, \c false if workplane parameters are not consistent @@ -180,40 +188,34 @@ private: */ void checkConstraintConsistence(Slvs_Constraint& theConstraint); -private: + private: // SolveSpace entities - Slvs_hGroup myID; ///< the index of the group - Slvs_Entity myWorkplane; ///< Workplane for the current group - std::vector myParams; ///< List of parameters of the constraints - Slvs_hParam myParamMaxID; ///< Actual maximal ID of parameters (not equal to myParams size) - std::vector myEntities; ///< List of entities of the constaints - Slvs_hEntity myEntityMaxID; ///< Actual maximal ID of entities (not equal to myEntities size) + Slvs_hGroup myID; ///< the index of the group + Slvs_Entity myWorkplane; ///< Workplane for the current group + std::vector myParams; ///< List of parameters of the constraints + Slvs_hParam myParamMaxID; ///< Actual maximal ID of parameters (not equal to myParams size) + std::vector myEntities; ///< List of entities of the constaints + Slvs_hEntity myEntityMaxID; ///< Actual maximal ID of entities (not equal to myEntities size) std::vector myConstraints; ///< List of constraints in SolveSpace format - Slvs_hConstraint myConstrMaxID; ///< Actual maximal ID of constraints (not equal to myConstraints size) - bool myNeedToSolve; ///< Indicator that something changed in the group and constraint system need to be rebuilt + Slvs_hConstraint myConstrMaxID; ///< Actual maximal ID of constraints (not equal to myConstraints size) + bool myNeedToSolve; ///< Indicator that something changed in the group and constraint system need to be rebuilt - SketchSolver_Solver myConstrSolver; ///< Solver for set of equations obtained by constraints + SketchSolver_Solver myConstrSolver; ///< Solver for set of equations obtained by constraints - std::vector myTempPointWhereDragged; ///< Parameters of one of the points which is moved by user - Slvs_hEntity myTempPointWDrgdID; ///< Identifier of such point - std::list myTempConstraints; ///< The list of identifiers of temporary constraints (SLVS_C_WHERE_DRAGGED) applied for all other points moved by user + std::vector myTempPointWhereDragged; ///< Parameters of one of the points which is moved by user + Slvs_hEntity myTempPointWDrgdID; ///< Identifier of such point + std::list myTempConstraints; ///< The list of identifiers of temporary constraints (SLVS_C_WHERE_DRAGGED) applied for all other points moved by user // SketchPlugin entities - boost::shared_ptr - mySketch; ///< Equivalent to workplane - std::map, Slvs_hConstraint> - myConstraintMap; ///< The map between SketchPlugin and SolveSpace constraints - std::map, Slvs_hEntity> - myEntityAttrMap; ///< The map between "attribute" parameters of constraints and their equivalent SolveSpace entities - std::map - myEntityFeatMap; ///< The map between "feature" parameters of constraints and their equivalent SolveSpace entities + boost::shared_ptr mySketch; ///< Equivalent to workplane + std::map, Slvs_hConstraint> myConstraintMap; ///< The map between SketchPlugin and SolveSpace constraints + std::map, Slvs_hEntity> myEntityAttrMap; ///< The map between "attribute" parameters of constraints and their equivalent SolveSpace entities + std::map myEntityFeatMap; ///< The map between "feature" parameters of constraints and their equivalent SolveSpace entities // Conincident items - std::vector< std::set > - myCoincidentPoints; ///< Stores the lists of identifiers of coincident points (to avoid unnecessary coincidence constraints) - std::set< boost::shared_ptr > - myExtraCoincidence; ///< Additional coincidence constraints which are not necessary (coincidence between points already done - ///< by other constraints) but created by GUI tools. Useful when some coincidence constraints were removed + std::vector > myCoincidentPoints; ///< Stores the lists of identifiers of coincident points (to avoid unnecessary coincidence constraints) + std::set > myExtraCoincidence; ///< Additional coincidence constraints which are not necessary (coincidence between points already done + ///< by other constraints) but created by GUI tools. Useful when some coincidence constraints were removed }; #endif diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index a87f3e69b..4a2cf08ee 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -22,14 +22,12 @@ #include - // Initialization of constraint manager self pointer SketchSolver_ConstraintManager* SketchSolver_ConstraintManager::_self = 0; /// Global constraint manager object SketchSolver_ConstraintManager* myManager = SketchSolver_ConstraintManager::Instance(); - // ======================================================== // ========= SketchSolver_ConstraintManager =============== // ======================================================== @@ -63,42 +61,38 @@ SketchSolver_ConstraintManager::~SketchSolver_ConstraintManager() // ============================================================================ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessage) { - if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED) || - theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED) || - theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) - { - const ModelAPI_ObjectUpdatedMessage* anUpdateMsg = - dynamic_cast(theMessage); - std::set< ObjectPtr > aFeatures = anUpdateMsg->objects(); - - bool isModifiedEvt = - theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED); - if (!isModifiedEvt) - { - std::set< ObjectPtr >::iterator aFeatIter; - for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) - { + if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED) + || theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED) + || theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) { + const ModelAPI_ObjectUpdatedMessage* anUpdateMsg = + dynamic_cast(theMessage); + std::set aFeatures = anUpdateMsg->objects(); + + bool isModifiedEvt = theMessage->eventID() + == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED); + if (!isModifiedEvt) { + std::set::iterator aFeatIter; + for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) { FeaturePtr aFeature = boost::dynamic_pointer_cast(*aFeatIter); - if (!aFeature) continue; + if (!aFeature) + continue; // Only sketches and constraints can be added by Create event const std::string& aFeatureKind = aFeature->getKind(); - if (aFeatureKind.compare(SketchPlugin_Sketch::ID()) == 0) - { - boost::shared_ptr aSketch = - boost::dynamic_pointer_cast(aFeature); + if (aFeatureKind.compare(SketchPlugin_Sketch::ID()) == 0) { + boost::shared_ptr aSketch = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(aFeature); if (aSketch) changeWorkplane(aSketch); continue; } - boost::shared_ptr aConstraint = - boost::dynamic_pointer_cast(aFeature); + boost::shared_ptr aConstraint = boost::dynamic_pointer_cast< + SketchPlugin_Constraint>(aFeature); if (aConstraint) changeConstraint(aConstraint); - else - { + else { // Sketch plugin features can be only updated - boost::shared_ptr aSFeature = - boost::dynamic_pointer_cast(aFeature); + boost::shared_ptr aSFeature = boost::dynamic_pointer_cast< + SketchPlugin_Feature>(aFeature); if (aSFeature) updateEntity(aSFeature); } @@ -107,11 +101,9 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa // Solve the set of constraints resolveConstraints(); - } - else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) - { - const ModelAPI_ObjectDeletedMessage* aDeleteMsg = - dynamic_cast(theMessage); + } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { + const ModelAPI_ObjectDeletedMessage* aDeleteMsg = + dynamic_cast(theMessage); const std::set& aFeatureGroups = aDeleteMsg->groups(); // Find SketchPlugin_Sketch::ID() in groups. The constraint groups should be updated when an object removed from Sketch @@ -119,23 +111,19 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa for (aFGrIter = aFeatureGroups.begin(); aFGrIter != aFeatureGroups.end(); aFGrIter++) if (aFGrIter->compare(ModelAPI_ResultConstruction::group()) == 0) break; - - if (aFGrIter != aFeatureGroups.end()) - { + + if (aFGrIter != aFeatureGroups.end()) { std::vector::iterator aGroupIter = myGroups.begin(); std::vector aSeparatedGroups; - while (aGroupIter != myGroups.end()) - { - if (!(*aGroupIter)->isWorkplaneValid()) - { // the group should be removed + while (aGroupIter != myGroups.end()) { + if (!(*aGroupIter)->isWorkplaneValid()) { // the group should be removed delete *aGroupIter; int aShift = aGroupIter - myGroups.begin(); myGroups.erase(aGroupIter); aGroupIter = myGroups.begin() + aShift; continue; } - if ((*aGroupIter)->updateGroup()) - { // some constraints were removed, try to split the group + if ((*aGroupIter)->updateGroup()) { // some constraints were removed, try to split the group (*aGroupIter)->splitGroup(aSeparatedGroups); } aGroupIter++; @@ -151,26 +139,24 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa // Class: SketchSolver_PluginManager // Purpose: update workplane by given parameters of the sketch // ============================================================================ -bool SketchSolver_ConstraintManager::changeWorkplane(boost::shared_ptr theSketch) +bool SketchSolver_ConstraintManager::changeWorkplane( + boost::shared_ptr theSketch) { - bool aResult = true; // changed when a workplane wrongly updated + bool aResult = true; // changed when a workplane wrongly updated bool isUpdated = false; // Try to update specified workplane in all groups std::vector::iterator aGroupIter; for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) - if ((*aGroupIter)->isBaseWorkplane(theSketch)) - { + if ((*aGroupIter)->isBaseWorkplane(theSketch)) { isUpdated = true; if (!(*aGroupIter)->updateWorkplane()) aResult = false; } // If the workplane is not updated, so this is a new workplane - if (!isUpdated) - { + if (!isUpdated) { SketchSolver_ConstraintGroup* aNewGroup = new SketchSolver_ConstraintGroup(theSketch); // Verify that the group is created successfully - if (!aNewGroup->isBaseWorkplane(theSketch)) - { + if (!aNewGroup->isBaseWorkplane(theSketch)) { delete aNewGroup; return false; } @@ -185,36 +171,31 @@ bool SketchSolver_ConstraintManager::changeWorkplane(boost::shared_ptr theConstraint) + boost::shared_ptr theConstraint) { // Search the groups which this constraint touches std::set aGroups; findGroups(theConstraint, aGroups); // Process the groups list - if (aGroups.size() == 0) - { // There are no groups applicable for this constraint => create new one + if (aGroups.size() == 0) { // There are no groups applicable for this constraint => create new one boost::shared_ptr aWP = findWorkplaneForConstraint(theConstraint); - if (!aWP) return false; + if (!aWP) + return false; SketchSolver_ConstraintGroup* aGroup = new SketchSolver_ConstraintGroup(aWP); - if (!aGroup->changeConstraint(theConstraint)) - { + if (!aGroup->changeConstraint(theConstraint)) { delete aGroup; return false; } myGroups.push_back(aGroup); return true; - } - else if (aGroups.size() == 1) - { // Only one group => add constraint into it + } else if (aGroups.size() == 1) { // Only one group => add constraint into it Slvs_hGroup aGroupId = *(aGroups.begin()); std::vector::iterator aGroupIter; for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) if ((*aGroupIter)->getId() == aGroupId) return (*aGroupIter)->changeConstraint(theConstraint); - } - else if (aGroups.size() > 1) - { // Several groups applicable for this constraint => need to merge them + } else if (aGroups.size() > 1) { // Several groups applicable for this constraint => need to merge them std::set::const_iterator aGroupsIter = aGroups.begin(); // Search first group @@ -227,13 +208,11 @@ bool SketchSolver_ConstraintManager::changeConstraint( // Append other groups to the first one std::vector::iterator anOtherGroupIter = aFirstGroupIter + 1; - for (aGroupsIter++; aGroupsIter != aGroups.end(); aGroupsIter++) - { - for ( ; anOtherGroupIter != myGroups.end(); anOtherGroupIter++) + for (aGroupsIter++; aGroupsIter != aGroups.end(); aGroupsIter++) { + for (; anOtherGroupIter != myGroups.end(); anOtherGroupIter++) if ((*anOtherGroupIter)->getId() == *aGroupsIter) break; - if (anOtherGroupIter == myGroups.end()) - { // Group disappears + if (anOtherGroupIter == myGroups.end()) { // Group disappears anOtherGroupIter = aFirstGroupIter + 1; continue; } @@ -243,7 +222,7 @@ bool SketchSolver_ConstraintManager::changeConstraint( int aShiftOther = anOtherGroupIter - myGroups.begin(); delete *anOtherGroupIter; myGroups.erase(anOtherGroupIter); - aFirstGroupIter = myGroups.begin() + aShiftFirst; + aFirstGroupIter = myGroups.begin() + aShiftFirst; anOtherGroupIter = myGroups.begin() + aShiftOther; } @@ -259,7 +238,8 @@ bool SketchSolver_ConstraintManager::changeConstraint( // Class: SketchSolver_PluginManager // Purpose: update any element on the sketch, which is used by constraints // ============================================================================ -void SketchSolver_ConstraintManager::updateEntity(boost::shared_ptr theFeature) +void SketchSolver_ConstraintManager::updateEntity( + boost::shared_ptr theFeature) { // Create list of attributes depending on type of the feature std::vector anAttrList; @@ -268,20 +248,17 @@ void SketchSolver_ConstraintManager::updateEntity(boost::shared_ptr::const_iterator anAttrIter; - for (anAttrIter = anAttrList.begin(); anAttrIter != anAttrList.end(); anAttrIter++) - { + for (anAttrIter = anAttrList.begin(); anAttrIter != anAttrList.end(); anAttrIter++) { std::vector::iterator aGroupIter; - for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) - { - if ((*aGroupIter)->isEmpty()) + for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) { + if ((*aGroupIter)->isEmpty()) continue; - boost::shared_ptr anAttribute = - boost::dynamic_pointer_cast(theFeature->data()->attribute(*anAttrIter)); + boost::shared_ptr anAttribute = boost::dynamic_pointer_cast< + ModelAPI_Attribute>(theFeature->data()->attribute(*anAttrIter)); (*aGroupIter)->updateEntityIfPossible(anAttribute); } } @@ -309,23 +284,21 @@ void SketchSolver_ConstraintManager::updateEntity(boost::shared_ptrupdateRelatedConstraints(theFeature); } - // ============================================================================ // Function: findGroups // Class: SketchSolver_PluginManager // Purpose: search groups of entities interacting with given constraint // ============================================================================ void SketchSolver_ConstraintManager::findGroups( - boost::shared_ptr theConstraint, - std::set& theGroupIDs) const + boost::shared_ptr theConstraint, + std::set& theGroupIDs) const { boost::shared_ptr aWP = findWorkplaneForConstraint(theConstraint); - SketchSolver_ConstraintGroup* anEmptyGroup = 0; // appropriate empty group for specified constraint + SketchSolver_ConstraintGroup* anEmptyGroup = 0; // appropriate empty group for specified constraint std::vector::const_iterator aGroupIter; for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) - if (aWP == (*aGroupIter)->getWorkplane() && (*aGroupIter)->isInteract(theConstraint)) - { + if (aWP == (*aGroupIter)->getWorkplane() && (*aGroupIter)->isInteract(theConstraint)) { if (!(*aGroupIter)->isEmpty()) theGroupIDs.insert((*aGroupIter)->getId()); else if (!anEmptyGroup) @@ -343,25 +316,24 @@ void SketchSolver_ConstraintManager::findGroups( // Purpose: search workplane containing given constraint // ============================================================================ boost::shared_ptr SketchSolver_ConstraintManager::findWorkplaneForConstraint( - boost::shared_ptr theConstraint) const + boost::shared_ptr theConstraint) const { // Already verified workplanes - std::set< boost::shared_ptr > aVerified; + std::set > aVerified; std::vector::const_iterator aGroupIter; - for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) - { + for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) { boost::shared_ptr aWP = (*aGroupIter)->getWorkplane(); if (aVerified.find(aWP) != aVerified.end()) continue; - boost::shared_ptr aWPFeatures = - boost::dynamic_pointer_cast(aWP->data()->attribute(SketchPlugin_Sketch::FEATURES_ID())); + boost::shared_ptr aWPFeatures = boost::dynamic_pointer_cast< + ModelAPI_AttributeRefList>(aWP->data()->attribute(SketchPlugin_Sketch::FEATURES_ID())); std::list aFeaturesList = aWPFeatures->list(); std::list::const_iterator anIter; for (anIter = aFeaturesList.begin(); anIter != aFeaturesList.end(); anIter++) if (*anIter == theConstraint) - return aWP; // workplane is found + return aWP; // workplane is found aVerified.insert(aWP); } diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.h b/src/SketchSolver/SketchSolver_ConstraintManager.h index 1f5f7f884..4101906ab 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.h +++ b/src/SketchSolver/SketchSolver_ConstraintManager.h @@ -20,7 +20,6 @@ #include #include - /** \class SketchSolver_ConstraintManager * \ingroup DataModel * \brief Listens the changes of SketchPlugin features and transforms the Constraint @@ -34,7 +33,7 @@ */ class SketchSolver_ConstraintManager : public Events_Listener { -public: + public: /** \brief Main method to create constraint manager * \return pointer to the singleton */ @@ -45,7 +44,7 @@ public: */ virtual void processEvent(const Events_Message* theMessage); -protected: + protected: SketchSolver_ConstraintManager(); ~SketchSolver_ConstraintManager(); @@ -84,24 +83,24 @@ protected: */ void resolveConstraints(); -private: + private: /** \brief Searches list of groups which interact with specified constraint * \param[in] theConstraint constraint to be found * \param[out] theGroups list of group indexes interacted with constraint */ void findGroups(boost::shared_ptr theConstraint, - std::set& theGroupIDs) const; + std::set& theGroupIDs) const; /** \brief Searches in the list of groups the workplane which constains specified constraint * \param[in] theConstraint constraint to be found * \return workplane containing the constraint */ boost::shared_ptr findWorkplaneForConstraint( - boost::shared_ptr theConstraint) const; + boost::shared_ptr theConstraint) const; -private: - static SketchSolver_ConstraintManager* _self; ///< Self pointer to implement singleton functionality - std::vector myGroups; ///< Groups of constraints + private: + static SketchSolver_ConstraintManager* _self; ///< Self pointer to implement singleton functionality + std::vector myGroups; ///< Groups of constraints }; #endif diff --git a/src/SketchSolver/SketchSolver_Solver.cpp b/src/SketchSolver/SketchSolver_Solver.cpp index b91d267f6..975588bbb 100644 --- a/src/SketchSolver/SketchSolver_Solver.cpp +++ b/src/SketchSolver/SketchSolver_Solver.cpp @@ -30,21 +30,21 @@ SketchSolver_Solver::SketchSolver_Solver() SketchSolver_Solver::~SketchSolver_Solver() { if (myEquationsSystem.param) - delete [] myEquationsSystem.param; + delete[] myEquationsSystem.param; if (myEquationsSystem.entity) - delete [] myEquationsSystem.entity; + delete[] myEquationsSystem.entity; if (myEquationsSystem.constraint) - delete [] myEquationsSystem.constraint; + delete[] myEquationsSystem.constraint; if (myEquationsSystem.failed) - delete [] myEquationsSystem.failed; + delete[] myEquationsSystem.failed; } void SketchSolver_Solver::setParameters(const std::vector& theParameters) { - if (theParameters.size() != myEquationsSystem.params) // number of parameters was changed => reallocate the memory - { + if (theParameters.size() != myEquationsSystem.params) // number of parameters was changed => reallocate the memory + { if (myEquationsSystem.param) - delete [] myEquationsSystem.param; + delete[] myEquationsSystem.param; myEquationsSystem.params = theParameters.size(); myEquationsSystem.param = new Slvs_Param[theParameters.size()]; } @@ -57,8 +57,7 @@ void SketchSolver_Solver::setParameters(const std::vector& theParame void SketchSolver_Solver::setDraggedParameters(const std::vector& theDragged) { - if (theDragged.size() == 0) - { + if (theDragged.size() == 0) { myEquationsSystem.dragged[0] = 0; myEquationsSystem.dragged[1] = 0; myEquationsSystem.dragged[2] = 0; @@ -71,10 +70,10 @@ void SketchSolver_Solver::setDraggedParameters(const std::vector& t void SketchSolver_Solver::setEntities(const std::vector& theEntities) { - if (theEntities.size() != myEquationsSystem.entities) // number of entities was changed => reallocate the memory - { + if (theEntities.size() != myEquationsSystem.entities) // number of entities was changed => reallocate the memory + { if (myEquationsSystem.entity) - delete [] myEquationsSystem.entity; + delete[] myEquationsSystem.entity; myEquationsSystem.entities = theEntities.size(); myEquationsSystem.entity = new Slvs_Entity[theEntities.size()]; } @@ -87,16 +86,16 @@ void SketchSolver_Solver::setEntities(const std::vector& theEntitie void SketchSolver_Solver::setConstraints(const std::vector& theConstraints) { - if (theConstraints.size() != myEquationsSystem.constraints) // number of constraints was changed => reallocate the memory - { + if (theConstraints.size() != myEquationsSystem.constraints) // number of constraints was changed => reallocate the memory + { if (myEquationsSystem.constraint) - delete [] myEquationsSystem.constraint; + delete[] myEquationsSystem.constraint; myEquationsSystem.constraints = theConstraints.size(); myEquationsSystem.constraint = new Slvs_Constraint[theConstraints.size()]; // Assign the memory for the failed constraints if (myEquationsSystem.failed) - delete [] myEquationsSystem.failed; + delete[] myEquationsSystem.failed; myEquationsSystem.failed = new Slvs_hConstraint[theConstraints.size()]; myEquationsSystem.faileds = theConstraints.size(); } @@ -125,13 +124,12 @@ bool SketchSolver_Solver::getResult(std::vector& theParameters) return false; if (theParameters.size() != myEquationsSystem.params) - return false; // number of parameters is not the same + return false; // number of parameters is not the same std::vector::iterator aParamIter = theParameters.begin(); - for (int i = 0; i < myEquationsSystem.params; i++, aParamIter++) - { + for (int i = 0; i < myEquationsSystem.params; i++, aParamIter++) { if (myEquationsSystem.param[i].h != aParamIter->h) - return false; // sequence of parameters was changed + return false; // sequence of parameters was changed aParamIter->val = myEquationsSystem.param[i].val; } diff --git a/src/SketchSolver/SketchSolver_Solver.h b/src/SketchSolver/SketchSolver_Solver.h index 412b0e180..8bdc566f0 100644 --- a/src/SketchSolver/SketchSolver_Solver.h +++ b/src/SketchSolver/SketchSolver_Solver.h @@ -18,7 +18,6 @@ typedef unsigned int UINT32; #include - #define SLVS_RESULT_EMPTY_SET -1 // Unknown constraint (for error reporting) @@ -26,17 +25,18 @@ typedef unsigned int UINT32; // Unknown entity #define SLVS_E_UNKNOWN 0 - class SketchSolver_Solver { -public: + public: SketchSolver_Solver(); ~SketchSolver_Solver(); /** \brief Initialize the ID of the group */ inline void setGroupID(Slvs_hGroup theGroupID) - { myGroupID = theGroupID; } + { + myGroupID = theGroupID; + } /** \brief Change array of parameters * \param[in] theParameters vector of parameters @@ -70,9 +70,9 @@ public: */ bool getResult(std::vector& theParameters); -private: + private: Slvs_hGroup myGroupID; ///< identifier of the group to be solved - Slvs_System myEquationsSystem; ///< set of equations for solving in SolveSpace + Slvs_System myEquationsSystem; ///< set of equations for solving in SolveSpace }; #endif diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index 4bfb31b9d..294faab4b 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -18,11 +18,10 @@ #include #endif - XGUI_ActionsMgr::XGUI_ActionsMgr(XGUI_Workshop* theParent) - : QObject(theParent), - myWorkshop(theParent), - myOperationMgr(theParent->operationMgr()) + : QObject(theParent), + myWorkshop(theParent), + myOperationMgr(theParent->operationMgr()) { // Default shortcuts myShortcuts << QKeySequence::Save; @@ -36,11 +35,10 @@ XGUI_ActionsMgr::~XGUI_ActionsMgr() { } - void XGUI_ActionsMgr::addCommand(QAction* theCmd) { QString aId = theCmd->data().toString(); - if(aId.isEmpty()) { + if (aId.isEmpty()) { return; } myActions.insert(aId, theCmd); @@ -60,7 +58,7 @@ void XGUI_ActionsMgr::addNestedCommands(const QString& theId, const QStringList& void XGUI_ActionsMgr::update() { - if(myOperationMgr->hasOperation()) { + if (myOperationMgr->hasOperation()) { setAllEnabled(false); ModuleBase_Operation* anOperation = myOperationMgr->currentOperation(); QString anOperationId = anOperation->id(); @@ -76,7 +74,8 @@ void XGUI_ActionsMgr::update() void XGUI_ActionsMgr::setAllEnabled(bool isEnabled) { - foreach(QString eachAction, myActions.keys()) { + foreach(QString eachAction, myActions.keys()) + { setActionEnabled(eachAction, isEnabled); } } @@ -85,14 +84,16 @@ void XGUI_ActionsMgr::setAllEnabled(bool isEnabled) void XGUI_ActionsMgr::setNestedCommandsEnabled(bool theEnabled, const QString& theParent) { QStringList ltNestedActions; - if(theParent.isEmpty()) { //Disable ALL nested - foreach(QString eachParent, myNestedActions.keys()) { + if (theParent.isEmpty()) { //Disable ALL nested + foreach(QString eachParent, myNestedActions.keys()) + { ltNestedActions << myNestedActions[eachParent]; } } else { ltNestedActions << myNestedActions[theParent]; } - foreach(QString eachNested, ltNestedActions) { + foreach(QString eachNested, ltNestedActions) + { setActionEnabled(eachNested, theEnabled); } } @@ -100,16 +101,15 @@ void XGUI_ActionsMgr::setNestedCommandsEnabled(bool theEnabled, const QString& t void XGUI_ActionsMgr::setActionChecked(const QString& theId, const bool theChecked) { QAction* anAction = myActions[theId]; - if(anAction && anAction->isCheckable()) { + if (anAction && anAction->isCheckable()) { anAction->setChecked(theChecked); } } - void XGUI_ActionsMgr::setActionEnabled(const QString& theId, const bool theEnabled) { QAction* anAction = myActions[theId]; - if(anAction) { + if (anAction) { anAction->setEnabled(theEnabled); } } @@ -117,11 +117,13 @@ void XGUI_ActionsMgr::setActionEnabled(const QString& theId, const bool theEnabl void XGUI_ActionsMgr::updateCheckState() { QString eachCommand = QString(); - foreach(eachCommand, myActions.keys()) { + foreach(eachCommand, myActions.keys()) + { setActionChecked(eachCommand, false); } QStringList ltActiveCommands = myOperationMgr->operationList(); - foreach(eachCommand, ltActiveCommands) { + foreach(eachCommand, ltActiveCommands) + { setActionChecked(eachCommand, true); } } @@ -135,7 +137,8 @@ QStringList XGUI_ActionsMgr::nestedCommands(const QString& theId) const bool XGUI_ActionsMgr::isNested(const QString& theId) const { - foreach(QString aId, myNestedActions.keys()) { + foreach(QString aId, myNestedActions.keys()) + { QStringList aList = myNestedActions[aId]; if (aList.contains(theId)) return true; @@ -145,11 +148,11 @@ bool XGUI_ActionsMgr::isNested(const QString& theId) const QKeySequence XGUI_ActionsMgr::registerShortcut(const QString& theKeySequence) { - if(theKeySequence.isEmpty()) { + if (theKeySequence.isEmpty()) { return QKeySequence(); } QKeySequence aResult(theKeySequence); - if(myShortcuts.contains(aResult)) { + if (myShortcuts.contains(aResult)) { QString aMessage = tr("Shortcut %1 is already defined. Ignore.").arg(theKeySequence); Events_Error::send(aMessage.toStdString()); return QKeySequence(); diff --git a/src/XGUI/XGUI_ActionsMgr.h b/src/XGUI/XGUI_ActionsMgr.h index 5f8c4ab93..753330a22 100644 --- a/src/XGUI/XGUI_ActionsMgr.h +++ b/src/XGUI/XGUI_ActionsMgr.h @@ -18,11 +18,11 @@ class XGUI_Workshop; class XGUI_OperationMgr; class QAction; -class XGUI_EXPORT XGUI_ActionsMgr: public QObject +class XGUI_EXPORT XGUI_ActionsMgr : public QObject { - Q_OBJECT +Q_OBJECT -public: + public: XGUI_ActionsMgr(XGUI_Workshop* theWorkshop); virtual ~XGUI_ActionsMgr(); @@ -39,7 +39,7 @@ public: QKeySequence registerShortcut(const QString& theKeySequence); -public slots: + public slots: //! Update workbench actions according to OperationMgr state: //! No active operations: all actions but nested are available //! There is active operation: current operation + it's nested @@ -48,7 +48,7 @@ public slots: //! Sets all commands checked if it's operation is active. void updateCheckState(); -protected: + protected: //! Sets all actions to isEnabled state. void setAllEnabled(bool isEnabled); //! Sets all nested actions to isEnabled state for the command with given ID. @@ -59,7 +59,7 @@ protected: //! Sets the action with theId to theEnabled state. void setActionEnabled(const QString& theId, const bool theEnabled); -private: + private: QMap myActions; QMap myNestedActions; QList myShortcuts; diff --git a/src/XGUI/XGUI_Command.cpp b/src/XGUI/XGUI_Command.cpp index 01b3bf835..59df312b1 100644 --- a/src/XGUI/XGUI_Command.cpp +++ b/src/XGUI/XGUI_Command.cpp @@ -3,14 +3,16 @@ #include XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable) - : QWidgetAction(parent), myCheckable(isCheckable) + : QWidgetAction(parent), + myCheckable(isCheckable) { setData(theId); } XGUI_Command::XGUI_Command(const QString& theId, const QIcon& icon, const QString& text, QObject* parent, bool isCheckable) - : QWidgetAction(parent), myCheckable(isCheckable) + : QWidgetAction(parent), + myCheckable(isCheckable) { setIcon(icon); setText(text); @@ -52,7 +54,7 @@ QWidget* XGUI_Command::createWidget(QWidget* theParent) void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot) { - connect(this, SIGNAL(triggered(bool)), theResiver, theSlot); + connect(this, SIGNAL(triggered(bool)), theResiver, theSlot); } const QStringList& XGUI_Command::nestedCommands() const diff --git a/src/XGUI/XGUI_Command.h b/src/XGUI/XGUI_Command.h index 9367e8375..696518789 100644 --- a/src/XGUI/XGUI_Command.h +++ b/src/XGUI/XGUI_Command.h @@ -4,7 +4,6 @@ #include "XGUI.h" #include - #define MIN_BUTTON_HEIGHT 25 #define MIN_BUTTON_WIDTH 60 @@ -12,19 +11,20 @@ * \ingroup GUI * \brief Represents a command item in the application menu (Workbench) */ -class XGUI_EXPORT XGUI_Command: public QWidgetAction +class XGUI_EXPORT XGUI_Command : public QWidgetAction { Q_OBJECT -public: + public: XGUI_Command(const QString& theId, QObject * parent, bool isCheckable = false); - XGUI_Command(const QString& theId, const QIcon& icon, const QString& text, QObject* parent, bool isCheckable = false); + XGUI_Command(const QString& theId, const QIcon& icon, const QString& text, QObject* parent, + bool isCheckable = false); ~XGUI_Command(); //VSV: Don't use this method for compatibility with SALOME. Use the construction below /*virtual QString id() const - { - return data().toString(); - }*/ + { + return data().toString(); + }*/ const QStringList& nestedCommands() const; void setNestedCommands(const QStringList& myUnblockableCommands); @@ -32,11 +32,11 @@ public: //! Connect the command to a slot virtual void connectTo(const QObject* theResiver, const char* theSlot); -protected: + protected: //! Creates a command representation widget dependently on parent widget type virtual QWidget* createWidget(QWidget* theParent); -private: + private: bool myCheckable; //! List of Ids of commands which WILL NOT be blocked when the command is on. QStringList myNestedCommands; diff --git a/src/XGUI/XGUI_Constants.h b/src/XGUI/XGUI_Constants.h index 5cd0f2523..5abd457b9 100644 --- a/src/XGUI/XGUI_Constants.h +++ b/src/XGUI/XGUI_Constants.h @@ -1,8 +1,7 @@ #ifndef XGUI_Constants_H #define XGUI_Constants_H -namespace XGUI -{ +namespace XGUI { //! Types of gradient type used in background of Viewer 3d enum GradientType @@ -22,32 +21,41 @@ enum GradientType //! Type of rotation point in viewer 3d enum RotationPointType { - GRAVITY, SELECTED + GRAVITY, + SELECTED }; //! Type of ribbon rect in Viewer 3d enum SketchingType { - NoSketching, Rect, Polygon + NoSketching, + Rect, + Polygon }; - //! View window operations accessible by hot keys enum HotOperation { - PAN, ZOOM, ROTATE, FIT_AREA + PAN, + ZOOM, + ROTATE, + FIT_AREA }; //! Types of view window interactions enum InteractionStyle { - STANDARD, KEY_FREE + STANDARD, + KEY_FREE }; //! Types of 2d mode in viewer 3d enum Mode2dType { - No2dMode, XYPlane, XZPlane, YZPlane + No2dMode, + XYPlane, + XZPlane, + YZPlane }; //! Types of background in view window @@ -71,6 +79,7 @@ const static char* PROP_PANEL = "property_panel_dock"; const static char* PROP_PANEL_OK = "property_panel_ok"; const static char* PROP_PANEL_CANCEL = "property_panel_cancel"; -}; +} +; #endif diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index e699b4a2a..914cce321 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -1,4 +1,3 @@ - #include "XGUI_ContextMenuMgr.h" #include "XGUI_Workshop.h" #include "XGUI_ObjectsBrowser.h" @@ -20,8 +19,9 @@ #include #include -XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent) : -QObject(theParent), myWorkshop(theParent) +XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent) + : QObject(theParent), + myWorkshop(theParent) { } @@ -89,7 +89,7 @@ void XGUI_ContextMenuMgr::onContextMenuRequest(QContextMenuEvent* theEvent) else if (sender() == myWorkshop->viewer()) { aMenu = viewerMenu(); } - + if (aMenu && (aMenu->actions().size() > 0)) { aMenu->exec(theEvent->globalPos()); delete aMenu; @@ -114,7 +114,7 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const if (aPart) { if (aMgr->currentDocument() == aPart->partDoc()) aMenu->addAction(action("DEACTIVATE_PART_CMD")); - else + else aMenu->addAction(action("ACTIVATE_PART_CMD")); } else if (aFeature) { aMenu->addAction(action("EDIT_CMD")); @@ -124,18 +124,21 @@ QMenu* XGUI_ContextMenuMgr::objectBrowserMenu() const else aMenu->addAction(action("SHOW_CMD")); } - } else { // If feature is 0 the it means that selected root object (document) - if (aMgr->currentDocument() != aMgr->rootDocument()) + } else { // If feature is 0 the it means that selected root object (document) + if (aMgr->currentDocument() != aMgr->rootDocument()) aMenu->addAction(action("ACTIVATE_PART_CMD")); } } else if (aSelected >= 1) { bool hasResult = false; bool hasFeature = false; - foreach(ObjectPtr aObj, aObjects) { + foreach(ObjectPtr aObj, aObjects) + { FeaturePtr aFeature = boost::dynamic_pointer_cast(aObj); ResultPtr aResult = boost::dynamic_pointer_cast(aObj); - if (aResult) hasResult = true; - if (aFeature) hasFeature = true; + if (aResult) + hasResult = true; + if (aFeature) + hasFeature = true; if (hasFeature && hasResult) break; } @@ -174,7 +177,8 @@ void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const //if (aObjects.size() == 1) // theMenu->addAction(action("EDIT_CMD")); bool isVisible = false; - foreach(ObjectPtr aObject, aObjects) { + foreach(ObjectPtr aObject, aObjects) + { ResultPtr aRes = boost::dynamic_pointer_cast(aObject); if (aRes && myWorkshop->displayer()->isVisible(aRes)) { isVisible = true; @@ -183,7 +187,7 @@ void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const } if (isVisible) theMenu->addAction(action("HIDE_CMD")); - else + else theMenu->addAction(action("SHOW_CMD")); //theMenu->addAction(action("DELETE_CMD")); } @@ -198,13 +202,13 @@ void XGUI_ContextMenuMgr::addViewerItems(QMenu* theMenu) const void XGUI_ContextMenuMgr::connectObjectBrowser() const { - connect(myWorkshop->objectBrowser(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), - this, SLOT(onContextMenuRequest(QContextMenuEvent*))); + connect(myWorkshop->objectBrowser(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, + SLOT(onContextMenuRequest(QContextMenuEvent*))); } void XGUI_ContextMenuMgr::connectViewer() const { - connect(myWorkshop->viewer(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), - this, SLOT(onContextMenuRequest(QContextMenuEvent*))); + connect(myWorkshop->viewer(), SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, + SLOT(onContextMenuRequest(QContextMenuEvent*))); } diff --git a/src/XGUI/XGUI_ContextMenuMgr.h b/src/XGUI/XGUI_ContextMenuMgr.h index a48bd79c7..64c846b18 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.h +++ b/src/XGUI/XGUI_ContextMenuMgr.h @@ -1,4 +1,3 @@ - #ifndef XGUI_ContextMenuMgr_H #define XGUI_ContextMenuMgr_H @@ -13,12 +12,12 @@ class QContextMenuEvent; class QMenu; /** -* A claas wihich provides manement of context menu -*/ -class XGUI_EXPORT XGUI_ContextMenuMgr: public QObject + * A claas wihich provides manement of context menu + */ +class XGUI_EXPORT XGUI_ContextMenuMgr : public QObject { Q_OBJECT -public: + public: XGUI_ContextMenuMgr(XGUI_Workshop* theParent); virtual ~XGUI_ContextMenuMgr(); @@ -46,20 +45,19 @@ public: signals: void actionTriggered(const QString& theId, bool isChecked); -private slots: + private slots: void onAction(bool isChecked); void onContextMenuRequest(QContextMenuEvent* theEvent); -private: + private: /** - * Add action - * \param theId - string ID of the item - * \param theAction - action to add - */ + * Add action + * \param theId - string ID of the item + * \param theAction - action to add + */ void addAction(const QString& theId, QAction* theAction); - QMenu* objectBrowserMenu() const; QMenu* viewerMenu() const; @@ -68,4 +66,4 @@ private: XGUI_Workshop* myWorkshop; }; -#endif \ No newline at end of file +#endif diff --git a/src/XGUI/XGUI_DataTreeModel.h b/src/XGUI/XGUI_DataTreeModel.h index 0b8844e2f..075c1e162 100644 --- a/src/XGUI/XGUI_DataTreeModel.h +++ b/src/XGUI/XGUI_DataTreeModel.h @@ -1,4 +1,3 @@ - #ifndef XGUI_DataTreeModel_H #define XGUI_DataTreeModel_H @@ -18,9 +17,12 @@ */ class XGUI_EXPORT XGUI_FeaturesModel : public QAbstractItemModel { -public: - XGUI_FeaturesModel(QObject* theParent): - QAbstractItemModel(theParent), myItemsColor(Qt::black) {} + public: + XGUI_FeaturesModel(QObject* theParent) + : QAbstractItemModel(theParent), + myItemsColor(Qt::black) + { + } //! Returns Feature object by the given Model index. //! Returns 0 if the given index is not index of a feature @@ -36,26 +38,36 @@ public: //! Returns index corresponded to the group virtual QModelIndex findGroup(const std::string& theGroup) const = 0; - void setItemsColor(const QColor& theColor) { myItemsColor = theColor; } + void setItemsColor(const QColor& theColor) + { + myItemsColor = theColor; + } - QColor itemsColor() const { return myItemsColor; } + QColor itemsColor() const + { + return myItemsColor; + } -protected: + protected: QColor myItemsColor; }; - /**\class XGUI_PartModel * \ingroup GUI * \brief Abstaract class of model object which operates with parts data. */ class XGUI_PartModel : public XGUI_FeaturesModel { -public: - XGUI_PartModel(QObject* theParent): - XGUI_FeaturesModel(theParent) {} + public: + XGUI_PartModel(QObject* theParent) + : XGUI_FeaturesModel(theParent) + { + } - void setPartId(int theId) { myId = theId; } + void setPartId(int theId) + { + myId = theId; + } //! Returns true if the given document is a sub-document of this tree virtual bool hasDocument(const DocumentPtr& theDoc) const = 0; @@ -63,10 +75,9 @@ public: //! Return a Part object virtual ResultPartPtr part() const = 0; -protected: + protected: //! Id of the current part object in the document int myId; }; - -#endif \ No newline at end of file +#endif diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 62c735ce7..57befeb24 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -25,7 +25,7 @@ #include -const int MOUSE_SENSITIVITY_IN_PIXEL = 10; ///< defines the local context mouse selection sensitivity +const int MOUSE_SENSITIVITY_IN_PIXEL = 10; ///< defines the local context mouse selection sensitivity XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop) { @@ -66,8 +66,8 @@ void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer) } } -void XGUI_Displayer::display(ObjectPtr theObject, - boost::shared_ptr theAIS, bool isUpdateViewer) +void XGUI_Displayer::display(ObjectPtr theObject, boost::shared_ptr theAIS, + bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); @@ -78,15 +78,14 @@ void XGUI_Displayer::display(ObjectPtr theObject, } } - - void XGUI_Displayer::erase(ObjectPtr theObject, const bool isUpdateViewer) { - if (!isVisible(theObject)) return; + if (!isVisible(theObject)) + return; Handle(AIS_InteractiveContext) aContext = AISContext(); boost::shared_ptr anObject = myResult2AISObjectMap[theObject]; - if (anObject) { + if (anObject) { Handle(AIS_InteractiveObject) anAIS = anObject->impl(); if (!anAIS.IsNull()) { aContext->Remove(anAIS, isUpdateViewer); @@ -95,36 +94,35 @@ void XGUI_Displayer::erase(ObjectPtr theObject, const bool isUpdateViewer) myResult2AISObjectMap.erase(theObject); } - /*bool XGUI_Displayer::redisplay(ObjectPtr theObject, - boost::shared_ptr theAIS, - const bool isUpdateViewer) -{ - bool isCreated = false; - Handle(AIS_InteractiveObject) anAIS = - theAIS ? theAIS->impl() : Handle(AIS_InteractiveObject)(); - Handle(AIS_InteractiveContext) aContext = AISContext(); - // Open local context if there is no one - if (!aContext->HasOpenedContext()) { - aContext->ClearCurrents(false); - aContext->OpenLocalContext(false /use displayed objects/, true /allow shape decomposition/); - // set mouse sensitivity - //aContext->SetSensitivityMode(StdSelect_SM_WINDOW); - //aContext->SetPixelTolerance(MOUSE_SENSITIVITY_IN_PIXEL); - } - // display or redisplay presentation - boost::shared_ptr anObj = myResult2AISObjectMap[theObject]; - if (isVisible(theObject) && anObj && !anObj->empty()) { - aContext->Redisplay(anAIS, isUpdateViewer); - //aContext->RecomputeSelectionOnly(anAIS); - } - else { - myResult2AISObjectMap[theObject] = theAIS; - aContext->Display(anAIS, isUpdateViewer); - isCreated = true; - } - return isCreated; -}*/ + boost::shared_ptr theAIS, + const bool isUpdateViewer) + { + bool isCreated = false; + Handle(AIS_InteractiveObject) anAIS = + theAIS ? theAIS->impl() : Handle(AIS_InteractiveObject)(); + Handle(AIS_InteractiveContext) aContext = AISContext(); + // Open local context if there is no one + if (!aContext->HasOpenedContext()) { + aContext->ClearCurrents(false); + aContext->OpenLocalContext(false /use displayed objects/, true /allow shape decomposition/); + // set mouse sensitivity + //aContext->SetSensitivityMode(StdSelect_SM_WINDOW); + //aContext->SetPixelTolerance(MOUSE_SENSITIVITY_IN_PIXEL); + } + // display or redisplay presentation + boost::shared_ptr anObj = myResult2AISObjectMap[theObject]; + if (isVisible(theObject) && anObj && !anObj->empty()) { + aContext->Redisplay(anAIS, isUpdateViewer); + //aContext->RecomputeSelectionOnly(anAIS); + } + else { + myResult2AISObjectMap[theObject] = theAIS; + aContext->Display(anAIS, isUpdateViewer); + isCreated = true; + } + return isCreated; + }*/ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) { @@ -146,7 +144,8 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) if (aResult) { boost::shared_ptr aShapePtr = ModelAPI_Tools::shape(aResult); if (aShapePtr) { - Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl()); + Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast( + aAISObj->impl()); if (!aAISShape.IsNull()) { aAISShape->Set(aShapePtr->impl()); aAISIO = aAISShape; @@ -163,8 +162,8 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) } } -void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, - const std::list& theModes, const bool isUpdateViewer) +void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, const std::list& theModes, + const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); // Open local context if there is no one @@ -182,7 +181,7 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, // Activate selection of objects from prs if (!anAIS.IsNull()) { - aContext->ClearSelected(false); // ToCheck + aContext->ClearSelected(false); // ToCheck //aContext->upClearSelected(false); // ToCheck aContext->Load(anAIS, -1, true/*allow decomposition*/); aContext->Deactivate(anAIS); @@ -202,9 +201,9 @@ void XGUI_Displayer::deactivate(ObjectPtr theObject) if (isVisible(theObject)) { Handle(AIS_InteractiveContext) aContext = AISContext(); - boost::shared_ptr anObj = myResult2AISObjectMap[theObject]; - Handle(AIS_InteractiveObject) anAIS = anObj->impl(); - aContext->Deactivate(anAIS); + boost::shared_ptr anObj = myResult2AISObjectMap[theObject]; + Handle(AIS_InteractiveObject) anAIS = anObj->impl(); + aContext->Deactivate(anAIS); } } @@ -213,9 +212,9 @@ void XGUI_Displayer::activate(ObjectPtr theObject) if (isVisible(theObject)) { Handle(AIS_InteractiveContext) aContext = AISContext(); - boost::shared_ptr anObj = myResult2AISObjectMap[theObject]; - Handle(AIS_InteractiveObject) anAIS = anObj->impl(); - aContext->Activate(anAIS); + boost::shared_ptr anObj = myResult2AISObjectMap[theObject]; + Handle(AIS_InteractiveObject) anAIS = anObj->impl(); + aContext->Activate(anAIS); } } @@ -230,18 +229,22 @@ void XGUI_Displayer::stopSelection(const QList& theResults, const boo for (; anIt != aLast; anIt++) { aFeature = *anIt; if (isVisible(aFeature)) - anAIS = Handle(AIS_Shape)::DownCast(myResult2AISObjectMap[aFeature]->impl()); + anAIS = Handle(AIS_Shape)::DownCast( + myResult2AISObjectMap[aFeature]->impl()); if (anAIS.IsNull()) continue; if (isStop) { QColor aColor(Qt::white); - anAIS->SetColor(Quantity_Color(aColor.red()/255., aColor.green()/255., aColor.blue()/255., Quantity_TOC_RGB)); + anAIS->SetColor( + Quantity_Color(aColor.red() / 255., aColor.green() / 255., aColor.blue() / 255., + Quantity_TOC_RGB)); anAIS->Redisplay(); - } - else { + } else { QColor aColor(Qt::red); - anAIS->SetColor(Quantity_Color(aColor.red()/255., aColor.green()/255., aColor.blue()/255., Quantity_TOC_RGB)); + anAIS->SetColor( + Quantity_Color(aColor.red() / 255., aColor.green() / 255., aColor.blue() / 255., + Quantity_TOC_RGB)); anAIS->Redisplay(); } } @@ -259,8 +262,9 @@ void XGUI_Displayer::setSelected(const QList& theResults, const bool aLocalContext->UnhilightLastDetected(myWorkshop->viewer()->activeView()); aContext->ClearSelected(); - foreach(ObjectPtr aResult, theResults) { - if (myResult2AISObjectMap.find(aResult) == myResult2AISObjectMap.end()) + foreach(ObjectPtr aResult, theResults) + { + if (myResult2AISObjectMap.find(aResult) == myResult2AISObjectMap.end()) continue; boost::shared_ptr anObj = myResult2AISObjectMap[aResult]; @@ -274,40 +278,39 @@ void XGUI_Displayer::setSelected(const QList& theResults, const bool updateViewer(); } - /*void XGUI_Displayer::EraseAll(const bool isUpdateViewer) -{ - Handle(AIS_InteractiveContext) ic = AISContext(); - - AIS_ListOfInteractive aList; - ic->DisplayedObjects(aList); - AIS_ListIteratorOfListOfInteractive anIter(aList); - for (; anIter.More(); anIter.Next()) { - if ((anIter.Value()->DynamicType() == STANDARD_TYPE(AIS_Trihedron))) - continue; - - // erase an object - Handle(AIS_InteractiveObject) anIO = anIter.Value(); - ic->Erase(anIO, false); - } - myResult2AISObjectMap.clear(); - if (isUpdateViewer) - updateViewer(); -}*/ + { + Handle(AIS_InteractiveContext) ic = AISContext(); + + AIS_ListOfInteractive aList; + ic->DisplayedObjects(aList); + AIS_ListIteratorOfListOfInteractive anIter(aList); + for (; anIter.More(); anIter.Next()) { + if ((anIter.Value()->DynamicType() == STANDARD_TYPE(AIS_Trihedron))) + continue; + + // erase an object + Handle(AIS_InteractiveObject) anIO = anIter.Value(); + ic->Erase(anIO, false); + } + myResult2AISObjectMap.clear(); + if (isUpdateViewer) + updateViewer(); + }*/ void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); - ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), - aFLast = myResult2AISObjectMap.end(); + ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), aFLast = + myResult2AISObjectMap.end(); std::list aRemoved; - for (; aFIt != aFLast; aFIt++) - { + for (; aFIt != aFLast; aFIt++) { ObjectPtr aFeature = (*aFIt).first; if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) { boost::shared_ptr anObj = (*aFIt).second; - if (!anObj) continue; + if (!anObj) + continue; Handle(AIS_InteractiveObject) anAIS = anObj->impl(); if (!anAIS.IsNull()) { aContext->Remove(anAIS, false); @@ -315,8 +318,7 @@ void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer) } } } - std::list::const_iterator anIt = aRemoved.begin(), - aLast = aRemoved.end(); + std::list::const_iterator anIt = aRemoved.begin(), aLast = aRemoved.end(); for (; anIt != aLast; anIt++) { myResult2AISObjectMap.erase(myResult2AISObjectMap.find(*anIt)); } @@ -341,11 +343,12 @@ boost::shared_ptr XGUI_Displayer::getAISObject(ObjectPtr theO ObjectPtr XGUI_Displayer::getObject(Handle(AIS_InteractiveObject) theIO) const { ObjectPtr aFeature; - ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), - aFLast = myResult2AISObjectMap.end(); + ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(), aFLast = + myResult2AISObjectMap.end(); for (; aFIt != aFLast && !aFeature; aFIt++) { boost::shared_ptr anObj = (*aFIt).second; - if (!anObj) continue; + if (!anObj) + continue; Handle(AIS_InteractiveObject) anAIS = anObj->impl(); if (anAIS != theIO) continue; @@ -371,12 +374,11 @@ void XGUI_Displayer::updateViewer() ic->UpdateCurrentViewer(); } -Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const -{ - return myWorkshop->viewer()->AISContext(); +Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const +{ + return myWorkshop->viewer()->AISContext(); } - void XGUI_Displayer::display(boost::shared_ptr theAIS, bool isUpdate) { Handle(AIS_InteractiveContext) aContext = AISContext(); diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index ebbfad740..ef3a3308d 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -36,7 +36,7 @@ class XGUI_Workshop; */ class XGUI_EXPORT XGUI_Displayer { -public: + public: /// Constructor /// \param theViewer the viewer XGUI_Displayer(XGUI_Workshop* theWorkshop); @@ -70,8 +70,8 @@ public: /// \param theShape a shape /// \param theMode a list of local selection modes /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - void activateInLocalContext(ObjectPtr theFeature, - const std::list& theModes, const bool isUpdateViewer = true); + void activateInLocalContext(ObjectPtr theFeature, const std::list& theModes, + const bool isUpdateViewer = true); /// Stop the current selection and color the given features to the selection color /// \param theFeatures a list of features to be disabled @@ -81,10 +81,10 @@ public: const bool isUpdateViewer); /** - * Add presentations which corresponds to the given features to current selection - * \param theFeatures a list of features to be selected - * isUpdateViewer the parameter whether the viewer should be update immediatelly - */ + * Add presentations which corresponds to the given features to current selection + * \param theFeatures a list of features to be selected + * isUpdateViewer the parameter whether the viewer should be update immediatelly + */ void setSelected(const QList& theFeatures, bool isUpdateViewer = true); /// Erase the feature and a shape. @@ -124,7 +124,7 @@ public: void activate(ObjectPtr theFeature); -protected: + protected: /// Deactivate local selection /// \param isUpdateViewer the state wether the viewer should be updated immediatelly void closeAllContexts(const bool isUpdateViewer); @@ -137,8 +137,9 @@ protected: /// \param theAIS AIS presentation /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly /// Returns true if the Feature succesfully displayed - void display(ObjectPtr theObject, boost::shared_ptr theAIS, bool isUpdateViewer = true); - + void display(ObjectPtr theObject, boost::shared_ptr theAIS, + bool isUpdateViewer = true); + /// Display the shape and activate selection of sub-shapes /// \param theFeature a feature instance /// \param theAIS an AIS object @@ -149,17 +150,16 @@ protected: // const bool isUpdateViewer = true); /** Redisplay the shape if it was displayed - * \param theFeature a feature instance - * \param isUpdateViewer the parameter whether the viewer should be update immediatelly - */ + * \param theFeature a feature instance + * \param isUpdateViewer the parameter whether the viewer should be update immediatelly + */ void redisplay(ObjectPtr theObject, bool isUpdateViewer = true); -protected: + protected: XGUI_Workshop* myWorkshop; typedef std::map > ResultToAISMap; ResultToAISMap myResult2AISObjectMap; }; - #endif diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index 6082e445b..17dfe99b9 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -25,7 +25,8 @@ #define PASSIVE_COLOR Qt::black XGUI_DocumentDataModel::XGUI_DocumentDataModel(QObject* theParent) - : QAbstractItemModel(theParent), myActivePart(0) + : QAbstractItemModel(theParent), + myActivePart(0) { // Register in event loop Events_Loop::loop()->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); @@ -37,20 +38,19 @@ XGUI_DocumentDataModel::XGUI_DocumentDataModel(QObject* theParent) myModel->setItemsColor(ACTIVE_COLOR); } - XGUI_DocumentDataModel::~XGUI_DocumentDataModel() { clearModelIndexes(); } - void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); // Created object event ******************* if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { - const ModelAPI_ObjectUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); + const ModelAPI_ObjectUpdatedMessage* aUpdMsg = + dynamic_cast(theMessage); std::set aObjects = aUpdMsg->objects(); std::set::const_iterator aIt; @@ -62,21 +62,22 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) DocumentPtr aDoc = aObject->document(); if (aDoc == aRootDoc) { // If root objects - if (aObject->groupName() == ModelAPI_ResultPart::group()) { // Update only Parts group - // Add a new part + if (aObject->groupName() == ModelAPI_ResultPart::group()) { // Update only Parts group + // Add a new part int aStart = myPartModels.size(); XGUI_PartDataModel* aModel = new XGUI_PartDataModel(this); aModel->setPartId(myPartModels.count()); myPartModels.append(aModel); insertRow(aStart, partFolderNode()); - } else { // Update top groups (other except parts + } else { // Update top groups (other except parts QModelIndex aIndex = myModel->findParent(aObject); int aStart = myModel->rowCount(aIndex) - 1; - if (aStart < 0) aStart = 0; - aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)); + if (aStart < 0) + aStart = 0; + aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex)); insertRow(aStart, aIndex); } - } else { // if sub-objects of first level nodes + } else { // if sub-objects of first level nodes XGUI_PartModel* aPartModel = 0; QList::const_iterator aIt; for (aIt = myPartModels.constBegin(); aIt != myPartModels.constEnd(); ++aIt) { @@ -87,15 +88,16 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) } if (aPartModel) { QModelIndex aIndex = aPartModel->findParent(aObject); - int aStart = aPartModel->rowCount(aIndex); // check this index - aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)); + int aStart = aPartModel->rowCount(aIndex); // check this index + aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex)); insertRow(aStart, aIndex); } } } - // Deleted object event *********************** + // Deleted object event *********************** } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) { - const ModelAPI_ObjectDeletedMessage* aUpdMsg = dynamic_cast(theMessage); + const ModelAPI_ObjectDeletedMessage* aUpdMsg = + dynamic_cast(theMessage); DocumentPtr aDoc = aUpdMsg->document(); std::set aGroups = aUpdMsg->groups(); @@ -103,7 +105,7 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) for (aIt = aGroups.begin(); aIt != aGroups.end(); ++aIt) { std::string aGroup = (*aIt); if (aDoc == aRootDoc) { // If root objects - if (aGroup == ModelAPI_ResultPart::group()) { // Update only Parts group + if (aGroup == ModelAPI_ResultPart::group()) { // Update only Parts group int aStart = myPartModels.size() - 1; removeSubModel(aStart); removeRow(aStart, partFolderNode()); @@ -112,10 +114,10 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) myActivePartIndex = QModelIndex(); myModel->setItemsColor(ACTIVE_COLOR); } - } else { // Update top groups (other except parts + } else { // Update top groups (other except parts QModelIndex aIndex = myModel->findGroup(aGroup); int aStart = myModel->rowCount(aIndex); - aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)); + aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex)); removeRow(aStart, aIndex); } } else { @@ -130,23 +132,23 @@ void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage) if (aPartModel) { QModelIndex aIndex = aPartModel->findGroup(aGroup); int aStart = aPartModel->rowCount(aIndex); - aIndex = createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)); + aIndex = createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex)); removeRow(aStart, aIndex); } } } - // Deleted object event *********************** + // Deleted object event *********************** } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) { //const ModelAPI_ObjectUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); //ObjectPtr aFeature = aUpdMsg->feature(); //DocumentPtr aDoc = aFeature->document(); - + // TODO: Identify the necessary index by the modified feature QModelIndex aIndex; emit dataChanged(aIndex, aIndex); - // Reset whole tree ************************** - } else { + // Reset whole tree ************************** + } else { rebuildDataTree(); } } @@ -159,7 +161,7 @@ void XGUI_DocumentDataModel::rebuildDataTree() clearModelIndexes(); int aNbParts = aRootDoc->size(ModelAPI_ResultPart::group()); - if (myPartModels.size() != aNbParts) { // resize internal models + if (myPartModels.size() != aNbParts) { // resize internal models while (myPartModels.size() > aNbParts) { delete myPartModels.last(); myPartModels.removeLast(); @@ -178,52 +180,52 @@ QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole) if (!theIndex.isValid()) return QVariant(); switch (theIndex.internalId()) { - case PartsFolder: - switch (theRole) { - case Qt::DisplayRole: - return tr("Parts") + QString(" (%1)").arg(rowCount(theIndex)); - case Qt::DecorationRole: - return QIcon(":pictures/constr_folder.png"); - case Qt::ToolTipRole: - return tr("Parts folder"); - case Qt::ForegroundRole: - if (myActivePart) - return QBrush(PASSIVE_COLOR); - else - return QBrush(ACTIVE_COLOR); - default: - return QVariant(); - } - break; - case HistoryNode: - { - int aOffset = historyOffset(); - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); - ObjectPtr aObj = aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset); - FeaturePtr aFeature = boost::dynamic_pointer_cast(aObj); - if (!aFeature) - return QVariant(); + case PartsFolder: switch (theRole) { - case Qt::DisplayRole: - if (aFeature) - return aFeature->data()->name().c_str(); - else - return QVariant(); - case Qt::DecorationRole: - return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind())); - case Qt::ToolTipRole: - return tr("Feature object"); - case Qt::ForegroundRole: - if (myActivePart) - return QBrush(PASSIVE_COLOR); - else - return QBrush(ACTIVE_COLOR); - default: - return QVariant(); - } - } - break; - } + case Qt::DisplayRole: + return tr("Parts") + QString(" (%1)").arg(rowCount(theIndex)); + case Qt::DecorationRole: + return QIcon(":pictures/constr_folder.png"); + case Qt::ToolTipRole: + return tr("Parts folder"); + case Qt::ForegroundRole: + if (myActivePart) + return QBrush(PASSIVE_COLOR); + else + return QBrush(ACTIVE_COLOR); + default: + return QVariant(); + } + break; + case HistoryNode: + { + int aOffset = historyOffset(); + DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + ObjectPtr aObj = aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset); + FeaturePtr aFeature = boost::dynamic_pointer_cast(aObj); + if (!aFeature) + return QVariant(); + switch (theRole) { + case Qt::DisplayRole: + if (aFeature) + return aFeature->data()->name().c_str(); + else + return QVariant(); + case Qt::DecorationRole: + return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind())); + case Qt::ToolTipRole: + return tr("Feature object"); + case Qt::ForegroundRole: + if (myActivePart) + return QBrush(PASSIVE_COLOR); + else + return QBrush(ACTIVE_COLOR); + default: + return QVariant(); + } + } + break; + } QModelIndex aParent = theIndex.parent(); if (aParent.isValid() && (aParent.internalId() == PartsFolder)) { return myPartModels.at(theIndex.row())->data(QModelIndex(), theRole); @@ -231,8 +233,8 @@ QVariant XGUI_DocumentDataModel::data(const QModelIndex& theIndex, int theRole) return toSourceModelIndex(theIndex)->data(theRole); } - -QVariant XGUI_DocumentDataModel::headerData(int theSection, Qt::Orientation theOrient, int theRole) const +QVariant XGUI_DocumentDataModel::headerData(int theSection, Qt::Orientation theOrient, + int theRole) const { return QVariant(); } @@ -256,13 +258,13 @@ int XGUI_DocumentDataModel::rowCount(const QModelIndex& theParent) const } QModelIndex* aParent = toSourceModelIndex(theParent); const QAbstractItemModel* aModel = aParent->model(); - if (!isSubModel(aModel)) + if (!isSubModel(aModel)) return 0; /*if (isPartSubModel(aModel)) { - if (aModel != myActivePart) - return 0; - }*/ + if (aModel != myActivePart) + return 0; + }*/ return aModel->rowCount(*aParent); } @@ -271,33 +273,34 @@ int XGUI_DocumentDataModel::columnCount(const QModelIndex& theParent) const return 1; } -QModelIndex XGUI_DocumentDataModel::index(int theRow, int theColumn, const QModelIndex& theParent) const +QModelIndex XGUI_DocumentDataModel::index(int theRow, int theColumn, + const QModelIndex& theParent) const { QModelIndex aIndex; if (!theParent.isValid()) { int aOffs = myModel->rowCount(); if (theRow < aOffs) { aIndex = myModel->index(theRow, theColumn, theParent); - aIndex = createIndex(theRow, theColumn, (void*)getModelIndex(aIndex)); + aIndex = createIndex(theRow, theColumn, (void*) getModelIndex(aIndex)); } else { if (theRow == aOffs) // Create Parts node aIndex = partFolderNode(); - else // create history node + else + // create history node aIndex = createIndex(theRow, theColumn, HistoryNode); } } else { if (theParent.internalId() == PartsFolder) { aIndex = myPartModels.at(theRow)->index(0, theColumn, QModelIndex()); } else { - QModelIndex* aParent = (QModelIndex*)theParent.internalPointer(); + QModelIndex* aParent = (QModelIndex*) theParent.internalPointer(); aIndex = aParent->model()->index(theRow, theColumn, (*aParent)); } - aIndex = createIndex(theRow, theColumn, (void*)getModelIndex(aIndex)); + aIndex = createIndex(theRow, theColumn, (void*) getModelIndex(aIndex)); } return aIndex; } - QModelIndex XGUI_DocumentDataModel::parent(const QModelIndex& theIndex) const { if ((theIndex.internalId() == PartsFolder) || (theIndex.internalId() == HistoryNode)) @@ -305,7 +308,7 @@ QModelIndex XGUI_DocumentDataModel::parent(const QModelIndex& theIndex) const QModelIndex* aIndex = toSourceModelIndex(theIndex); const QAbstractItemModel* aModel = aIndex->model(); - if (!isSubModel(aModel)) + if (!isSubModel(aModel)) return QModelIndex(); if (isPartSubModel(aModel)) { @@ -316,11 +319,10 @@ QModelIndex XGUI_DocumentDataModel::parent(const QModelIndex& theIndex) const QModelIndex aIndex1 = aModel->parent(*aIndex); if (aIndex1.isValid()) - return createIndex(aIndex1.row(), aIndex1.column(), (void*)getModelIndex(aIndex1)); + return createIndex(aIndex1.row(), aIndex1.column(), (void*) getModelIndex(aIndex1)); return aIndex1; } - bool XGUI_DocumentDataModel::hasChildren(const QModelIndex& theParent) const { if (!theParent.isValid()) @@ -328,14 +330,12 @@ bool XGUI_DocumentDataModel::hasChildren(const QModelIndex& theParent) const return rowCount(theParent) > 0; } - QModelIndex* XGUI_DocumentDataModel::toSourceModelIndex(const QModelIndex& theProxy) const { QModelIndex* aIndexPtr = static_cast(theProxy.internalPointer()); return aIndexPtr; } - QModelIndex* XGUI_DocumentDataModel::findModelIndex(const QModelIndex& theIndex) const { QList::const_iterator aIt; @@ -361,7 +361,7 @@ QModelIndex* XGUI_DocumentDataModel::getModelIndex(const QModelIndex& theIndex) void XGUI_DocumentDataModel::clearModelIndexes() { QList::const_iterator aIt; - for (aIt = myIndexes.constBegin(); aIt != myIndexes.constEnd(); ++aIt) + for (aIt = myIndexes.constBegin(); aIt != myIndexes.constEnd(); ++aIt) delete (*aIt); myIndexes.clear(); } @@ -376,7 +376,7 @@ ObjectPtr XGUI_DocumentDataModel::object(const QModelIndex& theIndex) const return aRootDoc->object(ModelAPI_Feature::group(), theIndex.row() - aOffset); } QModelIndex* aIndex = toSourceModelIndex(theIndex); - if (!isSubModel(aIndex->model())) + if (!isSubModel(aIndex->model())) return ObjectPtr(); const XGUI_FeaturesModel* aModel = dynamic_cast(aIndex->model()); @@ -404,7 +404,6 @@ bool XGUI_DocumentDataModel::removeRows(int theRow, int theCount, const QModelIn return true; } - void XGUI_DocumentDataModel::removeSubModel(int theModelId) { XGUI_PartModel* aModel = myPartModels.at(theModelId); @@ -414,7 +413,7 @@ void XGUI_DocumentDataModel::removeSubModel(int theModelId) aToRemove.append(i); } int aId; - while(aToRemove.size() > 0) { + while (aToRemove.size() > 0) { aId = aToRemove.last(); delete myIndexes.at(aId); myIndexes.removeAt(aId); @@ -433,7 +432,7 @@ bool XGUI_DocumentDataModel::isSubModel(const QAbstractItemModel* theModel) cons bool XGUI_DocumentDataModel::isPartSubModel(const QAbstractItemModel* theModel) const { - return myPartModels.contains((XGUI_PartModel*)theModel); + return myPartModels.contains((XGUI_PartModel*) theModel); } QModelIndex XGUI_DocumentDataModel::partFolderNode() const @@ -462,43 +461,44 @@ bool XGUI_DocumentDataModel::activatedIndex(const QModelIndex& theIndex) if (isPartSubModel(aModel)) { // if this is root node (Part item index) if (!aIndex->parent().isValid()) { - if (myActivePart) myActivePart->setItemsColor(PASSIVE_COLOR); + if (myActivePart) + myActivePart->setItemsColor(PASSIVE_COLOR); + + if (myActivePart == aModel) { + myActivePart = 0; + myActivePartIndex = QModelIndex(); + } else { + myActivePart = (XGUI_PartModel*)aModel; + myActivePartIndex = theIndex; + } - if (myActivePart == aModel) { - myActivePart = 0; - myActivePartIndex = QModelIndex(); - } else { - myActivePart = (XGUI_PartModel*)aModel; - myActivePartIndex = theIndex; + if (myActivePart) { + myActivePart->setItemsColor(ACTIVE_COLOR); + myModel->setItemsColor(PASSIVE_COLOR); + } else + myModel->setItemsColor(ACTIVE_COLOR); + return true; } - - if (myActivePart) { - myActivePart->setItemsColor(ACTIVE_COLOR); - myModel->setItemsColor(PASSIVE_COLOR); - } else - myModel->setItemsColor(ACTIVE_COLOR); - return true; } - } return false; } ResultPartPtr XGUI_DocumentDataModel::activePart() const { - if (myActivePart) + if (myActivePart) return myActivePart->part(); return ResultPartPtr(); } -void XGUI_DocumentDataModel::deactivatePart() -{ - if (myActivePart) +void XGUI_DocumentDataModel::deactivatePart() +{ + if (myActivePart) myActivePart->setItemsColor(PASSIVE_COLOR); - myActivePart = 0; - myActivePartIndex = QModelIndex(); - myModel->setItemsColor(ACTIVE_COLOR); -} - + myActivePart = 0; + myActivePartIndex = QModelIndex(); + myModel->setItemsColor(ACTIVE_COLOR); + } + Qt::ItemFlags XGUI_DocumentDataModel::flags(const QModelIndex& theIndex) const { Qt::ItemFlags aFlags = QAbstractItemModel::flags(theIndex); @@ -508,11 +508,12 @@ Qt::ItemFlags XGUI_DocumentDataModel::flags(const QModelIndex& theIndex) const return aFlags; } -QModelIndex XGUI_DocumentDataModel::partIndex(const ResultPartPtr& theObject) const +QModelIndex XGUI_DocumentDataModel::partIndex(const ResultPartPtr& theObject) const { int aRow = -1; XGUI_PartModel* aModel = 0; - foreach (XGUI_PartModel* aPartModel, myPartModels) { + foreach (XGUI_PartModel* aPartModel, myPartModels) + { aRow++; if (aPartModel->part() == theObject) { aModel = aPartModel; @@ -520,7 +521,7 @@ QModelIndex XGUI_DocumentDataModel::partIndex(const ResultPartPtr& theObject) co } } if (aModel) { - return createIndex(aRow, 0, (void*)getModelIndex(aModel->index(0, 0, QModelIndex()))); + return createIndex(aRow, 0, (void*) getModelIndex(aModel->index(0, 0, QModelIndex()))); } return QModelIndex(); } @@ -544,13 +545,15 @@ QModelIndex XGUI_DocumentDataModel::objectIndex(const ObjectPtr theObject) const return index(aId + historyOffset(), 0, QModelIndex()); } else { QModelIndex aIndex = myModel->objectIndex(theObject); - return aIndex.isValid()? - createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)) : - QModelIndex(); + return + aIndex.isValid() ? + createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex)) : + QModelIndex(); } } else { XGUI_PartModel* aPartModel = 0; - foreach(XGUI_PartModel* aModel, myPartModels) { + foreach(XGUI_PartModel* aModel, myPartModels) + { if (aModel->hasDocument(aDoc)) { aPartModel = aModel; break; @@ -558,9 +561,10 @@ QModelIndex XGUI_DocumentDataModel::objectIndex(const ObjectPtr theObject) const } if (aPartModel) { QModelIndex aIndex = aPartModel->objectIndex(theObject); - return aIndex.isValid()? - createIndex(aIndex.row(), aIndex.column(), (void*)getModelIndex(aIndex)) : - QModelIndex(); + return + aIndex.isValid() ? + createIndex(aIndex.row(), aIndex.column(), (void*) getModelIndex(aIndex)) : + QModelIndex(); } } return QModelIndex(); diff --git a/src/XGUI/XGUI_DocumentDataModel.h b/src/XGUI/XGUI_DocumentDataModel.h index c49c66965..393ce6bbe 100644 --- a/src/XGUI/XGUI_DocumentDataModel.h +++ b/src/XGUI/XGUI_DocumentDataModel.h @@ -1,4 +1,3 @@ - #ifndef XGUI_DocumentDataModel_H #define XGUI_DocumentDataModel_H @@ -22,9 +21,8 @@ class XGUI_TopDataModel; */ class XGUI_EXPORT XGUI_DocumentDataModel : public QAbstractItemModel, public Events_Listener { - Q_OBJECT -public: - +Q_OBJECT + public: XGUI_DocumentDataModel(QObject* theParent); virtual ~XGUI_DocumentDataModel(); @@ -32,16 +30,15 @@ public: // Event Listener method virtual void processEvent(const Events_Message* theMessage); - virtual QVariant data(const QModelIndex& theIndex, int theRole) const; - virtual QVariant headerData(int theSection, Qt::Orientation theOrient, - int theRole = Qt::DisplayRole) const; + virtual QVariant headerData(int theSection, Qt::Orientation theOrient, int theRole = + Qt::DisplayRole) const; virtual int rowCount(const QModelIndex& theParent = QModelIndex()) const; virtual int columnCount(const QModelIndex& theParent = QModelIndex()) const; - virtual QModelIndex index(int theRow, int theColumn, - const QModelIndex &parent = QModelIndex()) const; + virtual QModelIndex index(int theRow, int theColumn, const QModelIndex &parent = + QModelIndex()) const; virtual QModelIndex parent(const QModelIndex& theIndex) const; @@ -71,17 +68,23 @@ public: ResultPartPtr activePart() const; //! Retrurns QModelIndex of active part - QModelIndex activePartIndex() const { return myActivePartIndex; } + QModelIndex activePartIndex() const + { + return myActivePartIndex; + } //! Deactivates a Part void deactivatePart(); void rebuildDataTree(); -private: - - enum {PartsFolder, HistoryNode}; + private: + enum + { + PartsFolder, + HistoryNode + }; //! Converts QModelIndex of this model to QModelIndex of a one of sub-models. QModelIndex* toSourceModelIndex(const QModelIndex& theProxy) const; @@ -109,7 +112,6 @@ private: int historyOffset() const; - //! Data model of top part of data tree (not parts object) XGUI_TopDataModel* myModel; @@ -126,4 +128,4 @@ private: }; -#endif \ No newline at end of file +#endif diff --git a/src/XGUI/XGUI_ErrorDialog.cpp b/src/XGUI/XGUI_ErrorDialog.cpp index c3608f606..c6d2e90d6 100644 --- a/src/XGUI/XGUI_ErrorDialog.cpp +++ b/src/XGUI/XGUI_ErrorDialog.cpp @@ -20,10 +20,10 @@ XGUI_ErrorDialog::XGUI_ErrorDialog(QWidget* parent) myErrorLog = new QTextEdit(this); myErrorLog->setReadOnly(true); aDlgLay->addWidget(myErrorLog); - QDialogButtonBox* aButtonBox = - new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this); + QDialogButtonBox* aButtonBox = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, + this); aDlgLay->addWidget(aButtonBox); - aDlgLay->setContentsMargins(2,2,2,2); + aDlgLay->setContentsMargins(2, 2, 2, 2); aDlgLay->setSpacing(2); setLayout(aDlgLay); resize(420, 240); @@ -56,7 +56,7 @@ void XGUI_ErrorDialog::addError(const QString& theError) { myErrors.append(theError); refresh(); - if(!isVisible()) { + if (!isVisible()) { show(); raise(); activateWindow(); diff --git a/src/XGUI/XGUI_ErrorDialog.h b/src/XGUI/XGUI_ErrorDialog.h index 59de5059a..20af808bb 100644 --- a/src/XGUI/XGUI_ErrorDialog.h +++ b/src/XGUI/XGUI_ErrorDialog.h @@ -13,20 +13,17 @@ class QTextEdit; -class XGUI_ErrorDialog: public QDialog +class XGUI_ErrorDialog : public QDialog { - Q_OBJECT -public: - XGUI_EXPORT XGUI_ErrorDialog(QWidget* parent); - XGUI_EXPORT virtual ~XGUI_ErrorDialog(); +Q_OBJECT + public: + XGUI_EXPORT XGUI_ErrorDialog(QWidget* parent);XGUI_EXPORT virtual ~XGUI_ErrorDialog(); -public slots: - XGUI_EXPORT void refresh(); - XGUI_EXPORT void clear(); - XGUI_EXPORT void addError(const QString&); - XGUI_EXPORT void removeError(const QString&); + public slots: + XGUI_EXPORT void refresh();XGUI_EXPORT void clear();XGUI_EXPORT void addError(const QString&);XGUI_EXPORT void removeError( + const QString&); -private: + private: QTextEdit* myErrorLog; QStringList myErrors; }; diff --git a/src/XGUI/XGUI_MainMenu.cpp b/src/XGUI/XGUI_MainMenu.cpp index fb5fbce21..300219487 100644 --- a/src/XGUI/XGUI_MainMenu.cpp +++ b/src/XGUI/XGUI_MainMenu.cpp @@ -16,7 +16,8 @@ #include XGUI_MainMenu::XGUI_MainMenu(XGUI_MainWindow *parent) - : QWidget(parent), myDesktop(parent) + : QWidget(parent), + myDesktop(parent) { myGeneralPage = new XGUI_MenuGroupPanel(this); myGeneralPage->setObjectName("Default"); @@ -60,7 +61,6 @@ XGUI_Workbench* XGUI_MainMenu::findWorkbench(const QString& theObjName) const return myDesktop->findChild(theObjName); } - bool XGUI_MainMenu::eventFilter(QObject *theWatched, QEvent *theEvent) { if (theWatched == myGeneralPage) { @@ -81,12 +81,9 @@ void XGUI_MainMenu::insertConsole(QWidget* theConsole) aCloseTabButton->setFixedSize(16, 16); aCloseTabButton->setIcon(QIcon(":pictures/wnd_close.png")); aCloseTabButton->setFlat(true); - aTabBar->setTabButton(aConsoleTabId, - QTabBar::RightSide, - aCloseTabButton); + aTabBar->setTabButton(aConsoleTabId, QTabBar::RightSide, aCloseTabButton); - connect(aCloseTabButton, SIGNAL(clicked()), - myDesktop, SLOT(dockPythonConsole())); + connect(aCloseTabButton, SIGNAL(clicked()), myDesktop, SLOT(dockPythonConsole())); } void XGUI_MainMenu::removeConsole() @@ -101,9 +98,11 @@ XGUI_Command* XGUI_MainMenu::feature(const QString& theId) const result = myGeneralPage->feature(theId); if (!result) { XGUI_Workbench* aWbn; - foreach (aWbn, myWorkbenches) { + foreach (aWbn, myWorkbenches) + { result = aWbn->feature(theId); - if (result) break; + if (result) + break; } } return result; @@ -113,7 +112,8 @@ QList XGUI_MainMenu::features() const { QList aList = myGeneralPage->features(); XGUI_Workbench* aWbn; - foreach (aWbn, myWorkbenches) { + foreach (aWbn, myWorkbenches) + { aList.append(aWbn->features()); } return aList; @@ -136,8 +136,8 @@ int XGUI_MainMenu::menuHeight() const int XGUI_MainMenu::menuItemRowsCount() const { const int kDefaultRowsCount = 3; - int aRowsCount = XGUI_Preferences::resourceMgr()->integerValue( - XGUI_Preferences::MENU_SECTION, "rows_number", kDefaultRowsCount); + int aRowsCount = XGUI_Preferences::resourceMgr()->integerValue(XGUI_Preferences::MENU_SECTION, + "rows_number", kDefaultRowsCount); return aRowsCount; } diff --git a/src/XGUI/XGUI_MainMenu.h b/src/XGUI/XGUI_MainMenu.h index 4c3f0ec67..50c19c8a9 100644 --- a/src/XGUI/XGUI_MainMenu.h +++ b/src/XGUI/XGUI_MainMenu.h @@ -22,11 +22,11 @@ class QEvent; * \ingroup GUI * \brief Class for creation of main menu (set of workbenches) */ -class XGUI_EXPORT XGUI_MainMenu: public QWidget +class XGUI_EXPORT XGUI_MainMenu : public QWidget { - Q_OBJECT +Q_OBJECT -public: + public: XGUI_MainMenu(XGUI_MainWindow *parent); virtual ~XGUI_MainMenu(); @@ -34,10 +34,13 @@ public: XGUI_Workbench* addWorkbench(const QString& theId, const QString& theText = ""); //! Returns workbench (menu group) by the given name. - XGUI_Workbench* findWorkbench(const QString& theId) const; + XGUI_Workbench* findWorkbench(const QString& theId) const; //! Returns General page (predefined workbench) - XGUI_MenuGroupPanel* generalPage() const { return myGeneralPage; } + XGUI_MenuGroupPanel* generalPage() const + { + return myGeneralPage; + } //! Rerturns last created workbench in dock widget container //QDockWidget* getLastDockWindow() const; @@ -66,7 +69,7 @@ public: void updateFromResources(); -private: + private: XGUI_MainWindow* myDesktop; QTabWidget* myMenuTabs; XGUI_MenuGroupPanel* myGeneralPage; diff --git a/src/XGUI/XGUI_MainWindow.cpp b/src/XGUI/XGUI_MainWindow.cpp index 189f1cd35..b1171dc64 100644 --- a/src/XGUI/XGUI_MainWindow.cpp +++ b/src/XGUI/XGUI_MainWindow.cpp @@ -17,26 +17,26 @@ #include XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) - : QMainWindow(parent), - myPythonConsole(0) + : QMainWindow(parent), + myPythonConsole(0) { setWindowTitle(tr("New Geom")); createMainMenu(); QMdiArea* aMdiArea = new QMdiArea(this); aMdiArea->setContextMenuPolicy(Qt::ActionsContextMenu); setCentralWidget(aMdiArea); - connect(aMdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), - this, SLOT(onViewActivated(QMdiSubWindow*))); + connect(aMdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, + SLOT(onViewActivated(QMdiSubWindow*))); // Create actions of MDI area QAction* aAction = new QAction(QIcon(":pictures/new_view.png"), tr("Create Window"), aMdiArea); aMdiArea->addAction(aAction); connect(aAction, SIGNAL(triggered(bool)), this, SLOT(createSubWindow())); - + aAction = new QAction(QIcon(":pictures/tile_views.png"), tr("Tile"), aMdiArea); aMdiArea->addAction(aAction); connect(aAction, SIGNAL(triggered(bool)), aMdiArea, SLOT(tileSubWindows())); - + aAction = new QAction(QIcon(":pictures/cascade_views.png"), tr("Cascade"), aMdiArea); aMdiArea->addAction(aAction); connect(aAction, SIGNAL(triggered(bool)), this, SLOT(cascadeWindows())); @@ -46,10 +46,10 @@ XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) aMdiArea->addAction(aAction); myViewer = new XGUI_Viewer(this); - connect(myViewer, SIGNAL(viewCreated(XGUI_ViewWindow*)), - this, SLOT(onViewCreated(XGUI_ViewWindow*))); - connect(myViewer, SIGNAL(deleteView(XGUI_ViewWindow*)), - this, SLOT(onDeleteView(XGUI_ViewWindow*))); + connect(myViewer, SIGNAL(viewCreated(XGUI_ViewWindow*)), this, + SLOT(onViewCreated(XGUI_ViewWindow*))); + connect(myViewer, SIGNAL(deleteView(XGUI_ViewWindow*)), this, + SLOT(onDeleteView(XGUI_ViewWindow*))); } XGUI_MainWindow::~XGUI_MainWindow(void) @@ -88,19 +88,16 @@ void XGUI_MainWindow::dockPythonConsole() return; myMenuBar->removeConsole(); QDockWidget* aDock = new QDockWidget(this); - aDock->setFeatures(QDockWidget::AllDockWidgetFeatures | - QDockWidget::DockWidgetVerticalTitleBar); - aDock->setAllowedAreas(Qt::LeftDockWidgetArea | - Qt::RightDockWidgetArea | - Qt::BottomDockWidgetArea); + aDock->setFeatures(QDockWidget::AllDockWidgetFeatures | QDockWidget::DockWidgetVerticalTitleBar); + aDock->setAllowedAreas( + Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); aDock->setMinimumHeight(0); aDock->setWindowTitle("Console"); aDock->setWidget(myPythonConsole); addDockWidget(Qt::BottomDockWidgetArea, aDock); // Undock python console if widget is closed... - CloseEventWatcher* aWatcher = new CloseEventWatcher(aDock); - connect(aWatcher, SIGNAL(widgetClosed()), - this, SLOT(undockPythonConsole())); + CloseEventWatcher* aWatcher = new CloseEventWatcher(aDock); + connect(aWatcher, SIGNAL(widgetClosed()), this, SLOT(undockPythonConsole())); aDock->installEventFilter(aWatcher); } @@ -111,7 +108,7 @@ void XGUI_MainWindow::undockPythonConsole() QDockWidget* aDock = qobject_cast(myPythonConsole->parentWidget()); //When the application starts console will be displayed as //a wokbench tab, so there is no dock yet - if(aDock) { + if (aDock) { aDock->hide(); aDock->setWidget(NULL); aDock->deleteLater(); @@ -130,7 +127,7 @@ void XGUI_MainWindow::cascadeWindows() { QMdiArea* aMdiArea = static_cast(centralWidget()); QList aWindows = aMdiArea->subWindowList(); - + QSize aSize = aMdiArea->size(); QRect aRect = aMdiArea->geometry(); const int aOffset = 30; @@ -139,7 +136,8 @@ void XGUI_MainWindow::cascadeWindows() int w = aSize.width() / 2; int h = aSize.height() / 2; QMdiSubWindow* aLastWnd; - foreach(QMdiSubWindow* aWnd, aWindows) { + foreach(QMdiSubWindow* aWnd, aWindows) + { aWnd->showNormal(); aWnd->raise(); x = aOffset * i; @@ -152,8 +150,7 @@ void XGUI_MainWindow::cascadeWindows() y = 0; j = 0; } - aWnd->setGeometry(QStyle::visualRect(aWnd->layoutDirection(), aRect, - QRect(x, y, w, h))); + aWnd->setGeometry(QStyle::visualRect(aWnd->layoutDirection(), aRect, QRect(x, y, w, h))); i++; j++; viewer()->onWindowActivated(aWnd); @@ -174,7 +171,8 @@ void XGUI_MainWindow::onViewCreated(XGUI_ViewWindow* theWindow) aMDIWidget->addAction(aAction); QList aActions = aMDIWidget->actions(); - foreach(QAction* aAct, aActions) { + foreach(QAction* aAct, aActions) + { if (aAct->isCheckable()) aAct->setChecked(false); } @@ -189,7 +187,8 @@ void XGUI_MainWindow::onDeleteView(XGUI_ViewWindow* theWindow) QList aActions = aMDIWidget->actions(); QAction* aDelAct = 0; - foreach(QAction* aAct, aActions) { + foreach(QAction* aAct, aActions) + { if (aAct->text() == aTitle) { aDelAct = aAct; break; @@ -206,7 +205,8 @@ void XGUI_MainWindow::activateView() QList aWndList = aMdiArea->subWindowList(); QMdiSubWindow* aTargetView = 0; - foreach(QMdiSubWindow* aWnd, aWndList) { + foreach(QMdiSubWindow* aWnd, aWndList) + { if (aWnd->windowTitle() == aWndTitle) { aWnd->raise(); aWnd->activateWindow(); @@ -226,7 +226,8 @@ void XGUI_MainWindow::onViewActivated(QMdiSubWindow* theSubWnd) QMdiArea* aMdiArea = static_cast(centralWidget()); QString aWndTitle = theSubWnd->windowTitle(); QList aActionList = aMdiArea->actions(); - foreach(QAction* aAct, aActionList) { + foreach(QAction* aAct, aActionList) + { if (aAct->isCheckable()) aAct->setChecked(aAct->text() == aWndTitle); } @@ -251,9 +252,11 @@ void XGUI_MainWindow::createMainMenu() CloseEventWatcher::CloseEventWatcher(QObject* theParent) : QObject(theParent) -{} +{ +} -bool CloseEventWatcher::eventFilter(QObject *obj, QEvent *event) { +bool CloseEventWatcher::eventFilter(QObject *obj, QEvent *event) +{ if (event->type() == QEvent::Close) { emit widgetClosed(); event->ignore(); diff --git a/src/XGUI/XGUI_MainWindow.h b/src/XGUI/XGUI_MainWindow.h index 293163d4a..a8a067cf6 100644 --- a/src/XGUI/XGUI_MainWindow.h +++ b/src/XGUI/XGUI_MainWindow.h @@ -18,11 +18,11 @@ class QCloseEvent; * \brief Main window of the application (Desktop). * It contains: Object Browser, 3d Viewer, Python console, property panel, main menu */ -class XGUI_EXPORT XGUI_MainWindow: public QMainWindow +class XGUI_EXPORT XGUI_MainWindow : public QMainWindow { Q_OBJECT -public: + public: XGUI_MainWindow(QWidget* parent = 0); virtual ~XGUI_MainWindow(); @@ -41,7 +41,7 @@ public: return myViewer; } -public slots: + public slots: void showPythonConsole(); void hidePythonConsole(); //! Python console can be a dock widget @@ -50,8 +50,8 @@ public slots: void undockPythonConsole(); void createSubWindow(); - -private slots: + + private slots: void cascadeWindows(); void onViewCreated(XGUI_ViewWindow* theWindow); void onDeleteView(XGUI_ViewWindow* theWindow); @@ -61,24 +61,25 @@ private slots: signals: void exitKeySequence(); -protected: + protected: void closeEvent(QCloseEvent* event); void createMainMenu(); -private: + private: XGUI_MainMenu* myMenuBar; XGUI_Viewer* myViewer; PyConsole_EnhConsole* myPythonConsole; }; -class XGUI_EXPORT CloseEventWatcher: public QObject { - Q_OBJECT +class XGUI_EXPORT CloseEventWatcher : public QObject +{ +Q_OBJECT public: CloseEventWatcher(QObject* theParent); - signals: +signals: void widgetClosed(); protected: diff --git a/src/XGUI/XGUI_MenuGroupPanel.cpp b/src/XGUI/XGUI_MenuGroupPanel.cpp index f268c3691..30c459466 100644 --- a/src/XGUI/XGUI_MenuGroupPanel.cpp +++ b/src/XGUI/XGUI_MenuGroupPanel.cpp @@ -10,7 +10,10 @@ #include XGUI_MenuGroupPanel::XGUI_MenuGroupPanel(QWidget *parent) - : QFrame(parent), myNewRow(0), myNewCol(0), myMaxRow(1) + : QFrame(parent), + myNewRow(0), + myNewCol(0), + myMaxRow(1) { myLayout = new QGridLayout(this); myLayout->setSpacing(0); @@ -19,8 +22,6 @@ XGUI_MenuGroupPanel::XGUI_MenuGroupPanel(QWidget *parent) setFrameShape(QFrame::NoFrame); } - - void XGUI_MenuGroupPanel::addCommand(XGUI_Command* theAction) { myActions.append(theAction); @@ -59,10 +60,11 @@ void XGUI_MenuGroupPanel::resizeEvent(QResizeEvent* theEvent) myMaxRow = aMaxRow; myNewRow = 0; myNewCol = 0; - foreach(QWidget* eachWidget, myActionWidget) { + foreach(QWidget* eachWidget, myActionWidget) + { placeWidget(eachWidget); } - myLayout->setRowStretch(myMaxRow + 1, 1); + myLayout->setRowStretch(myMaxRow + 1, 1); } XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId, const QString& theTitle, @@ -78,10 +80,10 @@ XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId, const QStrin return aCommand; } - XGUI_Command* XGUI_MenuGroupPanel::feature(const QString& theId) const { - foreach (XGUI_Command* aCmd, myActions) { + foreach (XGUI_Command* aCmd, myActions) + { if (aCmd->data().toString() == theId) return aCmd; } diff --git a/src/XGUI/XGUI_MenuGroupPanel.h b/src/XGUI/XGUI_MenuGroupPanel.h index 07f51ed1e..7cf1f1d41 100644 --- a/src/XGUI/XGUI_MenuGroupPanel.h +++ b/src/XGUI/XGUI_MenuGroupPanel.h @@ -8,14 +8,13 @@ class XGUI_Command; class QGridLayout; - /**\class XGUI_MenuGroupPanel * \ingroup GUI * \brief Represents a one group in a page of main menu (workbench) */ -class XGUI_EXPORT XGUI_MenuGroupPanel: public QFrame +class XGUI_EXPORT XGUI_MenuGroupPanel : public QFrame { - Q_OBJECT +Q_OBJECT public: explicit XGUI_MenuGroupPanel(QWidget *parent = 0); @@ -29,18 +28,21 @@ class XGUI_EXPORT XGUI_MenuGroupPanel: public QFrame XGUI_Command* feature(const QString& theId) const; //! Returns list of created commands - QList features() const { return myActions; } + QList features() const + { + return myActions; + } -protected: + protected: virtual void resizeEvent(QResizeEvent *theEvent); -private: + private: void addWidget(QWidget* theWgt); void placeWidget(QWidget* theWgt); void addCommand(XGUI_Command* theAction); QList myActions; - QWidgetList myActionWidget; + QWidgetList myActionWidget; QGridLayout* myLayout; int myNewRow; diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index e0a736170..7e9694ebb 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -2,17 +2,15 @@ // Created: 3 June 2014 // Author: Vitaly Smetannikov - #include "XGUI_ModuleConnector.h" #include "XGUI_Workshop.h" #include "XGUI_ViewerProxy.h" #include "XGUI_SelectionMgr.h" #include "XGUI_Selection.h" - - -XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop) -: ModuleBase_IWorkshop(theWorkshop), myWorkshop(theWorkshop) +XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop) + : ModuleBase_IWorkshop(theWorkshop), + myWorkshop(theWorkshop) { XGUI_SelectionMgr* aSelector = myWorkshop->selector(); connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); @@ -27,7 +25,6 @@ Handle(AIS_InteractiveContext) XGUI_ModuleConnector::AISContext() const return myWorkshop->viewer()->AISContext(); } - QList XGUI_ModuleConnector::selectedObjects() const { return myWorkshop->selector()->selection()->selectedObjects(); @@ -36,4 +33,4 @@ QList XGUI_ModuleConnector::selectedObjects() const ModuleBase_IModule* XGUI_ModuleConnector::module() const { return myWorkshop->module(); -} \ No newline at end of file +} diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h index c7119b79e..3423a55f0 100644 --- a/src/XGUI/XGUI_ModuleConnector.h +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -5,7 +5,6 @@ #ifndef XGUI_ModuleConnector_H #define XGUI_ModuleConnector_H - #include "XGUI.h" #include #include @@ -15,12 +14,12 @@ class XGUI_Workshop; class XGUI_Displayer; /** -* Implementation of IWorkshop interface which provides access to Workshop sevices at module level -*/ -class XGUI_EXPORT XGUI_ModuleConnector: public ModuleBase_IWorkshop + * Implementation of IWorkshop interface which provides access to Workshop sevices at module level + */ +class XGUI_EXPORT XGUI_ModuleConnector : public ModuleBase_IWorkshop { - Q_OBJECT -public: +Q_OBJECT + public: XGUI_ModuleConnector(XGUI_Workshop* theWorkshop); virtual ~XGUI_ModuleConnector(); @@ -29,13 +28,13 @@ public: virtual Handle(AIS_InteractiveContext) AISContext() const; //! Returns list of currently selected data objects - virtual QList selectedObjects() const; + virtual QList selectedObjects() const; //! Returns instance of loaded module virtual ModuleBase_IModule* module() const; -private: + private: XGUI_Workshop* myWorkshop; }; -#endif \ No newline at end of file +#endif diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 45d287465..12d0dd6a7 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -15,10 +15,8 @@ #include #include - - XGUI_DataTree::XGUI_DataTree(QWidget* theParent) - : QTreeView(theParent) + : QTreeView(theParent) { setHeaderHidden(true); setModel(new XGUI_DocumentDataModel(this)); @@ -26,7 +24,7 @@ XGUI_DataTree::XGUI_DataTree(QWidget* theParent) setSelectionBehavior(QAbstractItemView::SelectRows); setSelectionMode(QAbstractItemView::ExtendedSelection); - connect(selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), + connect(selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&))); } @@ -34,14 +32,13 @@ XGUI_DataTree::~XGUI_DataTree() { } -XGUI_DocumentDataModel* XGUI_DataTree::dataModel() const -{ - return static_cast(model()); +XGUI_DocumentDataModel* XGUI_DataTree::dataModel() const +{ + return static_cast(model()); } - -void XGUI_DataTree::onSelectionChanged(const QItemSelection& theSelected, - const QItemSelection& theDeselected) +void XGUI_DataTree::onSelectionChanged(const QItemSelection& theSelected, + const QItemSelection& theDeselected) { mySelectedData.clear(); QModelIndexList aIndexes = selectionModel()->selectedIndexes(); @@ -71,7 +68,7 @@ void XGUI_DataTree::mouseDoubleClickEvent(QMouseEvent* theEvent) setExpanded(aIndex, true); emit activePartChanged(aModel->activePart()); } - } else + } else QTreeView::mouseDoubleClickEvent(theEvent); } @@ -97,7 +94,7 @@ void XGUI_DataTree::commitData(QWidget* theEditor) //******************************************************************** //******************************************************************** XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) - : QWidget(theParent) + : QWidget(theParent) { QVBoxLayout* aLayout = new QVBoxLayout(this); aLayout->setContentsMargins(0, 0, 0, 0); @@ -135,7 +132,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) myActiveDocLbl->installEventFilter(this); aLabelLay->addWidget(myActiveDocLbl); - aLabelLay->setStretch(1,1); + aLabelLay->setStretch(1, 1); myTreeView = new XGUI_DataTree(this); aLayout->addWidget(myTreeView); @@ -146,14 +143,16 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) aLabelWgt->setFrameShadow(myTreeView->frameShadow()); connect(myTreeView, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); - connect(myTreeView, SIGNAL(activePartChanged(ObjectPtr)), this, SLOT(onActivePartChanged(ObjectPtr))); - connect(myTreeView, SIGNAL(activePartChanged(ObjectPtr)), this, SIGNAL(activePartChanged(ObjectPtr))); - - connect(myActiveDocLbl, SIGNAL(customContextMenuRequested(const QPoint&)), - this, SLOT(onLabelContextMenuRequested(const QPoint&))); - connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), - this, SLOT(onContextMenuRequested(QContextMenuEvent*))); - + connect(myTreeView, SIGNAL(activePartChanged(ObjectPtr)), this, + SLOT(onActivePartChanged(ObjectPtr))); + connect(myTreeView, SIGNAL(activePartChanged(ObjectPtr)), this, + SIGNAL(activePartChanged(ObjectPtr))); + + connect(myActiveDocLbl, SIGNAL(customContextMenuRequested(const QPoint&)), this, + SLOT(onLabelContextMenuRequested(const QPoint&))); + connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, + SLOT(onContextMenuRequested(QContextMenuEvent*))); + onActivePartChanged(ObjectPtr()); // Create internal actions @@ -174,7 +173,7 @@ void XGUI_ObjectsBrowser::onActivePartChanged(ObjectPtr thePart) QPalette aPalet = myActiveDocLbl->palette(); if (thePart) { aPalet.setColor(QPalette::Text, Qt::black); - } else { + } else { aPalet.setColor(QPalette::Text, QColor(0, 72, 140)); } myActiveDocLbl->setPalette(aPalet); @@ -204,13 +203,13 @@ bool XGUI_ObjectsBrowser::eventFilter(QObject* obj, QEvent* theEvent) } else if (theEvent->type() == QEvent::KeyRelease) { QKeyEvent* aEvent = (QKeyEvent*) theEvent; switch (aEvent->key()) { - case Qt::Key_Return: // Accept current input - closeDocNameEditing(true); - break; - case Qt::Key_Escape: // Cancel the input - closeDocNameEditing(false); - break; - } + case Qt::Key_Return: // Accept current input + closeDocNameEditing(true); + break; + case Qt::Key_Escape: // Cancel the input + closeDocNameEditing(false); + break; + } } } } @@ -263,11 +262,12 @@ void XGUI_ObjectsBrowser::activatePart(const ResultPartPtr& thePart) } //*************************************************** -void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent) +void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent) { myObjectsList = myTreeView->selectedObjects(); bool toEnable = myObjectsList.size() > 0; - foreach(QAction* aCmd, actions()) { + foreach(QAction* aCmd, actions()) + { aCmd->setEnabled(toEnable); } emit contextMenuRequested(theEvent); @@ -278,12 +278,13 @@ void XGUI_ObjectsBrowser::onLabelContextMenuRequested(const QPoint& thePnt) { myObjectsList.clear(); //Empty feature pointer means that selected root document - myObjectsList.append(ObjectPtr()); + myObjectsList.append(ObjectPtr()); - foreach(QAction* aCmd, actions()) { + foreach(QAction* aCmd, actions()) + { aCmd->setEnabled(true); } - QContextMenuEvent aEvent( QContextMenuEvent::Mouse, thePnt, myActiveDocLbl->mapToGlobal(thePnt) ); + QContextMenuEvent aEvent(QContextMenuEvent::Mouse, thePnt, myActiveDocLbl->mapToGlobal(thePnt)); emit contextMenuRequested(&aEvent); } @@ -292,10 +293,11 @@ void XGUI_ObjectsBrowser::onEditItem() { if (myObjectsList.size() > 0) { ObjectPtr aFeature = myObjectsList.first(); - if (aFeature) { // Selection happens in TreeView + if (aFeature) { // Selection happens in TreeView // Find index which corresponds the feature QModelIndex aIndex; - foreach(QModelIndex aIdx, selectedIndexes()) { + foreach(QModelIndex aIdx, selectedIndexes()) + { ObjectPtr aFea = dataModel()->object(aIdx); if (dataModel()->object(aIdx)->isSame(aFeature)) { aIndex = aIdx; @@ -306,7 +308,7 @@ void XGUI_ObjectsBrowser::onEditItem() myTreeView->setCurrentIndex(aIndex); myTreeView->edit(aIndex); } - } else { //Selection happens in Upper label + } else { //Selection happens in Upper label myActiveDocLbl->setReadOnly(false); myActiveDocLbl->setFocus(); myActiveDocLbl->selectAll(); @@ -337,7 +339,8 @@ void XGUI_ObjectsBrowser::setObjectsSelected(const QList& theObjects) QItemSelectionModel* aSelectModel = myTreeView->selectionModel(); aSelectModel->clear(); - foreach(ObjectPtr aFeature, theObjects) { + foreach(ObjectPtr aFeature, theObjects) + { QModelIndex aIndex = myDocModel->objectIndex(aFeature); if (aIndex.isValid()) { aSelectModel->select(aIndex, QItemSelectionModel::Select); diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index 05a539566..c5149fdd9 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -1,4 +1,3 @@ - #ifndef XGUI_ObjectsBrowser_H #define XGUI_ObjectsBrowser_H @@ -13,68 +12,81 @@ class XGUI_DocumentDataModel; class QLineEdit; - -class XGUI_DataTree: public QTreeView +class XGUI_DataTree : public QTreeView { - Q_OBJECT -public: +Q_OBJECT + public: XGUI_DataTree(QWidget* theParent); virtual ~XGUI_DataTree(); //! Returns list of currently selected objects - QList selectedObjects() const { return mySelectedData; } + QList selectedObjects() const + { + return mySelectedData; + } XGUI_DocumentDataModel* dataModel() const; signals: //! Emited when selection is changed void selectionChanged(); - void activePartChanged(ObjectPtr thePart); - + void activePartChanged(ObjectPtr thePart); + //! Emited on context menu request void contextMenuRequested(QContextMenuEvent* theEvent); -protected slots: + protected slots: virtual void commitData(QWidget* theEditor); -protected: + protected: virtual void mouseDoubleClickEvent(QMouseEvent* theEvent); virtual void contextMenuEvent(QContextMenuEvent* theEvent); -private slots: + private slots: //! Called when selection in Data Tree is changed void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected); -private: + private: //! List of currently selected data QList mySelectedData; }; - /**\class XGUI_ObjectsBrowser * \ingroup GUI * \brief Object browser window object. Represents data tree of current data structure */ - class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget +class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget { - Q_OBJECT -public: +Q_OBJECT + public: XGUI_ObjectsBrowser(QWidget* theParent); virtual ~XGUI_ObjectsBrowser(); //! Returns Model which provides access to data objects - XGUI_DocumentDataModel* dataModel() const { return myDocModel; } + XGUI_DocumentDataModel* dataModel() const + { + return myDocModel; + } //! Returns list of currently selected objects - QList selectedObjects() const { return myObjectsList; } + QList selectedObjects() const + { + return myObjectsList; + } void setObjectsSelected(const QList& theObjects); //! Returns currently selected indexes - QModelIndexList selectedIndexes() const { return myTreeView->selectionModel()->selectedIndexes(); } + QModelIndexList selectedIndexes() const + { + return myTreeView->selectionModel()->selectedIndexes(); + } //! Returns TreeView widget - XGUI_DataTree* treeView() const { return myTreeView; } + XGUI_DataTree* treeView() const + { + return myTreeView; + } //! Activates currently selected part. Signal activePartChanged will not be sent void activatePart(const ResultPartPtr& thePart); @@ -86,15 +98,15 @@ signals: void selectionChanged(); //! Emited when current active document is changed - void activePartChanged(ObjectPtr thePart); - + void activePartChanged(ObjectPtr thePart); + //! Emited on context menu request void contextMenuRequested(QContextMenuEvent* theEvent); -protected: + protected: virtual bool eventFilter(QObject* obj, QEvent* theEvent); -private slots: + private slots: void onActivePartChanged(ObjectPtr thePart); void onContextMenuRequested(QContextMenuEvent* theEvent); void onLabelContextMenuRequested(const QPoint& thePnt); @@ -104,7 +116,7 @@ private slots: void onSelectionChanged(); -private: + private: void closeDocNameEditing(bool toSave); //! Internal model @@ -116,4 +128,4 @@ private: QList myObjectsList; }; -#endif \ No newline at end of file +#endif diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 236747a7d..4a93b9d47 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -13,7 +13,7 @@ #include XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent) -: QObject(theParent) + : QObject(theParent) { // listen to Escape signal to stop the current operation qApp->installEventFilter(this); @@ -48,8 +48,8 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation) connect(theOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped())); connect(theOperation, SIGNAL(started()), this, SIGNAL(operationStarted())); connect(theOperation, SIGNAL(resumed()), this, SIGNAL(operationResumed())); - connect(theOperation, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), - this, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*))); + connect(theOperation, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), this, + SIGNAL(activateNextWidget(ModuleBase_ModelWidget*))); theOperation->start(); validateCurrentOperation(); @@ -60,7 +60,7 @@ bool XGUI_OperationMgr::abortOperation() { ModuleBase_Operation* aCurrentOp = currentOperation(); if (!aCurrentOp || !canStopOperation()) - return false; + return false; aCurrentOp->abort(); return true; @@ -69,7 +69,8 @@ bool XGUI_OperationMgr::abortOperation() QStringList XGUI_OperationMgr::operationList() { QStringList result; - foreach(ModuleBase_Operation* eachOperation, myOperations) { + foreach(ModuleBase_Operation* eachOperation, myOperations) + { result << eachOperation->id(); } return result; @@ -88,10 +89,11 @@ void XGUI_OperationMgr::validateOperation(ModuleBase_Operation* theOperation) // std::list::iterator it = aValidators.begin(); bool isValid = true; - for(; it != aValidators.end(); it++) { + for (; it != aValidators.end(); it++) { const ModelAPI_FeatureValidator* aFeatureValidator = dynamic_cast(*it); - if (!aFeatureValidator) continue; + if (!aFeatureValidator) + continue; if (!aFeatureValidator->isValid(aFeature)) { isValid = false; break; @@ -102,7 +104,7 @@ void XGUI_OperationMgr::validateOperation(ModuleBase_Operation* theOperation) void XGUI_OperationMgr::validateCurrentOperation() { - if(!hasOperation()) + if (!hasOperation()) return; ModuleBase_Operation* anOperation = currentOperation(); validateOperation(currentOperation()); @@ -111,7 +113,7 @@ void XGUI_OperationMgr::validateCurrentOperation() bool XGUI_OperationMgr::eventFilter(QObject *theObject, QEvent *theEvent) { if (theEvent->type() == QEvent::KeyRelease) { - QKeyEvent* aKeyEvent = (QKeyEvent*)theEvent; + QKeyEvent* aKeyEvent = (QKeyEvent*) theEvent; if (aKeyEvent && aKeyEvent->key() == Qt::Key_Escape) { // TODO: this is Escape button processing when the property panel has empty content, // but the operation should be stopped by the Enter has been clicked @@ -131,8 +133,7 @@ bool XGUI_OperationMgr::canStartOperation(ModuleBase_Operation* theOperation) { bool aCanStart = true; ModuleBase_Operation* aCurrentOp = currentOperation(); - if (aCurrentOp && !theOperation->isGranted(aCurrentOp)) - { + if (aCurrentOp && !theOperation->isGranted(aCurrentOp)) { if (canStopOperation()) { aCurrentOp->abort(); } else { @@ -147,9 +148,10 @@ bool XGUI_OperationMgr::canStopOperation() ModuleBase_Operation* anOperation = currentOperation(); if (anOperation) { if (anOperation->isModified()) { - int anAnswer = QMessageBox::question(qApp->activeWindow(), tr("Operation launch"), - tr("Previous operation is not finished and will be aborted"), - QMessageBox::Ok, QMessageBox::Cancel); + int anAnswer = QMessageBox::question( + qApp->activeWindow(), tr("Operation launch"), + tr("Previous operation is not finished and will be aborted"), QMessageBox::Ok, + QMessageBox::Cancel); return anAnswer == QMessageBox::Ok; } } @@ -174,10 +176,11 @@ bool XGUI_OperationMgr::canAbortOperation() { ModuleBase_Operation* anOperation = currentOperation(); if (anOperation && anOperation->isModified()) { - int anAnswer = QMessageBox::question(qApp->activeWindow(), tr("Cancel operation"), - tr("Operation %1 will be cancelled. Continue?").arg(anOperation->id()), - QMessageBox::Yes, QMessageBox::No); - return anAnswer == QMessageBox::Yes; + int anAnswer = QMessageBox::question( + qApp->activeWindow(), tr("Cancel operation"), + tr("Operation %1 will be cancelled. Continue?").arg(anOperation->id()), QMessageBox::Yes, + QMessageBox::No); + return anAnswer == QMessageBox::Yes; } return true; } @@ -186,7 +189,7 @@ void XGUI_OperationMgr::onOperationStopped() { ModuleBase_Operation* aSenderOperation = dynamic_cast(sender()); ModuleBase_Operation* anOperation = currentOperation(); - if (!aSenderOperation || !anOperation || aSenderOperation != anOperation ) + if (!aSenderOperation || !anOperation || aSenderOperation != anOperation) return; myOperations.removeAll(anOperation); @@ -198,8 +201,7 @@ void XGUI_OperationMgr::onOperationStopped() ModuleBase_Operation* aResultOp = 0; QListIterator anIt(myOperations); anIt.toBack(); - while(anIt.hasPrevious()) - { + while (anIt.hasPrevious()) { ModuleBase_Operation* anOp = anIt.previous(); if (anOp) { aResultOp = anOp; diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 11a670088..6e55108e3 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -26,8 +26,8 @@ class QKeyEvent; */ class XGUI_EXPORT XGUI_OperationMgr : public QObject { - Q_OBJECT -public: +Q_OBJECT + public: /// Constructor /// \param theParent the parent XGUI_OperationMgr(QObject* theParent); @@ -54,7 +54,7 @@ public: virtual bool eventFilter(QObject *theObject, QEvent *theEvent); -public slots: + public slots: void validateCurrentOperation(); signals: @@ -71,7 +71,7 @@ signals: /// \param theWidget the model widget void activateNextWidget(ModuleBase_ModelWidget* theWidget); -protected: + protected: /// Sets the current operation or NULL /// \param theOperation the started operation /// \param isCheckBeforeStart the flag whether to check whether the operation can be started @@ -91,7 +91,7 @@ protected: void validateOperation(ModuleBase_Operation* theOperation); -protected slots: + protected slots: /// Slot that commits the current operation. void onCommitOperation(); /// Slot that aborts the current operation. @@ -110,10 +110,10 @@ protected slots: /// \param theWidget an activated widget void onWidgetActivated(ModuleBase_ModelWidget* theWidget); -private: - typedef QList 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 + private: + typedef QList 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 diff --git a/src/XGUI/XGUI_PartDataModel.cpp b/src/XGUI/XGUI_PartDataModel.cpp index d67c2ec4f..16adcadf7 100644 --- a/src/XGUI/XGUI_PartDataModel.cpp +++ b/src/XGUI/XGUI_PartDataModel.cpp @@ -16,7 +16,6 @@ #include #include - //ObjectPtr featureObj(const ObjectPtr& theFeature) //{ // ObjectPtr aObject = boost::dynamic_pointer_cast(theFeature); @@ -25,75 +24,71 @@ // return theFeature; //} - XGUI_TopDataModel::XGUI_TopDataModel(QObject* theParent) - : XGUI_FeaturesModel(theParent) + : XGUI_FeaturesModel(theParent) { } - + XGUI_TopDataModel::~XGUI_TopDataModel() { } - QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const { switch (theRole) { - case Qt::DisplayRole: - // return a name - switch (theIndex.internalId()) { - case ParamsFolder: - return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex)); - case ParamObject: - { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); - ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row()); - if (aObject) - return aObject->data()->name().c_str(); - } - break; - case ConstructFolder: - return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex)); - case ConstructObject: - { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); - ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row()); - if (aObject) - return aObject->data()->name().c_str(); + case Qt::DisplayRole: + // return a name + switch (theIndex.internalId()) { + case ParamsFolder: + return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex)); + case ParamObject: { + DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row()); + if (aObject) + return aObject->data()->name().c_str(); + } + break; + case ConstructFolder: + return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex)); + case ConstructObject: { + DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(), + theIndex.row()); + if (aObject) + return aObject->data()->name().c_str(); + } + break; + case BodiesFolder: + return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex)); + case BodiesObject: { + DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultBody::group(), theIndex.row()); + if (aObject) + return aObject->data()->name().c_str(); + } } break; - case BodiesFolder: - return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex)); - case BodiesObject: - { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); - ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultBody::group(), theIndex.row()); - if (aObject) - return aObject->data()->name().c_str(); + + case Qt::DecorationRole: + // return an Icon + switch (theIndex.internalId()) { + case ParamsFolder: + return QIcon(":pictures/params_folder.png"); + case BodiesFolder: + case ConstructFolder: + return QIcon(":pictures/constr_folder.png"); + case ConstructObject: + case BodiesObject: + return QIcon(":pictures/constr_object.png"); } - } - break; + break; - case Qt::DecorationRole: - // return an Icon - switch (theIndex.internalId()) { - case ParamsFolder: - return QIcon(":pictures/params_folder.png"); - case BodiesFolder: - case ConstructFolder: - return QIcon(":pictures/constr_folder.png"); - case ConstructObject: - case BodiesObject: - return QIcon(":pictures/constr_object.png"); - } - break; - - case Qt::ToolTipRole: - // return Tooltip - break; - case Qt::ForegroundRole: - return QBrush(myItemsColor); - break; + case Qt::ToolTipRole: + // return Tooltip + break; + case Qt::ForegroundRole: + return QBrush(myItemsColor); + break; } return QVariant(); } @@ -105,7 +100,7 @@ QVariant XGUI_TopDataModel::headerData(int section, Qt::Orientation orientation, int XGUI_TopDataModel::rowCount(const QModelIndex& theParent) const { - if (!theParent.isValid()) + if (!theParent.isValid()) return 3; DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); @@ -129,12 +124,12 @@ QModelIndex XGUI_TopDataModel::index(int theRow, int theColumn, const QModelInde { if (!theParent.isValid()) { switch (theRow) { - case 0: - return createIndex(theRow, theColumn, (qint32) ParamsFolder); - case 1: - return createIndex(theRow, theColumn, (qint32) ConstructFolder); - case 2: - return createIndex(theRow, theColumn, (qint32) BodiesFolder); + case 0: + return createIndex(theRow, theColumn, (qint32) ParamsFolder); + case 1: + return createIndex(theRow, theColumn, (qint32) ConstructFolder); + case 2: + return createIndex(theRow, theColumn, (qint32) BodiesFolder); } } else { if (theParent.internalId() == ParamsFolder) @@ -151,18 +146,18 @@ QModelIndex XGUI_TopDataModel::index(int theRow, int theColumn, const QModelInde QModelIndex XGUI_TopDataModel::parent(const QModelIndex& theIndex) const { - int aId = (int)theIndex.internalId(); + int aId = (int) theIndex.internalId(); switch (aId) { - case ParamsFolder: - case ConstructFolder: - case BodiesFolder: - return QModelIndex(); - case ParamObject: - return createIndex(0, 0, (qint32) ParamsFolder); - case ConstructObject: - return createIndex(1, 0, (qint32) ConstructFolder); - case BodiesObject: - return createIndex(2, 0, (qint32) BodiesFolder); + case ParamsFolder: + case ConstructFolder: + case BodiesFolder: + return QModelIndex(); + case ParamObject: + return createIndex(0, 0, (qint32) ParamsFolder); + case ConstructObject: + return createIndex(1, 0, (qint32) ConstructFolder); + case BodiesObject: + return createIndex(2, 0, (qint32) BodiesFolder); } return QModelIndex(); } @@ -175,22 +170,19 @@ bool XGUI_TopDataModel::hasChildren(const QModelIndex& theParent) const ObjectPtr XGUI_TopDataModel::object(const QModelIndex& theIndex) const { switch (theIndex.internalId()) { - case ParamsFolder: - case ConstructFolder: - case BodiesFolder: - return ObjectPtr(); - case ParamObject: - { + case ParamsFolder: + case ConstructFolder: + case BodiesFolder: + return ObjectPtr(); + case ParamObject: { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); return aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row()); } - case ConstructObject: - { + case ConstructObject: { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); return aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row()); } - case BodiesObject: - { + case BodiesObject: { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); return aRootDoc->object(ModelAPI_ResultBody::group(), theIndex.row()); } @@ -198,7 +190,6 @@ ObjectPtr XGUI_TopDataModel::object(const QModelIndex& theIndex) const return ObjectPtr(); } - QModelIndex XGUI_TopDataModel::findParent(const ObjectPtr& theObject) const { return findGroup(theObject->groupName().c_str()); @@ -241,17 +232,14 @@ QModelIndex XGUI_TopDataModel::objectIndex(const ObjectPtr& theObject) const return aIndex; } - - //****************************************************************** //****************************************************************** //****************************************************************** XGUI_PartDataModel::XGUI_PartDataModel(QObject* theParent) - : XGUI_PartModel(theParent) + : XGUI_PartModel(theParent) { } - XGUI_PartDataModel::~XGUI_PartDataModel() { } @@ -259,76 +247,72 @@ XGUI_PartDataModel::~XGUI_PartDataModel() QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) const { switch (theRole) { - case Qt::DisplayRole: - // return a name - switch (theIndex.internalId()) { - case MyRoot: - { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); - ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId); - if (aObject) - return boost::dynamic_pointer_cast(aObject)->data()->name().c_str(); + case Qt::DisplayRole: + // return a name + switch (theIndex.internalId()) { + case MyRoot: { + DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId); + if (aObject) + return boost::dynamic_pointer_cast(aObject)->data()->name().c_str(); + } + case ParamsFolder: + return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex)); + case ConstructFolder: + return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex)); + case BodiesFolder: + return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex)); + case ParamObject: { + ObjectPtr aObject = partDocument()->object(ModelAPI_ResultParameters::group(), + theIndex.row()); + if (aObject) + return boost::dynamic_pointer_cast(aObject)->data()->name().c_str(); + } + case ConstructObject: { + ObjectPtr aObject = partDocument()->object(ModelAPI_ResultConstruction::group(), + theIndex.row()); + if (aObject) + return boost::dynamic_pointer_cast(aObject)->data()->name().c_str(); + } + case BodiesObject: { + ObjectPtr aObject = partDocument()->object(ModelAPI_ResultBody::group(), theIndex.row()); + if (aObject) + return aObject->data()->name().c_str(); + } + case HistoryObject: { + ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3); + if (aObject) + return aObject->data()->name().c_str(); + } } - case ParamsFolder: - return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex)); - case ConstructFolder: - return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex)); - case BodiesFolder: - return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex)); - case ParamObject: - { - ObjectPtr aObject = partDocument()->object(ModelAPI_ResultParameters::group(), theIndex.row()); - if (aObject) - return boost::dynamic_pointer_cast(aObject)->data()->name().c_str(); - } - case ConstructObject: - { - ObjectPtr aObject = partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row()); - if (aObject) - return boost::dynamic_pointer_cast(aObject)->data()->name().c_str(); - } - case BodiesObject: - { - ObjectPtr aObject = partDocument()->object(ModelAPI_ResultBody::group(), theIndex.row()); - if (aObject) - return aObject->data()->name().c_str(); - } - case HistoryObject: - { - ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3); - if (aObject) - return aObject->data()->name().c_str(); - } - } - break; - case Qt::DecorationRole: - // return an Icon - switch (theIndex.internalId()) { - case MyRoot: - return QIcon(":pictures/part_ico.png"); - case ParamsFolder: - return QIcon(":pictures/params_folder.png"); - case ConstructFolder: - case BodiesFolder: - return QIcon(":pictures/constr_folder.png"); - case ConstructObject: - case BodiesObject: - return QIcon(":pictures/constr_object.png"); - case HistoryObject: - { - ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3); - FeaturePtr aFeature = boost::dynamic_pointer_cast(aObject); - if (aFeature) - return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind())); + break; + case Qt::DecorationRole: + // return an Icon + switch (theIndex.internalId()) { + case MyRoot: + return QIcon(":pictures/part_ico.png"); + case ParamsFolder: + return QIcon(":pictures/params_folder.png"); + case ConstructFolder: + case BodiesFolder: + return QIcon(":pictures/constr_folder.png"); + case ConstructObject: + case BodiesObject: + return QIcon(":pictures/constr_object.png"); + case HistoryObject: { + ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3); + FeaturePtr aFeature = boost::dynamic_pointer_cast(aObject); + if (aFeature) + return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind())); + } } - } - break; - case Qt::ToolTipRole: - // return Tooltip - break; - case Qt::ForegroundRole: - return QBrush(myItemsColor); - break; + break; + case Qt::ToolTipRole: + // return Tooltip + break; + case Qt::ForegroundRole: + return QBrush(myItemsColor); + break; } return QVariant(); } @@ -344,18 +328,18 @@ int XGUI_PartDataModel::rowCount(const QModelIndex& parent) const DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); if (aRootDoc->object(ModelAPI_ResultPart::group(), myId)) return 1; - else + else return 0; } switch (parent.internalId()) { - case MyRoot: - return 3 + partDocument()->size(ModelAPI_Feature::group()); - case ParamsFolder: - return partDocument()->size(ModelAPI_ResultParameters::group()); - case ConstructFolder: - return partDocument()->size(ModelAPI_ResultConstruction::group()); - case BodiesFolder: - return partDocument()->size(ModelAPI_ResultBody::group()); + case MyRoot: + return 3 + partDocument()->size(ModelAPI_Feature::group()); + case ParamsFolder: + return partDocument()->size(ModelAPI_ResultParameters::group()); + case ConstructFolder: + return partDocument()->size(ModelAPI_ResultConstruction::group()); + case BodiesFolder: + return partDocument()->size(ModelAPI_ResultBody::group()); } return 0; } @@ -370,25 +354,25 @@ QModelIndex XGUI_PartDataModel::index(int theRow, int theColumn, const QModelInd if (!theParent.isValid()) return createIndex(theRow, 0, (qint32) MyRoot); - int aId = (int)theParent.internalId(); + int aId = (int) theParent.internalId(); switch (aId) { - case MyRoot: - switch (theRow) { - case 0: - return createIndex(0, 0, (qint32) ParamsFolder); - case 1: - return createIndex(1, 0, (qint32) ConstructFolder); - case 2: - return createIndex(2, 0, (qint32) BodiesFolder); - default: - return createIndex(theRow, theColumn, (qint32) HistoryObject); - } - case ParamsFolder: - return createIndex(theRow, 0, (qint32) ParamObject); - case ConstructFolder: - return createIndex(theRow, 0, (qint32) ConstructObject); - case BodiesFolder: - return createIndex(theRow, 0, (qint32) BodiesObject); + case MyRoot: + switch (theRow) { + case 0: + return createIndex(0, 0, (qint32) ParamsFolder); + case 1: + return createIndex(1, 0, (qint32) ConstructFolder); + case 2: + return createIndex(2, 0, (qint32) BodiesFolder); + default: + return createIndex(theRow, theColumn, (qint32) HistoryObject); + } + case ParamsFolder: + return createIndex(theRow, 0, (qint32) ParamObject); + case ConstructFolder: + return createIndex(theRow, 0, (qint32) ConstructObject); + case BodiesFolder: + return createIndex(theRow, 0, (qint32) BodiesObject); } return QModelIndex(); } @@ -396,19 +380,19 @@ QModelIndex XGUI_PartDataModel::index(int theRow, int theColumn, const QModelInd QModelIndex XGUI_PartDataModel::parent(const QModelIndex& theIndex) const { switch (theIndex.internalId()) { - case MyRoot: - return QModelIndex(); - case ParamsFolder: - case ConstructFolder: - case BodiesFolder: - case HistoryObject: - return createIndex(0, 0, (qint32) MyRoot); - case ParamObject: - return createIndex(0, 0, (qint32) ParamsFolder); - case ConstructObject: - return createIndex(1, 0, (qint32) ConstructFolder); - case BodiesObject: - return createIndex(2, 0, (qint32) BodiesFolder); + case MyRoot: + return QModelIndex(); + case ParamsFolder: + case ConstructFolder: + case BodiesFolder: + case HistoryObject: + return createIndex(0, 0, (qint32) MyRoot); + case ParamObject: + return createIndex(0, 0, (qint32) ParamsFolder); + case ConstructObject: + return createIndex(1, 0, (qint32) ConstructFolder); + case BodiesObject: + return createIndex(2, 0, (qint32) BodiesFolder); } return QModelIndex(); } @@ -418,7 +402,6 @@ bool XGUI_PartDataModel::hasChildren(const QModelIndex& theParent) const return rowCount(theParent) > 0; } - DocumentPtr XGUI_PartDataModel::partDocument() const { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); @@ -426,27 +409,26 @@ DocumentPtr XGUI_PartDataModel::partDocument() const ResultPartPtr aPart = boost::dynamic_pointer_cast(aObject); return aPart->partDoc(); } - + ObjectPtr XGUI_PartDataModel::object(const QModelIndex& theIndex) const { switch (theIndex.internalId()) { - case MyRoot: - { + case MyRoot: { DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); return aRootDoc->object(ModelAPI_ResultPart::group(), myId); } - case ParamsFolder: - case ConstructFolder: - case BodiesFolder: - return ObjectPtr(); - case ParamObject: - return partDocument()->object(ModelAPI_ResultParameters::group(), theIndex.row()); - case ConstructObject: - return partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row()); - case BodiesObject: - return partDocument()->object(ModelAPI_ResultBody::group(), theIndex.row()); - case HistoryObject: - return partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3); + case ParamsFolder: + case ConstructFolder: + case BodiesFolder: + return ObjectPtr(); + case ParamObject: + return partDocument()->object(ModelAPI_ResultParameters::group(), theIndex.row()); + case ConstructObject: + return partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row()); + case BodiesObject: + return partDocument()->object(ModelAPI_ResultBody::group(), theIndex.row()); + case HistoryObject: + return partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3); } return ObjectPtr(); } @@ -456,7 +438,6 @@ bool XGUI_PartDataModel::hasDocument(const DocumentPtr& theDoc) const return (partDocument() == theDoc); } - QModelIndex XGUI_PartDataModel::findParent(const ObjectPtr& theObject) const { return findGroup(theObject->groupName().c_str()); @@ -484,7 +465,7 @@ QModelIndex XGUI_PartDataModel::objectIndex(const ObjectPtr& theObject) const { QModelIndex aIndex; if (theObject) { - if (part() == theObject) + if (part() == theObject) return aIndex; std::string aGroup = theObject->groupName(); @@ -500,11 +481,11 @@ QModelIndex XGUI_PartDataModel::objectIndex(const ObjectPtr& theObject) const if (aRow == -1) return aIndex; if (aGroup == ModelAPI_ResultParameters::group()) - return createIndex(aRow, 0, (qint32) ParamObject); + return createIndex(aRow, 0, (qint32) ParamObject); else if (aGroup == ModelAPI_ResultConstruction::group()) - return createIndex(aRow, 0, (qint32) ConstructObject); + return createIndex(aRow, 0, (qint32) ConstructObject); else if (aGroup == ModelAPI_ResultBody::group()) - return createIndex(aRow, 0, (qint32) BodiesObject); + return createIndex(aRow, 0, (qint32) BodiesObject); else return createIndex(aRow + 3, 0, (qint32) HistoryObject); } diff --git a/src/XGUI/XGUI_PartDataModel.h b/src/XGUI/XGUI_PartDataModel.h index 87e5d7f42..2dd977c10 100644 --- a/src/XGUI/XGUI_PartDataModel.h +++ b/src/XGUI/XGUI_PartDataModel.h @@ -1,4 +1,3 @@ - #ifndef XGUI_PartDataModel_H #define XGUI_PartDataModel_H @@ -12,8 +11,8 @@ */ class XGUI_EXPORT XGUI_TopDataModel : public XGUI_FeaturesModel { - Q_OBJECT -public: +Q_OBJECT + public: XGUI_TopDataModel(QObject* theParent); virtual ~XGUI_TopDataModel(); @@ -25,8 +24,8 @@ public: virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; - virtual QModelIndex index(int theRow, int theColumn, - const QModelIndex& theParent = QModelIndex()) const; + virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent = + QModelIndex()) const; virtual QModelIndex parent(const QModelIndex& theIndex) const; @@ -46,9 +45,10 @@ public: //! Returns index corresponded to the group virtual QModelIndex findGroup(const std::string& theGroup) const; -private: + private: //! Types of QModelIndexes - enum DataIds { + enum DataIds + { ParamsFolder, ParamObject, ConstructFolder, @@ -59,7 +59,6 @@ private: }; - /**\class XGUI_PartDataModel * \ingroup GUI * \brief This is a data model for Object Browser (QTreeView). @@ -67,8 +66,8 @@ private: */ class XGUI_PartDataModel : public XGUI_PartModel { - Q_OBJECT -public: +Q_OBJECT + public: XGUI_PartDataModel(QObject* theParent); virtual ~XGUI_PartDataModel(); @@ -80,8 +79,8 @@ public: virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; - virtual QModelIndex index(int theRow, int theColumn, - const QModelIndex& theParent = QModelIndex()) const; + virtual QModelIndex index(int theRow, int theColumn, const QModelIndex& theParent = + QModelIndex()) const; virtual QModelIndex parent(const QModelIndex& theIndex) const; @@ -107,13 +106,14 @@ public: //! Return a Part object virtual ResultPartPtr part() const; -private: + private: //! Returns document of the current part DocumentPtr partDocument() const; //! Types of QModelIndexes - enum DataIds { + enum DataIds + { MyRoot, ParamsFolder, ParamObject, @@ -126,4 +126,4 @@ private: }; -#endif \ No newline at end of file +#endif diff --git a/src/XGUI/XGUI_Preferences.cpp b/src/XGUI/XGUI_Preferences.cpp index 4df3d1296..0d3f69a12 100644 --- a/src/XGUI/XGUI_Preferences.cpp +++ b/src/XGUI/XGUI_Preferences.cpp @@ -12,14 +12,11 @@ #include #include - const QString XGUI_Preferences::VIEWER_SECTION = "Viewer"; const QString XGUI_Preferences::MENU_SECTION = "Menu"; - SUIT_ResourceMgr* XGUI_Preferences::myResourceMgr = 0; - SUIT_ResourceMgr* XGUI_Preferences::resourceMgr() { if (!myResourceMgr) { @@ -41,60 +38,58 @@ bool XGUI_Preferences::editPreferences(XGUI_Prefs& theModified) return false; } - void XGUI_Preferences::updateCustomProps() { Config_Properties aProps = Config_PropManager::getProperties(); Config_Properties::iterator aIt; - for (aIt = aProps.begin(); aIt != aProps.end(); ++ aIt) { + for (aIt = aProps.begin(); aIt != aProps.end(); ++aIt) { Config_Prop* aProp = (*aIt); - QString aVal = myResourceMgr->stringValue(QString(aProp->section().c_str()), + QString aVal = myResourceMgr->stringValue(QString(aProp->section().c_str()), QString(aProp->name().c_str())); if (!aVal.isNull()) aProp->setValue(qPrintable(aVal)); } } - void XGUI_Preferences::loadCustomProps() { QStringList aSections = myResourceMgr->sections(); - foreach (QString aSection, aSections) { + foreach (QString aSection, aSections) + { QStringList aParams = myResourceMgr->parameters(aSection); - foreach (QString aParam, aParams) { - Config_PropManager::registerProp(qPrintable(aSection), - qPrintable(aParam), - "", Config_Prop::Disabled, + foreach (QString aParam, aParams) + { + Config_PropManager::registerProp(qPrintable(aSection), qPrintable(aParam), "", + Config_Prop::Disabled, qPrintable(myResourceMgr->stringValue(aSection, aParam))); } } } - - //********************************************************** //********************************************************** //********************************************************** XGUI_PreferencesDlg::XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent) - : QDialog(theParent), myIsChanged(false) + : QDialog(theParent), + myIsChanged(false) { - setWindowTitle( tr("Edit preferences") ); + setWindowTitle(tr("Edit preferences")); QVBoxLayout* main = new QVBoxLayout(this); - main->setMargin( 5 ); - main->setSpacing( 5 ); + main->setMargin(5); + main->setSpacing(5); myPreferences = new XGUI_PreferencesMgr(theResurces, this); - main->addWidget( myPreferences ); + main->addWidget(myPreferences); - setFocusProxy( myPreferences ); - myPreferences->setFrameStyle( QFrame::Box | QFrame::Sunken ); + setFocusProxy(myPreferences); + myPreferences->setFrameStyle(QFrame::Box | QFrame::Sunken); - QDialogButtonBox* aBtnBox = new QDialogButtonBox( - QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); + QDialogButtonBox* aBtnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, + Qt::Horizontal, this); main->addWidget(aBtnBox); connect(aBtnBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(aBtnBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(aBtnBox, SIGNAL(rejected()), this, SLOT(reject())); createEditors(); myPreferences->retrieve(); @@ -120,51 +115,47 @@ void XGUI_PreferencesDlg::createEditors() void XGUI_PreferencesDlg::createViewerPage(int thePageId) { - int viewTab = myPreferences->addItem( tr("Viewer"), thePageId ); + int viewTab = myPreferences->addItem(tr("Viewer"), thePageId); QStringList gradList; - gradList << tr("Horizontal gradient") << tr("Vertical gradient") << - tr("First diagonal gradient") << tr("Second diagonal gradient") << - tr("First corner gradient") << tr("Second corner gradient") << - tr("Third corner gradient") << tr("Fourth corner gradient"); - + gradList << tr("Horizontal gradient") << tr("Vertical gradient") << tr("First diagonal gradient") + << tr("Second diagonal gradient") << tr("First corner gradient") + << tr("Second corner gradient") << tr("Third corner gradient") + << tr("Fourth corner gradient"); + QList idList; for (int i = 0; i < gradList.size(); i++) idList << i; - int bgGroup = myPreferences->addItem( tr( "Background" ), viewTab ); + int bgGroup = myPreferences->addItem(tr("Background"), viewTab); QString aImgFiles("Image files (*.bmp *.gif *.pix *.xwd *.rgb *.rs)"); - int bgId = myPreferences->addItem( tr("Viewer 3d" ), bgGroup, - SUIT_PreferenceMgr::Background, - XGUI_Preferences::VIEWER_SECTION, "background" ); - myPreferences->setItemProperty( "gradient_names", gradList, bgId ); - myPreferences->setItemProperty( "gradient_ids", idList, bgId ); - myPreferences->setItemProperty( "texture_enabled", true, bgId ); - myPreferences->setItemProperty( "texture_center_enabled", true, bgId ); - myPreferences->setItemProperty( "texture_tile_enabled", true, bgId ); - myPreferences->setItemProperty( "texture_stretch_enabled", true, bgId ); - myPreferences->setItemProperty( "custom_enabled", false, bgId ); - myPreferences->setItemProperty( "image_formats", aImgFiles, bgId ); + int bgId = myPreferences->addItem(tr("Viewer 3d"), bgGroup, SUIT_PreferenceMgr::Background, + XGUI_Preferences::VIEWER_SECTION, "background"); + myPreferences->setItemProperty("gradient_names", gradList, bgId); + myPreferences->setItemProperty("gradient_ids", idList, bgId); + myPreferences->setItemProperty("texture_enabled", true, bgId); + myPreferences->setItemProperty("texture_center_enabled", true, bgId); + myPreferences->setItemProperty("texture_tile_enabled", true, bgId); + myPreferences->setItemProperty("texture_stretch_enabled", true, bgId); + myPreferences->setItemProperty("custom_enabled", false, bgId); + myPreferences->setItemProperty("image_formats", aImgFiles, bgId); } void XGUI_PreferencesDlg::createMenuPage(int thePageId) { - int aMenuTab = myPreferences->addItem(tr("Main menu"), thePageId ); - - int aSizeGroup = myPreferences->addItem(tr("Size"), aMenuTab ); - myPreferences->setItemProperty( "columns", 1, aSizeGroup ); - - int aRowsNb = myPreferences->addItem( tr( "Number of rows" ), - aSizeGroup, - SUIT_PreferenceMgr::IntSpin, - XGUI_Preferences::MENU_SECTION, - "rows_number" ); - myPreferences->setItemProperty( "min", 1, aRowsNb ); - myPreferences->setItemProperty( "max", 6, aRowsNb ); -} + int aMenuTab = myPreferences->addItem(tr("Main menu"), thePageId); + + int aSizeGroup = myPreferences->addItem(tr("Size"), aMenuTab); + myPreferences->setItemProperty("columns", 1, aSizeGroup); + int aRowsNb = myPreferences->addItem(tr("Number of rows"), aSizeGroup, + SUIT_PreferenceMgr::IntSpin, XGUI_Preferences::MENU_SECTION, + "rows_number"); + myPreferences->setItemProperty("min", 1, aRowsNb); + myPreferences->setItemProperty("max", 6, aRowsNb); +} void XGUI_PreferencesDlg::createCustomPage(int thePageId) { @@ -176,8 +167,8 @@ void XGUI_PreferencesDlg::createCustomPage(int thePageId) std::list::const_iterator it; for (it = aSections.cbegin(); it != aSections.cend(); ++it) { Config_Properties aProps = Config_PropManager::getProperties(*it); - int aTab = myPreferences->addItem(QString((*it).c_str()), thePageId ); - myPreferences->setItemProperty( "columns", 2, aTab ); + int aTab = myPreferences->addItem(QString((*it).c_str()), thePageId); + myPreferences->setItemProperty("columns", 2, aTab); Config_Properties::const_iterator aIt; for (aIt = aProps.cbegin(); aIt != aProps.cend(); ++aIt) { @@ -191,15 +182,13 @@ void XGUI_PreferencesDlg::createCustomPage(int thePageId) } // Add item if (aProp->type() != Config_Prop::Disabled) - myPreferences->addItem( tr(aProp->title().c_str()), aTab, - (SUIT_PreferenceMgr::PrefItemType)aProp->type(), - QString(aProp->section().c_str()), - QString(aProp->name().c_str()) ); + myPreferences->addItem(tr(aProp->title().c_str()), aTab, + (SUIT_PreferenceMgr::PrefItemType) aProp->type(), + QString(aProp->section().c_str()), QString(aProp->name().c_str())); } } } - void XGUI_PreferencesDlg::accept() { myPreferences->store(); @@ -210,25 +199,22 @@ void XGUI_PreferencesDlg::accept() QDialog::accept(); } - void XGUI_PreferencesDlg::modified(XGUI_Prefs& theModified) const { theModified = myPreferences->modified(); } - - //********************************************************** //********************************************************** //********************************************************** -void XGUI_PreferencesMgr::changedResources( const ResourceMap& theMap) +void XGUI_PreferencesMgr::changedResources(const ResourceMap& theMap) { myModified.clear(); ResourceMap::ConstIterator it; QString sec, param; - for (it = theMap.begin(); it != theMap.end(); ++it ) { + for (it = theMap.begin(); it != theMap.end(); ++it) { XGUI_Pref aPref; - it.key()->resource( aPref.first, aPref.second ); + it.key()->resource(aPref.first, aPref.second); myModified.append(aPref); } } diff --git a/src/XGUI/XGUI_Preferences.h b/src/XGUI/XGUI_Preferences.h index a694c34ba..7307de3ef 100644 --- a/src/XGUI/XGUI_Preferences.h +++ b/src/XGUI/XGUI_Preferences.h @@ -18,12 +18,11 @@ class QWidget; typedef QPair XGUI_Pref; typedef QList XGUI_Prefs; - //*********************************************************************** /// Class for manipulation with preferences in the application class XGUI_EXPORT XGUI_Preferences { -public: + public: static const QString VIEWER_SECTION; static const QString MENU_SECTION; @@ -35,7 +34,7 @@ public: static void loadCustomProps(); -private: + private: static SUIT_ResourceMgr* myResourceMgr; }; @@ -43,50 +42,58 @@ private: /// Manager of preferences class XGUI_EXPORT XGUI_PreferencesMgr : public SUIT_PreferenceMgr { - Q_OBJECT -public: +Q_OBJECT + public: XGUI_PreferencesMgr(QtxResourceMgr* theResource, QWidget* theParent) - :SUIT_PreferenceMgr(theResource, theParent) {} + : SUIT_PreferenceMgr(theResource, theParent) + { + } - virtual ~XGUI_PreferencesMgr() {} + virtual ~XGUI_PreferencesMgr() + { + } - XGUI_Prefs modified() const { return myModified; } + XGUI_Prefs modified() const + { + return myModified; + } -protected: - virtual void changedResources( const ResourceMap& theMap); + protected: + virtual void changedResources(const ResourceMap& theMap); -private: + private: XGUI_Prefs myModified; }; - //*********************************************************************** /// Dialog box for preferences editing -class XGUI_EXPORT XGUI_PreferencesDlg: public QDialog +class XGUI_EXPORT XGUI_PreferencesDlg : public QDialog { - Q_OBJECT -public: +Q_OBJECT + public: XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0); virtual ~XGUI_PreferencesDlg(); - bool isChanged() const { return myIsChanged; } + bool isChanged() const + { + return myIsChanged; + } void modified(XGUI_Prefs& theModified) const; -public slots: + public slots: virtual void accept(); -private: + private: void createEditors(); void createViewerPage(int thePageId); void createMenuPage(int thePageId); void createCustomPage(int thePageId); void updateCustomProps(); - + XGUI_PreferencesMgr* myPreferences; bool myIsChanged; }; - -#endif \ No newline at end of file +#endif diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index b686fcebf..9a6e9500c 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -22,8 +22,8 @@ #include #endif -XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) : -QDockWidget(theParent) +XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) + : QDockWidget(theParent) { this->setWindowTitle(tr("Property Panel")); QAction* aViewAct = this->toggleViewAction(); @@ -72,7 +72,7 @@ XGUI_PropertyPanel::~XGUI_PropertyPanel() void XGUI_PropertyPanel::cleanContent() { - myWidgets.clear(); + myWidgets.clear(); qDeleteAll(myCustomWidget->children()); } @@ -81,21 +81,22 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& t myWidgets = theWidgets; if (!theWidgets.empty()) { - QList::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end(); + QList::const_iterator anIt = theWidgets.begin(), aLast = + theWidgets.end(); for (; anIt != aLast; anIt++) { - connect(*anIt, SIGNAL(keyReleased(const std::string&, QKeyEvent*)), - this, SIGNAL(keyReleased(const std::string&, QKeyEvent*))); + connect(*anIt, SIGNAL(keyReleased(const std::string&, QKeyEvent*)), this, + SIGNAL(keyReleased(const std::string&, QKeyEvent*))); - connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), - this, SLOT(onActivateNextWidget(ModuleBase_ModelWidget*))); + connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this, + SLOT(onActivateNextWidget(ModuleBase_ModelWidget*))); //connect(*anIt, SIGNAL(activated(ModuleBase_ModelWidget*)), // this, SIGNAL(widgetActivated(ModuleBase_ModelWidget*))); ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast(*anIt); if (aPointWidget) - connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), - this, SIGNAL(storedPoint2D(ObjectPtr, const std::string&))); + connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this, + SIGNAL(storedPoint2D(ObjectPtr, const std::string&))); } ModuleBase_ModelWidget* aLastWidget = theWidgets.last(); if (aLastWidget) { @@ -125,7 +126,7 @@ bool XGUI_PropertyPanel::eventFilter(QObject *theObject, QEvent *theEvent) QPushButton* aCancelBtn = findChild(XGUI::PROP_PANEL_CANCEL); if (theObject == anOkBtn || theObject == aCancelBtn) { if (theEvent->type() == QEvent::KeyRelease) { - QKeyEvent* aKeyEvent = (QKeyEvent*)theEvent; + QKeyEvent* aKeyEvent = (QKeyEvent*) theEvent; if (aKeyEvent && aKeyEvent->key() == Qt::Key_Return) { // TODO: this is enter button processing when the focus is on "Apply" or "Cancel" buttons emit keyReleased("", (QKeyEvent*) theEvent); @@ -143,7 +144,8 @@ QWidget* XGUI_PropertyPanel::contentWidget() void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature) { - foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) { + foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) + { eachWidget->setFeature(theFeature); eachWidget->restoreValue(); } @@ -154,10 +156,9 @@ void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature) void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget) { ModuleBase_ModelWidget* aNextWidget = 0; - QList::const_iterator anIt = myWidgets.begin(), - aLast = myWidgets.end(); + QList::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end(); bool isFoundWidget = false; - for (;anIt != aLast && !aNextWidget; anIt++) { + for (; anIt != aLast && !aNextWidget; anIt++) { if (isFoundWidget || !theWidget) { if ((*anIt)->focusTo()) { aNextWidget = *anIt; diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index 7b55b2c0f..7331bc531 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -18,10 +18,10 @@ class QKeyEvent; class QVBoxLayout; -class XGUI_EXPORT XGUI_PropertyPanel: public QDockWidget +class XGUI_EXPORT XGUI_PropertyPanel : public QDockWidget { - Q_OBJECT -public: +Q_OBJECT + public: XGUI_PropertyPanel(QWidget* theParent); virtual ~XGUI_PropertyPanel(); @@ -31,10 +31,10 @@ public: void cleanContent(); -protected: + protected: virtual bool eventFilter(QObject *theObject, QEvent *theEvent); -public slots: + public slots: void updateContentWidget(FeaturePtr theFeature); /// slot to activate the next widget in the property panel /// \param theWidget a widget. The next widget should be activated @@ -56,7 +56,7 @@ signals: /// \param the attribute of the feature void storedPoint2D(ObjectPtr theFeature, const std::string& theAttribute); -private: + private: QWidget* myCustomWidget; QList myWidgets; diff --git a/src/XGUI/XGUI_RubberBand.cpp b/src/XGUI/XGUI_RubberBand.cpp index 66140015b..f6cf5857b 100644 --- a/src/XGUI/XGUI_RubberBand.cpp +++ b/src/XGUI/XGUI_RubberBand.cpp @@ -21,13 +21,14 @@ */ XGUI_AbstractRubberBand::XGUI_AbstractRubberBand(QWidget* theParent) - : QWidget(theParent), myPoints(), myIsClosed(false) + : QWidget(theParent), + myPoints(), + myIsClosed(false) { setAttribute(Qt::WA_TransparentForMouseEvents); #ifndef WIN32 setAttribute(Qt::WA_NoSystemBackground); -#endif //WIN32 setAttribute(Qt::WA_WState_ExplicitShowHide); setVisible(false); theParent->installEventFilter(this); - setGeometry(QRect(QPoint(0, 0), theParent->size())); +#endif //WIN32 setAttribute(Qt::WA_WState_ExplicitShowHide); setVisible(false); theParent->installEventFilter(this); setGeometry(QRect(QPoint(0, 0), theParent->size())); } /*! @@ -100,7 +101,7 @@ QRegion createRegion(const QPointF& p1, const QPointF& p2) if (p1 == p2) return QRegion(); - QLineF n = QLineF(p1, p2).normalVector(); //.unitVector(); + QLineF n = QLineF(p1, p2).normalVector(); //.unitVector(); n.setLength(1); n.translate(p1 * -1); QPointF nPoint = n.p2(); @@ -116,7 +117,7 @@ void XGUI_AbstractRubberBand::updateMask() QRegion r; QVectorIterator it(myPoints); - while(it.hasNext()) { + while (it.hasNext()) { QPoint p = it.next(); if (!it.hasNext()) break; @@ -151,7 +152,7 @@ void XGUI_RectRubberBand::initGeometry(const QRect& theRect) { myPoints.clear(); myPoints << theRect.topLeft() << theRect.topRight() << theRect.bottomRight() - << theRect.bottomLeft(); + << theRect.bottomLeft(); //setMask( QRegion( myPoints ) ); updateMask(); } @@ -175,7 +176,7 @@ void XGUI_RectRubberBand::setEndPoint(const QPoint& thePoint) void XGUI_RectRubberBand::clearGeometry() { QMutableVectorIterator i(myPoints); - while(i.hasNext()) { + while (i.hasNext()) { i.next(); i.setValue(QPoint(-1, -1)); } diff --git a/src/XGUI/XGUI_RubberBand.h b/src/XGUI/XGUI_RubberBand.h index 3f6199af9..e31eafdee 100644 --- a/src/XGUI/XGUI_RubberBand.h +++ b/src/XGUI/XGUI_RubberBand.h @@ -5,26 +5,26 @@ #include /*! - \class XGUI_AbstractRubberBand - \ingroup GUI - \brief Analog of class QRubberBand with possibility of creation non-rectangular contour for selection. - - Currently this class does not support Style functionality in full. -*/ -class XGUI_EXPORT XGUI_AbstractRubberBand: public QWidget + \class XGUI_AbstractRubberBand + \ingroup GUI + \brief Analog of class QRubberBand with possibility of creation non-rectangular contour for selection. + + Currently this class does not support Style functionality in full. + */ +class XGUI_EXPORT XGUI_AbstractRubberBand : public QWidget { Q_OBJECT -protected: + protected: XGUI_AbstractRubberBand(QWidget*); -public: + public: virtual ~XGUI_AbstractRubberBand(); virtual void clearGeometry(); bool isClosed(); -protected: + protected: virtual void paintEvent(QPaintEvent*); virtual void showEvent(QShowEvent*); virtual void moveEvent(QMoveEvent*); @@ -34,24 +34,24 @@ protected: virtual void updateMask(); -protected: + protected: QPolygon myPoints; bool myIsClosed; }; /*! - \class XGUI_RectRubberBand - \ingroup GUI - \brief Analog of class QRubberBand with possibility of creation non-rectangular contour for selection. - - Redefinition for rectangular rubber band -*/ -class XGUI_RectRubberBand: public XGUI_AbstractRubberBand + \class XGUI_RectRubberBand + \ingroup GUI + \brief Analog of class QRubberBand with possibility of creation non-rectangular contour for selection. + + Redefinition for rectangular rubber band + */ +class XGUI_RectRubberBand : public XGUI_AbstractRubberBand { Q_OBJECT -public: + public: XGUI_RectRubberBand(QWidget*); virtual ~XGUI_RectRubberBand(); @@ -62,11 +62,11 @@ public: virtual void clearGeometry(); }; -class XGUI_PolyRubberBand: public XGUI_AbstractRubberBand +class XGUI_PolyRubberBand : public XGUI_AbstractRubberBand { Q_OBJECT -public: + public: XGUI_PolyRubberBand(QWidget*); virtual ~XGUI_PolyRubberBand(); diff --git a/src/XGUI/XGUI_SalomeConnector.h b/src/XGUI/XGUI_SalomeConnector.h index 48bb6e10f..58489c127 100644 --- a/src/XGUI/XGUI_SalomeConnector.h +++ b/src/XGUI/XGUI_SalomeConnector.h @@ -10,12 +10,12 @@ class QMainWindow; class XGUI_SalomeViewer; /** -* An interface which provides a connection of XGUI functionality -* with functionality of SALOME module interface. -*/ + * An interface which provides a connection of XGUI functionality + * with functionality of SALOME module interface. + */ class XGUI_EXPORT XGUI_SalomeConnector { -public: + public: //! Creates a feature (command) in SALOME desktop //! \param theWBName - a workbench name //! \param theId - an id of the feature @@ -25,13 +25,9 @@ public: //! \param isCheckable - is checkable or not //! \param theKeys - hot keys //! returns created action - virtual QAction* addFeature(const QString& theWBName, - const QString& theId, - const QString& theTitle, - const QString& theTip, - const QIcon& theIcon, - const QKeySequence& theKeys, - bool isCheckable) = 0; + virtual QAction* addFeature(const QString& theWBName, const QString& theId, + const QString& theTitle, const QString& theTip, const QIcon& theIcon, + const QKeySequence& theKeys, bool isCheckable) = 0; //! Creates a command in Edit menu of SALOME desktop //! \param theId - an id of the feature @@ -41,12 +37,9 @@ public: //! \param isCheckable - is checkable or not //! \param theKeys - hot keys //! returns created action - virtual QAction* addEditCommand(const QString& theId, - const QString& theTitle, - const QString& theTip, - const QIcon& theIcon, - const QKeySequence& theKeys, - bool isCheckable) = 0; + virtual QAction* addEditCommand(const QString& theId, const QString& theTitle, + const QString& theTip, const QIcon& theIcon, + const QKeySequence& theKeys, bool isCheckable) = 0; //! Insert separator into Edit menu of SALOME desktop virtual void addEditMenuSeparator() = 0; @@ -78,4 +71,4 @@ public: virtual XGUI_SalomeViewer* viewer() const = 0; }; -#endif \ No newline at end of file +#endif diff --git a/src/XGUI/XGUI_SalomeViewer.h b/src/XGUI/XGUI_SalomeViewer.h index d35937900..1b3de1d1f 100644 --- a/src/XGUI/XGUI_SalomeViewer.h +++ b/src/XGUI/XGUI_SalomeViewer.h @@ -12,14 +12,17 @@ class QKeyEvent; class QContextMenuEvent; /** -* A Base object for definition of connector object to -* Salome Viewer. Reimplemented in NewGeom_SalomeViewer class -*/ -class XGUI_EXPORT XGUI_SalomeViewer: public QObject + * A Base object for definition of connector object to + * Salome Viewer. Reimplemented in NewGeom_SalomeViewer class + */ +class XGUI_EXPORT XGUI_SalomeViewer : public QObject { - Q_OBJECT -public: - XGUI_SalomeViewer(QObject* theParent):QObject(theParent) {} +Q_OBJECT + public: + XGUI_SalomeViewer(QObject* theParent) + : QObject(theParent) + { + } //! Returns AIS_InteractiveContext from current OCCViewer virtual Handle(AIS_InteractiveContext) AISContext() const = 0; @@ -62,4 +65,4 @@ signals: void contextMenuRequested(QContextMenuEvent*); }; -#endif \ No newline at end of file +#endif diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index b42f8c4b9..d39e31359 100644 --- a/src/XGUI/XGUI_Selection.cpp +++ b/src/XGUI/XGUI_Selection.cpp @@ -14,9 +14,8 @@ #include - XGUI_Selection::XGUI_Selection(XGUI_Workshop* theWorkshop) -: myWorkshop(theWorkshop) + : myWorkshop(theWorkshop) { } @@ -81,7 +80,7 @@ QList XGUI_Selection::selectedObjects() const { return myWorkshop->objectBrowser()->selectedObjects(); } - + QList XGUI_Selection::selectedPresentations() const { QList aSelectedList; @@ -96,10 +95,9 @@ QList XGUI_Selection::selectedPresentations() const return aSelectedList; } - //************************************************************** -QModelIndexList XGUI_Selection::selectedIndexes() const -{ +QModelIndexList XGUI_Selection::selectedIndexes() const +{ return myWorkshop->objectBrowser()->selectedIndexes(); } diff --git a/src/XGUI/XGUI_Selection.h b/src/XGUI/XGUI_Selection.h index dd3b48586..b67adbc52 100644 --- a/src/XGUI/XGUI_Selection.h +++ b/src/XGUI/XGUI_Selection.h @@ -20,9 +20,9 @@ class XGUI_Workshop; -class XGUI_EXPORT XGUI_Selection: public ModuleBase_ISelection +class XGUI_EXPORT XGUI_Selection : public ModuleBase_ISelection { -public: + public: XGUI_Selection(XGUI_Workshop* theWorkshop); /// Returns a list of viewer selected presentations @@ -36,15 +36,15 @@ public: virtual std::list getHighlighted(int theShapeTypeToSkip = -1) const; /** - * Returns list of currently selected objects - */ + * Returns list of currently selected objects + */ virtual QList selectedObjects() const; /** - * Returns list of currently selected results - */ + * Returns list of currently selected results + */ virtual QList selectedPresentations() const; - + //! Returns list of currently selected QModelIndexes virtual QModelIndexList selectedIndexes() const; @@ -54,8 +54,8 @@ public: //! Returns list of currently selected shapes virtual void selectedShapes(NCollection_List& theList) const; -private: + private: XGUI_Workshop* myWorkshop; }; -#endif \ No newline at end of file +#endif diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index caf78cede..2d37228ba 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -15,10 +15,9 @@ #include #include - - -XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) : - QObject(theParent), myWorkshop(theParent) +XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) + : QObject(theParent), + myWorkshop(theParent) { mySelection = new XGUI_Selection(myWorkshop); } @@ -31,12 +30,11 @@ XGUI_SelectionMgr::~XGUI_SelectionMgr() //************************************************************** void XGUI_SelectionMgr::connectViewers() { - connect(myWorkshop->objectBrowser(), SIGNAL(selectionChanged()), - this, SLOT(onObjectBrowserSelection())); + connect(myWorkshop->objectBrowser(), SIGNAL(selectionChanged()), this, + SLOT(onObjectBrowserSelection())); //Connect to other viewers - connect(myWorkshop->viewer(), SIGNAL(selectionChanged()), - this, SLOT(onViewerSelection())); + connect(myWorkshop->viewer(), SIGNAL(selectionChanged()), this, SLOT(onViewerSelection())); } //************************************************************** @@ -68,33 +66,33 @@ void XGUI_SelectionMgr::onViewerSelection() //************************************************************** /*QFeatureList XGUI_SelectionMgr::selectedFeatures() const -{ - return myWorkshop->objectBrowser()->selectedFeatures(); -} + { + return myWorkshop->objectBrowser()->selectedFeatures(); + } -//************************************************************** -QModelIndexList XGUI_SelectionMgr::selectedIndexes() const -{ - return myWorkshop->objectBrowser()->selectedIndexes(); -} + //************************************************************** + QModelIndexList XGUI_SelectionMgr::selectedIndexes() const + { + return myWorkshop->objectBrowser()->selectedIndexes(); + } -//************************************************************** -void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const -{ - Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); - theList.Clear(); - for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) - theList.Append(aContext->SelectedInteractive()); -} + //************************************************************** + void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const + { + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + theList.Clear(); + for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) + theList.Append(aContext->SelectedInteractive()); + } -//************************************************************** -void XGUI_SelectionMgr::selectedShapes(NCollection_List& theList) const -{ - theList.Clear(); - Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); - for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { - TopoDS_Shape aShape = aContext->SelectedShape(); - if (!aShape.IsNull()) - theList.Append(aShape); - } -}*/ + //************************************************************** + void XGUI_SelectionMgr::selectedShapes(NCollection_List& theList) const + { + theList.Clear(); + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { + TopoDS_Shape aShape = aContext->SelectedShape(); + if (!aShape.IsNull()) + theList.Append(aShape); + } + }*/ diff --git a/src/XGUI/XGUI_SelectionMgr.h b/src/XGUI/XGUI_SelectionMgr.h index 0519e29d0..7a445878c 100644 --- a/src/XGUI/XGUI_SelectionMgr.h +++ b/src/XGUI/XGUI_SelectionMgr.h @@ -21,12 +21,15 @@ class XGUI_Selection; */ class XGUI_EXPORT XGUI_SelectionMgr : public QObject { - Q_OBJECT -public: +Q_OBJECT + public: XGUI_SelectionMgr(XGUI_Workshop* theParent); virtual ~XGUI_SelectionMgr(); - XGUI_Selection* selection() const { return mySelection; } + XGUI_Selection* selection() const + { + return mySelection; + } //! Connects the manager to all viewers accessible by Workshop void connectViewers(); @@ -35,11 +38,11 @@ signals: //! Emited when selection in a one of viewers was changed void selectionChanged(); -private slots: + private slots: void onObjectBrowserSelection(); void onViewerSelection(); -private: + private: XGUI_Workshop* myWorkshop; XGUI_Selection* mySelection; }; diff --git a/src/XGUI/XGUI_Tools.cpp b/src/XGUI/XGUI_Tools.cpp index 5672163dc..95a219c6a 100644 --- a/src/XGUI/XGUI_Tools.cpp +++ b/src/XGUI/XGUI_Tools.cpp @@ -9,8 +9,7 @@ #include #include -namespace XGUI_Tools -{ +namespace XGUI_Tools { //****************************************************************** QString dir(const QString& path, bool isAbs) { @@ -25,7 +24,7 @@ QString dir(const QString& path, bool isAbs) QString file(const QString& path, bool withExt) { QString fPath = path; - while(!fPath.isEmpty() && (fPath[fPath.length() - 1] == '\\' || fPath[fPath.length() - 1] == '/')) + while (!fPath.isEmpty() && (fPath[fPath.length() - 1] == '\\' || fPath[fPath.length() - 1] == '/')) fPath.remove(fPath.length() - 1, 1); if (withExt) @@ -65,7 +64,7 @@ bool isModelObject(FeaturePtr theFeature) //****************************************************************** std::string featureInfo(FeaturePtr theFeature) { - std::ostringstream aStream; + std::ostringstream aStream; if (theFeature) aStream << theFeature.get() << " " << theFeature->getKind(); return QString(aStream.str().c_str()).toStdString(); @@ -73,14 +72,13 @@ std::string featureInfo(FeaturePtr theFeature) //****************************************************************** /*FeaturePtr realFeature(const FeaturePtr theFeature) -{ - if (theFeature->data()) { - return theFeature; - } else { - ObjectPtr aObject = boost::dynamic_pointer_cast(theFeature); - return aObject->featureRef(); - } -}*/ - + { + if (theFeature->data()) { + return theFeature; + } else { + ObjectPtr aObject = boost::dynamic_pointer_cast(theFeature); + return aObject->featureRef(); + } + }*/ } diff --git a/src/XGUI/XGUI_Tools.h b/src/XGUI/XGUI_Tools.h index 0ad21160a..518d5e597 100644 --- a/src/XGUI/XGUI_Tools.h +++ b/src/XGUI/XGUI_Tools.h @@ -19,58 +19,57 @@ \param abs if true (default) \a path parameter is treated as absolute file path \return directory part of the file path */ -namespace XGUI_Tools -{ - QString XGUI_EXPORT dir(const QString& path, bool isAbs = true); - - /*! - \brief Return file name part of the file path. - - \param path file path - \param withExt if true (default) complete file name (with all - extension except the last) is returned, otherwise only base name - is returned - \return file name part of the file path - */ - QString XGUI_EXPORT file(const QString& path, bool withExt = true); - - /*! - \brief Return extension part of the file path. - - \param path file path - \param full if true complete extension (all extensions, dot separated) - is returned, otherwise (default) only last extension is returned - \return extension part of the file path - */ - QString XGUI_EXPORT extension(const QString& path, bool full = false); - - /*! - \brief Add a slash (platform-specific) to the end of \a path - if it is not already there. - \param path directory path - \return modified path (with slash added to the end) - */ - QString XGUI_EXPORT addSlash(const QString& path); - - /*! - Creates a rect with TopLeft = ( min(x1,x2), min(y1,y2) ) - and BottomRight = ( TopLeft + (x2-x1)(y2-y1) ) - */ - QRect XGUI_EXPORT makeRect(const int x1, const int y1, const int x2, const int y2); - - /// The model concerning tools - - /*! - Returns true if the feature is a model object - \param theFeature a feature - */ - bool XGUI_EXPORT isModelObject(FeaturePtr theFeature); - - /*! - Returns the string presentation of the given feature - \param theFeature a feature - */ - std::string XGUI_EXPORT featureInfo(FeaturePtr theFeature); +namespace XGUI_Tools { +QString XGUI_EXPORT dir(const QString& path, bool isAbs = true); + +/*! + \brief Return file name part of the file path. + + \param path file path + \param withExt if true (default) complete file name (with all + extension except the last) is returned, otherwise only base name + is returned + \return file name part of the file path + */ +QString XGUI_EXPORT file(const QString& path, bool withExt = true); + +/*! + \brief Return extension part of the file path. + + \param path file path + \param full if true complete extension (all extensions, dot separated) + is returned, otherwise (default) only last extension is returned + \return extension part of the file path + */ +QString XGUI_EXPORT extension(const QString& path, bool full = false); + +/*! + \brief Add a slash (platform-specific) to the end of \a path + if it is not already there. + \param path directory path + \return modified path (with slash added to the end) + */ +QString XGUI_EXPORT addSlash(const QString& path); + +/*! + Creates a rect with TopLeft = ( min(x1,x2), min(y1,y2) ) + and BottomRight = ( TopLeft + (x2-x1)(y2-y1) ) + */ +QRect XGUI_EXPORT makeRect(const int x1, const int y1, const int x2, const int y2); + +/// The model concerning tools + +/*! + Returns true if the feature is a model object + \param theFeature a feature + */ +bool XGUI_EXPORT isModelObject(FeaturePtr theFeature); + +/*! + Returns the string presentation of the given feature + \param theFeature a feature + */ +std::string XGUI_EXPORT featureInfo(FeaturePtr theFeature); } #endif diff --git a/src/XGUI/XGUI_ViewBackground.cpp b/src/XGUI/XGUI_ViewBackground.cpp index 580f4cff0..c7ac791cc 100644 --- a/src/XGUI/XGUI_ViewBackground.cpp +++ b/src/XGUI/XGUI_ViewBackground.cpp @@ -5,7 +5,9 @@ Creates invalid background data. */ XGUI_ViewBackground::XGUI_ViewBackground() - : myTextureMode(XGUI::CenterTexture), myGradientType(XGUI::NoGradient), myTextureShown(false) + : myTextureMode(XGUI::CenterTexture), + myGradientType(XGUI::NoGradient), + myTextureShown(false) { setMode(XGUI::NoBackground); } @@ -16,7 +18,9 @@ XGUI_ViewBackground::XGUI_ViewBackground() \param c color */ XGUI_ViewBackground::XGUI_ViewBackground(const QColor& theColor) - : myTextureMode(XGUI::CenterTexture), myGradientType(XGUI::NoGradient), myTextureShown(false) + : myTextureMode(XGUI::CenterTexture), + myGradientType(XGUI::NoGradient), + myTextureShown(false) { setColor(theColor); } @@ -31,7 +35,9 @@ XGUI_ViewBackground::XGUI_ViewBackground(const QColor& theColor) */ XGUI_ViewBackground::XGUI_ViewBackground(XGUI::GradientType type, const QColor& c1, const QColor& c2) - : myTextureMode(XGUI::CenterTexture), myGradientType(XGUI::NoGradient), myTextureShown(false) + : myTextureMode(XGUI::CenterTexture), + myGradientType(XGUI::NoGradient), + myTextureShown(false) { setGradient(type, c1, c2); } @@ -42,7 +48,9 @@ XGUI_ViewBackground::XGUI_ViewBackground(XGUI::GradientType type, const QColor& \param grad gradient data */ XGUI_ViewBackground::XGUI_ViewBackground(const QGradient& grad) - : myTextureMode(XGUI::CenterTexture), myGradientType(XGUI::NoGradient), myTextureShown(false) + : myTextureMode(XGUI::CenterTexture), + myGradientType(XGUI::NoGradient), + myTextureShown(false) { setGradient(grad); } diff --git a/src/XGUI/XGUI_ViewBackground.h b/src/XGUI/XGUI_ViewBackground.h index 789c3543e..74528490a 100644 --- a/src/XGUI/XGUI_ViewBackground.h +++ b/src/XGUI/XGUI_ViewBackground.h @@ -47,7 +47,7 @@ typedef QList QColorList; //!< list of colors */ class XGUI_EXPORT XGUI_ViewBackground { -public: + public: XGUI_ViewBackground(); XGUI_ViewBackground(const QColor& theColor); XGUI_ViewBackground(XGUI::GradientType type, const QColor& theColor1, const QColor& theColor2); @@ -96,7 +96,7 @@ public: const QGradient* gradient() const; void setGradient(const QGradient&); -private: + private: XGUI::BackgroundMode myMode; XGUI::TextureMode myTextureMode; QString myFileName; diff --git a/src/XGUI/XGUI_ViewPort.cpp b/src/XGUI/XGUI_ViewPort.cpp index f59055beb..d5f31152b 100644 --- a/src/XGUI/XGUI_ViewPort.cpp +++ b/src/XGUI/XGUI_ViewPort.cpp @@ -1,4 +1,3 @@ - #include "XGUI_ViewPort.h" #include "XGUI_ViewWindow.h" #include "XGUI_Viewer.h" @@ -28,7 +27,6 @@ static int sx = 0; static int sy = 0; static Standard_Boolean zRotation = Standard_False; - /*! Create native view window for CasCade view [ static ] */ @@ -44,12 +42,10 @@ Handle(Aspect_Window) CreateCasWindow(const Handle(V3d_View)& view, WId winId) return viewWindow; } - //************************************************************************ //************************************************************************ //************************************************************************ -XGUI_ViewPort::XGUI_ViewPort(XGUI_ViewWindow* theParent, - const Handle(V3d_Viewer)& theViewer, +XGUI_ViewPort::XGUI_ViewPort(XGUI_ViewWindow* theParent, const Handle(V3d_Viewer)& theViewer, V3d_TypeOfView theType) : QWidget(theParent), myPaintersRedrawing(false), @@ -92,7 +88,7 @@ bool XGUI_ViewPort::mapView(const Handle(V3d_View)& theView) if (!mapped(theView)) { theView->SetWindow(myWindow); //if (theView != activeView()) - //theView->View()->Deactivate(); + //theView->View()->Deactivate(); } /* create static trihedron (16551: EDF PAL 501) */ @@ -155,78 +151,80 @@ void XGUI_ViewPort::updateBackground() // single-colored). // In OCCT 6.5.3 all above mentioned problems are fixed; so, above comment should be removed as soon // as SALOME is migrated to OCCT 6.5.3. The same concerns #ifdef statements in the below code - switch(myBackground.mode()) { - case Qtx::ColorBackground: { - QColor c = myBackground.color(); - if (c.isValid()) { - // Unset texture should be done here - // ... - Quantity_Color qCol(c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB); - activeView()->SetBgGradientStyle(Aspect_GFM_NONE); // cancel gradient background - activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background - // then change background color - activeView()->SetBackgroundColor(qCol); - // update viewer - activeView()->Update(); + switch (myBackground.mode()) { + case Qtx::ColorBackground: { + QColor c = myBackground.color(); + if (c.isValid()) { + // Unset texture should be done here + // ... + Quantity_Color qCol(c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB); + activeView()->SetBgGradientStyle(Aspect_GFM_NONE); // cancel gradient background + activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background + // then change background color + activeView()->SetBackgroundColor(qCol); + // update viewer + activeView()->Update(); + } + break; } - break; - } - case Qtx::SimpleGradientBackground: { - QColor c1, c2; - int type = myBackground.gradient(c1, c2); - if (c1.isValid() && type >= XGUI::HorizontalGradient && type <= XGUI::LastGradient) { - // Unset texture should be done here - // ... - // Get colors and set-up gradiented background - if (!c2.isValid()) - c2 = c1; - Quantity_Color qCol1(c1.red() / 255., c1.green() / 255., c1.blue() / 255., Quantity_TOC_RGB); - Quantity_Color qCol2(c2.red() / 255., c2.green() / 255., c2.blue() / 255., Quantity_TOC_RGB); - activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background - switch(type) { - case XGUI::HorizontalGradient: - activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_HOR, - Standard_True); - break; - case XGUI::VerticalGradient: - activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_VER, - Standard_True); - break; - case XGUI::Diagonal1Gradient: - activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG1, - Standard_True); - break; - case XGUI::Diagonal2Gradient: - activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG2, - Standard_True); - break; - case XGUI::Corner1Gradient: - activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER1, - Standard_True); - break; - case XGUI::Corner2Gradient: - activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER2, - Standard_True); - break; - case XGUI::Corner3Gradient: - activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER3, - Standard_True); - break; - case XGUI::Corner4Gradient: - activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER4, - Standard_True); - break; - default: - break; + case Qtx::SimpleGradientBackground: { + QColor c1, c2; + int type = myBackground.gradient(c1, c2); + if (c1.isValid() && type >= XGUI::HorizontalGradient && type <= XGUI::LastGradient) { + // Unset texture should be done here + // ... + // Get colors and set-up gradiented background + if (!c2.isValid()) + c2 = c1; + Quantity_Color qCol1(c1.red() / 255., c1.green() / 255., c1.blue() / 255., + Quantity_TOC_RGB); + Quantity_Color qCol2(c2.red() / 255., c2.green() / 255., c2.blue() / 255., + Quantity_TOC_RGB); + activeView()->SetBgImageStyle(Aspect_FM_NONE); // cancel texture background + switch (type) { + case XGUI::HorizontalGradient: + activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_HOR, + Standard_True); + break; + case XGUI::VerticalGradient: + activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_VER, + Standard_True); + break; + case XGUI::Diagonal1Gradient: + activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG1, + Standard_True); + break; + case XGUI::Diagonal2Gradient: + activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_DIAG2, + Standard_True); + break; + case XGUI::Corner1Gradient: + activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER1, + Standard_True); + break; + case XGUI::Corner2Gradient: + activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER2, + Standard_True); + break; + case XGUI::Corner3Gradient: + activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER3, + Standard_True); + break; + case XGUI::Corner4Gradient: + activeView()->SetBgGradientColors(qCol1, qCol2, Aspect_GFM_CORNER4, + Standard_True); + break; + default: + break; + } } + break; } - break; - } - case Qtx::CustomGradientBackground: - // NOT IMPLEMENTED YET - break; - default: - break; + case Qtx::CustomGradientBackground: + // NOT IMPLEMENTED YET + break; + default: + break; } // VSR: In OCCT before v6.5.3 below code can't be used because of very ugly bug - it has been impossible to // clear the background texture image as soon as it was once set to the viewer. @@ -236,21 +234,21 @@ void XGUI_ViewPort::updateBackground() QFileInfo fi(fileName); if (!fileName.isEmpty() && fi.exists()) { // set texture image: file name and fill mode - switch(textureMode) { - case XGUI::CenterTexture: - activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(), - Aspect_FM_CENTERED); - break; - case XGUI::TileTexture: - activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(), - Aspect_FM_TILED); - break; - case XGUI::StretchTexture: - activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(), - Aspect_FM_STRETCH); - break; - default: - break; + switch (textureMode) { + case XGUI::CenterTexture: + activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(), + Aspect_FM_CENTERED); + break; + case XGUI::TileTexture: + activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(), + Aspect_FM_TILED); + break; + case XGUI::StretchTexture: + activeView()->SetBackgroundImage(fi.absoluteFilePath().toLatin1().constData(), + Aspect_FM_STRETCH); + break; + default: + break; } activeView()->Update(); } @@ -351,36 +349,36 @@ void XGUI_ViewPort::startRotation(int x, int y, int theRotationPointType, const gp_Pnt& theSelectedPoint) { if (!activeView().IsNull()) { - switch(theRotationPointType) { - case XGUI::GRAVITY: - activeView()->StartRotation(x, y, 0.45); - break; - case XGUI::SELECTED: - sx = x; - sy = y; - - double X, Y; - activeView()->Size(X, Y); - rx = Standard_Real(activeView()->Convert(X)); - ry = Standard_Real(activeView()->Convert(Y)); - - activeView()->Rotate(0., 0., 0., theSelectedPoint.X(), theSelectedPoint.Y(), - theSelectedPoint.Z(), - Standard_True); - - Quantity_Ratio zRotationThreshold; - zRotation = Standard_False; - zRotationThreshold = 0.45; - if (zRotationThreshold > 0.) { - Standard_Real dx = Abs(sx - rx / 2.); - Standard_Real dy = Abs(sy - ry / 2.); - Standard_Real dd = zRotationThreshold * (rx + ry) / 2.; - if (dx > dd || dy > dd) - zRotation = Standard_True; - } - break; - default: - break; + switch (theRotationPointType) { + case XGUI::GRAVITY: + activeView()->StartRotation(x, y, 0.45); + break; + case XGUI::SELECTED: + sx = x; + sy = y; + + double X, Y; + activeView()->Size(X, Y); + rx = Standard_Real(activeView()->Convert(X)); + ry = Standard_Real(activeView()->Convert(Y)); + + activeView()->Rotate(0., 0., 0., theSelectedPoint.X(), theSelectedPoint.Y(), + theSelectedPoint.Z(), + Standard_True); + + Quantity_Ratio zRotationThreshold; + zRotation = Standard_False; + zRotationThreshold = 0.45; + if (zRotationThreshold > 0.) { + Standard_Real dx = Abs(sx - rx / 2.); + Standard_Real dy = Abs(sy - ry / 2.); + Standard_Real dd = zRotationThreshold * (rx + ry) / 2.; + if (dx > dd || dy > dd) + zRotation = Standard_True; + } + break; + default: + break; } activeView()->DepthFitAll(); } @@ -392,28 +390,28 @@ void XGUI_ViewPort::startRotation(int x, int y, int theRotationPointType, void XGUI_ViewPort::rotate(int x, int y, int theRotationPointType, const gp_Pnt& theSelectedPoint) { if (!activeView().IsNull()) { - switch(theRotationPointType) { - case XGUI::GRAVITY: - activeView()->Rotation(x, y); - break; - case XGUI::SELECTED: - double dx, dy, dz; - if (zRotation) { - dz = atan2(Standard_Real(x) - rx / 2., ry / 2. - Standard_Real(y)) - - atan2(sx - rx / 2., ry / 2. - sy); - dx = dy = 0.; - } else { - dx = (Standard_Real(x) - sx) * M_PI / rx; - dy = (sy - Standard_Real(y)) * M_PI / ry; - dz = 0.; - } - - activeView()->Rotate(dx, dy, dz, theSelectedPoint.X(), theSelectedPoint.Y(), - theSelectedPoint.Z(), - Standard_False); - break; - default: - break; + switch (theRotationPointType) { + case XGUI::GRAVITY: + activeView()->Rotation(x, y); + break; + case XGUI::SELECTED: + double dx, dy, dz; + if (zRotation) { + dz = atan2(Standard_Real(x) - rx / 2., ry / 2. - Standard_Real(y)) + - atan2(sx - rx / 2., ry / 2. - sy); + dx = dy = 0.; + } else { + dx = (Standard_Real(x) - sx) * M_PI / rx; + dy = (sy - Standard_Real(y)) * M_PI / ry; + dz = 0.; + } + + activeView()->Rotate(dx, dy, dz, theSelectedPoint.X(), theSelectedPoint.Y(), + theSelectedPoint.Z(), + Standard_False); + break; + default: + break; } emit vpTransformed(); } @@ -503,52 +501,57 @@ void XGUI_ViewPort::setBackground(const Qtx::BackgroundData& bgData) void XGUI_ViewPort::fitAll(bool theKeepScale, bool theWithZ, bool theUpd) { - if ( activeView().IsNull() ) + if (activeView().IsNull()) return; - if ( theKeepScale ) + if (theKeepScale) myScale = activeView()->Scale(); Standard_Real aMargin = 0.01; - activeView()->FitAll( aMargin, theWithZ, theUpd ); + activeView()->FitAll(aMargin, theWithZ, theUpd); activeView()->SetZSize(0.); - emit vpTransformed( ); + emit vpTransformed(); } -void XGUI_ViewPort::syncronizeWith( const XGUI_ViewPort* ref ) +void XGUI_ViewPort::syncronizeWith(const XGUI_ViewPort* ref) { Handle(V3d_View) refView = ref->getView(); Handle(V3d_View) tgtView = getView(); /* The following params are copied: - - view type( ortho/persp ) - - position of view point - - orientation of high point - - position of the eye - - projection vector - - view center ( 2D ) - - view twist - - view scale - */ + - view type( ortho/persp ) + - position of view point + - orientation of high point + - position of the eye + - projection vector + - view center ( 2D ) + - view twist + - view scale + */ /* we'll update after setting all params */ - tgtView->SetImmediateUpdate( Standard_False ); + tgtView->SetImmediateUpdate( Standard_False); /* perspective */ - if ( refView->Type() == V3d_PERSPECTIVE ) - tgtView->SetFocale( refView->Focale() ); + if (refView->Type() == V3d_PERSPECTIVE) + tgtView->SetFocale(refView->Focale()); /* copy params */ Standard_Real x, y, z; - refView->At( x, y, z ); tgtView->SetAt( x, y, z ); - refView->Up( x, y, z ); tgtView->SetUp( x, y, z ); - refView->Eye( x, y, z ); tgtView->SetEye( x, y, z ); - refView->Proj( x, y, z ); tgtView->SetProj( x, y, z ); - refView->Center( x, y ); tgtView->SetCenter( x, y ); - tgtView->SetScale( refView->Scale() ); - tgtView->SetTwist( refView->Twist() ); + refView->At(x, y, z); + tgtView->SetAt(x, y, z); + refView->Up(x, y, z); + tgtView->SetUp(x, y, z); + refView->Eye(x, y, z); + tgtView->SetEye(x, y, z); + refView->Proj(x, y, z); + tgtView->SetProj(x, y, z); + refView->Center(x, y); + tgtView->SetCenter(x, y); + tgtView->SetScale(refView->Scale()); + tgtView->SetTwist(refView->Twist()); /* update */ tgtView->Update(); - tgtView->SetImmediateUpdate( Standard_True ); + tgtView->SetImmediateUpdate( Standard_True); } diff --git a/src/XGUI/XGUI_ViewPort.h b/src/XGUI/XGUI_ViewPort.h index 2988e8fed..7c2ad4b22 100644 --- a/src/XGUI/XGUI_ViewPort.h +++ b/src/XGUI/XGUI_ViewPort.h @@ -12,10 +12,10 @@ class XGUI_ViewWindow; -class XGUI_EXPORT XGUI_ViewPort: public QWidget +class XGUI_EXPORT XGUI_ViewPort : public QWidget { Q_OBJECT -public: + public: XGUI_ViewPort(XGUI_ViewWindow* theParent, const Handle(V3d_Viewer)& theViewer, V3d_TypeOfView theType = V3d_ORTHOGRAPHIC); virtual ~XGUI_ViewPort(); @@ -60,7 +60,7 @@ public: void setBackground(const Qtx::BackgroundData& bgData); - void syncronizeWith( const XGUI_ViewPort* ref ); + void syncronizeWith(const XGUI_ViewPort* ref); signals: void vpChangeBackground(const Qtx::BackgroundData&); @@ -70,11 +70,11 @@ signals: void vpUpdated(); void resized(); -protected: + protected: virtual void paintEvent(QPaintEvent*); virtual void resizeEvent(QResizeEvent*); -private: + private: Handle(V3d_View) activeView() const { return myActiveView; diff --git a/src/XGUI/XGUI_ViewWindow.cpp b/src/XGUI/XGUI_ViewWindow.cpp index c62a26652..69e4f2a4a 100644 --- a/src/XGUI/XGUI_ViewWindow.cpp +++ b/src/XGUI/XGUI_ViewWindow.cpp @@ -78,9 +78,10 @@ const char* imageCrossCursor[] = { "32 32 3 1", ". c None", "a c #000000", "# c "................................", "................................", "................................", "................................" }; - ViewerToolbar::ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort) - : QToolBar(theParent), myVPort(thePort), myResize(false) + : QToolBar(theParent), + myVPort(thePort), + myResize(false) { connect(myVPort, SIGNAL(resized()), this, SLOT(onViewPortResized())); } @@ -95,8 +96,8 @@ void ViewerToolbar::paintEvent(QPaintEvent* theEvent) QPoint aGlobPnt = mapToGlobal(aRect.topLeft()); QPoint aPnt = myVPort->mapFromGlobal(aGlobPnt); - QRect aImgRect(QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), - aRect.width(), aRect.height())); + QRect aImgRect( + QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), aRect.width(), aRect.height())); QImage aImg = myVPort->dumpView(aImgRect, myResize); if (!aImg.isNull()) aPainter.drawImage(aRect, aImg); @@ -112,11 +113,11 @@ void ViewerToolbar::paintEvent(QPaintEvent* theEvent) style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &aOpt, &aPainter, this); } - - //************************************************************************** ViewerLabel::ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort) - : QLabel(theParent), myVPort(thePort), myResize(false) + : QLabel(theParent), + myVPort(thePort), + myResize(false) { connect(myVPort, SIGNAL(resized()), this, SLOT(onViewPortResized())); } @@ -128,8 +129,8 @@ void ViewerLabel::paintEvent(QPaintEvent* theEvent) QPoint aGlobPnt = mapToGlobal(aRect.topLeft()); QPoint aPnt = myVPort->mapFromGlobal(aGlobPnt); - QRect aImgRect(QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), - aRect.width(), aRect.height())); + QRect aImgRect( + QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), aRect.width(), aRect.height())); QImage aImg = myVPort->dumpView(aImgRect, myResize); if (!aImg.isNull()) QPainter(this).drawImage(aRect, aImg); @@ -141,25 +142,34 @@ void ViewerLabel::paintEvent(QPaintEvent* theEvent) //************************************************************************** //************************************************************************** XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType) - : QFrame(), - myViewer(theViewer), - myMoving(false), - MinimizeIco(":pictures/wnd_minimize.png"), - MaximizeIco(":pictures/wnd_maximize.png"), - CloseIco(":pictures/wnd_close.png"), - RestoreIco(":pictures/wnd_restore.png"), - myInteractionStyle(XGUI::STANDARD), - myRectBand(0), - myIsKeyFree(false), - my2dMode(XGUI::No2dMode), - myCurrPointType(XGUI::GRAVITY), - myPrevPointType(XGUI::GRAVITY), - myRotationPointSelection(false), - myClosable(true), - myStartX(0), myStartY(0), myCurrX(0), myCurrY(0), myCurScale(0.0), myCurSketch(0), - myDrawRect(false), myEnableDrawMode(false), myCursorIsHand(false), myEventStarted(false), - myIsActive(false), - myLastState(WindowNormalState), myOperation(NOTHING) + : QFrame(), + myViewer(theViewer), + myMoving(false), + MinimizeIco(":pictures/wnd_minimize.png"), + MaximizeIco(":pictures/wnd_maximize.png"), + CloseIco(":pictures/wnd_close.png"), + RestoreIco(":pictures/wnd_restore.png"), + myInteractionStyle(XGUI::STANDARD), + myRectBand(0), + myIsKeyFree(false), + my2dMode(XGUI::No2dMode), + myCurrPointType(XGUI::GRAVITY), + myPrevPointType(XGUI::GRAVITY), + myRotationPointSelection(false), + myClosable(true), + myStartX(0), + myStartY(0), + myCurrX(0), + myCurrY(0), + myCurScale(0.0), + myCurSketch(0), + myDrawRect(false), + myEnableDrawMode(false), + myCursorIsHand(false), + myEventStarted(false), + myIsActive(false), + myLastState(WindowNormalState), + myOperation(NOTHING) { mySelectedPoint = gp_Pnt(0., 0., 0.); setFrameStyle(QFrame::Raised); @@ -185,14 +195,14 @@ XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType) QVBoxLayout* aVPLay = new QVBoxLayout(myViewPort); aVPLay->setMargin(0); aVPLay->setSpacing(0); - aVPLay->setContentsMargins(0,0,0,0); + aVPLay->setContentsMargins(0, 0, 0, 0); QHBoxLayout* aToolLay = new QHBoxLayout(); aToolLay->setMargin(0); aToolLay->setSpacing(0); - aToolLay->setContentsMargins(0,0,0,0); + aToolLay->setContentsMargins(0, 0, 0, 0); aVPLay->addLayout(aToolLay); - aVPLay->addStretch(); + aVPLay->addStretch(); myGripWgt = new ViewerLabel(this, myViewPort); myGripWgt->setPixmap(QPixmap(":pictures/wnd_grip.png")); @@ -201,10 +211,10 @@ XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType) myGripWgt->setCursor(Qt::OpenHandCursor); aToolLay->addWidget(myGripWgt); - // Create Viewer management buttons + // Create Viewer management buttons myViewBar = new ViewerToolbar(this, myViewPort); myViewBar->setCursor(Qt::PointingHandCursor); - aToolLay->addWidget(myViewBar); + aToolLay->addWidget(myViewBar); aToolLay->addStretch(); QAction* aBtn; @@ -270,7 +280,7 @@ XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType) connect(aBtn, SIGNAL(triggered()), SLOT(cloneView())); myViewBar->addAction(aBtn); - // Create Window management buttons + // Create Window management buttons myWindowBar = new ViewerToolbar(this, myViewPort); myWindowBar->setCursor(Qt::PointingHandCursor); aToolLay->addWidget(myWindowBar); @@ -293,8 +303,8 @@ XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType) //Support copy of background on updating of viewer connect(myViewPort, SIGNAL(vpTransformed()), this, SLOT(updateToolBar())); connect(myViewPort, SIGNAL(vpUpdated()), this, SLOT(updateToolBar())); - connect(this, SIGNAL(vpTransformationFinished(XGUI_ViewWindow::OperationType)), - this, SLOT(updateToolBar())); + connect(this, SIGNAL(vpTransformationFinished(XGUI_ViewWindow::OperationType)), this, + SLOT(updateToolBar())); } //**************************************************************** @@ -302,7 +312,6 @@ XGUI_ViewWindow::~XGUI_ViewWindow() { } - //**************************************************************** void XGUI_ViewWindow::showEvent(QShowEvent* theEvent) { @@ -318,7 +327,7 @@ void XGUI_ViewWindow::changeEvent(QEvent* theEvent) if (isMinimized()) { if (myPicture->isHidden()) { myViewBar->hide(); - myGripWgt->hide(); + myGripWgt->hide(); myWindowBar->hide(); myViewPort->hide(); myPicture->show(); @@ -340,8 +349,6 @@ void XGUI_ViewWindow::changeEvent(QEvent* theEvent) QWidget::changeEvent(theEvent); } - - //**************************************************************** void XGUI_ViewWindow::windowActivated() { @@ -354,9 +361,10 @@ void XGUI_ViewWindow::windowActivated() } myViewBar->show(); myWindowBar->show(); - myGripWgt->setVisible(!(isMaximized() || isMinimized() || - parentWidget()->isMaximized() || parentWidget()->isMinimized())); - } else + myGripWgt->setVisible( + !(isMaximized() || isMinimized() || parentWidget()->isMaximized() + || parentWidget()->isMinimized())); + } else myIsActive = false; } @@ -372,11 +380,10 @@ void XGUI_ViewWindow::windowDeactivated() } myViewBar->hide(); myWindowBar->hide(); - myGripWgt->hide(); + myGripWgt->hide(); } } - //**************************************************************** void XGUI_ViewWindow::onClose() { @@ -397,15 +404,16 @@ void XGUI_ViewWindow::onMinimize() int aH = height(); double aR = aW / 100.; int aNewH = int(aH / aR); - myPicture->setPixmap(aPMap.scaled(100, aNewH)); + myPicture->setPixmap(aPMap.scaled(100, aNewH)); - myLastState = (isMaximized() || parentWidget()->isMaximized()) ? MaximizedState : WindowNormalState; + myLastState = + (isMaximized() || parentWidget()->isMaximized()) ? MaximizedState : WindowNormalState; showMinimized(); parentWidget()->showMinimized(); parentWidget()->setGeometry(parentWidget()->x(), parentWidget()->y(), 100, aNewH); parentWidget()->lower(); windowDeactivated(); - myViewer->onWindowMinimized((QMdiSubWindow*)parentWidget()); + myViewer->onWindowMinimized((QMdiSubWindow*) parentWidget()); } //**************************************************************** @@ -424,7 +432,7 @@ void XGUI_ViewWindow::onMaximize() } parentWidget()->activateWindow(); myMinimizeBtn->setIcon(MinimizeIco); - + // In order to avoid frosen background in toolbars when it shown as a second view QTimer::singleShot(50, parentWidget(), SLOT(setFocus())); } @@ -432,57 +440,57 @@ void XGUI_ViewWindow::onMaximize() //**************************************************************** bool XGUI_ViewWindow::processWindowControls(QObject *theObj, QEvent *theEvent) { - switch(theEvent->type()) { - case QEvent::MouseButtonPress: { - QMouseEvent* aEvent = static_cast(theEvent); - if ((aEvent->button() == Qt::LeftButton) && (!myMoving)) { - myMoving = true; - myMousePnt = aEvent->globalPos(); - return true; - } - } - break; - case QEvent::MouseButtonRelease: { - QMouseEvent* aEvent = static_cast(theEvent); - if ((aEvent->button() == Qt::LeftButton) && myMoving) { - myMoving = false; - return true; + switch (theEvent->type()) { + case QEvent::MouseButtonPress: { + QMouseEvent* aEvent = static_cast(theEvent); + if ((aEvent->button() == Qt::LeftButton) && (!myMoving)) { + myMoving = true; + myMousePnt = aEvent->globalPos(); + return true; + } } - } - break; - case QEvent::MouseMove: { - QMouseEvent* aEvent = static_cast(theEvent); - if (myMoving) { - QMdiSubWindow* aParent = static_cast(parentWidget()); - QMdiArea* aMDIArea = aParent->mdiArea(); - - QPoint aPnt = aEvent->globalPos(); - QPoint aMDIPnt = aMDIArea->mapFromGlobal(aPnt); - if (aMDIArea->rect().contains(aMDIPnt)) { - int aX = aParent->x() + (aPnt.x() - myMousePnt.x()); - int aY = aParent->y() + (aPnt.y() - myMousePnt.y()); - aParent->move(aX, aY); - myMousePnt = aPnt; + break; + case QEvent::MouseButtonRelease: { + QMouseEvent* aEvent = static_cast(theEvent); + if ((aEvent->button() == Qt::LeftButton) && myMoving) { + myMoving = false; + return true; } - return true; } - } - break; - case QEvent::MouseButtonDblClick: - if (theObj == myPicture) { - myMoving = false; - if (myLastState == MaximizedState) { - showMaximized(); - } else { - showNormal(); + break; + case QEvent::MouseMove: { + QMouseEvent* aEvent = static_cast(theEvent); + if (myMoving) { + QMdiSubWindow* aParent = static_cast(parentWidget()); + QMdiArea* aMDIArea = aParent->mdiArea(); + + QPoint aPnt = aEvent->globalPos(); + QPoint aMDIPnt = aMDIArea->mapFromGlobal(aPnt); + if (aMDIArea->rect().contains(aMDIPnt)) { + int aX = aParent->x() + (aPnt.x() - myMousePnt.x()); + int aY = aParent->y() + (aPnt.y() - myMousePnt.y()); + aParent->move(aX, aY); + myMousePnt = aPnt; + } + return true; } - myViewer->onWindowActivated((QMdiSubWindow*)parentWidget()); + } + break; + case QEvent::MouseButtonDblClick: + if (theObj == myPicture) { + myMoving = false; + if (myLastState == MaximizedState) { + showMaximized(); + } else { + showNormal(); + } + myViewer->onWindowActivated((QMdiSubWindow*) parentWidget()); - // In order to avoid frosen background in toolbars when it shown as a second view - QTimer::singleShot(20, parentWidget(), SLOT(setFocus())); + // In order to avoid frosen background in toolbars when it shown as a second view + QTimer::singleShot(20, parentWidget(), SLOT(setFocus())); - return true; - } + return true; + } } return false; } @@ -490,34 +498,33 @@ bool XGUI_ViewWindow::processWindowControls(QObject *theObj, QEvent *theEvent) //**************************************************************** bool XGUI_ViewWindow::processViewPort(QEvent *theEvent) { - switch(theEvent->type()) { - case QEvent::MouseButtonPress: - vpMousePressEvent((QMouseEvent*) theEvent); - return true; - - case QEvent::MouseButtonRelease: - vpMouseReleaseEvent((QMouseEvent*) theEvent); - return true; - - case QEvent::MouseMove: - vpMouseMoveEvent((QMouseEvent*) theEvent); - return true; - - case QEvent::MouseButtonDblClick: - emit mouseDoubleClicked(this, (QMouseEvent*) theEvent); - return true; - case QEvent::Wheel: - { - QWheelEvent* aEvent = (QWheelEvent*) theEvent; - myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() ); - double aDelta = (double)( aEvent->delta() ) / ( 15 * 8 ); - int x = aEvent->x(); - int y = aEvent->y(); - int x1 = (int)( aEvent->x() + width()*aDelta/100 ); - int y1 = (int)( aEvent->y() + height()*aDelta/100 ); - myViewPort->zoom( x, y, x1, y1 ); - } - return true; + switch (theEvent->type()) { + case QEvent::MouseButtonPress: + vpMousePressEvent((QMouseEvent*) theEvent); + return true; + + case QEvent::MouseButtonRelease: + vpMouseReleaseEvent((QMouseEvent*) theEvent); + return true; + + case QEvent::MouseMove: + vpMouseMoveEvent((QMouseEvent*) theEvent); + return true; + + case QEvent::MouseButtonDblClick: + emit mouseDoubleClicked(this, (QMouseEvent*) theEvent); + return true; + case QEvent::Wheel: { + QWheelEvent* aEvent = (QWheelEvent*) theEvent; + myViewPort->startZoomAtPoint(aEvent->x(), aEvent->y()); + double aDelta = (double) (aEvent->delta()) / (15 * 8); + int x = aEvent->x(); + int y = aEvent->y(); + int x1 = (int) (aEvent->x() + width() * aDelta / 100); + int y1 = (int) (aEvent->y() + height() * aDelta / 100); + myViewPort->zoom(x, y, x1, y1); + } + return true; } return false; } @@ -575,97 +582,97 @@ void XGUI_ViewWindow::vpMousePressEvent(QMouseEvent* theEvent) aSwitchToZoom = getButtonState(theEvent, anInteractionStyle) == ZOOMVIEW; } - switch(myOperation) { - case WINDOWFIT: - if (theEvent->button() == Qt::LeftButton) - emit vpTransformationStarted(WINDOWFIT); - break; - - case PANGLOBAL: - if (theEvent->button() == Qt::LeftButton) - emit vpTransformationStarted(PANGLOBAL); - break; - - case ZOOMVIEW: - if (theEvent->button() == Qt::LeftButton) { - myViewPort->startZoomAtPoint(myStartX, myStartY); - emit vpTransformationStarted(ZOOMVIEW); - } - break; - - case PANVIEW: - if (aSwitchToZoom) { - myViewPort->startZoomAtPoint(myStartX, myStartY); - activateZoom(); - } else if (theEvent->button() == Qt::LeftButton) - emit vpTransformationStarted(PANVIEW); - break; - - case ROTATE: - if (aSwitchToZoom) { - myViewPort->startZoomAtPoint(myStartX, myStartY); - activateZoom(); - } else if (theEvent->button() == Qt::LeftButton) { - myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint); - emit vpTransformationStarted(ROTATE); - } - break; - - default: - /* Try to activate a transformation */ - OperationType aState; - if (interactionStyle() == XGUI::STANDARD) - aState = getButtonState(theEvent, anInteractionStyle); - else { - aState = XGUI_ViewWindow::NOTHING; - myIsKeyFree = true; - } - switch(aState) { + switch (myOperation) { + case WINDOWFIT: + if (theEvent->button() == Qt::LeftButton) + emit vpTransformationStarted(WINDOWFIT); + break; + + case PANGLOBAL: + if (theEvent->button() == Qt::LeftButton) + emit vpTransformationStarted(PANGLOBAL); + break; + case ZOOMVIEW: - myViewPort->startZoomAtPoint(myStartX, myStartY); - activateZoom(); + if (theEvent->button() == Qt::LeftButton) { + myViewPort->startZoomAtPoint(myStartX, myStartY); + emit vpTransformationStarted(ZOOMVIEW); + } break; + case PANVIEW: - activatePanning(); + if (aSwitchToZoom) { + myViewPort->startZoomAtPoint(myStartX, myStartY); + activateZoom(); + } else if (theEvent->button() == Qt::LeftButton) + emit vpTransformationStarted(PANVIEW); break; + case ROTATE: - activateRotation(); - myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint); + if (aSwitchToZoom) { + myViewPort->startZoomAtPoint(myStartX, myStartY); + activateZoom(); + } else if (theEvent->button() == Qt::LeftButton) { + myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint); + emit vpTransformationStarted(ROTATE); + } break; + default: - if (myRotationPointSelection) { - if (theEvent->button() == Qt::LeftButton) { - Handle(AIS_InteractiveContext) ic = myViewer->AISContext(); - ic->Select(); - for(ic->InitSelected(); ic->MoreSelected(); ic->NextSelected()) { - TopoDS_Shape aShape = ic->SelectedShape(); - if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) { - gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(ic->SelectedShape())); - /*if ( mySetRotationPointDlg ) { - myRotationPointSelection = false; - mySetRotationPointDlg->setCoords(aPnt.X(), aPnt.Y(), aPnt.Z()); - }*/ - } else { - myCurrPointType = myPrevPointType; - break; + /* Try to activate a transformation */ + OperationType aState; + if (interactionStyle() == XGUI::STANDARD) + aState = getButtonState(theEvent, anInteractionStyle); + else { + aState = XGUI_ViewWindow::NOTHING; + myIsKeyFree = true; + } + switch (aState) { + case ZOOMVIEW: + myViewPort->startZoomAtPoint(myStartX, myStartY); + activateZoom(); + break; + case PANVIEW: + activatePanning(); + break; + case ROTATE: + activateRotation(); + myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint); + break; + default: + if (myRotationPointSelection) { + if (theEvent->button() == Qt::LeftButton) { + Handle(AIS_InteractiveContext) ic = myViewer->AISContext(); + ic->Select(); + for (ic->InitSelected(); ic->MoreSelected(); ic->NextSelected()) { + TopoDS_Shape aShape = ic->SelectedShape(); + if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX) { + gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(ic->SelectedShape())); + /*if ( mySetRotationPointDlg ) { + myRotationPointSelection = false; + mySetRotationPointDlg->setCoords(aPnt.X(), aPnt.Y(), aPnt.Z()); + }*/ + } else { + myCurrPointType = myPrevPointType; + break; + } + } + if (ic->NbSelected() == 0) + myCurrPointType = myPrevPointType; + //if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange(); + ic->CloseAllContexts(); + myOperation = NOTHING; + myViewPort->setCursor(myCursor); + myCursorIsHand = false; + myRotationPointSelection = false; } - } - if (ic->NbSelected() == 0) - myCurrPointType = myPrevPointType; - //if ( mySetRotationPointDlg ) mySetRotationPointDlg->toggleChange(); - ic->CloseAllContexts(); - myOperation = NOTHING; - myViewPort->setCursor(myCursor); - myCursorIsHand = false; - myRotationPointSelection = false; - } - } else - emit mousePressed(this, theEvent); - break; - } - /* notify that we start a transformation */ - if (transformRequested()) - emit vpTransformationStarted(myOperation); + } else + emit mousePressed(this, theEvent); + break; + } + /* notify that we start a transformation */ + if (transformRequested()) + emit vpTransformationStarted(myOperation); } if (transformRequested()) setTransformInProcess(true); @@ -689,51 +696,51 @@ void XGUI_ViewWindow::contextMenuEvent(QContextMenuEvent* theEvent) //**************************************************************** void XGUI_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent) { - switch(myOperation) { - case NOTHING: { - int prevState = myCurSketch; - /* if(theEvent->button() == Qt::RightButton) { - QList::Iterator it; - for ( it = mySketchers.begin(); it != mySketchers.end() && myCurSketch != -1; ++it ) { - OCCViewer_ViewSketcher* sk = (*it); - if( ( sk->sketchButton() & theEvent->button() ) && sk->sketchButton() == myCurSketch ) - myCurSketch = -1; - } - } - */ - emit mouseReleased(this, theEvent); - } - break; - case ROTATE: - myViewPort->endRotation(); - resetState(); - break; - - case PANVIEW: - case ZOOMVIEW: - resetState(); - break; - - case PANGLOBAL: - if (theEvent->button() == Qt::LeftButton) { - myViewPort->setCenter(theEvent->x(), theEvent->y()); - myViewPort->getView()->SetScale(myCurScale); - resetState(); + switch (myOperation) { + case NOTHING: { + int prevState = myCurSketch; + /* if(theEvent->button() == Qt::RightButton) { + QList::Iterator it; + for ( it = mySketchers.begin(); it != mySketchers.end() && myCurSketch != -1; ++it ) { + OCCViewer_ViewSketcher* sk = (*it); + if( ( sk->sketchButton() & theEvent->button() ) && sk->sketchButton() == myCurSketch ) + myCurSketch = -1; + } + } + */ + emit mouseReleased(this, theEvent); } - break; - - case WINDOWFIT: - if (theEvent->button() == Qt::LeftButton) { - myCurrX = theEvent->x(); - myCurrY = theEvent->y(); - drawRect(); - QRect rect = XGUI_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY); - if (!rect.isEmpty()) - myViewPort->fitRect(rect); - endDrawRect(); + break; + case ROTATE: + myViewPort->endRotation(); resetState(); - } - break; + break; + + case PANVIEW: + case ZOOMVIEW: + resetState(); + break; + + case PANGLOBAL: + if (theEvent->button() == Qt::LeftButton) { + myViewPort->setCenter(theEvent->x(), theEvent->y()); + myViewPort->getView()->SetScale(myCurScale); + resetState(); + } + break; + + case WINDOWFIT: + if (theEvent->button() == Qt::LeftButton) { + myCurrX = theEvent->x(); + myCurrY = theEvent->y(); + drawRect(); + QRect rect = XGUI_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY); + if (!rect.isEmpty()) + myViewPort->fitRect(rect); + endDrawRect(); + resetState(); + } + break; } // NOTE: viewer 3D detects a rectangle of selection using this event @@ -755,97 +762,97 @@ void XGUI_ViewWindow::vpMouseMoveEvent(QMouseEvent* theEvent) { if (myIsKeyFree && interactionStyle() == XGUI::KEY_FREE) { myIsKeyFree = false; - switch(getButtonState(theEvent, interactionStyle())) { + switch (getButtonState(theEvent, interactionStyle())) { + case ZOOMVIEW: + myViewPort->startZoomAtPoint(myStartX, myStartY); + activateZoom(); + break; + case PANVIEW: + activatePanning(); + break; + case ROTATE: + activateRotation(); + myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint); + break; + default: + break; + } + } + + myCurrX = theEvent->x(); + myCurrY = theEvent->y(); + switch (myOperation) { + case ROTATE: + myViewPort->rotate(myCurrX, myCurrY, myCurrPointType, mySelectedPoint); + break; + case ZOOMVIEW: - myViewPort->startZoomAtPoint(myStartX, myStartY); - activateZoom(); + myViewPort->zoom(myStartX, myStartY, myCurrX, myCurrY); + myStartX = myCurrX; + myStartY = myCurrY; break; + case PANVIEW: - activatePanning(); - break; - case ROTATE: - activateRotation(); - myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint); + myViewPort->pan(myCurrX - myStartX, myStartY - myCurrY); + myStartX = myCurrX; + myStartY = myCurrY; break; - default: + + case PANGLOBAL: break; - } - } - myCurrX = theEvent->x(); - myCurrY = theEvent->y(); - switch(myOperation) { - case ROTATE: - myViewPort->rotate(myCurrX, myCurrY, myCurrPointType, mySelectedPoint); - break; - - case ZOOMVIEW: - myViewPort->zoom(myStartX, myStartY, myCurrX, myCurrY); - myStartX = myCurrX; - myStartY = myCurrY; - break; - - case PANVIEW: - myViewPort->pan(myCurrX - myStartX, myStartY - myCurrY); - myStartX = myCurrX; - myStartY = myCurrY; - break; - - case PANGLOBAL: - break; - - default: - if (myRotationPointSelection /*|| isSketcherStyle()*/) { - emit mouseMoving(this, theEvent); - } else { - int aState = theEvent->modifiers(); - int aButton = theEvent->buttons(); - int anInteractionStyle = interactionStyle(); - if (((anInteractionStyle == XGUI::STANDARD) && (aButton == Qt::LeftButton) - && (aState == Qt::NoModifier || Qt::ShiftModifier)) - || ((anInteractionStyle == XGUI::KEY_FREE) && (aButton == Qt::LeftButton) - && (aState == Qt::ControlModifier - || aState == (Qt::ControlModifier | Qt::ShiftModifier)))) { - myDrawRect = myEnableDrawMode; - if (myDrawRect) { - drawRect(); - if (!myCursorIsHand) { // we are going to sketch a rectangle - QCursor handCursor(Qt::PointingHandCursor); - myCursorIsHand = true; - myCursor = cursor(); - myViewPort->setCursor(handCursor); - } - } - emit mouseMoving(this, theEvent); - } /* else if ( ( (anInteractionStyle == XGUI::STANDARD) && - (aButton == Qt::RightButton) && - ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) || - ( (anInteractionStyle == XGUI::KEY_FREE) && - (aButton == Qt::RightButton) && - ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) { - OCCViewer_ViewSketcher* sketcher = 0; - QList::Iterator it; - for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it ) { - OCCViewer_ViewSketcher* sk = (*it); - if( sk->isDefault() && sk->sketchButton() == aButton ) - sketcher = sk; - } - if ( sketcher && myCurSketch == -1 ) { - activateSketching( sketcher->type() ); - if ( mypSketcher ) { - myCurSketch = mypSketcher->sketchButton(); - - if ( l_mbPressEvent ) { - QApplication::sendEvent( getViewPort(), l_mbPressEvent ); - delete l_mbPressEvent; - l_mbPressEvent = 0; - } - QApplication::sendEvent( getViewPort(), theEvent ); - } - } - } */else + default: + if (myRotationPointSelection /*|| isSketcherStyle()*/) { emit mouseMoving(this, theEvent); - } + } else { + int aState = theEvent->modifiers(); + int aButton = theEvent->buttons(); + int anInteractionStyle = interactionStyle(); + if (((anInteractionStyle == XGUI::STANDARD) && (aButton == Qt::LeftButton) + && (aState == Qt::NoModifier || Qt::ShiftModifier)) + || ((anInteractionStyle == XGUI::KEY_FREE) && (aButton == Qt::LeftButton) + && (aState == Qt::ControlModifier + || aState == (Qt::ControlModifier | Qt::ShiftModifier)))) { + myDrawRect = myEnableDrawMode; + if (myDrawRect) { + drawRect(); + if (!myCursorIsHand) { // we are going to sketch a rectangle + QCursor handCursor(Qt::PointingHandCursor); + myCursorIsHand = true; + myCursor = cursor(); + myViewPort->setCursor(handCursor); + } + } + emit mouseMoving(this, theEvent); + } /* else if ( ( (anInteractionStyle == XGUI::STANDARD) && + (aButton == Qt::RightButton) && + ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) || + ( (anInteractionStyle == XGUI::KEY_FREE) && + (aButton == Qt::RightButton) && + ( aState == Qt::ControlModifier || aState == ( Qt::ControlModifier|Qt::ShiftModifier ) ) ) ) { + OCCViewer_ViewSketcher* sketcher = 0; + QList::Iterator it; + for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it ) { + OCCViewer_ViewSketcher* sk = (*it); + if( sk->isDefault() && sk->sketchButton() == aButton ) + sketcher = sk; + } + if ( sketcher && myCurSketch == -1 ) { + activateSketching( sketcher->type() ); + if ( mypSketcher ) { + myCurSketch = mypSketcher->sketchButton(); + + if ( l_mbPressEvent ) { + QApplication::sendEvent( getViewPort(), l_mbPressEvent ); + delete l_mbPressEvent; + l_mbPressEvent = 0; + } + QApplication::sendEvent( getViewPort(), theEvent ); + } + } + } */else + emit mouseMoving(this, theEvent); + } } } @@ -943,22 +950,22 @@ void XGUI_ViewWindow::activatePanning() } /*! - \brief Start global panning operation + \brief Start global panning operation - Sets the corresponding cursor for the widget. -*/ + Sets the corresponding cursor for the widget. + */ void XGUI_ViewWindow::activateGlobalPanning() { Handle(V3d_View) aView3d = myViewPort->getView(); - if ( !aView3d.IsNull() ) { - QPixmap globalPanPixmap (imageCrossCursor); - QCursor glPanCursor (globalPanPixmap); + if (!aView3d.IsNull()) { + QPixmap globalPanPixmap(imageCrossCursor); + QCursor glPanCursor(globalPanPixmap); myCurScale = aView3d->Scale(); aView3d->FitAll(0.01, false); myCursor = cursor(); // save old cursor - myViewPort->fitAll(); // fits view before selecting a new scene center - if( setTransformRequested( PANGLOBAL ) ) - myViewPort->setCursor( glPanCursor ); + myViewPort->fitAll(); // fits view before selecting a new scene center + if (setTransformRequested(PANGLOBAL)) + myViewPort->setCursor(glPanCursor); } } @@ -1011,20 +1018,20 @@ Qtx::BackgroundData XGUI_ViewWindow::background() const void XGUI_ViewWindow::setBackground(const Qtx::BackgroundData& theBackground) { - if (myViewPort) - myViewPort->setBackground( theBackground ); + if (myViewPort) + myViewPort->setBackground(theBackground); } /*! - \brief Create one more window with same content. -*/ + \brief Create one more window with same content. + */ void XGUI_ViewWindow::cloneView() { QMdiSubWindow* vw = myViewer->createView(); XGUI_ViewWindow* aNewWnd = static_cast(vw->widget()); aNewWnd->viewPort()->syncronizeWith(myViewPort); - emit viewCloned( vw ); + emit viewCloned(vw); // In order to avoid frosen background in toolbars when it shown as a second view QTimer::singleShot(20, vw, SLOT(setFocus())); @@ -1034,15 +1041,16 @@ void XGUI_ViewWindow::dumpView() { QString aFilter(tr("Images Files (*.bmp *.png *.jpg *.jpeg *.eps *.ps)")); QString aSelectedFilter; - QString aFileName = QFileDialog::getSaveFileName(this, "Save picture", QString(), aFilter, &aSelectedFilter); + QString aFileName = QFileDialog::getSaveFileName(this, "Save picture", QString(), aFilter, + &aSelectedFilter); if (!aFileName.isNull()) { - QApplication::setOverrideCursor( Qt::WaitCursor ); + QApplication::setOverrideCursor(Qt::WaitCursor); QImage aPicture = myViewPort->dumpView(); QString aFmt = XGUI_Tools::extension(aFileName).toUpper(); - if( aFmt.isEmpty() ) - aFmt = QString( "BMP" ); // default format - else if( aFmt == "JPG" ) + if (aFmt.isEmpty()) + aFmt = QString("BMP"); // default format + else if (aFmt == "JPG") aFmt = "JPEG"; Handle(Visual3d_View) a3dView = myViewPort->getView()->View(); @@ -1051,128 +1059,126 @@ void XGUI_ViewWindow::dumpView() else if (aFmt == "EPS") a3dView->Export(strdup(qPrintable(aFileName)), Graphic3d_EF_EnhPostScript); else - aPicture.save( aFileName, aFmt.toLatin1() ); + aPicture.save(aFileName, aFmt.toLatin1()); QApplication::restoreOverrideCursor(); } } void XGUI_ViewWindow::fitAll() { - emit vpTransformationStarted( FITALLVIEW ); + emit vpTransformationStarted(FITALLVIEW); myViewPort->fitAll(); - emit vpTransformationFinished( FITALLVIEW ); + emit vpTransformationFinished(FITALLVIEW); } /*! - \brief Starts fit operation. + \brief Starts fit operation. - Sets the corresponding cursor for the widget. -*/ + Sets the corresponding cursor for the widget. + */ void XGUI_ViewWindow::activateWindowFit() { - if ( !transformRequested() && !myCursorIsHand ) - myCursor = cursor(); /* save old cursor */ + if (!transformRequested() && !myCursorIsHand) + myCursor = cursor(); /* save old cursor */ - if ( myOperation != WINDOWFIT ) { - QCursor handCursor (Qt::PointingHandCursor); - if( setTransformRequested ( WINDOWFIT ) ) { - myViewPort->setCursor ( handCursor ); + if (myOperation != WINDOWFIT) { + QCursor handCursor(Qt::PointingHandCursor); + if (setTransformRequested(WINDOWFIT)) { + myViewPort->setCursor(handCursor); myCursorIsHand = true; } } } - /*! - \brief Perform "front view" transformation. -*/ + \brief Perform "front view" transformation. + */ void XGUI_ViewWindow::frontView() { - emit vpTransformationStarted ( FRONTVIEW ); + emit vpTransformationStarted(FRONTVIEW); Handle(V3d_View) aView3d = myViewPort->getView(); - if ( !aView3d.IsNull() ) - aView3d->SetProj (V3d_Xpos); + if (!aView3d.IsNull()) + aView3d->SetProj(V3d_Xpos); myViewPort->fitAll(); - emit vpTransformationFinished ( FRONTVIEW ); + emit vpTransformationFinished(FRONTVIEW); } /*! - \brief Perform "back view" transformation. -*/ + \brief Perform "back view" transformation. + */ void XGUI_ViewWindow::backView() { - emit vpTransformationStarted ( BACKVIEW ); + emit vpTransformationStarted(BACKVIEW); Handle(V3d_View) aView3d = myViewPort->getView(); - if ( !aView3d.IsNull() ) - aView3d->SetProj (V3d_Xneg); + if (!aView3d.IsNull()) + aView3d->SetProj(V3d_Xneg); myViewPort->fitAll(); - emit vpTransformationFinished ( BACKVIEW ); + emit vpTransformationFinished(BACKVIEW); } /*! - \brief Perform "top view" transformation. -*/ + \brief Perform "top view" transformation. + */ void XGUI_ViewWindow::topView() { - emit vpTransformationStarted ( TOPVIEW ); + emit vpTransformationStarted(TOPVIEW); Handle(V3d_View) aView3d = myViewPort->getView(); - if ( !aView3d.IsNull() ) - aView3d->SetProj (V3d_Zpos); + if (!aView3d.IsNull()) + aView3d->SetProj(V3d_Zpos); myViewPort->fitAll(); - emit vpTransformationFinished ( TOPVIEW ); + emit vpTransformationFinished(TOPVIEW); } /*! - \brief Perform "bottom view" transformation. -*/ + \brief Perform "bottom view" transformation. + */ void XGUI_ViewWindow::bottomView() { - emit vpTransformationStarted ( BOTTOMVIEW ); + emit vpTransformationStarted(BOTTOMVIEW); Handle(V3d_View) aView3d = myViewPort->getView(); - if ( !aView3d.IsNull() ) - aView3d->SetProj (V3d_Zneg); + if (!aView3d.IsNull()) + aView3d->SetProj(V3d_Zneg); myViewPort->fitAll(); - emit vpTransformationFinished ( BOTTOMVIEW ); + emit vpTransformationFinished(BOTTOMVIEW); } /*! - \brief Perform "left view" transformation. -*/ + \brief Perform "left view" transformation. + */ void XGUI_ViewWindow::leftView() { - emit vpTransformationStarted ( LEFTVIEW ); + emit vpTransformationStarted(LEFTVIEW); Handle(V3d_View) aView3d = myViewPort->getView(); - if ( !aView3d.IsNull() ) - aView3d->SetProj (V3d_Yneg); + if (!aView3d.IsNull()) + aView3d->SetProj(V3d_Yneg); myViewPort->fitAll(); - emit vpTransformationFinished ( LEFTVIEW ); + emit vpTransformationFinished(LEFTVIEW); } /*! - \brief Perform "right view" transformation. -*/ + \brief Perform "right view" transformation. + */ void XGUI_ViewWindow::rightView() { - emit vpTransformationStarted ( RIGHTVIEW ); + emit vpTransformationStarted(RIGHTVIEW); Handle(V3d_View) aView3d = myViewPort->getView(); - if ( !aView3d.IsNull() ) - aView3d->SetProj (V3d_Ypos); + if (!aView3d.IsNull()) + aView3d->SetProj(V3d_Ypos); myViewPort->fitAll(); - emit vpTransformationFinished ( RIGHTVIEW ); + emit vpTransformationFinished(RIGHTVIEW); } void XGUI_ViewWindow::reset() { - emit vpTransformationStarted( RESETVIEW ); - bool upd = myViewPort->getView()->SetImmediateUpdate( false ); - myViewPort->getView()->Reset( false ); - myViewPort->fitAll( false, true, false ); - myViewPort->getView()->SetImmediateUpdate( upd ); + emit vpTransformationStarted(RESETVIEW); + bool upd = myViewPort->getView()->SetImmediateUpdate(false); + myViewPort->getView()->Reset(false); + myViewPort->fitAll(false, true, false); + myViewPort->getView()->SetImmediateUpdate(upd); myViewPort->getView()->Update(); - emit vpTransformationFinished( RESETVIEW ); + emit vpTransformationFinished(RESETVIEW); } - void XGUI_ViewWindow::updateToolBar() { myGripWgt->update(); @@ -1181,10 +1187,9 @@ void XGUI_ViewWindow::updateToolBar() } /*! - \brief Update state of enable draw mode state. -*/ + \brief Update state of enable draw mode state. + */ void XGUI_ViewWindow::updateEnabledDrawMode() { - myEnableDrawMode = myViewer->isSelectionEnabled() && - myViewer->isMultiSelectionEnabled(); + myEnableDrawMode = myViewer->isSelectionEnabled() && myViewer->isMultiSelectionEnabled(); } diff --git a/src/XGUI/XGUI_ViewWindow.h b/src/XGUI/XGUI_ViewWindow.h index 016c261d9..bd2aef20e 100644 --- a/src/XGUI/XGUI_ViewWindow.h +++ b/src/XGUI/XGUI_ViewWindow.h @@ -23,16 +23,16 @@ class XGUI_RectRubberBand; class QMdiSubWindow; /*! - \class XGUI_ViewWindow - \ingroup GUI - \brief Implements a one view window of 3d viewer object. - It contains a view port object (drawing area) and toolbars for view camera and window management. - Also it managements events in view port -*/ -class XGUI_EXPORT XGUI_ViewWindow: public QFrame + \class XGUI_ViewWindow + \ingroup GUI + \brief Implements a one view window of 3d viewer object. + It contains a view port object (drawing area) and toolbars for view camera and window management. + Also it managements events in view port + */ +class XGUI_EXPORT XGUI_ViewWindow : public QFrame { Q_OBJECT -public: + public: //! Types of viewer operations enum OperationType { @@ -83,16 +83,28 @@ public: void setBackground(const Qtx::BackgroundData& theBackground); //! Returns true if the current view window can be closed - bool closable() const { return myClosable; } + bool closable() const + { + return myClosable; + } //! Sets the current view window closable or not - void setClosable( const bool isClosable ) { myClosable = isClosable; } + void setClosable(const bool isClosable) + { + myClosable = isClosable; + } //! Enable/Disable drawing of ribbon line - void enableDrawMode(bool toEnable) { myEnableDrawMode = toEnable; } + void enableDrawMode(bool toEnable) + { + myEnableDrawMode = toEnable; + } //! Returns true if ribbon line drawing enabled - bool isDrawModeEnabled() const { return myEnableDrawMode; } + bool isDrawModeEnabled() const + { + return myEnableDrawMode; + } //! Updates drawing mode in the view window void updateEnabledDrawMode(); @@ -113,7 +125,7 @@ signals: void tryClosing(XGUI_ViewWindow*); //! Emited when window is closing - void closed( QMdiSubWindow* ); + void closed(QMdiSubWindow*); //! Emited on mouse press in view port void mousePressed(XGUI_ViewWindow*, QMouseEvent*); @@ -126,20 +138,20 @@ signals: //! Emited on mouse moving in view port void mouseMoving(XGUI_ViewWindow*, QMouseEvent*); - + //! Emited on key press in view port void keyPressed(XGUI_ViewWindow*, QKeyEvent*); - + //! Emited on key release in view port void keyReleased(XGUI_ViewWindow*, QKeyEvent*); - + //! Emited on context menu request in view port void contextMenuRequested(QContextMenuEvent *e); //void viewModified(XGUI_ViewWindow*); - void viewCloned( QMdiSubWindow* theView ); + void viewCloned(QMdiSubWindow* theView); -public slots: + public slots: //! Start zooming operation void activateZoom(); @@ -189,7 +201,7 @@ public slots: void windowDeactivated(); -protected: + protected: virtual void changeEvent(QEvent* theEvent); virtual bool eventFilter(QObject *theObj, QEvent *theEvent); @@ -198,7 +210,7 @@ protected: virtual void contextMenuEvent(QContextMenuEvent* theEvent); -private slots: + private slots: void onClose(); void onMinimize(); void onMaximize(); @@ -206,7 +218,7 @@ private slots: void updateToolBar(); // void repaintToolBar(); -private: + private: enum WindowState { MinimizedState, @@ -240,7 +252,7 @@ private: myEventStarted = bOn; } -private: + private: XGUI_Viewer* myViewer; QLabel* myPicture; @@ -287,7 +299,7 @@ private: gp_Pnt mySelectedPoint; - XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band + XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band typedef QMap MapOfTransformStatus; MapOfTransformStatus myStatus; @@ -297,48 +309,52 @@ private: //****************************************************** /*! - \class ViewerToolbar - \ingroup GUI - \brief Provides a toolbar widget with treansparent background over OCCT View window -*/ -class ViewerToolbar: public QToolBar + \class ViewerToolbar + \ingroup GUI + \brief Provides a toolbar widget with treansparent background over OCCT View window + */ +class ViewerToolbar : public QToolBar { Q_OBJECT -public: + public: ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort); -protected slots: - void onViewPortResized() { myResize = true; } + protected slots: + void onViewPortResized() + { + myResize = true; + } -protected: + protected: virtual void paintEvent(QPaintEvent* theEvent); - - -private: + private: XGUI_ViewPort* myVPort; bool myResize; }; //****************************************************** /*! - \class ViewerToolbar - \ingroup GUI - \brief Provides a Label widget with treansparent background over OCCT View window -*/ -class ViewerLabel: public QLabel + \class ViewerToolbar + \ingroup GUI + \brief Provides a Label widget with treansparent background over OCCT View window + */ +class ViewerLabel : public QLabel { Q_OBJECT -public: + public: ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort); -protected slots: - void onViewPortResized() { myResize = true; } + protected slots: + void onViewPortResized() + { + myResize = true; + } -protected: + protected: virtual void paintEvent(QPaintEvent* theEvent); -private: + private: XGUI_ViewPort* myVPort; bool myResize; }; diff --git a/src/XGUI/XGUI_Viewer.cpp b/src/XGUI/XGUI_Viewer.cpp index e605d2a07..a2864475b 100644 --- a/src/XGUI/XGUI_Viewer.cpp +++ b/src/XGUI/XGUI_Viewer.cpp @@ -27,7 +27,6 @@ #include #include - #ifdef WIN32 #include #else @@ -71,13 +70,13 @@ Handle(V3d_Viewer) CreateViewer(const Standard_ExtString name, const Standard_CS */ QString XGUI_Viewer::backgroundData(QStringList& gradList, QIntList& idList, QIntList& txtList) { - gradList << tr("Horizontal gradient") << tr("Vertical gradient") - << tr("First diagonal gradient") << tr("Second diagonal gradient") - << tr("First corner gradient") << tr("Second corner gradient") - << tr("Third corner gradient") << tr("Fourth corner gradient"); + gradList << tr("Horizontal gradient") << tr("Vertical gradient") << tr("First diagonal gradient") + << tr("Second diagonal gradient") << tr("First corner gradient") + << tr("Second corner gradient") << tr("Third corner gradient") + << tr("Fourth corner gradient"); idList << XGUI::HorizontalGradient << XGUI::VerticalGradient << XGUI::Diagonal1Gradient - << XGUI::Diagonal2Gradient << XGUI::Corner1Gradient << XGUI::Corner2Gradient - << XGUI::Corner3Gradient << XGUI::Corner4Gradient; + << XGUI::Diagonal2Gradient << XGUI::Corner1Gradient << XGUI::Corner2Gradient + << XGUI::Corner3Gradient << XGUI::Corner4Gradient; #ifdef OCC_ENABLE_TEXTURED_BACKGROUND txtList << XGUI::CenterTexture << XGUI::TileTexture << XGUI::StretchTexture; #endif @@ -85,16 +84,16 @@ QString XGUI_Viewer::backgroundData(QStringList& gradList, QIntList& idList, QIn } XGUI_Viewer::XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron) - : QObject(theParent), - myMainWindow(theParent), - myPreselectionEnabled(true), - mySelectionEnabled(true), - myMultiSelectionEnabled(true), - myIsRelative(true), - myInteractionStyle(XGUI::STANDARD), - myTrihedronSize(100), - myActiveView(0), - myWndIdCount(0) + : QObject(theParent), + myMainWindow(theParent), + myPreselectionEnabled(true), + mySelectionEnabled(true), + myMultiSelectionEnabled(true), + myIsRelative(true), + myInteractionStyle(XGUI::STANDARD), + myTrihedronSize(100), + myActiveView(0), + myWndIdCount(0) { if (!isInitialized) { isInitialized = true; @@ -122,8 +121,8 @@ XGUI_Viewer::XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron) XGUI_Viewer::myStateMap[XGUI::KEY_FREE][XGUI::ROTATE] = Qt::NoModifier; XGUI_Viewer::myButtonMap[XGUI::KEY_FREE][XGUI::ROTATE] = Qt::LeftButton; - XGUI_Viewer::myStateMap[XGUI::KEY_FREE][XGUI::FIT_AREA] = Qt::NoModifier; // unused - XGUI_Viewer::myButtonMap[XGUI::KEY_FREE][XGUI::FIT_AREA] = Qt::NoButton; // unused + XGUI_Viewer::myStateMap[XGUI::KEY_FREE][XGUI::FIT_AREA] = Qt::NoModifier; // unused + XGUI_Viewer::myButtonMap[XGUI::KEY_FREE][XGUI::FIT_AREA] = Qt::NoButton; // unused } // init CasCade viewers @@ -158,7 +157,8 @@ XGUI_Viewer::XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron) //myZoomingStyle = 0; QMdiArea* aMDI = myMainWindow->mdiArea(); - connect(aMDI, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(onWindowActivated(QMdiSubWindow*))); + connect(aMDI, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, + SLOT(onWindowActivated(QMdiSubWindow*))); } @@ -180,11 +180,12 @@ QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType) //vw->setBackground( background(0) ); // 0 means MAIN_VIEW (other views are not yet created here) // connect signal from viewport //connect(view->viewPort(), SIGNAL(vpClosed()), this, SLOT(onViewClosed())); - //connect(view->viewPort(), SIGNAL(vpMapped()), this, SLOT(onViewMapped())); - if (myViews.size() == 0) + //connect(view->viewPort(), SIGNAL(vpMapped()), this, SLOT(onViewMapped())); + if (myViews.size() == 0) setTrihedronShown(true); - Qtx::BackgroundData aBk = XGUI_Preferences::resourceMgr()->backgroundValue("Viewer", "background"); + Qtx::BackgroundData aBk = XGUI_Preferences::resourceMgr()->backgroundValue("Viewer", + "background"); view->setBackground(aBk); view->updateEnabledDrawMode(); @@ -200,15 +201,16 @@ QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType) void XGUI_Viewer::updateFromResources() { - Qtx::BackgroundData aBk = XGUI_Preferences::resourceMgr()->backgroundValue("Viewer", "background"); - foreach (QMdiSubWindow* aWnd, myViews) { + Qtx::BackgroundData aBk = XGUI_Preferences::resourceMgr()->backgroundValue("Viewer", + "background"); + foreach (QMdiSubWindow* aWnd, myViews) + { XGUI_ViewWindow* aView = dynamic_cast(aWnd->widget()); if (aView) aView->setBackground(aBk); } } - XGUI_ViewWindow* XGUI_Viewer::activeViewWindow() const { if (myActiveView) @@ -386,7 +388,7 @@ bool XGUI_Viewer::computeTrihedronSize(double& theNewSize, double& theSize) if (aMaxSide < Precision::Confusion()) return false; - static float EPS = (float)5.0E-3; + static float EPS = (float) 5.0E-3; theSize = trihedron()->Size(); //theNewSize = aMaxSide*aSizeInPercents / 100.0; @@ -395,18 +397,19 @@ bool XGUI_Viewer::computeTrihedronSize(double& theNewSize, double& theSize) void XGUI_Viewer::onViewClosed(QMdiSubWindow* theView) { - if ( !theView ) + if (!theView) return; - emit deleteView( static_cast(theView->widget()) ); - removeView( theView ); + emit deleteView(static_cast(theView->widget())); + removeView(theView); // if this is last view if (myViews.size() == 0) { Standard_Integer aViewsNb = 0; - for ( myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews(); myV3dViewer->NextActiveViews()) + for (myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews(); + myV3dViewer->NextActiveViews()) ++aViewsNb; - if ( aViewsNb < 2 ) { + if (aViewsNb < 2) { //clean up presentations before last view is closed myAISContext->RemoveAll(Standard_False); } @@ -415,83 +418,79 @@ void XGUI_Viewer::onViewClosed(QMdiSubWindow* theView) /*!Remove view window \a theView from view manager. *And close the last view, if it has \a theView. -*/ -void XGUI_Viewer::removeView( QMdiSubWindow* theView ) + */ +void XGUI_Viewer::removeView(QMdiSubWindow* theView) { - XGUI_ViewWindow* aWindow = static_cast(theView->widget()); - - aWindow->disconnect( this ); - myViews.removeAt( myViews.indexOf( theView ) ); - if ( myActiveView == theView ) - myActiveView = 0; - if ( myViews.size() == 0 ) - emit lastViewClosed(); -} + XGUI_ViewWindow* aWindow = static_cast(theView->widget()); + aWindow->disconnect(this); + myViews.removeAt(myViews.indexOf(theView)); + if (myActiveView == theView) + myActiveView = 0; + if (myViews.size() == 0) + emit lastViewClosed(); +} /*void XGUI_Viewer::onViewMapped() -{ - setTrihedronShown(true); -}*/ - + { + setTrihedronShown(true); + }*/ void XGUI_Viewer::addView(QMdiSubWindow* theView) { - XGUI_ViewWindow* aWindow = dynamic_cast(theView->widget()); + XGUI_ViewWindow* aWindow = dynamic_cast(theView->widget()); - connect(aWindow, SIGNAL(closed(QMdiSubWindow*)), - this, SLOT(onViewClosed(QMdiSubWindow*))); + connect(aWindow, SIGNAL(closed(QMdiSubWindow*)), this, SLOT(onViewClosed(QMdiSubWindow*))); - connect(aWindow, SIGNAL(tryClosing(XGUI_ViewWindow*)), - this, SIGNAL(tryCloseView(XGUI_ViewWindow*))); + connect(aWindow, SIGNAL(tryClosing(XGUI_ViewWindow*)), this, + SIGNAL(tryCloseView(XGUI_ViewWindow*))); - connect(aWindow, SIGNAL(mousePressed(XGUI_ViewWindow*, QMouseEvent*)), - this, SLOT(onMousePressed(XGUI_ViewWindow*, QMouseEvent*))); + connect(aWindow, SIGNAL(mousePressed(XGUI_ViewWindow*, QMouseEvent*)), this, + SLOT(onMousePressed(XGUI_ViewWindow*, QMouseEvent*))); - connect(aWindow, SIGNAL(mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*)), - this, SIGNAL(mouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*))); + connect(aWindow, SIGNAL(mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*)), this, + SIGNAL(mouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*))); - connect(aWindow, SIGNAL(mouseMoving(XGUI_ViewWindow*, QMouseEvent*)), - this, SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*))); + connect(aWindow, SIGNAL(mouseMoving(XGUI_ViewWindow*, QMouseEvent*)), this, + SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*))); - connect(aWindow, SIGNAL(keyPressed(XGUI_ViewWindow*, QKeyEvent*)), - this, SIGNAL(keyPress(XGUI_ViewWindow*, QKeyEvent*))); + connect(aWindow, SIGNAL(keyPressed(XGUI_ViewWindow*, QKeyEvent*)), this, + SIGNAL(keyPress(XGUI_ViewWindow*, QKeyEvent*))); - connect(aWindow, SIGNAL(keyReleased(XGUI_ViewWindow*, QKeyEvent*)), - this, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*))); + connect(aWindow, SIGNAL(keyReleased(XGUI_ViewWindow*, QKeyEvent*)), this, + SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*))); - //connect(aWindow, SIGNAL(contextMenuRequested( QContextMenuEvent* )), - // this, SLOT (onContextMenuRequested( QContextMenuEvent* ))); - connect(aWindow, SIGNAL( contextMenuRequested(QContextMenuEvent*) ), - this, SIGNAL( contextMenuRequested(QContextMenuEvent*) ) ); + //connect(aWindow, SIGNAL(contextMenuRequested( QContextMenuEvent* )), + // this, SLOT (onContextMenuRequested( QContextMenuEvent* ))); + connect(aWindow, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, + SIGNAL(contextMenuRequested(QContextMenuEvent*))); - connect(aWindow, SIGNAL(mouseMoving(XGUI_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseMove(XGUI_ViewWindow*, QMouseEvent*))); + connect(aWindow, SIGNAL(mouseMoving(XGUI_ViewWindow*, QMouseEvent*)), this, + SLOT(onMouseMove(XGUI_ViewWindow*, QMouseEvent*))); - connect(aWindow, SIGNAL(mouseReleased(XGUI_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseReleased(XGUI_ViewWindow*, QMouseEvent*))); + connect(aWindow, SIGNAL(mouseReleased(XGUI_ViewWindow*, QMouseEvent*)), this, + SLOT(onMouseReleased(XGUI_ViewWindow*, QMouseEvent*))); - myViews.append(theView); + myViews.append(theView); } /*! - Emit activated for view \a view. -*/ + Emit activated for view \a view. + */ void XGUI_Viewer::onWindowActivated(QMdiSubWindow* view) { if (view && (view != myActiveView) && (!view->isMinimized())) { myActiveView = view; - ((XGUI_ViewWindow*)myActiveView->widget())->windowActivated(); + ((XGUI_ViewWindow*) myActiveView->widget())->windowActivated(); QList::iterator aIt; for (aIt = myViews.begin(); aIt != myViews.end(); ++aIt) { if ((*aIt) != myActiveView) { - ((XGUI_ViewWindow*)(*aIt)->widget())->windowDeactivated(); + ((XGUI_ViewWindow*) (*aIt)->widget())->windowDeactivated(); } } } } - void XGUI_Viewer::onWindowMinimized(QMdiSubWindow* theWnd) { if (myActiveView == theWnd) { @@ -508,31 +507,34 @@ void XGUI_Viewer::onWindowMinimized(QMdiSubWindow* theWnd) } /*! - SLOT: called on mouse button press, stores current mouse position as start point for transformations -*/ + SLOT: called on mouse button press, stores current mouse position as start point for transformations + */ void XGUI_Viewer::onMousePressed(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent) { - myStartPnt.setX(theEvent->x()); myStartPnt.setY(theEvent->y()); + myStartPnt.setX(theEvent->x()); + myStartPnt.setY(theEvent->y()); emit mousePress(theWindow, theEvent); } /*! - SLOT: called on mouse move, processes hilighting -*/ + SLOT: called on mouse move, processes hilighting + */ void XGUI_Viewer::onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent) { - myCurPnt.setX(theEvent->x()); myCurPnt.setY(theEvent->y()); - if (!mySelectionEnabled) return; + myCurPnt.setX(theEvent->x()); + myCurPnt.setY(theEvent->y()); + if (!mySelectionEnabled) + return; Handle(V3d_View) aView3d = theWindow->viewPort()->getView(); - if ( !aView3d.IsNull() ) { + if (!aView3d.IsNull()) { myAISContext->MoveTo(theEvent->x(), theEvent->y(), aView3d); } } /*! - SLOT: called on mouse button release, finishes selection -*/ + SLOT: called on mouse button release, finishes selection + */ void XGUI_Viewer::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent) { if (!mySelectionEnabled || theEvent->button() != Qt::LeftButton) { @@ -540,16 +542,17 @@ void XGUI_Viewer::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEv return; } - myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y()); + myEndPnt.setX(theEvent->x()); + myEndPnt.setY(theEvent->y()); bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); - + //if (!aHasShift) // emit deselection(); if (myStartPnt == myEndPnt) { // the MoveTo is necessary for the second click in the same point. Otherwise the selection is lost. Handle(V3d_View) aView3d = theWindow->viewPort()->getView(); - if ( !aView3d.IsNull() ) { + if (!aView3d.IsNull()) { myAISContext->MoveTo(theEvent->x(), theEvent->y(), aView3d); } if (aHasShift && myMultiSelectionEnabled) @@ -558,21 +561,19 @@ void XGUI_Viewer::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEv myAISContext->Select(); } else { if (aHasShift && myMultiSelectionEnabled) - myAISContext->ShiftSelect(myStartPnt.x(), myStartPnt.y(), - myEndPnt.x(), myEndPnt.y(), - theWindow->viewPort()->getView(), false ); + myAISContext->ShiftSelect(myStartPnt.x(), myStartPnt.y(), myEndPnt.x(), myEndPnt.y(), + theWindow->viewPort()->getView(), false); else - myAISContext->Select(myStartPnt.x(), myStartPnt.y(), - myEndPnt.x(), myEndPnt.y(), - theWindow->viewPort()->getView(), false ); + myAISContext->Select(myStartPnt.x(), myStartPnt.y(), myEndPnt.x(), myEndPnt.y(), + theWindow->viewPort()->getView(), false); int Nb = myAISContext->NbSelected(); - if( Nb>1 && !myMultiSelectionEnabled ) { + if (Nb > 1 && !myMultiSelectionEnabled) { myAISContext->InitSelected(); Handle( SelectMgr_EntityOwner ) anOwner = myAISContext->SelectedOwner(); - if( !anOwner.IsNull() ) { - myAISContext->ClearSelected( Standard_False ); - myAISContext->AddOrRemoveSelected( anOwner, Standard_False ); + if (!anOwner.IsNull()) { + myAISContext->ClearSelected( Standard_False); + myAISContext->AddOrRemoveSelected(anOwner, Standard_False); } } @@ -583,23 +584,24 @@ void XGUI_Viewer::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEv } //****************************************************** -void XGUI_Viewer::setMultiSelectionEnabled(bool toEnable) -{ - myMultiSelectionEnabled = toEnable; +void XGUI_Viewer::setMultiSelectionEnabled(bool toEnable) +{ + myMultiSelectionEnabled = toEnable; updateViewsDrawMode(); } //****************************************************** -void XGUI_Viewer::setSelectionEnabled(bool toEnable) -{ - mySelectionEnabled = toEnable; +void XGUI_Viewer::setSelectionEnabled(bool toEnable) +{ + mySelectionEnabled = toEnable; updateViewsDrawMode(); } //****************************************************** void XGUI_Viewer::updateViewsDrawMode() const { - foreach(QMdiSubWindow* aWnd, myViews){ + foreach(QMdiSubWindow* aWnd, myViews) + { XGUI_ViewWindow* aView = static_cast(aWnd->widget()); aView->updateEnabledDrawMode(); } diff --git a/src/XGUI/XGUI_Viewer.h b/src/XGUI/XGUI_Viewer.h index 218fd26d0..2ae7cdd04 100644 --- a/src/XGUI/XGUI_Viewer.h +++ b/src/XGUI/XGUI_Viewer.h @@ -17,7 +17,6 @@ #include #include - class XGUI_MainWindow; class QMdiSubWindow; class XGUI_ViewWindow; @@ -31,10 +30,10 @@ class AIS_ListOfInteractive; * \brief Represents a 3d viewer. The viewer manages 3d scene and a set of view windows * when each of view window is a one point of view on this scene. */ -class XGUI_EXPORT XGUI_Viewer: public QObject +class XGUI_EXPORT XGUI_Viewer : public QObject { Q_OBJECT -public: + public: static QString backgroundData(QStringList&, QIntList&, QIntList&); XGUI_Viewer(XGUI_MainWindow* theParent, bool DisplayTrihedron = true); @@ -66,7 +65,7 @@ public: /// Return objects selected in 3D viewer /// \param theList - list to be filled with selected objects - void getSelectedObjects(AIS_ListOfInteractive& theList); + void getSelectedObjects(AIS_ListOfInteractive& theList); /// Return shapes selected in 3D viewer /// \param theList - list to be filled with selected shapes @@ -74,17 +73,23 @@ public: /// Selects objects in 3D viewer. Other selected objects are left as selected /// \param theList - list objects to be selected - void setObjectsSelected(const AIS_ListOfInteractive& theList); + void setObjectsSelected(const AIS_ListOfInteractive& theList); /// Returns true if selection in the viewer is enabled - bool isSelectionEnabled() const { return mySelectionEnabled; } + bool isSelectionEnabled() const + { + return mySelectionEnabled; + } /// Enable or disable selectioon in the viewer // \param toEnable - true or false (enable or disable selection) void setSelectionEnabled(bool toEnable); /// Returns true if multi-selection in the viewer is enabled - bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; } + bool isMultiSelectionEnabled() const + { + return myMultiSelectionEnabled; + } /// Enable or disable selectioon in the viewer // \param toEnable - true or false (enable or disable selection) @@ -92,7 +97,10 @@ public: /// Select the object in 3D viewer. /// \param theIO - list objects to be selected - void setSelected(const Handle(AIS_InteractiveObject)& theIO) { myAISContext->SetSelected(theIO); } + void setSelected(const Handle(AIS_InteractiveObject)& theIO) + { + myAISContext->SetSelected(theIO); + } //! Trihedron 3d object shown in the viewer Handle(AIS_Trihedron) trihedron() const @@ -126,7 +134,10 @@ public: bool computeTrihedronSize(double& theNewSize, double& theSize); //! Add action to the viewer - void addAction(QAction* theAction) { myActions.append(theAction); } + void addAction(QAction* theAction) + { + myActions.append(theAction); + } void updateFromResources(); @@ -160,18 +171,18 @@ signals: void contextMenuRequested(QContextMenuEvent*); -public slots: + public slots: void onWindowMinimized(QMdiSubWindow*); void onWindowActivated(QMdiSubWindow*); -private slots: + private slots: void onViewClosed(QMdiSubWindow*); void onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent); void onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent); void onMousePressed(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent); //void onContextMenuRequested(QContextMenuEvent* theEvent); -private: + private: void addView(QMdiSubWindow* theView); /*! Removes the View from internal Views list.*/ @@ -179,12 +190,10 @@ private: void updateViewsDrawMode() const; -private: + private: XGUI_MainWindow* myMainWindow; - Handle(V3d_Viewer) myV3dViewer; - Handle(AIS_Trihedron) myTrihedron; - Handle(AIS_InteractiveContext) myAISContext; + Handle(V3d_Viewer) myV3dViewer;Handle(AIS_Trihedron) myTrihedron;Handle(AIS_InteractiveContext) myAISContext; XGUI::InteractionStyle myInteractionStyle; @@ -194,7 +203,7 @@ private: bool myIsRelative; double myTrihedronSize; - + QList myViews; QMdiSubWindow* myActiveView; diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index 65c21fc58..ad1685d52 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -6,13 +6,12 @@ #include "XGUI_Viewer.h" #include "XGUI_SalomeConnector.h" - XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent) -: XGUI_SalomeViewer(theParent), myWorkshop(theParent) + : XGUI_SalomeViewer(theParent), + myWorkshop(theParent) { } - Handle(AIS_InteractiveContext) XGUI_ViewerProxy::AISContext() const { if (myWorkshop->isSalomeMode()) { @@ -37,18 +36,17 @@ Handle(V3d_View) XGUI_ViewerProxy::activeView() const return myWorkshop->salomeConnector()->viewer()->activeView(); } else { XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); - return (aViewer->activeViewWindow())? - aViewer->activeViewWindow()->viewPort()->getView(): - Handle(V3d_View)(); + return (aViewer->activeViewWindow()) ? aViewer->activeViewWindow()->viewPort()->getView() : + Handle(V3d_View)(); } } - + void XGUI_ViewerProxy::setViewProjection(double theX, double theY, double theZ) { Handle(V3d_View) aView3d = activeView(); - if ( !aView3d.IsNull() ) { + if (!aView3d.IsNull()) { aView3d->SetProj(theX, theY, theZ); - aView3d->FitAll( 0.01, true, true ); + aView3d->FitAll(0.01, true, true); aView3d->SetZSize(0.); } } @@ -57,8 +55,7 @@ void XGUI_ViewerProxy::fitAll() { if (myWorkshop->isSalomeMode()) { myWorkshop->salomeConnector()->viewer()->fitAll(); - } - else { + } else { XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); if (aViewer->activeViewWindow()) aViewer->activeViewWindow()->viewPort()->fitAll(); @@ -70,69 +67,54 @@ void XGUI_ViewerProxy::connectToViewer() if (myWorkshop->isSalomeMode()) { XGUI_SalomeViewer* aViewer = myWorkshop->salomeConnector()->viewer(); - connect(aViewer, SIGNAL(lastViewClosed()), - this, SIGNAL(lastViewClosed())); - connect(aViewer, SIGNAL(tryCloseView()), - this, SIGNAL(tryCloseView())); - connect(aViewer, SIGNAL(deleteView()), - this, SIGNAL(deleteView())); - connect(aViewer, SIGNAL(viewCreated()), - this, SIGNAL(viewCreated())); - connect(aViewer, SIGNAL(activated()), - this, SIGNAL(activated())); - - connect(aViewer, SIGNAL(mousePress(QMouseEvent*)), - this, SIGNAL(mousePress(QMouseEvent*))); - - connect(aViewer, SIGNAL(mouseRelease(QMouseEvent*)), - this, SIGNAL(mouseRelease(QMouseEvent*))); - - connect(aViewer, SIGNAL(mouseDoubleClick(QMouseEvent*)), - this, SIGNAL(mouseDoubleClick(QMouseEvent*))); - - connect(aViewer, SIGNAL(mouseMove(QMouseEvent*)), - this, SIGNAL(mouseMove(QMouseEvent*))); - - connect(aViewer, SIGNAL(keyPress(QKeyEvent*)), - this, SIGNAL(keyPress(QKeyEvent*))); - - connect(aViewer, SIGNAL(keyRelease(QKeyEvent*)), - this, SIGNAL(keyRelease(QKeyEvent*))); + connect(aViewer, SIGNAL(lastViewClosed()), this, SIGNAL(lastViewClosed())); + connect(aViewer, SIGNAL(tryCloseView()), this, SIGNAL(tryCloseView())); + connect(aViewer, SIGNAL(deleteView()), this, SIGNAL(deleteView())); + connect(aViewer, SIGNAL(viewCreated()), this, SIGNAL(viewCreated())); + connect(aViewer, SIGNAL(activated()), this, SIGNAL(activated())); + + connect(aViewer, SIGNAL(mousePress(QMouseEvent*)), this, SIGNAL(mousePress(QMouseEvent*))); + + connect(aViewer, SIGNAL(mouseRelease(QMouseEvent*)), this, SIGNAL(mouseRelease(QMouseEvent*))); + + connect(aViewer, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, + SIGNAL(mouseDoubleClick(QMouseEvent*))); + + connect(aViewer, SIGNAL(mouseMove(QMouseEvent*)), this, SIGNAL(mouseMove(QMouseEvent*))); + + connect(aViewer, SIGNAL(keyPress(QKeyEvent*)), this, SIGNAL(keyPress(QKeyEvent*))); + + connect(aViewer, SIGNAL(keyRelease(QKeyEvent*)), this, SIGNAL(keyRelease(QKeyEvent*))); connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); - connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), - this, SIGNAL(contextMenuRequested(QContextMenuEvent*))); + connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, + SIGNAL(contextMenuRequested(QContextMenuEvent*))); } else { XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer(); - connect(aViewer, SIGNAL(lastViewClosed()), - this, SIGNAL(lastViewClosed())); - connect(aViewer, SIGNAL(tryCloseView(XGUI_ViewWindow*)), - this, SIGNAL(tryCloseView())); - connect(aViewer, SIGNAL(deleteView(XGUI_ViewWindow*)), - this, SIGNAL(deleteView())); - connect(aViewer, SIGNAL(viewCreated(XGUI_ViewWindow*)), - this, SIGNAL(viewCreated())); - connect(aViewer, SIGNAL(activated(XGUI_ViewWindow*)), - this, SIGNAL(activated())); - - connect(aViewer, SIGNAL(mousePress(XGUI_ViewWindow*, QMouseEvent*)), - this, SLOT(onMousePress(XGUI_ViewWindow*, QMouseEvent*))); - connect(aViewer, SIGNAL(mouseRelease(XGUI_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseRelease(XGUI_ViewWindow*, QMouseEvent*))); - connect(aViewer, SIGNAL(mouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*))); - connect(aViewer, SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseMove(XGUI_ViewWindow*, QMouseEvent*))); - connect(aViewer, SIGNAL(keyPress(XGUI_ViewWindow*, QKeyEvent*)), - this, SLOT(onKeyPress(XGUI_ViewWindow*, QKeyEvent*))); - connect(aViewer, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*)), - this, SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*))); + connect(aViewer, SIGNAL(lastViewClosed()), this, SIGNAL(lastViewClosed())); + connect(aViewer, SIGNAL(tryCloseView(XGUI_ViewWindow*)), this, SIGNAL(tryCloseView())); + connect(aViewer, SIGNAL(deleteView(XGUI_ViewWindow*)), this, SIGNAL(deleteView())); + connect(aViewer, SIGNAL(viewCreated(XGUI_ViewWindow*)), this, SIGNAL(viewCreated())); + connect(aViewer, SIGNAL(activated(XGUI_ViewWindow*)), this, SIGNAL(activated())); + + connect(aViewer, SIGNAL(mousePress(XGUI_ViewWindow*, QMouseEvent*)), this, + SLOT(onMousePress(XGUI_ViewWindow*, QMouseEvent*))); + connect(aViewer, SIGNAL(mouseRelease(XGUI_ViewWindow*, QMouseEvent*)), this, + SLOT(onMouseRelease(XGUI_ViewWindow*, QMouseEvent*))); + connect(aViewer, SIGNAL(mouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*)), this, + SLOT(onMouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*))); + connect(aViewer, SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*)), this, + SLOT(onMouseMove(XGUI_ViewWindow*, QMouseEvent*))); + connect(aViewer, SIGNAL(keyPress(XGUI_ViewWindow*, QKeyEvent*)), this, + SLOT(onKeyPress(XGUI_ViewWindow*, QKeyEvent*))); + connect(aViewer, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*)), this, + SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*))); connect(aViewer, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); - connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), - this, SIGNAL(contextMenuRequested(QContextMenuEvent*))); + connect(aViewer, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, + SIGNAL(contextMenuRequested(QContextMenuEvent*))); } } diff --git a/src/XGUI/XGUI_ViewerProxy.h b/src/XGUI/XGUI_ViewerProxy.h index dfd632bda..6bc769cdd 100644 --- a/src/XGUI/XGUI_ViewerProxy.h +++ b/src/XGUI/XGUI_ViewerProxy.h @@ -8,15 +8,15 @@ class XGUI_Workshop; class XGUI_ViewWindow; /** -* Proxy class which repersents or XGUI_Viewer or Salome Viewer -* dependently on current launching environment. -* It is reccomennded to use this class in operation for accessing to viewer -* functionality instead of direct access to a viewer -*/ -class XGUI_EXPORT XGUI_ViewerProxy: public XGUI_SalomeViewer + * Proxy class which repersents or XGUI_Viewer or Salome Viewer + * dependently on current launching environment. + * It is reccomennded to use this class in operation for accessing to viewer + * functionality instead of direct access to a viewer + */ +class XGUI_EXPORT XGUI_ViewerProxy : public XGUI_SalomeViewer { - Q_OBJECT -public: +Q_OBJECT + public: XGUI_ViewerProxy(XGUI_Workshop* theParent); //! Returns AIS_InteractiveContext from current OCCViewer @@ -52,7 +52,7 @@ public: /// Connects to a viewer according to current environment void connectToViewer(); -private slots: + private slots: void onMousePress(XGUI_ViewWindow*, QMouseEvent*); void onMouseRelease(XGUI_ViewWindow*, QMouseEvent*); void onMouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*); @@ -60,7 +60,7 @@ private slots: void onKeyPress(XGUI_ViewWindow*, QKeyEvent*); void onKeyRelease(XGUI_ViewWindow*, QKeyEvent*); -private: + private: XGUI_Workshop* myWorkshop; }; diff --git a/src/XGUI/XGUI_Workbench.cpp b/src/XGUI/XGUI_Workbench.cpp index 36efadf9f..8826b335f 100644 --- a/src/XGUI/XGUI_Workbench.cpp +++ b/src/XGUI/XGUI_Workbench.cpp @@ -8,15 +8,15 @@ #define SCROLL_STEP 20 //************************************************** -class CommandsArea: public QScrollArea +class CommandsArea : public QScrollArea { -public: + public: CommandsArea(QWidget* theParent) : QScrollArea(theParent) { } -protected: + protected: virtual void resizeEvent(QResizeEvent * theEvent); }; @@ -84,7 +84,7 @@ XGUI_MenuGroupPanel* XGUI_Workbench::addGroup(const QString& theId) XGUI_MenuGroupPanel* aGroup = new XGUI_MenuGroupPanel(myChildWidget); aGroup->setObjectName(theId); myLayout->addWidget(aGroup); - if(theId != "Default") { + if (theId != "Default") { addSeparator(); } myLayout->addStretch(); @@ -188,7 +188,8 @@ XGUI_Command* XGUI_Workbench::feature(const QString& theId) const QList XGUI_Workbench::features() const { QList aList; - foreach (XGUI_MenuGroupPanel* aGroup, myGroups) { + foreach (XGUI_MenuGroupPanel* aGroup, myGroups) + { aList.append(aGroup->features()); } return aList; diff --git a/src/XGUI/XGUI_Workbench.h b/src/XGUI/XGUI_Workbench.h index 144a23a2d..7ede0b98f 100644 --- a/src/XGUI/XGUI_Workbench.h +++ b/src/XGUI/XGUI_Workbench.h @@ -13,10 +13,10 @@ class CommandsArea; class QHBoxLayout; class QPushButton; -class XGUI_EXPORT XGUI_Workbench: public QWidget +class XGUI_EXPORT XGUI_Workbench : public QWidget { Q_OBJECT -public: + public: XGUI_Workbench(QWidget* theParent); XGUI_MenuGroupPanel* addGroup(const QString& theId); @@ -28,16 +28,15 @@ public: //! Returns list of created commands QList features() const; -private slots: + private slots: void onLeftScroll(); void onRightScroll(); -protected: + protected: virtual void resizeEvent(QResizeEvent * theEvent); virtual bool eventFilter(QObject *theObj, QEvent *theEvent); - -private: + private: void addSeparator(); bool isExceedsLeft(); bool isExceedsRight(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 021ab16b1..ad35f6f81 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -81,15 +81,15 @@ QString XGUI_Workshop::featureIcon(const std::string& theId) } XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) - : QObject(), - myCurrentDir(QString()), - myModule(NULL), - mySalomeConnector(theConnector), - myPropertyPanel(0), - myObjectBrowser(0), - myDisplayer(0) + : QObject(), + myCurrentDir(QString()), + myModule(NULL), + mySalomeConnector(theConnector), + myPropertyPanel(0), + myObjectBrowser(0), + myDisplayer(0) { - myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow(); + myMainWindow = mySalomeConnector ? 0 : new XGUI_MainWindow(); myDisplayer = new XGUI_Displayer(this); @@ -100,20 +100,22 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) myActionsMgr = new XGUI_ActionsMgr(this); myErrorDlg = new XGUI_ErrorDialog(myMainWindow); myContextMenuMgr = new XGUI_ContextMenuMgr(this); - connect(myContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), - this, SLOT(onContextMenuCommand(const QString&, bool))); + connect(myContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this, + SLOT(onContextMenuCommand(const QString&, bool))); myViewerProxy = new XGUI_ViewerProxy(this); connect(myViewerProxy, SIGNAL(selectionChanged()), this, SLOT(updateCommandsOnViewSelection())); - + myModuleConnector = new XGUI_ModuleConnector(this); connect(myOperationMgr, SIGNAL(operationStarted()), SLOT(onOperationStarted())); connect(myOperationMgr, SIGNAL(operationResumed()), SLOT(onOperationStarted())); - connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), SLOT(onOperationStopped(ModuleBase_Operation*))); + connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), + SLOT(onOperationStopped(ModuleBase_Operation*))); connect(myMainWindow, SIGNAL(exitKeySequence()), SLOT(onExit())); connect(myOperationMgr, SIGNAL(operationStarted()), myActionsMgr, SLOT(update())); - connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), myActionsMgr, SLOT(update())); + connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), myActionsMgr, + SLOT(update())); connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&))); } @@ -128,7 +130,7 @@ void XGUI_Workshop::startApplication() initMenu(); //Initialize event listening Events_Loop* aLoop = Events_Loop::loop(); - aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors. + aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors. //TODO(sbh): Implement static method to extract event id [SEID] aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_LOADED)); // TODO Is it good to use non standard event within workshop? @@ -156,15 +158,14 @@ void XGUI_Workshop::initMenu() if (isSalomeMode()) { // Create only Undo, Redo commands - QAction* aAction = salomeConnector()->addEditCommand("UNDO_CMD", - tr("Undo"), tr("Undo last command"), - QIcon(":pictures/undo.png"), - QKeySequence::Undo, false); + QAction* aAction = salomeConnector()->addEditCommand("UNDO_CMD", tr("Undo"), + tr("Undo last command"), + QIcon(":pictures/undo.png"), + QKeySequence::Undo, false); connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onUndo())); - aAction = salomeConnector()->addEditCommand("REDO_CMD", - tr("Redo"), tr("Redo last command"), - QIcon(":pictures/redo.png"), - QKeySequence::Redo, false); + aAction = salomeConnector()->addEditCommand("REDO_CMD", tr("Redo"), tr("Redo last command"), + QIcon(":pictures/redo.png"), QKeySequence::Redo, + false); connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRedo())); salomeConnector()->addEditMenuSeparator(); return; @@ -230,8 +231,9 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) { //A message to start feature creation received. if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED)) { - const Config_FeatureMessage* aFeatureMsg = dynamic_cast(theMessage); - if(!aFeatureMsg->isInternal()) { + const Config_FeatureMessage* aFeatureMsg = + dynamic_cast(theMessage); + if (!aFeatureMsg->isInternal()) { addFeature(aFeatureMsg); } return; @@ -239,14 +241,16 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) // Process creation of Part if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) { - const ModelAPI_ObjectUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); + const ModelAPI_ObjectUpdatedMessage* aUpdMsg = + dynamic_cast(theMessage); onFeatureCreatedMsg(aUpdMsg); return; } // Redisplay feature if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) { - const ModelAPI_ObjectUpdatedMessage* aUpdMsg = dynamic_cast(theMessage); + const ModelAPI_ObjectUpdatedMessage* aUpdMsg = + dynamic_cast(theMessage); onFeatureRedisplayMsg(aUpdMsg); return; } @@ -270,17 +274,18 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) if (theMessage->eventID() == Events_LongOp::eventID()) { if (Events_LongOp::isPerformed()) QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - //QTimer::singleShot(10, this, SLOT(onStartWaiting())); - else + //QTimer::singleShot(10, this, SLOT(onStartWaiting())); + else QApplication::restoreOverrideCursor(); return; } //An operation passed by message. Start it, process and commit. if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) { - const Config_PointerMessage* aPartSetMsg = dynamic_cast(theMessage); + const Config_PointerMessage* aPartSetMsg = + dynamic_cast(theMessage); //myPropertyPanel->cleanContent(); - ModuleBase_Operation* anOperation = (ModuleBase_Operation*)aPartSetMsg->pointer(); + ModuleBase_Operation* anOperation = (ModuleBase_Operation*) aPartSetMsg->pointer(); if (myOperationMgr->startOperation(anOperation)) { myPropertyPanel->updateContentWidget(anOperation->feature()); @@ -310,16 +315,15 @@ void XGUI_Workshop::onStartWaiting() void XGUI_Workshop::onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg) { std::set aFeatures = theMsg->objects(); - if (myOperationMgr->hasOperation()) - { + if (myOperationMgr->hasOperation()) { FeaturePtr aCurrentFeature = myOperationMgr->currentOperation()->feature(); std::set::const_iterator aIt; for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) { ObjectPtr aNewFeature = (*aIt); - if(aNewFeature == aCurrentFeature) { + if (aNewFeature == aCurrentFeature) { myPropertyPanel->updateContentWidget(aCurrentFeature); break; - } + } } } myOperationMgr->validateCurrentOperation(); @@ -335,13 +339,13 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* t if (!aObj->data() || !aObj->data()->isValid()) myDisplayer->erase(aObj, false); else { - if (myDisplayer->isVisible(aObj)) // TODO VSV: Correction sketch drawing - myDisplayer->display(aObj, false); // In order to update presentation + if (myDisplayer->isVisible(aObj)) // TODO VSV: Correction sketch drawing + myDisplayer->display(aObj, false); // In order to update presentation else { - if(myOperationMgr->hasOperation()) { + if (myOperationMgr->hasOperation()) { ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); - if (aOperation->hasObject(aObj)) { // Display only current operation results - myDisplayer->display(aObj, false); + if (aOperation->hasObject(aObj)) { // Display only current operation results + myDisplayer->display(aObj, false); } } } @@ -362,11 +366,11 @@ void XGUI_Workshop::onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* the ResultPartPtr aPart = boost::dynamic_pointer_cast(*aIt); if (aPart) { aHasPart = true; - // If a feature is created from the aplication's python console - // it doesn't stored in the operation mgr and doesn't displayed - } else if(myOperationMgr->hasOperation()) { + // If a feature is created from the aplication's python console + // it doesn't stored in the operation mgr and doesn't displayed + } else if (myOperationMgr->hasOperation()) { ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); - if (aOperation->hasObject(*aIt)) { // Display only current operation results + if (aOperation->hasObject(*aIt)) { // Display only current operation results myDisplayer->display(*aIt, false); isDisplayed = true; } @@ -392,7 +396,7 @@ void XGUI_Workshop::onOperationStarted() { ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); - if(aOperation->getDescription()->hasXmlRepresentation()) { //!< No need for property panel + if (aOperation->getDescription()->hasXmlRepresentation()) { //!< No need for property panel connectWithOperation(aOperation); showPropertyPanel(); @@ -402,7 +406,7 @@ void XGUI_Workshop::onOperationStarted() myPropertyPanel->cleanContent(); aFactory.createWidget(myPropertyPanel->contentWidget()); - + QList aWidgets = aFactory.getModelWidgets(); QList::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end(); ModuleBase_ModelWidget* aWidget; @@ -410,12 +414,11 @@ void XGUI_Workshop::onOperationStarted() aWidget = *anIt; aWidget->setFeature(aOperation->feature()); //QObject::connect(aWidget, SIGNAL(valuesChanged()), aOperation, SLOT(storeCustomValue())); - QObject::connect(aWidget, SIGNAL(valuesChanged()), - this, SLOT(onWidgetValuesChanged())); + QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged())); // Init default values if (!aOperation->isEditOperation() && aWidget->hasDefaultValue()) { //aWidget->storeValue(aOperation->feature()); - + aWidget->storeValue(); } } @@ -455,12 +458,11 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage) bool isUsePropPanel = theMessage->isUseInput(); QString aFeatureId = QString::fromStdString(theMessage->id()); if (isSalomeMode()) { - QAction* aAction = salomeConnector()->addFeature(aWchName, - aFeatureId, - QString::fromStdString(theMessage->text()), - QString::fromStdString(theMessage->tooltip()), - QIcon(theMessage->icon().c_str()), - QKeySequence(), isUsePropPanel); + QAction* aAction = salomeConnector()->addFeature(aWchName, aFeatureId, + QString::fromStdString(theMessage->text()), + QString::fromStdString(theMessage->tooltip()), + QIcon(theMessage->icon().c_str()), + QKeySequence(), isUsePropPanel); salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" ")); myActionsMgr->addCommand(aAction); myModule->featureCreated(aAction); @@ -484,8 +486,8 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage) XGUI_Command* aCommand = aGroup->addFeature(aFeatureId, QString::fromStdString(theMessage->text()), QString::fromStdString(theMessage->tooltip()), - QIcon(theMessage->icon().c_str()), - aHotKey, isUsePropPanel); + QIcon(theMessage->icon().c_str()), aHotKey, + isUsePropPanel); aCommand->setNestedCommands(aNestedFeatures.split(" ", QString::SkipEmptyParts)); myActionsMgr->addCommand(aCommand); myModule->featureCreated(aCommand); @@ -528,14 +530,13 @@ void XGUI_Workshop::onExit() { PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); DocumentPtr aDoc = aMgr->rootDocument(); - if(aDoc->isModified()) { + if (aDoc->isModified()) { int anAnswer = QMessageBox::question( - myMainWindow, tr("Save current file"), - tr("The document is modified, save before exit?"), + myMainWindow, tr("Save current file"), tr("The document is modified, save before exit?"), QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel); - if(anAnswer == QMessageBox::Save) { + if (anAnswer == QMessageBox::Save) { bool saved = onSave(); - if(!saved) { + if (!saved) { return; } } else if (anAnswer == QMessageBox::Cancel) { @@ -571,13 +572,13 @@ void XGUI_Workshop::onOpen() //save current file before close if modified PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); DocumentPtr aDoc = aMgr->rootDocument(); - if(aDoc->isModified()) { + if (aDoc->isModified()) { //TODO(sbh): re-launch the app? int anAnswer = QMessageBox::question( myMainWindow, tr("Save current file"), tr("The document is modified, save before opening another?"), QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel); - if(anAnswer == QMessageBox::Save) { + if (anAnswer == QMessageBox::Save) { onSave(); } else if (anAnswer == QMessageBox::Cancel) { return; @@ -588,10 +589,10 @@ void XGUI_Workshop::onOpen() //show file dialog, check if readable and open myCurrentDir = QFileDialog::getExistingDirectory(mainWindow()); - if(myCurrentDir.isEmpty()) + if (myCurrentDir.isEmpty()) return; QFileInfo aFileInfo(myCurrentDir); - if(!aFileInfo.exists() || !aFileInfo.isReadable()) { + if (!aFileInfo.exists() || !aFileInfo.isReadable()) { QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file.")); myCurrentDir = ""; return; @@ -607,7 +608,7 @@ void XGUI_Workshop::onOpen() //****************************************************** bool XGUI_Workshop::onSave() { - if(myCurrentDir.isEmpty()) { + if (myCurrentDir.isEmpty()) { return onSaveAs(); } saveDocument(myCurrentDir); @@ -625,18 +626,19 @@ bool XGUI_Workshop::onSaveAs() dialog.setOptions(QFileDialog::HideNameFilterDetails | QFileDialog::ShowDirsOnly); dialog.setViewMode(QFileDialog::Detail); - if(!dialog.exec()) { + if (!dialog.exec()) { return false; } QString aTempDir = dialog.selectedFiles().first(); QDir aDir(aTempDir); - if(aDir.exists() && !aDir.entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries).isEmpty()) { - int answer = QMessageBox::question(myMainWindow, - //: Title of the dialog which asks user if he wants to save study in existing non-empty folder - tr("Save"), - tr("The folder already contains some files, save anyway?"), - QMessageBox::Save|QMessageBox::Cancel); - if(answer == QMessageBox::Cancel) { + if (aDir.exists() && !aDir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries).isEmpty()) { + int answer = QMessageBox::question( + myMainWindow, + //: Title of the dialog which asks user if he wants to save study in existing non-empty folder + tr("Save"), + tr("The folder already contains some files, save anyway?"), + QMessageBox::Save | QMessageBox::Cancel); + if (answer == QMessageBox::Cancel) { return false; } } @@ -675,13 +677,14 @@ void XGUI_Workshop::onPreferences() XGUI_Preferences::editPreferences(aModif); if (aModif.size() > 0) { QString aSection; - foreach (XGUI_Pref aPref, aModif) { + foreach (XGUI_Pref aPref, aModif) + { aSection = aPref.first; if (aSection == XGUI_Preferences::VIEWER_SECTION) { - if (!isSalomeMode()) + if (!isSalomeMode()) myMainWindow->viewer()->updateFromResources(); } else if (aSection == XGUI_Preferences::MENU_SECTION) { - if (!isSalomeMode()) + if (!isSalomeMode()) myMainWindow->menuObject()->updateFromResources(); } } @@ -691,11 +694,9 @@ void XGUI_Workshop::onPreferences() //****************************************************** ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule) { - QString libName = - QString::fromStdString(library(theModule.toStdString())); + QString libName = QString::fromStdString(library(theModule.toStdString())); if (libName.isEmpty()) { - qWarning( - qPrintable( tr( "Information about module \"%1\" doesn't exist." ).arg( theModule ) )); + qWarning(qPrintable(tr("Information about module \"%1\" doesn't exist.").arg(theModule))); return 0; } @@ -743,7 +744,7 @@ ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule) if (mainWindow()) { QMessageBox::warning(mainWindow(), tr("Error"), err); } else { - qWarning( qPrintable( err )); + qWarning(qPrintable(err)); } } return aModule; @@ -766,7 +767,7 @@ bool XGUI_Workshop::activateModule() void XGUI_Workshop::updateCommandStatus() { QList aCommands; - if (isSalomeMode()) { // update commands in SALOME mode + if (isSalomeMode()) { // update commands in SALOME mode aCommands = salomeConnector()->commandList(); } else { XGUI_MainMenu* aMenuBar = myMainWindow->menuObject(); @@ -777,26 +778,29 @@ void XGUI_Workshop::updateCommandStatus() if (aMgr->hasRootDocument()) { QAction* aUndoCmd; QAction* aRedoCmd; - foreach(QAction* aCmd, aCommands) { + foreach(QAction* aCmd, aCommands) + { QString aId = aCmd->data().toString(); if (aId == "UNDO_CMD") aUndoCmd = aCmd; else if (aId == "REDO_CMD") aRedoCmd = aCmd; - else // Enable all commands + else + // Enable all commands aCmd->setEnabled(true); } DocumentPtr aDoc = aMgr->rootDocument(); aUndoCmd->setEnabled(aDoc->canUndo()); aRedoCmd->setEnabled(aDoc->canRedo()); } else { - foreach(QAction* aCmd, aCommands) { + foreach(QAction* aCmd, aCommands) + { QString aId = aCmd->data().toString(); if (aId == "NEW_CMD") aCmd->setEnabled(true); else if (aId == "EXIT_CMD") aCmd->setEnabled(true); - else + else aCmd->setEnabled(false); } } @@ -807,11 +811,12 @@ void XGUI_Workshop::updateCommandStatus() QList XGUI_Workshop::getModuleCommands() const { QList aCommands; - if (isSalomeMode()) { // update commands in SALOME mode + if (isSalomeMode()) { // update commands in SALOME mode aCommands = salomeConnector()->commandList(); } else { XGUI_MainMenu* aMenuBar = myMainWindow->menuObject(); - foreach(XGUI_Command* aCmd, aMenuBar->features()) { + foreach(XGUI_Command* aCmd, aMenuBar->features()) + { aCommands.append(aCmd); } } @@ -824,9 +829,11 @@ QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent) QDockWidget* aObjDock = new QDockWidget(theParent); aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); aObjDock->setWindowTitle(tr("Object browser")); - aObjDock->setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }"); + aObjDock->setStyleSheet( + "::title { position: relative; padding-left: 5px; text-align: left center }"); myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock); - connect(myObjectBrowser, SIGNAL(activePartChanged(ObjectPtr)), this, SLOT(changeCurrentDocument(ObjectPtr))); + connect(myObjectBrowser, SIGNAL(activePartChanged(ObjectPtr)), this, + SLOT(changeCurrentDocument(ObjectPtr))); aObjDock->setWidget(myObjectBrowser); myContextMenuMgr->connectObjectBrowser(); @@ -840,13 +847,12 @@ QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent) */ void XGUI_Workshop::createDockWidgets() { - QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() : - myMainWindow; + QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow; QDockWidget* aObjDock = createObjectBrowser(aDesktop); aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock); myPropertyPanel = new XGUI_PropertyPanel(aDesktop); aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel); - hidePropertyPanel(); //tabifyDockWidget(aObjDock, myPropertyPanel); @@ -855,15 +861,15 @@ void XGUI_Workshop::createDockWidgets() QPushButton* aCancelBtn = myPropertyPanel->findChild(XGUI::PROP_PANEL_CANCEL); connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation())); - connect(myPropertyPanel, SIGNAL(keyReleased(const std::string&, QKeyEvent*)), - myOperationMgr, SLOT(onKeyReleased(const std::string&, QKeyEvent*))); + connect(myPropertyPanel, SIGNAL(keyReleased(const std::string&, QKeyEvent*)), myOperationMgr, + SLOT(onKeyReleased(const std::string&, QKeyEvent*))); - connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), - myOperationMgr, SLOT(onWidgetActivated(ModuleBase_ModelWidget*))); - connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), - myPropertyPanel, SLOT(onActivateNextWidget(ModuleBase_ModelWidget*))); - connect(myOperationMgr, SIGNAL(operationValidated(bool)), - myPropertyPanel, SLOT(setAcceptEnabled(bool))); + connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), myOperationMgr, + SLOT(onWidgetActivated(ModuleBase_ModelWidget*))); + connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), myPropertyPanel, + SLOT(onActivateNextWidget(ModuleBase_ModelWidget*))); + connect(myOperationMgr, SIGNAL(operationValidated(bool)), myPropertyPanel, + SLOT(setAcceptEnabled(bool))); } @@ -922,7 +928,7 @@ void XGUI_Workshop::changeCurrentDocument(ObjectPtr theObj) return; } } - } + } aMgr->setCurrentDocument(aMgr->rootDocument()); } @@ -932,11 +938,10 @@ void XGUI_Workshop::salomeViewerSelectionChanged() emit salomeViewerSelection(); } - //************************************************************** -XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const -{ - return mySalomeConnector->viewer(); +XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const +{ + return mySalomeConnector->viewer(); } //************************************************************** @@ -946,7 +951,7 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) if ((theId == "ACTIVATE_PART_CMD") && (aObjects.size() > 0)) { ResultPartPtr aPart = boost::dynamic_pointer_cast(aObjects.first()); activatePart(aPart); - } else if (theId == "DEACTIVATE_PART_CMD") + } else if (theId == "DEACTIVATE_PART_CMD") activatePart(ResultPartPtr()); else if (theId == "DELETE_CMD") deleteObjects(aObjects); @@ -970,7 +975,7 @@ void XGUI_Workshop::onWidgetValuesChanged() QList::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end(); for (; anIt != aLast; anIt++) { ModuleBase_ModelWidget* aCustom = *anIt; - if (aCustom && (/*!aCustom->isInitialized(aFeature) ||*/ aCustom == aSenderWidget)) { + if (aCustom && (/*!aCustom->isInitialized(aFeature) ||*/aCustom == aSenderWidget)) { //aCustom->storeValue(aFeature); aCustom->storeValue(); } @@ -999,15 +1004,16 @@ void XGUI_Workshop::activateLastPart() //************************************************************** void XGUI_Workshop::deleteObjects(const QList& theList) { - QMainWindow* aDesktop = isSalomeMode()? salomeConnector()->desktop() : myMainWindow; - QMessageBox::StandardButton aRes = QMessageBox::warning(aDesktop, tr("Delete features"), - tr("Seleted features will be deleted. Continue?"), - QMessageBox::No | QMessageBox::Yes, QMessageBox::No); + QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow; + QMessageBox::StandardButton aRes = QMessageBox::warning( + aDesktop, tr("Delete features"), tr("Seleted features will be deleted. Continue?"), + QMessageBox::No | QMessageBox::Yes, QMessageBox::No); // ToDo: definbe deleting method if (aRes == QMessageBox::Yes) { PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); aMgr->rootDocument()->startOperation(); - foreach (ObjectPtr aObj, theList) { + foreach (ObjectPtr aObj, theList) + { ResultPartPtr aPart = boost::dynamic_pointer_cast(aObj); if (aPart) { DocumentPtr aDoc = aPart->document(); @@ -1029,7 +1035,8 @@ void XGUI_Workshop::deleteObjects(const QList& theList) //************************************************************** void XGUI_Workshop::showObjects(const QList& theList, bool isVisible) { - foreach (ObjectPtr aObj, theList) { + foreach (ObjectPtr aObj, theList) + { ResultPtr aRes = boost::dynamic_pointer_cast(aObj); if (aRes) { if (isVisible) { @@ -1052,15 +1059,16 @@ void XGUI_Workshop::updateCommandsOnViewSelection() return; QList aActions = getModuleCommands(); - foreach(QAction* aAction, aActions) { + foreach(QAction* aAction, aActions) + { QString aId = aAction->data().toString(); std::list aValidators; aFactory->validators(aId.toStdString(), aValidators); std::list::iterator aValidator = aValidators.begin(); - for(; aValidator != aValidators.end(); aValidator++) { + for (; aValidator != aValidators.end(); aValidator++) { if (*aValidator) { - const ModuleBase_SelectionValidator* aSelValidator = - dynamic_cast(*aValidator); + const ModuleBase_SelectionValidator* aSelValidator = + dynamic_cast(*aValidator); if (aSelValidator) { aAction->setEnabled(aSelValidator->isValid(aSelection)); } @@ -1069,7 +1077,6 @@ void XGUI_Workshop::updateCommandsOnViewSelection() } } - //************************************************************** void XGUI_Workshop::registerValidators() const { @@ -1077,7 +1084,6 @@ void XGUI_Workshop::registerValidators() const ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); } - //************************************************************** void XGUI_Workshop::displayAllResults() { diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index f80b8cf7d..458b8a4c4 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -13,7 +13,6 @@ #include #include - class XGUI_MainWindow; class XGUI_Command; class XGUI_Workbench; @@ -47,10 +46,10 @@ class QAction; * \ingroup GUI * \brief Class which defines a configuration of the application (Workshop) and launches it. */ -class XGUI_EXPORT XGUI_Workshop: public QObject, public Events_Listener +class XGUI_EXPORT XGUI_Workshop : public QObject, public Events_Listener { Q_OBJECT -public: + public: XGUI_Workshop(XGUI_SalomeConnector* theConnector = 0); virtual ~XGUI_Workshop(); @@ -65,22 +64,41 @@ public: } //! Returns selection manager object - XGUI_SelectionMgr* selector() const { return mySelector; } + XGUI_SelectionMgr* selector() const + { + return mySelector; + } //! Returns displayer - XGUI_Displayer* displayer() const { return myDisplayer; } + XGUI_Displayer* displayer() const + { + return myDisplayer; + } //! ! Returns operation manager. - XGUI_OperationMgr* operationMgr() const { return myOperationMgr; } + XGUI_OperationMgr* operationMgr() const + { + return myOperationMgr; + } //! ! Returns an actions manager - XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; }; + XGUI_ActionsMgr* actionsMgr() const + { + return myActionsMgr; + } + ; //! Returns property panel widget - XGUI_PropertyPanel* propertyPanel() const { return myPropertyPanel; } + XGUI_PropertyPanel* propertyPanel() const + { + return myPropertyPanel; + } //! Returns context menu manager object - XGUI_ContextMenuMgr* contextMenuMgr() const { return myContextMenuMgr; } + XGUI_ContextMenuMgr* contextMenuMgr() const + { + return myContextMenuMgr; + } //! Creates and adds a new workbench (menu group) with the given name and returns it XGUI_Workbench* addWorkbench(const QString& theName); @@ -89,24 +107,39 @@ public: virtual void processEvent(const Events_Message* theMessage); //! Returns an object which provides interface to Salome Module (LightApp_Module) - XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; } + XGUI_SalomeConnector* salomeConnector() const + { + return mySalomeConnector; + } //! Provides an object which provides interface to Salome Viewer XGUI_SalomeViewer* salomeViewer() const; //! Returns true if the application works as SALOME module - bool isSalomeMode() const { return mySalomeConnector != 0; } + bool isSalomeMode() const + { + return mySalomeConnector != 0; + } //! Returns Object browser - XGUI_ObjectsBrowser* objectBrowser() const { return myObjectBrowser; } + XGUI_ObjectsBrowser* objectBrowser() const + { + return myObjectBrowser; + } void salomeViewerSelectionChanged(); - XGUI_ViewerProxy* viewer() const { return myViewerProxy; } + XGUI_ViewerProxy* viewer() const + { + return myViewerProxy; + } /// Returns the module connectory /// \returns the instance of connector - XGUI_ModuleConnector* moduleConnector() const { return myModuleConnector; } + XGUI_ModuleConnector* moduleConnector() const + { + return myModuleConnector; + } //! Returns icon name according to feature Id static QString featureIcon(const std::string& theId); @@ -121,13 +154,16 @@ public: //! Show the given features in 3d Viewer void showObjects(const QList& theList, bool isVisible); - ModuleBase_IModule* module() const { return myModule; } + ModuleBase_IModule* module() const + { + return myModule; + } signals: void salomeViewerSelection(); void errorOccurred(const QString&); -public slots: + public slots: void updateCommandStatus(); void updateCommandsOnViewSelection(); @@ -150,7 +186,7 @@ public slots: void activateLastPart(); -protected: + protected: //Event-loop processing methods: void addFeature(const Config_FeatureMessage*); void connectWithOperation(ModuleBase_Operation* theOperation); @@ -169,7 +205,7 @@ protected: void displayDocumentResults(DocumentPtr theDoc); void displayGroupResults(DocumentPtr theDoc, std::string theGroup); -protected slots: + 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(); @@ -184,12 +220,11 @@ protected slots: void onStartWaiting(); -private: + private: void initMenu(); void registerValidators() const; - ModuleBase_IModule* loadModule(const QString& theModule); bool activateModule(); @@ -205,7 +240,7 @@ private: XGUI_PropertyPanel* myPropertyPanel; XGUI_SelectionMgr* mySelector; XGUI_Displayer* myDisplayer; - XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations + XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations XGUI_ActionsMgr* myActionsMgr; XGUI_SalomeConnector* mySalomeConnector; XGUI_ErrorDialog* myErrorDlg;