-/*
- * Config_Common.cpp
- *
- * Created on: Apr 17, 2014
- * Author: sbh
- */
-
-#include "Config_Common.h"
-#include <Config_Keywords.h>
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include <sstream> //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<std::string>& 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;
-}
+/*\r
+ * Config_Common.cpp\r
+ *\r
+ * Created on: Apr 17, 2014\r
+ * Author: sbh\r
+ */\r
+\r
+#include "Config_Common.h"\r
+#include <Config_Keywords.h>\r
+\r
+#include <libxml/parser.h>\r
+#include <libxml/tree.h>\r
+\r
+#include <sstream> //for stringstream\r\r
+bool isElementNode(xmlNodePtr theNode)\r
+{\r
+ return theNode->type == XML_ELEMENT_NODE;\r
+}\r
+\r
+bool isNode(xmlNodePtr theNode, const char* theNodeName, ...)\r
+{\r
+ bool result = false;\r
+ const xmlChar* aName = theNode->name;\r
+ if (!aName || !isElementNode(theNode)) {\r
+ return false;\r
+ }\r
+ if (!xmlStrcmp(aName, (const xmlChar *) theNodeName)) {\r
+ return true;\r
+ }\r
+ va_list args; // define argument list variable\r
+ va_start(args, theNodeName); // init list; point to last defined argument\r
+ while (true) {\r
+ char *anArg = va_arg (args, char*); // get next argument\r
+ if (anArg == NULL)\r
+ break;\r
+ if (!xmlStrcmp(aName, (const xmlChar *) anArg)) {\r
+ va_end(args); // cleanup the system stack\r
+ return true;\r
+ }\r
+ }\r
+ va_end(args); // cleanup the system stack\r
+ return false;\r
+}\r
+\r
+bool hasChild(xmlNodePtr theNode)\r
+{\r
+ xmlNodePtr aNode = theNode->children;\r
+ for (; aNode; aNode = aNode->next) {\r
+ if (isElementNode(theNode)) {\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+}\r
+\r
+bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId,\r
+ std::list<std::string>& outValidatorParameters)\r
+{\r
+ //Validator id:\r
+ char* anIdProp = (char*) xmlGetProp(theNode, BAD_CAST _ID);\r
+ if (!anIdProp || anIdProp[0] == 0) {\r
+ return false;\r
+ }\r
+ outValidatorId = std::string(anIdProp);\r
+\r
+ //Validator parameters:\r
+ char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST VALIDATOR_PARAMETERS);\r
+ if (aParamProp && aParamProp[0] != 0) {\r
+ std::string aPropString = std::string(aParamProp);\r
+ std::stringstream aPropStringStream(aPropString);\r
+ char COMMA_DELIM = ',';\r
+ std::string aValidatorParameter;\r
+ while (std::getline(aPropStringStream, aValidatorParameter, ',')) {\r
+ outValidatorParameters.push_back(aValidatorParameter);\r
+ }\r
+ }\r
+ return true;\r
+}\r
+\r
+std::string library(const std::string& theLibName)\r
+{\r
+ std::string aLibName = theLibName;\r
+#ifndef WIN32\r
+ static std::string aLibExt( ".so" );\r
+ if (aLibName.size() < 3 || aLibName.substr(0, 3) !="lib") {\r
+ aLibName = "lib" + aLibName;\r
+ }\r
+#else\r
+ static std::string aLibExt(".dll");\r
+#endif\r
+ std::string anExt = aLibName.substr(aLibName.size() - 4);\r
+ if (anExt != aLibExt)\r
+ aLibName += aLibExt;\r
+\r
+ return aLibName;\r
+}\r
/*
*
*/
-CONFIG_EXPORT bool getValidatorInfo(xmlNodePtr theNode,
- std::string& outValidatorId,
+CONFIG_EXPORT bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId,
std::list<std::string>& outValidatorParameters);
/*!
* Example of the feature entry:\r
* <feature id="Part" text="New part" tooltip="Creates a new part" icon=":pictures/part_ico.png"/>\r
*/\r
-class Config_FeatureMessage: public Events_Message\r
+class Config_FeatureMessage : public Events_Message\r
{\r
std::string myId; //Feature unique id\r
- std::string myText; //Represents action's text\r
+ std::string myText; //Represents action's text\r
std::string myTooltip; //Represents action's tooltip\r
- std::string myIcon; //Represents action's icon\r
+ std::string myIcon; //Represents action's icon\r
std::string myKeysequence; //Represents action's key sequence\r
\r
std::string myGroupId; //Id of feature's group\r
std::string myWorkbenchId; //Id of feature's workbench\r
std::string myPluginLibrary; //Name of feature's library\r
\r
- bool myUseInput; //Action is being checked until user commit the operation\r
- bool myInternal; //Internal feature without GUI representation\r
+ bool myUseInput; //Action is being checked until user commit the operation\r
+ bool myInternal; //Internal feature without GUI representation\r
std::string myNestedFeatures;\r
\r
-public:\r
+ public:\r
//const Events_ID theID, const void* theSender = 0\r
- CONFIG_EXPORT Config_FeatureMessage(const Events_ID theId, const void* theParent = 0);\r
- CONFIG_EXPORT virtual ~Config_FeatureMessage();\r
+ CONFIG_EXPORT Config_FeatureMessage(const Events_ID theId, const void* theParent = 0);CONFIG_EXPORT virtual ~Config_FeatureMessage();\r
\r
//Auto-generated getters/setters\r
- CONFIG_EXPORT const std::string& icon() const;\r
- CONFIG_EXPORT const std::string& id() const;\r
- CONFIG_EXPORT const std::string& keysequence() const;\r
- CONFIG_EXPORT const std::string& text() const;\r
- CONFIG_EXPORT const std::string& tooltip() const;\r
+ CONFIG_EXPORT const std::string& icon() const;CONFIG_EXPORT const std::string& id() const;CONFIG_EXPORT const std::string& keysequence() const;CONFIG_EXPORT const std::string& text() const;CONFIG_EXPORT const std::string& tooltip() const;\r
\r
- CONFIG_EXPORT const std::string& groupId() const;\r
- CONFIG_EXPORT const std::string& workbenchId() const;\r
- CONFIG_EXPORT const std::string& pluginLibrary() const;\r
- CONFIG_EXPORT const std::string& nestedFeatures() const;\r
- CONFIG_EXPORT bool isUseInput() const;\r
- CONFIG_EXPORT bool isInternal() const;\r
+ CONFIG_EXPORT const std::string& groupId() const;CONFIG_EXPORT const std::string& workbenchId() const;CONFIG_EXPORT const std::string& pluginLibrary() const;CONFIG_EXPORT const std::string& nestedFeatures() const;CONFIG_EXPORT bool isUseInput() const;CONFIG_EXPORT bool isInternal() const;\r
\r
- CONFIG_EXPORT void setIcon(const std::string& icon);\r
- CONFIG_EXPORT void setId(const std::string& id);\r
- CONFIG_EXPORT void setKeysequence(const std::string& keysequence);\r
- CONFIG_EXPORT void setText(const std::string& text);\r
- CONFIG_EXPORT void setTooltip(const std::string& tooltip);\r
- CONFIG_EXPORT void setGroupId(const std::string& groupId);\r
- CONFIG_EXPORT void setWorkbenchId(const std::string& workbenchId);\r
- CONFIG_EXPORT void setPluginLibrary(const std::string& thePluginLibrary);\r
- CONFIG_EXPORT void setNestedFeatures(const std::string& theNestedFeatures);\r
- CONFIG_EXPORT void setUseInput(bool isUseInput);\r
- CONFIG_EXPORT void setInternal(bool isInternal);\r
+ CONFIG_EXPORT void setIcon(const std::string& icon);CONFIG_EXPORT void setId(\r
+ const std::string& id);CONFIG_EXPORT void setKeysequence(const std::string& keysequence);CONFIG_EXPORT void setText(\r
+ const std::string& text);CONFIG_EXPORT void setTooltip(const std::string& tooltip);CONFIG_EXPORT void setGroupId(\r
+ const std::string& groupId);CONFIG_EXPORT void setWorkbenchId(const std::string& workbenchId);CONFIG_EXPORT void setPluginLibrary(\r
+ const std::string& thePluginLibrary);CONFIG_EXPORT void setNestedFeatures(\r
+ const std::string& theNestedFeatures);CONFIG_EXPORT void setUseInput(bool isUseInput);CONFIG_EXPORT void setInternal(\r
+ bool isInternal);\r
};\r
\r
-#endif // CONFIG_MESSAGE_H\r
+#endif // CONFIG_MESSAGE_H\r
\ No newline at end of file
#include <iostream>
#endif
-
Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile,
const std::string& theLibraryName,
const char* theEventGenerated)
//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);
}
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);
bool isInternal = isInternalFeature(theNode);
outFeatureMessage.setInternal(isInternal);
- if(isInternal) {
+ if (isInternal) {
//Internal feature has no visual representation.
return;
}
{
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;
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<std::string> 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;
//toolbox/switch properties
const static char* CONTAINER_PAGE_NAME = "title";
-
/*
* Hardcoded xml entities of plugins.xml
*/
#endif
Config_ModuleReader::Config_ModuleReader(const char* theEventGenerated)
- : Config_XMLReader("plugins.xml"), myEventGenerated(theEventGenerated)
+ : Config_XMLReader("plugins.xml"),
+ myEventGenerated(theEventGenerated)
{
}
std::string aPluginLibrary = getProperty(theNode, PLUGIN_LIBRARY);
std::list<std::string> aFeatures = importPlugin(aPluginLibrary, aPluginConf);
std::list<std::string>::iterator it = aFeatures.begin();
- for(; it != aFeatures.end(); it++) {
+ for (; it != aFeatures.end(); it++) {
myFeaturesInFiles[*it] = aPluginConf;
}
}
std::list<std::string> 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<std::string>();
}
#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
#include <list>
#include <string>
-
-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<std::string, std::string>& featuresInFiles() const;
/// 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<std::string> importPlugin(const std::string& thePluginLibrary,
const std::string& thePluginFile);
-
-private:
+ private:
std::map<std::string, std::string> myFeaturesInFiles;
const char* myEventGenerated;
#include <Config_PointerMessage.h>
Config_PointerMessage::Config_PointerMessage(const Events_ID theId, const void* theParent)
- : Events_Message(theId, theParent), myPointer(0)
+ : Events_Message(theId, theParent),
+ myPointer(0)
{
}
/*
* 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;
};
/// 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;
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;
typedef std::list<Config_Prop*> Config_Properties;
-#endif
\ No newline at end of file
+#endif
#include "Config_PropManager.h"
-
-
std::vector<int> 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);
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) {
return NULL;
}
-
Config_Properties Config_PropManager::getProperties()
{
Config_Properties aRes;
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;
return theDefault;
}
-
-std::vector<int> Config_PropManager::color(const std::string& theSection,
+std::vector<int> Config_PropManager::color(const std::string& theSection,
const std::string& theName,
const std::string& theDefault)
{
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<int> stringToRGB(const std::string& theColor)
{
std::vector<int> aRes(3);
//! 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();
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<int> 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<int> 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
#include <Config_ValidatorMessage.h>
Config_ValidatorMessage::Config_ValidatorMessage(const Events_ID theId, const void* theParent)
-: Events_Message(theId, theParent)
+ : Events_Message(theId, theParent)
{
myValidatorId = "";
myFeatureId = "";
std::string myAttributeId;
std::list<std::string> 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<std::string>& 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<std::string>& 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<std::string>& parameters);
};
#endif /* Config_ValidatorMessage_H_ */
#include <libxml/parser.h>
#include <libxml/tree.h>
-
Config_WidgetAPI::Config_WidgetAPI(std::string theRawXml)
{
myDoc = xmlParseDoc(BAD_CAST theRawXml.c_str());
myCurrentNode = xmlDocGetRootElement(myDoc);
}
-
Config_WidgetAPI::~Config_WidgetAPI()
{
xmlFreeDoc(myDoc);
xmlNodePtr aNextNode = myCurrentNode;
do {
aNextNode = aNextNode->next;
- } while(aNextNode && !isElementNode(aNextNode));
+ } while (aNextNode && !isElementNode(aNextNode));
- if(!aNextNode) {
+ if (!aNextNode) {
toParentWidget();
return false;
}
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;
bool Config_WidgetAPI::toParentWidget()
{
- if(myCurrentNode) {
+ if (myCurrentNode) {
myCurrentNode = myCurrentNode->parent;
}
return myCurrentNode != NULL;
std::string Config_WidgetAPI::widgetType() const
{
std::string result = "";
- if(myCurrentNode) {
+ if (myCurrentNode) {
result = std::string((char *) myCurrentNode->name);
}
return result;
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
struct _xmlDoc;
//<<
-
class CONFIG_EXPORT Config_WidgetAPI
{
-public:
+ public:
Config_WidgetAPI(std::string theRawXml);
virtual ~Config_WidgetAPI();
std::string getProperty(const char* thePropName) const;
-private:
+ private:
xmlDocPtr myDoc;
xmlNodePtr myCurrentNode;
#include <iostream>
#endif
-
Config_WidgetReader::Config_WidgetReader(const std::string& theXmlFile)
: Config_XMLReader(theXmlFile)
return myDescriptionCache[theFeatureName];
}
-
void Config_WidgetReader::processNode(xmlNodePtr theNode)
{
if (isNode(theNode, NODE_FEATURE, NULL)) {
{
xmlNodePtr aNode = xmlFirstElementChild(theNode);
std::list<xmlNodePtr> 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();
}
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;
}
//Remove "SOURCE" node.
std::list<xmlNodePtr>::iterator it = aSourceNodes.begin();
- for(; it != aSourceNodes.end(); it++) {
+ for (; it != aSourceNodes.end(); it++) {
xmlUnlinkNode(*it);
xmlFreeNode(*it);
}
#include <map>
#include <string>
-
-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<std::string, std::string> myWidgetCache;
std::map<std::string, std::string> myDescriptionCache;
#include <libxml/tree.h>
/*
-#ifdef WIN32
-//For GetModuleFileNameW
-#include <windows.h>
-#endif
-*/
+ #ifdef WIN32
+ //For GetModuleFileNameW
+ #include <windows.h>
+ #endif
+ */
#ifdef _DEBUG
#include <iostream>
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);
}
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);
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));
*/
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);
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_ */
-#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\r
+#define CONFIG_H\r
+\r
+#if defined CONFIG_EXPORTS\r
+#if defined WIN32\r
+#define CONFIG_EXPORT __declspec( dllexport )\r
+#else\r
+#define CONFIG_EXPORT\r
+#endif\r
+#else\r
+#if defined WIN32\r
+#define CONFIG_EXPORT __declspec( dllimport )\r
+#else\r
+#define CONFIG_EXPORT\r
+#endif\r
+#endif\r
+\r
+#endif //CONFIG_H\r
\ No newline at end of file
// 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);
#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();
};
data()->addAttribute(POINT_ATTR_Z, ModelAPI_AttributeDouble::type());
}
-void ConstructionPlugin_Point::execute()
+void ConstructionPlugin_Point::execute()
{
- boost::shared_ptr<GeomAPI_Pnt> aPnt(new GeomAPI_Pnt(
- data()->real(POINT_ATTR_X)->value(),
- data()->real(POINT_ATTR_Y)->value(),
- data()->real(POINT_ATTR_Z)->value()));
+ boost::shared_ptr<GeomAPI_Pnt> aPnt(
+ new GeomAPI_Pnt(data()->real(POINT_ATTR_X)->value(), data()->real(POINT_ATTR_Y)->value(),
+ data()->real(POINT_ATTR_Z)->value()));
boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
aConstr->setShape(GeomAlgoAPI_PointBuilder::point(aPnt));
* \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();
#include <Events_Loop.h>
Events_Error::Events_Error(char* theDescription, const void* theSender)
- : Events_Message(Events_Error::errorID(), theSender)
+ : Events_Message(Events_Error::errorID(), theSender)
{
myDescription = theDescription;
}
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);
}
#include <string>
-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();
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);
};
* 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;
};
std::map<void*, int> MY_SENDERS;
Events_LongOp::Events_LongOp(void* theSender)
- : Events_Message(Events_LongOp::eventID(), theSender)
+ : Events_Message(Events_LongOp::eventID(), 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) {
{
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);
* 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();
/// 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);
};
char* aResult;
string aName(theName);
map<string, char*>::iterator aFound = CREATED_EVENTS.find(aName);
- if (aFound == CREATED_EVENTS.end()) { //not created yet
- aResult = strdup(theName); // copy to make unique internal pointer
+ 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;
if (isGroup) {
Events_MessageGroup* aGroup = dynamic_cast<Events_MessageGroup*>(&theMessage);
if (aGroup) {
- std::map<char*, Events_MessageGroup*>::iterator aMyGroup =
- myGroups.find(aGroup->eventID().eventText());
- if (aMyGroup == myGroups.end()) { // create a new group of messages for accumulation
+ std::map<char*, Events_MessageGroup*>::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());
}
theMessage.sender());
if (aFindSender != aFindID->second.end()) {
list<Events_Listener*>& aListeners = aFindSender->second;
- for(list<Events_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
+ for (list<Events_Listener*>::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<Events_Listener*>& aListeners = aFindSender->second;
- for(list<Events_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
+ for (list<Events_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
(*aL)->processEvent(&theMessage);
}
}
}
void Events_Loop::registerListener(Events_Listener* theListener, const Events_ID theID,
- void* theSender)
+ void* theSender)
{
map<char*, map<void*, list<Events_Listener*> > >::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<void*, list<Events_Listener*> >();
aFindID = myListeners.find(theID.eventText());
}
map<void*, list<Events_Listener*> >::iterator aFindSender = aFindID->second.find(theSender);
- if (aFindSender == aFindID->second.end()) { // create container associated with sender
+ if (aFindSender == aFindID->second.end()) { // create container associated with sender
aFindID->second[theSender] = list<Events_Listener*>();
aFindSender = aFindID->second.find(theSender);
}
// check that listener was not registered wit hsuch parameters before
list<Events_Listener*>& aListeners = aFindSender->second;
- for(list<Events_Listener*>::iterator aL = aListeners.begin(); aL != aListeners.end(); aL++)
+ for (list<Events_Listener*>::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<char*, Events_MessageGroup*>::iterator aMyGroup =
- myGroups.find(theID.eventText());
- if (aMyGroup != myGroups.end()) { // really sends
+ std::map<char*, Events_MessageGroup*>::iterator aMyGroup = myGroups.find(theID.eventText());
+ if (aMyGroup != myGroups.end()) { // really sends
Events_MessageGroup* aGroup = aMyGroup->second;
myGroups.erase(aMyGroup);
send(*aGroup, false);
* 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<char*, std::map<void*, std::list<Events_Listener*> > >
- myListeners;
+ std::map<char*, std::map<void*, std::list<Events_Listener*> > > myListeners;
/// map from event ID to groupped messages (accumulated on flush)
std::map<char*, Events_MessageGroup*> 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
//! 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);
* 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
* \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
* 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;
void FeaturesPlugin_Extrusion::execute()
{
- boost::shared_ptr<ModelAPI_AttributeReference> aFaceRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
+ boost::shared_ptr<ModelAPI_AttributeReference> aFaceRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeReference>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
if (!aFaceRef)
return;
- boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
- boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aFaceRef->value());
- if (!aConstr)
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = boost::dynamic_pointer_cast<
+ ModelAPI_ResultConstruction>(aFaceRef->value());
+ if (!aConstr)
return;
boost::shared_ptr<GeomAPI_Shape> aFace = aConstr->shape();
if (!aFace)
#include "FeaturesPlugin.h"
#include <ModelAPI_Feature.h>
-class FeaturesPlugin_Extrusion: public ModelAPI_Feature
+class FeaturesPlugin_Extrusion : public ModelAPI_Feature
{
-public:
+ public:
/// Extrusion kind
inline static const std::string& ID()
{
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");
}
/// 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();
// 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);
#ifndef FeaturesPlugin_Plugin_H_
#define FeaturesPlugin_Plugin_H_
-
#include "FeaturesPlugin.h"
#include <ModelAPI_Plugin.h>
#include <ModelAPI_Feature.h>
-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();
};
#include <AIS_RadiusDimension.hxx>
#include <AIS_Shape.hxx>
-
-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;
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<GeomAPI_Shape> theShape)
{
- const TopoDS_Shape& aTDS = (theShape && theShape->implPtr<TopoDS_Shape>()) ?
- theShape->impl<TopoDS_Shape>() : TopoDS_Shape();
+ const TopoDS_Shape& aTDS =
+ (theShape && theShape->implPtr<TopoDS_Shape>()) ?
+ theShape->impl<TopoDS_Shape>() : TopoDS_Shape();
Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
- 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
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<GeomAPI_Pnt> theStartPoint,
boost::shared_ptr<GeomAPI_Pnt> theEndPoint,
boost::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
- boost::shared_ptr<GeomAPI_Pln> thePlane,
- double theDistance)
+ boost::shared_ptr<GeomAPI_Pln> thePlane, double theDistance)
{
double aFlyout = 0;
- if (theFlyoutPoint)
- {
- boost::shared_ptr<GeomAPI_Lin> aLine =
- boost::shared_ptr<GeomAPI_Lin>(new GeomAPI_Lin(theStartPoint, theEndPoint));
+ if (theFlyoutPoint) {
+ boost::shared_ptr<GeomAPI_Lin> aLine = boost::shared_ptr<GeomAPI_Lin>(
+ new GeomAPI_Lin(theStartPoint, theEndPoint));
double aDist = aLine->distance(theFlyoutPoint);
boost::shared_ptr<GeomAPI_XYZ> aLineDir = theEndPoint->xyz()->decreased(theStartPoint->xyz());
- boost::shared_ptr<GeomAPI_XYZ> aFOutDir = theFlyoutPoint->xyz()->decreased(theStartPoint->xyz());
+ boost::shared_ptr<GeomAPI_XYZ> aFOutDir = theFlyoutPoint->xyz()->decreased(
+ theStartPoint->xyz());
boost::shared_ptr<GeomAPI_XYZ> aNorm = thePlane->direction()->xyz();
if (aLineDir->cross(aFOutDir)->dot(aNorm) < 0)
aDist = -aDist;
}
Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
- if (anAIS.IsNull())
- {
- Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension(
- theStartPoint->impl<gp_Pnt>(), theEndPoint->impl<gp_Pnt>(), thePlane->impl<gp_Pln>());
+ if (anAIS.IsNull()) {
+ Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension(theStartPoint->impl<gp_Pnt>(),
+ theEndPoint->impl<gp_Pnt>(),
+ thePlane->impl<gp_Pln>());
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);
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<gp_Pnt>(), theEndPoint->impl<gp_Pnt>(),
+ aDimAIS->SetMeasuredGeometry(theStartPoint->impl<gp_Pnt>(), theEndPoint->impl<gp_Pnt>(),
thePlane->impl<gp_Pln>());
aDimAIS->SetCustomValue(theDistance);
aDimAIS->SetFlyout(aFlyout);
}
void GeomAPI_AISObject::createRadius(boost::shared_ptr<GeomAPI_Circ> theCircle,
- boost::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
- double theRadius)
+ boost::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
+ double theRadius)
{
boost::shared_ptr<GeomAPI_Pnt> aCenter = theCircle->center();
anAnchor->setZ(anAnchor->z() + aDelta * aDeltaDir->z());
Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
- if (anAIS.IsNull())
- {
- Handle(AIS_RadiusDimension) aDimAIS =
- new AIS_RadiusDimension(theCircle->impl<gp_Circ>(), anAnchor->impl<gp_Pnt>());
+ if (anAIS.IsNull()) {
+ Handle(AIS_RadiusDimension) aDimAIS = new AIS_RadiusDimension(theCircle->impl<gp_Circ>(),
+ anAnchor->impl<gp_Pnt>());
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<gp_Circ>(), anAnchor->impl<gp_Pnt>());
aDimAIS->SetCustomValue(theRadius);
aDimAIS->Redisplay(Standard_True);
void GeomAPI_AISObject::createParallel(boost::shared_ptr<GeomAPI_Shape> theLine1,
boost::shared_ptr<GeomAPI_Shape> theLine2,
- boost::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
- boost::shared_ptr<GeomAPI_Pln> thePlane)
+ boost::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
+ boost::shared_ptr<GeomAPI_Pln> thePlane)
{
Handle(Geom_Plane) aPlane = new Geom_Plane(thePlane->impl<gp_Pln>());
Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
- if (anAIS.IsNull())
- {
- Handle(AIS_ParallelRelation) aParallel =
- new AIS_ParallelRelation(theLine1->impl<TopoDS_Shape>(), theLine2->impl<TopoDS_Shape>(), aPlane);
+ if (anAIS.IsNull()) {
+ Handle(AIS_ParallelRelation) aParallel = new AIS_ParallelRelation(
+ theLine1->impl<TopoDS_Shape>(), theLine2->impl<TopoDS_Shape>(), aPlane);
if (theFlyoutPoint)
aParallel->SetPosition(theFlyoutPoint->impl<gp_Pnt>());
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<TopoDS_Shape>());
aParallel->SetSecondShape(theLine2->impl<TopoDS_Shape>());
aParallel->SetPlane(aPlane);
void GeomAPI_AISObject::createPerpendicular(boost::shared_ptr<GeomAPI_Shape> theLine1,
boost::shared_ptr<GeomAPI_Shape> theLine2,
- boost::shared_ptr<GeomAPI_Pln> thePlane)
+ boost::shared_ptr<GeomAPI_Pln> thePlane)
{
Handle(Geom_Plane) aPlane = new Geom_Plane(thePlane->impl<gp_Pln>());
Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
- if (anAIS.IsNull())
- {
- Handle(AIS_PerpendicularRelation) aPerpendicular =
- new AIS_PerpendicularRelation(theLine1->impl<TopoDS_Shape>(), theLine2->impl<TopoDS_Shape>(), aPlane);
+ if (anAIS.IsNull()) {
+ Handle(AIS_PerpendicularRelation) aPerpendicular = new AIS_PerpendicularRelation(
+ theLine1->impl<TopoDS_Shape>(), theLine2->impl<TopoDS_Shape>(), 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<TopoDS_Shape>());
aPerpendicular->SetSecondShape(theLine2->impl<TopoDS_Shape>());
aPerpendicular->SetPlane(aPlane);
}
}
-
void GeomAPI_AISObject::setColor(const int& theColor)
{
Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
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()) {
{
Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
if (anAIS.IsNull())
- return ;
+ return;
anAIS->SetWidth(theWidth);
}
{
Handle(AIS_InteractiveObject) anAIS = impl<Handle(AIS_InteractiveObject)>();
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()) {
bool GeomAPI_AISObject::empty() const
{
- Handle(AIS_InteractiveObject) anAIS =
- const_cast<GeomAPI_AISObject*>(this)->impl<Handle(AIS_InteractiveObject)>();
+ Handle(AIS_InteractiveObject) anAIS = const_cast<GeomAPI_AISObject*>(this)
+ ->impl<Handle(AIS_InteractiveObject)>();
if (anAIS.IsNull())
return true;
return false;
class GEOMAPI_EXPORT GeomAPI_AISObject : public GeomAPI_Interface
{
-public:
+ public:
/// \brief Creation of empty AIS object
GeomAPI_AISObject();
void createDistance(boost::shared_ptr<GeomAPI_Pnt> theStartPoint,
boost::shared_ptr<GeomAPI_Pnt> theEndPoint,
boost::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
- boost::shared_ptr<GeomAPI_Pln> thePlane,
- double theDistance);
+ boost::shared_ptr<GeomAPI_Pln> thePlane, double theDistance);
/** \brief Creates AIS_RadiusDimension object
* \param[in] theCircle the radius is created for this circle
* \param[in] theRadius value of the radius to be shown
*/
void createRadius(boost::shared_ptr<GeomAPI_Circ> theCircle,
- boost::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
- double theRadius);
+ boost::shared_ptr<GeomAPI_Pnt> theFlyoutPoint, double theRadius);
/** \brief Creates AIS_ParallelRelation object for two lines
* \param[in] theLine1 first parallel line
*/
void createParallel(boost::shared_ptr<GeomAPI_Shape> theLine1,
boost::shared_ptr<GeomAPI_Shape> theLine2,
- boost::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
- boost::shared_ptr<GeomAPI_Pln> thePlane);
+ boost::shared_ptr<GeomAPI_Pnt> theFlyoutPoint,
+ boost::shared_ptr<GeomAPI_Pln> thePlane);
/** \brief Creates AIS_PerpendicularRelation object for two lines
* \param[in] theLine1 first parallel line
*/
void createPerpendicular(boost::shared_ptr<GeomAPI_Shape> theLine1,
boost::shared_ptr<GeomAPI_Shape> theLine2,
- boost::shared_ptr<GeomAPI_Pln> thePlane);
+ boost::shared_ptr<GeomAPI_Pln> thePlane);
/** \brief Assigns the color for the shape
* \param[in] theColor index of the color
#define MY_CIRC static_cast<gp_Circ*>(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<GeomAPI_Pnt>& theCenter,
- const boost::shared_ptr<GeomAPI_Dir>& theDir,
- double theRadius)
- : GeomAPI_Interface(newCirc(theCenter->impl<gp_Pnt>(),
- theDir->impl<gp_Dir>(), theRadius))
+ const boost::shared_ptr<GeomAPI_Dir>& theDir, double theRadius)
+ : GeomAPI_Interface(newCirc(theCenter->impl<gp_Pnt>(), theDir->impl<gp_Dir>(), theRadius))
{
}
-const boost::shared_ptr<GeomAPI_Pnt> GeomAPI_Circ::project(const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const
+const boost::shared_ptr<GeomAPI_Pnt> GeomAPI_Circ::project(
+ const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const
{
boost::shared_ptr<GeomAPI_Pnt> aResult;
if (!MY_CIRC)
- return aResult;
+ return aResult;
Handle(Geom_Circle) aCircle = new Geom_Circle(*MY_CIRC);
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<GeomAPI_Pnt>(
- new GeomAPI_Pnt(aNewPoint.X(), aNewPoint.Y(), aNewPoint.Z()));
+ new GeomAPI_Pnt(aNewPoint.X(), aNewPoint.Y(), aNewPoint.Z()));
}
}
}
* \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<GeomAPI_Pnt>& theCenter,
- const boost::shared_ptr<GeomAPI_Dir>& theDir,
- double theRadius);
+ const boost::shared_ptr<GeomAPI_Dir>& theDir, double theRadius);
/// Return center of the circle
const boost::shared_ptr<GeomAPI_Pnt> center() const;
double radius() const;
/// Project point on circle
- const boost::shared_ptr<GeomAPI_Pnt> project(const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const;
+ const boost::shared_ptr<GeomAPI_Pnt> project(
+ const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const;
};
#endif
#define MY_CIRC2D static_cast<gp_Circ2d*>(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);
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<GeomAPI_Pnt2d>& theCenter,
const boost::shared_ptr<GeomAPI_Pnt2d>& 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<GeomAPI_Pnt2d>& theCenter,
- const boost::shared_ptr<GeomAPI_Dir2d>& theDir,
- double theRadius)
- : GeomAPI_Interface(newCirc2d(theCenter->x(), theCenter->y(),
- theDir->impl<gp_Dir2d>(), theRadius))
+ const boost::shared_ptr<GeomAPI_Dir2d>& theDir, double theRadius)
+ : GeomAPI_Interface(
+ newCirc2d(theCenter->x(), theCenter->y(), theDir->impl<gp_Dir2d>(), theRadius))
{
}
-const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Circ2d::project(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) const
+const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Circ2d::project(
+ const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) const
{
boost::shared_ptr<GeomAPI_Pnt2d> 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<gp_Pnt2d>();
* \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<GeomAPI_Pnt2d>& theCenter,
const boost::shared_ptr<GeomAPI_Pnt2d>& theCirclePoint);
/// Creation of circle defined by center point, direction and circle radius
GeomAPI_Circ2d(const boost::shared_ptr<GeomAPI_Pnt2d>& theCenter,
- const boost::shared_ptr<GeomAPI_Dir2d>& theDir,
- double theRadius);
+ const boost::shared_ptr<GeomAPI_Dir2d>& theDir, double theRadius);
/// Return center of the circle
const boost::shared_ptr<GeomAPI_Pnt2d> center() const;
double radius() const;
/// Project point on line
- const boost::shared_ptr<GeomAPI_Pnt2d> project(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) const;
+ const boost::shared_ptr<GeomAPI_Pnt2d> project(
+ const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) const;
};
#endif
#define MY_DIR static_cast<gp_Dir*>(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<GeomAPI_XYZ>& 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
{
return MY_DIR->Z();
}
-const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_Dir::xyz()
+const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_Dir::xyz()
{
return boost::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(MY_DIR->X(), MY_DIR->Y(), MY_DIR->Z()));
}
return MY_DIR->Dot(theArg->impl<gp_Dir>());
}
-const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_Dir::cross(const boost::shared_ptr<GeomAPI_Dir>& theArg) const
+const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_Dir::cross(
+ const boost::shared_ptr<GeomAPI_Dir>& theArg) const
{
gp_XYZ aResult = MY_DIR->XYZ().Crossed(theArg->impl<gp_Dir>().XYZ());
return boost::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(aResult.X(), aResult.Y(), aResult.Z()));
* \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
#define MY_DIR static_cast<gp_Dir2d*>(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<GeomAPI_XY>& theCoords)
- : GeomAPI_Interface(new gp_Dir2d(theCoords->x(), theCoords->y()))
-{}
+ : GeomAPI_Interface(new gp_Dir2d(theCoords->x(), theCoords->y()))
+{
+}
double GeomAPI_Dir2d::x() const
{
return MY_DIR->Y();
}
-const boost::shared_ptr<GeomAPI_XY> GeomAPI_Dir2d::xy()
+const boost::shared_ptr<GeomAPI_XY> GeomAPI_Dir2d::xy()
{
return boost::shared_ptr<GeomAPI_XY>(new GeomAPI_XY(MY_DIR->X(), MY_DIR->Y()));
}
* \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
#include <Geom_Circle.hxx>
GeomAPI_Edge::GeomAPI_Edge()
- : GeomAPI_Shape()
-{}
+ : GeomAPI_Shape()
+{
+}
bool GeomAPI_Edge::isLine() const
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
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;
const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
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;
const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
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;
* \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;
#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;
};
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<class T> inline T* implPtr() {return static_cast<T*>(myImpl);}
+ template<class T> inline T* implPtr()
+ {
+ return static_cast<T*>(myImpl);
+ }
/// Returns the reference object of the impl
- template<class T> inline const T& impl() {return *(static_cast<T*>(myImpl));}
+ template<class T> inline const T& impl()
+ {
+ return *(static_cast<T*>(myImpl));
+ }
/// Updates the impl (deletes the old one)
void setImpl(void* theImpl);
};
#define MY_LIN static_cast<gp_Lin*>(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<GeomAPI_Pnt>& theStart,
const boost::shared_ptr<GeomAPI_Pnt>& 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<GeomAPI_Pnt>& thePoint) const
{
}
const boost::shared_ptr<GeomAPI_Pnt> GeomAPI_Lin::intersect(
- const boost::shared_ptr<GeomAPI_Lin>& theLine) const
+ const boost::shared_ptr<GeomAPI_Lin>& theLine) const
{
if (MY_LIN->SquareDistance(theLine->impl<gp_Lin>()) > Precision::Confusion())
- return boost::shared_ptr<GeomAPI_Pnt>();
+ return boost::shared_ptr<GeomAPI_Pnt>();
const gp_Dir& aDir1 = MY_LIN->Direction();
const gp_Dir& aDir2 = theLine->impl<gp_Lin>().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<gp_Lin>());
IntAna2d_AnaIntersection anInter(aPrjLine1, aPrjLine1);
if (!anInter.IsDone() || anInter.IsEmpty())
- return boost::shared_ptr<GeomAPI_Pnt>();
+ return boost::shared_ptr<GeomAPI_Pnt>();
const gp_Pnt2d& anIntPnt2d = anInter.Point(0).Value();
gp_Pnt aResult = ElSLib::Value(anIntPnt2d.X(), anIntPnt2d.Y(), aPlane);
return boost::shared_ptr<GeomAPI_Pnt>(
- new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z()));
+ new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z()));
}
-const boost::shared_ptr<GeomAPI_Pnt> GeomAPI_Lin::project(const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const
+const boost::shared_ptr<GeomAPI_Pnt> GeomAPI_Lin::project(
+ const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const
{
const gp_XYZ& aDir = MY_LIN->Direction().XYZ();
const gp_XYZ& aLoc = MY_LIN->Location().XYZ();
* \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<GeomAPI_Pnt>& theStart,
const boost::shared_ptr<GeomAPI_Pnt>& theEnd);
/// Distance between two points
double distance(const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const;
/// Intersection of two lines
- const boost::shared_ptr<GeomAPI_Pnt> intersect(const boost::shared_ptr<GeomAPI_Lin>& theLine) const;
+ const boost::shared_ptr<GeomAPI_Pnt> intersect(
+ const boost::shared_ptr<GeomAPI_Lin>& theLine) const;
/// Project point on line
- const boost::shared_ptr<GeomAPI_Pnt> project(const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const;
+ const boost::shared_ptr<GeomAPI_Pnt> project(
+ const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const;
};
#endif
#define MY_LIN2D static_cast<gp_Lin2d*>(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<GeomAPI_Pnt2d>& theStart,
- const boost::shared_ptr<GeomAPI_Pnt2d>& theEnd)
- : GeomAPI_Interface(newLine2d(theStart->x(), theStart->y(),
- theEnd->x(), theEnd->y()))
-{}
+ const boost::shared_ptr<GeomAPI_Pnt2d>& theEnd)
+ : GeomAPI_Interface(newLine2d(theStart->x(), theStart->y(), theEnd->x(), theEnd->y()))
+{
+}
double GeomAPI_Lin2d::distance(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther) const
{
}
const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Lin2d::intersect(
- const boost::shared_ptr<GeomAPI_Lin2d>& theLine) const
+ const boost::shared_ptr<GeomAPI_Lin2d>& theLine) const
{
IntAna2d_AnaIntersection anInter(*MY_LIN2D, theLine->impl<gp_Lin2d>());
if (!anInter.IsDone() || anInter.IsEmpty())
- return boost::shared_ptr<GeomAPI_Pnt2d>();
+ return boost::shared_ptr<GeomAPI_Pnt2d>();
const gp_Pnt2d& aResult = anInter.Point(1).Value();
return boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aResult.X(), aResult.Y()));
}
-const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Lin2d::project(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) const
+const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Lin2d::project(
+ const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) const
{
const gp_XY& aDir = MY_LIN2D->Direction().XY();
const gp_XY& aLoc = MY_LIN2D->Location().XY();
* \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<GeomAPI_Pnt2d>& theStart,
const boost::shared_ptr<GeomAPI_Pnt2d>& theEnd);
/// Distance between two points
double distance(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther) const;
/// Intersection of two lines
- const boost::shared_ptr<GeomAPI_Pnt2d> intersect(const boost::shared_ptr<GeomAPI_Lin2d>& theLine) const;
+ const boost::shared_ptr<GeomAPI_Pnt2d> intersect(
+ const boost::shared_ptr<GeomAPI_Lin2d>& theLine) const;
/// Project point on line
- const boost::shared_ptr<GeomAPI_Pnt2d> project(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) const;
+ const boost::shared_ptr<GeomAPI_Pnt2d> project(
+ const boost::shared_ptr<GeomAPI_Pnt2d>& 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<GeomAPI_Pnt2d>& thePoint) const;
};
using namespace std;
GeomAPI_Pln::GeomAPI_Pln(const boost::shared_ptr<GeomAPI_Pnt>& thePoint,
- const boost::shared_ptr<GeomAPI_Dir>& theNormal)
-: GeomAPI_Interface(new gp_Pln(thePoint->impl<gp_Pnt>(),
- theNormal->impl<gp_Dir>()))
+ const boost::shared_ptr<GeomAPI_Dir>& theNormal)
+ : GeomAPI_Interface(new gp_Pln(thePoint->impl<gp_Pnt>(), theNormal->impl<gp_Dir>()))
{
}
-GeomAPI_Pln::GeomAPI_Pln(
- const double theA, const double theB, const double theC, const double theD)
-: GeomAPI_Interface(new gp_Pln(theA, theB, theC, theD))
+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))
{
}
* \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<GeomAPI_Pnt>& thePoint,
const boost::shared_ptr<GeomAPI_Dir>& theNormal);
#define MY_PNT static_cast<gp_Pnt*>(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<GeomAPI_XYZ>& 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
{
return MY_PNT->SetZ(theZ);
}
-const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_Pnt::xyz()
+const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_Pnt::xyz()
{
return boost::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(MY_PNT->X(), MY_PNT->Y(), MY_PNT->Z()));
}
* \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
#define MY_PNT2D static_cast<gp_Pnt2d*>(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<GeomAPI_XY>& theCoords)
- : GeomAPI_Interface(new gp_Pnt2d(theCoords->x(), theCoords->y()))
-{}
+ : GeomAPI_Interface(new gp_Pnt2d(theCoords->x(), theCoords->y()))
+{
+}
double GeomAPI_Pnt2d::x() const
{
const boost::shared_ptr<GeomAPI_Dir>& theDirX,
const boost::shared_ptr<GeomAPI_Dir>& theDirY)
{
- boost::shared_ptr<GeomAPI_XYZ> aSum = theOrigin->xyz()->added(
- theDirX->xyz()->multiplied(x()))->added(theDirY->xyz()->multiplied(y()));
+ boost::shared_ptr<GeomAPI_XYZ> aSum = theOrigin->xyz()->added(theDirX->xyz()->multiplied(x()))
+ ->added(theDirY->xyz()->multiplied(y()));
return boost::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum));
}
* \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
#define MY_PNT static_cast<gp_Pnt*>(myImpl)
GeomAPI_Shape::GeomAPI_Shape()
- : GeomAPI_Interface(new TopoDS_Shape()) {
+ : GeomAPI_Interface(new TopoDS_Shape())
+{
}
bool GeomAPI_Shape::isNull()
return MY_SHAPE->IsNull();
}
-
bool GeomAPI_Shape::isVertex() const
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
#define MY_SHAPE static_cast<TopoDS_Shape*>(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();
#define MY_XY static_cast<gp_XY*>(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
{
return MY_XY->SetY(theY);
}
-const boost::shared_ptr<GeomAPI_XY> GeomAPI_XY::added(
- const boost::shared_ptr<GeomAPI_XY>& theArg)
+const boost::shared_ptr<GeomAPI_XY> GeomAPI_XY::added(const boost::shared_ptr<GeomAPI_XY>& theArg)
{
- boost::shared_ptr<GeomAPI_XY> aResult(
- new GeomAPI_XY(MY_XY->X() + theArg->x(), MY_XY->Y() + theArg->y()));
+ boost::shared_ptr<GeomAPI_XY> aResult(new GeomAPI_XY(MY_XY->X() + theArg->x(), MY_XY->Y() + theArg->y()));
return aResult;
}
const boost::shared_ptr<GeomAPI_XY> GeomAPI_XY::multiplied(const double theArg)
{
- boost::shared_ptr<GeomAPI_XY> aResult(
- new GeomAPI_XY(MY_XY->X() * theArg, MY_XY->Y() * theArg));
+ boost::shared_ptr<GeomAPI_XY> aResult(new GeomAPI_XY(MY_XY->X() * theArg, MY_XY->Y() * theArg));
return aResult;
}
* \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);
#define MY_XYZ static_cast<gp_XYZ*>(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
{
}
const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::added(
- const boost::shared_ptr<GeomAPI_XYZ>& theArg)
+ const boost::shared_ptr<GeomAPI_XYZ>& theArg)
{
boost::shared_ptr<GeomAPI_XYZ> 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> GeomAPI_XYZ::decreased(
- const boost::shared_ptr<GeomAPI_XYZ>& theArg)
+ const boost::shared_ptr<GeomAPI_XYZ>& theArg)
{
boost::shared_ptr<GeomAPI_XYZ> 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> GeomAPI_XYZ::multiplied(const double theArg)
{
boost::shared_ptr<GeomAPI_XYZ> 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;
}
return MY_XYZ->Dot(theArg->impl<gp_XYZ>());
}
-const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::cross(const boost::shared_ptr<GeomAPI_XYZ>& theArg) const
+const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::cross(
+ const boost::shared_ptr<GeomAPI_XYZ>& theArg) const
{
gp_XYZ aResult = MY_XYZ->Crossed(theArg->impl<gp_XYZ>());
return boost::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(aResult.X(), aResult.Y(), aResult.Z()));
* \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);
#include <BRep_Builder.hxx>
#include <TopoDS_Compound.hxx>
-boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_CompoundBuilder::compound
- (std::list<boost::shared_ptr<GeomAPI_Shape> > theShapes)
+boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_CompoundBuilder::compound(
+ std::list<boost::shared_ptr<GeomAPI_Shape> > theShapes)
{
BRep_Builder aBuilder;
TopoDS_Compound aComp;
aBuilder.MakeCompound(aComp);
- std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = theShapes.begin(),
- aLast = theShapes.end();
+ std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = theShapes.begin(), aLast =
+ theShapes.end();
for (; anIt != aLast; anIt++) {
aBuilder.Add(aComp, (*anIt)->impl<TopoDS_Shape>());
}
class GEOMALGOAPI_EXPORT GeomAlgoAPI_CompoundBuilder
{
-public:
+ public:
/// Creates compund of the given shapes
/// \param theShapes a list of shapes
- static boost::shared_ptr<GeomAPI_Shape> compound
- (std::list<boost::shared_ptr<GeomAPI_Shape> > theShapes);
+ static boost::shared_ptr<GeomAPI_Shape> compound(
+ std::list<boost::shared_ptr<GeomAPI_Shape> > theShapes);
};
#endif
#include <gp_Circ.hxx>
boost::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::line(
- boost::shared_ptr<GeomAPI_Pnt> theStart, boost::shared_ptr<GeomAPI_Pnt> theEnd)
+ boost::shared_ptr<GeomAPI_Pnt> theStart, boost::shared_ptr<GeomAPI_Pnt> theEnd)
{
const gp_Pnt& aStart = theStart->impl<gp_Pnt>();
const gp_Pnt& anEnd = theEnd->impl<gp_Pnt>();
}
boost::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::lineCircle(
- boost::shared_ptr<GeomAPI_Pnt> theCenter,
- boost::shared_ptr<GeomAPI_Dir> theNormal, double theRadius)
+ boost::shared_ptr<GeomAPI_Pnt> theCenter, boost::shared_ptr<GeomAPI_Dir> theNormal,
+ double theRadius)
{
const gp_Pnt& aCenter = theCenter->impl<gp_Pnt>();
const gp_Dir& aDir = theNormal->impl<gp_Dir>();
}
boost::shared_ptr<GeomAPI_Edge> GeomAlgoAPI_EdgeBuilder::lineCircleArc(
- boost::shared_ptr<GeomAPI_Pnt> theCenter,
- boost::shared_ptr<GeomAPI_Pnt> theStartPoint,
- boost::shared_ptr<GeomAPI_Pnt> theEndPoint,
- boost::shared_ptr<GeomAPI_Dir> theNormal)
+ boost::shared_ptr<GeomAPI_Pnt> theCenter, boost::shared_ptr<GeomAPI_Pnt> theStartPoint,
+ boost::shared_ptr<GeomAPI_Pnt> theEndPoint, boost::shared_ptr<GeomAPI_Dir> theNormal)
{
const gp_Pnt& aCenter = theCenter->impl<gp_Pnt>();
const gp_Dir& aDir = theNormal->impl<gp_Dir>();
const gp_Pnt& anEnd = theEndPoint->impl<gp_Pnt>();
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);
class GEOMALGOAPI_EXPORT GeomAlgoAPI_EdgeBuilder
{
-public:
+ public:
/// Creates linear edge by two points
- static boost::shared_ptr<GeomAPI_Edge> line(
- boost::shared_ptr<GeomAPI_Pnt> theStart, boost::shared_ptr<GeomAPI_Pnt> theEnd);
+ static boost::shared_ptr<GeomAPI_Edge> line(boost::shared_ptr<GeomAPI_Pnt> theStart,
+ boost::shared_ptr<GeomAPI_Pnt> theEnd);
/// Creates linear edge in a form of a circle by a point and a circle radius
- static boost::shared_ptr<GeomAPI_Edge> lineCircle(
- boost::shared_ptr<GeomAPI_Pnt> theCenter,
- boost::shared_ptr<GeomAPI_Dir> theNormal, double theRadius);
+ static boost::shared_ptr<GeomAPI_Edge> lineCircle(boost::shared_ptr<GeomAPI_Pnt> theCenter,
+ boost::shared_ptr<GeomAPI_Dir> theNormal,
+ double theRadius);
/// Creates linear edge in a form of a circle arc by a three points
- static boost::shared_ptr<GeomAPI_Edge> lineCircleArc(
- boost::shared_ptr<GeomAPI_Pnt> theCenter,
- boost::shared_ptr<GeomAPI_Pnt> theStartPoint,
- boost::shared_ptr<GeomAPI_Pnt> theEndPoint,
- boost::shared_ptr<GeomAPI_Dir> theNormal);
+ static boost::shared_ptr<GeomAPI_Edge> lineCircleArc(boost::shared_ptr<GeomAPI_Pnt> theCenter,
+ boost::shared_ptr<GeomAPI_Pnt> theStartPoint,
+ boost::shared_ptr<GeomAPI_Pnt> theEndPoint,
+ boost::shared_ptr<GeomAPI_Dir> theNormal);
};
#endif
const double tolerance = Precision::Angular();
boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Extrusion::makeExtrusion(
- boost::shared_ptr<GeomAPI_Shape> theShape,
- boost::shared_ptr<GeomAPI_Dir> theDir,
- double theSize)
+ boost::shared_ptr<GeomAPI_Shape> theShape, boost::shared_ptr<GeomAPI_Dir> theDir,
+ double theSize)
{
const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
gp_Vec aDir(theDir->impl<gp_Dir>().XYZ() * theSize);
}
boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_Extrusion::makeExtrusion(
- boost::shared_ptr<GeomAPI_Shape> theShape,
- double theSize)
+ boost::shared_ptr<GeomAPI_Shape> theShape, double theSize)
{
bool isFirstNorm = true;
gp_Dir aShapeNormal;
const TopoDS_Shape& aShape = theShape->impl<TopoDS_Shape>();
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<GeomAPI_Shape>();
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<GeomAPI_Shape>();
}
boost::shared_ptr<GeomAPI_Dir> 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);
}
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<GeomAPI_Shape> makeExtrusion(
- boost::shared_ptr<GeomAPI_Shape> theShape,
- boost::shared_ptr<GeomAPI_Dir> theDir,
- double theSize);
+ static boost::shared_ptr<GeomAPI_Shape> makeExtrusion(boost::shared_ptr<GeomAPI_Shape> theShape,
+ boost::shared_ptr<GeomAPI_Dir> 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<GeomAPI_Shape> makeExtrusion(
- boost::shared_ptr<GeomAPI_Shape> theShape,
- double theSize);
+ static boost::shared_ptr<GeomAPI_Shape> makeExtrusion(boost::shared_ptr<GeomAPI_Shape> theShape,
+ double theSize);
};
#endif
#include <Geom_Plane.hxx>
boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
- boost::shared_ptr<GeomAPI_Pnt> theCenter, boost::shared_ptr<GeomAPI_Dir> theNormal,
- const double theSize)
+ boost::shared_ptr<GeomAPI_Pnt> theCenter, boost::shared_ptr<GeomAPI_Dir> theNormal,
+ const double theSize)
{
const gp_Pnt& aCenter = theCenter->impl<gp_Pnt>();
const gp_Dir& aDir = theNormal->impl<gp_Dir>();
gp_Pln aPlane(aCenter, aDir);
// half of the size in each direction from the center
- BRepBuilderAPI_MakeFace aFaceBuilder(aPlane,
- -theSize / 2., theSize / 2., -theSize / 2., theSize / 2.);
+ BRepBuilderAPI_MakeFace aFaceBuilder(aPlane, -theSize / 2., theSize / 2., -theSize / 2.,
+ theSize / 2.);
boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
return aRes;
}
boost::shared_ptr<GeomAPI_Pln> GeomAlgoAPI_FaceBuilder::plane(
- boost::shared_ptr<GeomAPI_Shape> theFace)
+ boost::shared_ptr<GeomAPI_Shape> theFace)
{
boost::shared_ptr<GeomAPI_Pln> aResult;
- if (!theFace) return aResult; // bad shape
+ if (!theFace)
+ return aResult; // bad shape
TopoDS_Shape aShape = theFace->impl<TopoDS_Shape>();
- 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<GeomAPI_Pln>(new GeomAPI_Pln(aA, aB, aC, aD));
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<GeomAPI_Shape> square(boost::shared_ptr<GeomAPI_Pnt> theCenter,
- boost::shared_ptr<GeomAPI_Dir> theNormal, const double theSize);
+ boost::shared_ptr<GeomAPI_Dir> theNormal,
+ const double theSize);
/// Returns the plane of the planar face. If it is not planar, returns empty ptr.
static boost::shared_ptr<GeomAPI_Pln> plane(boost::shared_ptr<GeomAPI_Shape> theFace);
// Created: 02 Jun 2014
// Author: Mikhail PONIKAROV
-
-
#include <GeomAlgoAPI_PointBuilder.h>
#include <GeomAPI_Pnt.h>
#include <GeomAPI_Shape.h>
class GEOMALGOAPI_EXPORT GeomAlgoAPI_PointBuilder
{
-public:
+ public:
/// Creates linear edge by two points
- static boost::shared_ptr<GeomAPI_Shape> point(
- boost::shared_ptr<GeomAPI_Pnt> thePoint);
+ static boost::shared_ptr<GeomAPI_Shape> point(boost::shared_ptr<GeomAPI_Pnt> thePoint);
};
#endif
#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<TopoDS_Shape>::iterator& theStartEdge,
const std::list<TopoDS_Shape>::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<TopoDS_Shape>::iterator& theStartEdge,
const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
- const std::set<Handle(TopoDS_TShape)>& theEdgesInLoops,
- std::list<TopoDS_Wire>& theResWires);
+ const std::set<Handle(TopoDS_TShape)>& theEdgesInLoops,
+ std::list<TopoDS_Wire>& 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<TopoDS_Shape>::iterator& theStartVertex,
- std::list<TopoDS_Shape>::iterator& theStartEdge,
- const std::list<TopoDS_Shape>::iterator& theEndOfVertexes,
- const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
- BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE);
-
-
-
+static void removeWasteEdges(std::list<TopoDS_Shape>::iterator& theStartVertex,
+ std::list<TopoDS_Shape>::iterator& theStartEdge,
+ const std::list<TopoDS_Shape>::iterator& theEndOfVertexes,
+ const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
+ BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE);
void GeomAlgoAPI_SketchBuilder::createFaces(
- const boost::shared_ptr<GeomAPI_Pnt>& theOrigin,
- const boost::shared_ptr<GeomAPI_Dir>& theDirX,
- const boost::shared_ptr<GeomAPI_Dir>& theDirY,
- const boost::shared_ptr<GeomAPI_Dir>& theNorm,
- const std::list< boost::shared_ptr<GeomAPI_Shape> >& theFeatures,
- std::list< boost::shared_ptr<GeomAPI_Shape> >& theResultFaces,
- std::list< boost::shared_ptr<GeomAPI_Shape> >& theResultWires)
+ const boost::shared_ptr<GeomAPI_Pnt>& theOrigin, const boost::shared_ptr<GeomAPI_Dir>& theDirX,
+ const boost::shared_ptr<GeomAPI_Dir>& theDirY, const boost::shared_ptr<GeomAPI_Dir>& theNorm,
+ const std::list<boost::shared_ptr<GeomAPI_Shape> >& theFeatures,
+ std::list<boost::shared_ptr<GeomAPI_Shape> >& theResultFaces,
+ std::list<boost::shared_ptr<GeomAPI_Shape> >& theResultWires)
{
if (theFeatures.empty())
- return ;
+ return;
// Create the list of edges with shared vertexes
BOPAlgo_Builder aBuilder;
TopoDS_Shape aFeaturesCompound;
// Obtain only edges from the features list
- std::list< boost::shared_ptr<GeomAPI_Shape> > anEdges;
- std::list< boost::shared_ptr<GeomAPI_Shape> >::const_iterator aFeatIt = theFeatures.begin();
- for ( ; aFeatIt != theFeatures.end(); aFeatIt++)
- {
+ std::list<boost::shared_ptr<GeomAPI_Shape> > anEdges;
+ std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator aFeatIt = theFeatures.begin();
+ for (; aFeatIt != theFeatures.end(); aFeatIt++) {
boost::shared_ptr<GeomAPI_Shape> aShape(*aFeatIt);
const TopoDS_Edge& anEdge = aShape->impl<TopoDS_Edge>();
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<TopoDS_Shape>();
- }
- else
- {
- std::list< boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = anEdges.begin();
- for (; anIt != anEdges.end(); anIt++)
- {
+ } else {
+ std::list<boost::shared_ptr<GeomAPI_Shape> >::const_iterator anIt = anEdges.begin();
+ for (; anIt != anEdges.end(); anIt++) {
boost::shared_ptr<GeomAPI_Shape> aPreview(*anIt);
aBuilder.AddArgument(aPreview->impl<TopoDS_Edge>());
}
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<gp_Dir>();
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<TopoDS_Shape>::iterator aVertIter = aProcVertexes.begin();
- std::list<TopoDS_Shape>::iterator anEdgeIter = aProcEdges.begin();
- for ( ; aVertIter != aProcVertexes.end(); aVertIter++)
- {
+ std::list<TopoDS_Shape>::iterator aVertIter = aProcVertexes.begin();
+ std::list<TopoDS_Shape>::iterator anEdgeIter = aProcEdges.begin();
+ for (; aVertIter != aProcVertexes.end(); aVertIter++) {
if (aVertIter->TShape() == aNextVertex.TShape())
break;
if (anEdgeIter != aProcEdges.end())
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;
// 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<GeomAPI_Shape> aFace(new GeomAPI_Shape);
aFace->setImpl(new TopoDS_Face(aPatch));
theResultFaces.push_back(aFace);
// revert the list of remaining edges
std::list<TopoDS_Shape> aRemainVertexes;
- for ( ; aVertIter != aProcVertexes.end(); aVertIter++)
+ for (; aVertIter != aProcVertexes.end(); aVertIter++)
aRemainVertexes.push_front(*aVertIter);
std::list<TopoDS_Shape> 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());
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<TopoDS_Shape>::reverse_iterator aVRIter = aProcVertexes.rbegin();
std::list<TopoDS_Shape>::reverse_iterator aERIter = aProcEdges.rbegin();
if (aVRIter != aProcVertexes.rend())
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<TopoDS_Shape>::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<TopoDS_Wire> aTail;
createWireList(*aVRIter, aEIter, aProcEdges.end(), anEdgesInLoops, aTail);
std::list<TopoDS_Wire>::const_iterator aTailIter = aTail.begin();
- for ( ; aTailIter != aTail.end(); aTailIter++)
- if (!aTailIter->IsNull())
- {
+ for (; aTailIter != aTail.end(); aTailIter++)
+ if (!aTailIter->IsNull()) {
boost::shared_ptr<GeomAPI_Shape> aWire(new GeomAPI_Shape);
aWire->setImpl(new TopoDS_Shape(*aTailIter));
theResultWires.push_back(aWire);
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();
}
void GeomAlgoAPI_SketchBuilder::fixIntersections(
- std::list< boost::shared_ptr<GeomAPI_Shape> >& theFaces)
+ std::list<boost::shared_ptr<GeomAPI_Shape> >& theFaces)
{
BRepClass_FaceClassifier aClassifier;
- std::list< boost::shared_ptr<GeomAPI_Shape> >::iterator anIter1 = theFaces.begin();
- std::list< boost::shared_ptr<GeomAPI_Shape> >::iterator anIter2;
- for ( ; anIter1 != theFaces.end(); anIter1++)
- {
+ std::list<boost::shared_ptr<GeomAPI_Shape> >::iterator anIter1 = theFaces.begin();
+ std::list<boost::shared_ptr<GeomAPI_Shape> >::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<TopoDS_Face>();
- 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<TopoDS_Shape>(), 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<TopoDS_Face>();
- 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<TopoDS_Shape>(), 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<TopoDS_Shape>(),
- (*anIter1)->impl<TopoDS_Shape>());
+ if (!aVert1.More()) { // first shape should be cut from the second
+ BRepAlgoAPI_Cut aCut((*anIter2)->impl<TopoDS_Shape>(), (*anIter1)->impl<TopoDS_Shape>());
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<GeomAPI_Shape> 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<TopoDS_Shape>(),
- (*anIter2)->impl<TopoDS_Shape>());
+ } else { // second shape should be cut from the first
+ BRepAlgoAPI_Cut aCut((*anIter1)->impl<TopoDS_Shape>(), (*anIter2)->impl<TopoDS_Shape>());
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<GeomAPI_Shape> aShape(new GeomAPI_Shape);
aShape->setImpl(new TopoDS_Shape(anExp.Current()));
theFaces.push_back(aShape);
}
}
-
// =================== 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;
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();
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
}
}
-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;
}
theBuilder.Add(theWire, anEdge);
}
-void createFace(const TopoDS_Shape& theStartVertex,
+void createFace(const TopoDS_Shape& theStartVertex,
const std::list<TopoDS_Shape>::iterator& theStartEdge,
- const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
- const gp_Pln& thePlane,
- TopoDS_Face& theResFace)
+ const std::list<TopoDS_Shape>::iterator& theEndOfEdges, const gp_Pln& thePlane,
+ TopoDS_Face& theResFace)
{
TopoDS_Wire aResWire;
BRep_Builder aBuilder;
TopoDS_Shape aCurVertex = theStartVertex;
std::list<TopoDS_Shape>::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);
}
theResFace = aFaceBuilder.Face();
}
-void createWireList(const TopoDS_Shape& theStartVertex,
+void createWireList(const TopoDS_Shape& theStartVertex,
const std::list<TopoDS_Shape>::iterator& theStartEdge,
const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
- const std::set<Handle(TopoDS_TShape)>& theEdgesInLoops,
- std::list<TopoDS_Wire>& theResWires)
+ const std::set<Handle(TopoDS_TShape)>& theEdgesInLoops,
+ std::list<TopoDS_Wire>& theResWires)
{
BRep_Builder aBuilder;
bool needNewWire = true;
TopoDS_Shape aCurVertex = theStartVertex;
std::list<TopoDS_Shape>::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;
}
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();
return gp_Dir(aTang);
}
-void removeWasteEdges(
- std::list<TopoDS_Shape>::iterator& theStartVertex,
- std::list<TopoDS_Shape>::iterator& theStartEdge,
- const std::list<TopoDS_Shape>::iterator& theEndOfVertexes,
- const std::list<TopoDS_Shape>::iterator& theEndOfEdges,
- BOPCol_IndexedDataMapOfShapeListOfShape& theMapVE)
+void removeWasteEdges(std::list<TopoDS_Shape>::iterator& theStartVertex,
+ std::list<TopoDS_Shape>::iterator& theStartEdge,
+ const std::list<TopoDS_Shape>::iterator& theEndOfVertexes,
+ const std::list<TopoDS_Shape>::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())
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
*/
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
* 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<GeomAPI_Pnt>& theOrigin,
- const boost::shared_ptr<GeomAPI_Dir>& theDirX,
- const boost::shared_ptr<GeomAPI_Dir>& theDirY,
- const boost::shared_ptr<GeomAPI_Dir>& theNorm,
- const std::list< boost::shared_ptr<GeomAPI_Shape> >& theFeatures,
- std::list< boost::shared_ptr<GeomAPI_Shape> >& theResultFaces,
- std::list< boost::shared_ptr<GeomAPI_Shape> >& theResultWires);
+ static void createFaces(const boost::shared_ptr<GeomAPI_Pnt>& theOrigin,
+ const boost::shared_ptr<GeomAPI_Dir>& theDirX,
+ const boost::shared_ptr<GeomAPI_Dir>& theDirY,
+ const boost::shared_ptr<GeomAPI_Dir>& theNorm,
+ const std::list<boost::shared_ptr<GeomAPI_Shape> >& theFeatures,
+ std::list<boost::shared_ptr<GeomAPI_Shape> >& theResultFaces,
+ std::list<boost::shared_ptr<GeomAPI_Shape> >& 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<GeomAPI_Shape> >& theFaces);
+ static void fixIntersections(std::list<boost::shared_ptr<GeomAPI_Shape> >& theFaces);
};
#endif
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);
boost::shared_ptr<GeomAPI_Dir> GeomData_Dir::dir()
{
- return boost::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(
- myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
+ return boost::shared_ptr<GeomAPI_Dir>(
+ new GeomAPI_Dir(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
}
GeomData_Dir::GeomData_Dir(TDF_Label& theLabel)
*/
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
/// Returns the direction of this attribute
GEOMDATA_EXPORT virtual boost::shared_ptr<GeomAPI_Dir> dir();
-protected:
+ protected:
/// Initializes attributes
GEOMDATA_EXPORT GeomData_Dir(TDF_Label& theLabel);
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);
boost::shared_ptr<GeomAPI_Pnt> GeomData_Point::pnt()
{
- boost::shared_ptr<GeomAPI_Pnt> aResult(new GeomAPI_Pnt(
- myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
+ boost::shared_ptr<GeomAPI_Pnt> aResult(
+ new GeomAPI_Pnt(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
return aResult;
}
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
/// Returns the 3D point
GEOMDATA_EXPORT virtual boost::shared_ptr<GeomAPI_Pnt> pnt();
-protected:
+ protected:
/// Initializes attributes
GEOMDATA_EXPORT GeomData_Point(TDF_Label& theLabel);
boost::shared_ptr<GeomAPI_Pnt2d> GeomData_Point2D::pnt()
{
boost::shared_ptr<GeomAPI_Pnt2d> aResult(
- new GeomAPI_Pnt2d(myCoords->Value(0), myCoords->Value(1)));
+ new GeomAPI_Pnt2d(myCoords->Value(0), myCoords->Value(1)));
return aResult;
}
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
/// Returns the 2D point
GEOMDATA_EXPORT virtual boost::shared_ptr<GeomAPI_Pnt2d> pnt();
-protected:
+ protected:
/// Initializes attributes
GEOMDATA_EXPORT GeomData_Point2D(TDF_Label& theLabel);
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
virtual boost::shared_ptr<GeomAPI_Dir> 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
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
virtual boost::shared_ptr<GeomAPI_Pnt> 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
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
virtual boost::shared_ptr<GeomAPI_Pnt2d> 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
// 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];
//=======================================================================
void Model_Application::Formats(TColStd_SequenceOfExtendedString& theFormats)
{
- theFormats.Append(TCollection_ExtendedString("BinOcaf")); // standard binary schema
+ theFormats.Append(TCollection_ExtendedString("BinOcaf")); // standard binary schema
}
//=======================================================================
* 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();
//! 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();
//! 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<std::string, boost::shared_ptr<Model_Document> > myDocs;
/// Path for the loaded by demand documents
bool Model_AttributeBoolean::value()
{
- return myBool->Get() == Standard_True;
+ return myBool->Get() == Standard_True ;
}
Model_AttributeBoolean::Model_AttributeBoolean(TDF_Label& theLabel)
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);
{
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<ModelAPI_Document>();
}
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)) {
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<ModelAPI_Document> theDoc);
/// Returns document referenced from this attribute
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> value();
-protected:
+ protected:
/// Initializes attibutes
Model_AttributeDocRef(TDF_Label& theLabel);
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);
void Model_AttributeRefAttr::setAttr(boost::shared_ptr<ModelAPI_Attribute> theAttr)
{
- boost::shared_ptr<Model_Data> aData =
- boost::dynamic_pointer_cast<Model_Data>(theAttr->owner()->data());
+ boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(
+ 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());
{
ObjectPtr anObj = object();
if (anObj) {
- boost::shared_ptr<Model_Data> aData =
- boost::dynamic_pointer_cast<Model_Data>(anObj->data());
+ boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(anObj->data());
return aData->attribute(TCollection_AsciiString(myID->Get()).ToCString());
}
// not initialized
void Model_AttributeRefAttr::setObject(ObjectPtr theObject)
{
if (!myIsInitialized || myID->Get().Length() != 0 || object() != theObject) {
- boost::shared_ptr<Model_Data> aData =
- boost::dynamic_pointer_cast<Model_Data>(theObject->data());
+ boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(
+ 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<Model_Document> aDoc =
- boost::dynamic_pointer_cast<Model_Document>(owner()->document());
+ if (myRef->Get() != myRef->Label()) { // initialized
+ boost::shared_ptr<Model_Document> aDoc = boost::dynamic_pointer_cast<Model_Document>(
+ owner()->document());
if (aDoc) {
TDF_Label aRefLab = myRef->Get();
return aDoc->object(aRefLab);
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);
}
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();
/// 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);
void Model_AttributeRefList::append(ObjectPtr theObject)
{
- boost::shared_ptr<Model_Data> aData =
- boost::dynamic_pointer_cast<Model_Data>(theObject->data());
- myRef->Append(aData->label().Father()); // store label of the object
+ boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(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<Model_Data> aData =
- boost::dynamic_pointer_cast<Model_Data>(theObject->data());
+ boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theObject->data());
myRef->Remove(aData->label().Father());
owner()->data()->sendAttributeUpdated(this);
list<ObjectPtr> Model_AttributeRefList::list()
{
- std::list< ObjectPtr > aResult;
- boost::shared_ptr<Model_Document> aDoc =
- boost::dynamic_pointer_cast<Model_Document>(owner()->document());
+ std::list<ObjectPtr> aResult;
+ boost::shared_ptr<Model_Document> aDoc = boost::dynamic_pointer_cast<Model_Document>(
+ 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);
}
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);
MODEL_EXPORT virtual int size();
/// Returns the list of features
- MODEL_EXPORT virtual std::list<ObjectPtr > list();
+ MODEL_EXPORT virtual std::list<ObjectPtr> list();
-protected:
+ protected:
/// Objects are created for features automatically
MODEL_EXPORT Model_AttributeRefList(TDF_Label& theLabel);
void Model_AttributeReference::setValue(ObjectPtr theObject)
{
if (!myIsInitialized || value() != theObject) {
- boost::shared_ptr<Model_Data> aData =
- boost::dynamic_pointer_cast<Model_Data>(theObject->data());
- myRef->Set(aData->label().Father()); // references to the feature label
+ boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(
+ theObject->data());
+ myRef->Set(aData->label().Father()); // references to the feature label
owner()->data()->sendAttributeUpdated(this);
}
}
ObjectPtr Model_AttributeReference::value()
{
if (myIsInitialized) {
- boost::shared_ptr<Model_Document> aDoc =
- boost::dynamic_pointer_cast<Model_Document>(owner()->document());
+ boost::shared_ptr<Model_Document> aDoc = boost::dynamic_pointer_cast<Model_Document>(
+ owner()->document());
if (aDoc) {
TDF_Label aRefLab = myRef->Get();
return aDoc->object(aRefLab);
{
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
}
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);
#include <Events_Loop.h>
#include <Events_Error.h>
-
using namespace std;
Model_Data::Model_Data()
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)
}
// 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)
if (anAttr) {
myAttrs[theID] = boost::shared_ptr<ModelAPI_Attribute>(anAttr);
anAttr->setObject(myObject);
- }
- else {
+ } else {
Events_Error::send("Can not create unknown type of attribute " + theAttrType);
}
}
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeDocRef>();
}
- boost::shared_ptr<ModelAPI_AttributeDocRef> aRes =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDocRef>(aFound->second);
+ boost::shared_ptr<ModelAPI_AttributeDocRef> aRes = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeDocRef>(aFound->second);
if (!aRes) {
// TODO: generate error on invalid attribute type request
}
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeDouble>();
}
- boost::shared_ptr<ModelAPI_AttributeDouble> aRes =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aFound->second);
+ boost::shared_ptr<ModelAPI_AttributeDouble> aRes = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeDouble>(aFound->second);
if (!aRes) {
// TODO: generate error on invalid attribute type request
}
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeBoolean>();
}
- boost::shared_ptr<ModelAPI_AttributeBoolean> aRes =
- boost::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(aFound->second);
+ boost::shared_ptr<ModelAPI_AttributeBoolean> aRes = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeBoolean>(aFound->second);
if (!aRes) {
// TODO: generate error on invalid attribute type request
}
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeReference>();
}
- boost::shared_ptr<ModelAPI_AttributeReference> aRes =
- boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aFound->second);
+ boost::shared_ptr<ModelAPI_AttributeReference> aRes = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeReference>(aFound->second);
if (!aRes) {
// TODO: generate error on invalid attribute type request
}
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeRefAttr>();
}
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRes =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aFound->second);
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> aRes = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(aFound->second);
if (!aRes) {
// TODO: generate error on invalid attribute type request
}
// TODO: generate error on unknown attribute request and/or add mechanism for customization
return boost::shared_ptr<ModelAPI_AttributeRefList>();
}
- boost::shared_ptr<ModelAPI_AttributeRefList> aRes =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aFound->second);
+ boost::shared_ptr<ModelAPI_AttributeRefList> aRes = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefList>(aFound->second);
if (!aRes) {
// TODO: generate error on invalid attribute type request
}
boost::shared_ptr<ModelAPI_Attribute> Model_Data::attribute(const std::string& theID)
{
boost::shared_ptr<ModelAPI_Attribute> aResult;
- if (myAttrs.find(theID) == myAttrs.end()) // no such attribute
+ if (myAttrs.find(theID) == myAttrs.end()) // no such attribute
return aResult;
return myAttrs[theID];
}
const string& Model_Data::id(const boost::shared_ptr<ModelAPI_Attribute>& theAttr)
{
map<string, boost::shared_ptr<ModelAPI_Attribute> >::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;
{
boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theData);
if (aData)
- return myLab.IsEqual(aData->myLab) == Standard_True;
+ return myLab.IsEqual(aData->myLab) == Standard_True ;
return false;
}
{
list<boost::shared_ptr<ModelAPI_Attribute> > aResult;
map<string, boost::shared_ptr<ModelAPI_Attribute> >::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);
}
* 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<std::string, boost::shared_ptr<ModelAPI_Attribute> > myAttrs;
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
/// Returns the attribute that contains real value with double precision
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeDouble> real(const std::string& theID);
/// Returns the attribute that contains reference to a feature
- MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeReference>
- reference(const std::string& theID);
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeReference>
+ reference(const std::string& theID);
/// Returns the attribute that contains reference to an attribute of a feature
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeRefAttr>
- refattr(const std::string& theID);
+ refattr(const std::string& theID);
/// Returns the attribute that contains list of references to features
- MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeRefList>
- reflist(const std::string& theID);
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeRefList>
+ reflist(const std::string& theID);
/// Returns the attribute that contains boolean value
- MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeBoolean>
- boolean(const std::string& theID);
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_AttributeBoolean>
+ boolean(const std::string& theID);
/// Returns the generic attribute by identifier
/// \param theID identifier of the attribute
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID);
/// Returns all attributes ofthe feature of the given type
/// or all attributes if "theType" is empty
MODEL_EXPORT virtual std::list<boost::shared_ptr<ModelAPI_Attribute> >
- attributes(const std::string& theType);
+ attributes(const std::string& theType);
/// Identifier by the id (not fast, iteration by map)
/// \param theAttr attribute already created in this data
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
/// Sets the object of this data
MODEL_EXPORT virtual void setObject(ObjectPtr theObject)
- {myObject = theObject;}
+ {
+ myObject = theObject;
+ }
};
#endif
# 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;
/// 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;
}
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) {
#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
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<std::string>::iterator aSubIter = mySubs.begin();
- for(; aSubIter != mySubs.end() && isDone; aSubIter++)
+ for (; aSubIter != mySubs.end() && isDone; aSubIter++)
isDone = subDocument(*aSubIter)->save(theFileName);
}
return isDone;
void Model_Document::close()
{
boost::shared_ptr<ModelAPI_PluginManager> 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<std::string>::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();
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<std::string>::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;
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>(Model_PluginManager::get())->
- setCheckTransactions(false); // for nested transaction commit
+ boost::static_pointer_cast<Model_PluginManager>(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>(Model_PluginManager::get())->
- setCheckTransactions(true); // for nested transaction commit
+ boost::static_pointer_cast<Model_PluginManager>(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) {
}
} 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<std::string>::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();
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<std::string>::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()
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<std::string>::iterator aSubIter = mySubs.begin();
- for(; aSubIter != mySubs.end(); aSubIter++)
+ for (; aSubIter != mySubs.end(); aSubIter++)
if (subDocument(*aSubIter)->canUndo())
return true;
return false;
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<std::string>::iterator aSubIter = mySubs.begin();
- for(; aSubIter != mySubs.end(); aSubIter++)
+ for (; aSubIter != mySubs.end(); aSubIter++)
subDocument(*aSubIter)->undo();
}
return true;
// check other subs contains operation that can be redoed
std::set<std::string>::iterator aSubIter = mySubs.begin();
- for(; aSubIter != mySubs.end(); aSubIter++)
+ for (; aSubIter != mySubs.end(); aSubIter++)
if (subDocument(*aSubIter)->canRedo())
return true;
return false;
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<std::string>::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);
TDF_Label anEmptyLab;
FeaturePtr anEmptyFeature;
FeaturePtr aFeature = ModelAPI_PluginManager::get()->createFeature(theID);
- boost::shared_ptr<Model_Document> aDocToAdd =
- boost::dynamic_pointer_cast<Model_Document>(aFeature->documentToAdd());
+ boost::shared_ptr<Model_Document> aDocToAdd = boost::dynamic_pointer_cast<Model_Document>(
+ 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);
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);
/// 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;
{
boost::shared_ptr<Model_Data> aData = boost::static_pointer_cast<Model_Data>(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();
static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
- for(; aRIter != aResults.cend(); aRIter++) {
+ for (; aRIter != aResults.cend(); aRIter++) {
boost::shared_ptr<ModelAPI_Result> aRes = *aRIter;
- aRes->setData(boost::shared_ptr<ModelAPI_Data>()); // deleted flag
+ aRes->setData(boost::shared_ptr<ModelAPI_Data>()); // deleted flag
ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
ModelAPI_EventCreator::get()->sendDeleted(theFeature->document(), aRes->groupName());
}
{
if (myObjs.IsBound(theLabel))
return myObjs.Find(theLabel);
- return FeaturePtr(); // not found
+ return FeaturePtr(); // not found
}
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<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.cbegin();
- for(; aRIter != aResults.cend(); aRIter++) {
- boost::shared_ptr<Model_Data> aResData =
- boost::dynamic_pointer_cast<Model_Data>((*aRIter)->data());
+ for (; aRIter != aResults.cend(); aRIter++) {
+ boost::shared_ptr<Model_Data> aResData = boost::dynamic_pointer_cast<Model_Data>(
+ (*aRIter)->data());
if (aResData->label().Father().IsEqual(theLabel))
return *aRIter;
}
}
- return FeaturePtr(); // not found
+ return FeaturePtr(); // not found
}
boost::shared_ptr<ModelAPI_Document> Model_Document::subDocument(std::string theDocID)
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);
// 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<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
std::list<boost::shared_ptr<ModelAPI_Result> >::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;
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()) {
} 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<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
- for(; aRIter != aResults.cend(); aRIter++) {
+ for (; aRIter != aResults.cend(); aRIter++) {
if ((theHidden || (*aRIter)->isInHistory()) && (*aRIter)->groupName() == theGroupID) {
aResult++;
}
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<TDF_Label, FeaturePtr>::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<<theFeature->getKind()<<"_"<<aNumObjects + 1;
+ aNameStream << theFeature->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<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
std::list<boost::shared_ptr<ModelAPI_Result> >::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<<theFeature->getKind()<<"_"<<aNumObjects + 1;
+ aNameStream << theFeature->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<ModelAPI_Document> aThis =
- Model_Application::getApplication()->getDocument(myID);
+void Model_Document::initData(ObjectPtr theObj, TDF_Label theLab, const int theTag)
+{
+ boost::shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(
+ myID);
boost::shared_ptr<Model_Data> aData(new Model_Data);
aData->setLabel(theLab.FindChild(theTag));
aData->setObject(theObj);
theObj->setData(aData);
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(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<ModelAPI_Document> aThis =
- Model_Application::getApplication()->getDocument(myID);
+ boost::shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(
+ myID);
// update all objects by checking are they of labels or not
std::set<FeaturePtr> 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;
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);
}
// execute new features to restore results: after features creation to make all references valid
/*std::set<FeaturePtr>::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<TDF_Label, FeaturePtr>::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();
static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = aFeature->results();
std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
- for(; aRIter != aResults.cend(); aRIter++) {
+ for (; aRIter != aResults.cend(); aRIter++) {
boost::shared_ptr<ModelAPI_Result> aRes = *aRIter;
//aRes->setData(boost::shared_ptr<ModelAPI_Data>()); // deleted flag
ModelAPI_EventCreator::get()->sendUpdated(aRes, EVENT_DISP);
}
// 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>(Model_PluginManager::get())->
- setCheckTransactions(false);
+ boost::static_pointer_cast<Model_PluginManager>(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>(Model_PluginManager::get())->
- setCheckTransactions(true);
+ boost::static_pointer_cast<Model_PluginManager>(Model_PluginManager::get())->setCheckTransactions(
+ true);
}
void Model_Document::storeResult(boost::shared_ptr<ModelAPI_Data> theFeatureData,
- boost::shared_ptr<ModelAPI_Result> theResult, const int theResultIndex)
+ boost::shared_ptr<ModelAPI_Result> theResult,
+ const int theResultIndex)
{
- boost::shared_ptr<ModelAPI_Document> aThis =
- Model_Application::getApplication()->getDocument(myID);
+ boost::shared_ptr<ModelAPI_Document> aThis = Model_Application::getApplication()->getDocument(
+ myID);
theResult->setDoc(aThis);
- initData(theResult, boost::dynamic_pointer_cast<Model_Data>(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<Model_Data>(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<ModelAPI_ResultConstruction> Model_Document::createConstruction(
- const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+ const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
{
- ObjectPtr anOldObject = object(boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->
- label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theIndex + 1));
+ ObjectPtr anOldObject = object(
+ boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->label().Father().FindChild(
+ TAG_FEATURE_RESULTS).FindChild(theIndex + 1));
boost::shared_ptr<ModelAPI_ResultConstruction> aResult;
if (anOldObject) {
aResult = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anOldObject);
}
boost::shared_ptr<ModelAPI_ResultBody> Model_Document::createBody(
- const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+ const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
{
- ObjectPtr anOldObject = object(boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->
- label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theIndex + 1));
+ ObjectPtr anOldObject = object(
+ boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->label().Father().FindChild(
+ TAG_FEATURE_RESULTS).FindChild(theIndex + 1));
boost::shared_ptr<ModelAPI_ResultBody> aResult;
if (anOldObject) {
aResult = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(anOldObject);
}
boost::shared_ptr<ModelAPI_ResultPart> Model_Document::createPart(
- const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+ const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
{
- ObjectPtr anOldObject = object(boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->
- label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theIndex + 1));
+ ObjectPtr anOldObject = object(
+ boost::dynamic_pointer_cast<Model_Data>(theFeatureData)->label().Father().FindChild(
+ TAG_FEATURE_RESULTS).FindChild(theIndex + 1));
boost::shared_ptr<ModelAPI_ResultPart> aResult;
if (anOldObject) {
aResult = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(anOldObject);
}
boost::shared_ptr<ModelAPI_Feature> Model_Document::feature(
- const boost::shared_ptr<ModelAPI_Result>& theResult)
+ const boost::shared_ptr<ModelAPI_Result>& theResult)
{
boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(theResult->data());
if (aData) {
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);
}
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
* 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
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> 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
//! \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
/// Creates a construction cresults
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_ResultConstruction> createConstruction(
- const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+ const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
/// Creates a body results
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_ResultBody> createBody(
- const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+ const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
/// Creates a part results
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_ResultPart> createPart(
- const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+ const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
//! Returns a feature by result (owner of result)
- MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature>
- feature(const boost::shared_ptr<ModelAPI_Result>& theResult);
+ MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature>
+ feature(const boost::shared_ptr<ModelAPI_Result>& theResult);
-
-protected:
+ protected:
//! Returns (creates if needed) the features label
TDF_Label featuresLabel();
//! 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();
//! 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<ModelAPI_Data> theFeatureData,
- boost::shared_ptr<ModelAPI_Result> theResult, const int theResultIndex = 0);
-
+ boost::shared_ptr<ModelAPI_Result> 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)
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<ModelAPI_Document>& theDoc, const std::string& theGroup) const
+void Model_EventCreator::sendDeleted(const boost::shared_ptr<ModelAPI_Document>& theDoc,
+ const std::string& theGroup) const
{
Model_ObjectDeletedMessage aMsg(theDoc, theGroup);
Events_Loop::loop()->send(aMsg, true);
}
/////////////////////// 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<ObjectPtr> Model_ObjectUpdatedMessage::objects() const
+std::set<ObjectPtr> 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<Model_ObjectUpdatedMessage*>(&theJoined);
- std::set<ObjectPtr >::iterator aFIter = aJoined->myObjects.begin();
- for(; aFIter != aJoined->myObjects.end(); aFIter++) {
+ std::set<ObjectPtr>::iterator aFIter = aJoined->myObjects.begin();
+ for (; aFIter != aJoined->myObjects.end(); aFIter++) {
myObjects.insert(*aFIter);
}
}
/////////////////////// DELETED MESSAGE /////////////////////////////
Model_ObjectDeletedMessage::Model_ObjectDeletedMessage(
- const boost::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup)
- : ModelAPI_ObjectDeletedMessage(messageId(), 0), myDoc(theDoc)
+ const boost::shared_ptr<ModelAPI_Document>& 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, "");
}
{
Model_ObjectDeletedMessage* aJoined = dynamic_cast<Model_ObjectDeletedMessage*>(&theJoined);
std::set<std::string>::iterator aGIter = aJoined->myGroups.begin();
- for(; aGIter != aJoined->myGroups.end(); aGIter++) {
+ for (; aGIter != aJoined->myGroups.end(); aGIter++) {
myGroups.insert(*aGIter);
}
}
#include <ModelAPI_Events.h>
/// 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<ModelAPI_Document>& theDoc, const std::string& theGroup) const;
+ virtual void sendDeleted(const boost::shared_ptr<ModelAPI_Document>& 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<ObjectPtr> myObjects; ///< which feature is changed
+class Model_ObjectUpdatedMessage : public ModelAPI_ObjectUpdatedMessage
+{
+ std::set<ObjectPtr> 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<ObjectPtr> objects() const;
};
/// Message that feature was deleted (used for Object Browser update)
-class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage {
- boost::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
- std::set<std::string> myGroups; ///< group identifiers that contained the deleted feature
+class Model_ObjectDeletedMessage : public ModelAPI_ObjectDeletedMessage
+{
+ boost::shared_ptr<ModelAPI_Document> myDoc; ///< document owner of the feature
+ std::set<std::string> myGroups; ///< group identifiers that contained the deleted feature
/// Use ModelAPI for creation of this event.
- Model_ObjectDeletedMessage(
- const boost::shared_ptr<ModelAPI_Document>& theDoc, const std::string& theGroup);
+ Model_ObjectDeletedMessage(const boost::shared_ptr<ModelAPI_Document>& theDoc,
+ const std::string& theGroup);
friend class Model_EventCreator;
-public:
+ public:
/// Returns the feature that has been updated
- virtual boost::shared_ptr<ModelAPI_Document> document() const {return myDoc;}
+ virtual boost::shared_ptr<ModelAPI_Document> document() const
+ {
+ return myDoc;
+ }
/// Returns the group where the feature was deleted
- virtual const std::set<std::string >& groups() const {return myGroups;}
+ virtual const std::set<std::string>& groups() const
+ {
+ return myGroups;
+ }
virtual Events_MessageGroup* newEmpty();
-
virtual const Events_ID messageId();
virtual void Join(Events_MessageGroup& theJoined);
#include <boost/shared_ptr.hpp>
bool Model_FeatureValidator::isValid(const boost::shared_ptr<ModelAPI_Feature>& theFeature
- /*, const std::string theAttr*/
- /*, std::list<std::string> theArguments*/) const
+/*, const std::string theAttr*/
+/*, std::list<std::string> theArguments*/) const
{
boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- if(!aData->isValid())
+ if (!aData->isValid())
return false;
const std::string kAllTypes = "";
std::list<AttributePtr> aLtAttributes = aData->attributes(kAllTypes);
std::list<AttributePtr>::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;
}
#include <boost/shared_ptr.hpp>
-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<ModelAPI_Feature>& theFeature) const;
#include <TDF_RelocationTable.hxx>
#include <TDF_ClosureTool.hxx>
-
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()) {
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<ModelAPI_Document> Model_PluginManager::rootDocument()
{
return boost::shared_ptr<ModelAPI_Document>(
- Model_Application::getApplication()->getDocument("root"));
+ Model_Application::getApplication()->getDocument("root"));
}
bool Model_PluginManager::hasRootDocument()
}
boost::shared_ptr<ModelAPI_Document> Model_PluginManager::copy(
- boost::shared_ptr<ModelAPI_Document> theSource, std::string theID)
+ boost::shared_ptr<ModelAPI_Document> theSource, std::string theID)
{
// create a new document
boost::shared_ptr<Model_Document> aNew = boost::dynamic_pointer_cast<Model_Document>(
- Model_Application::getApplication()->getDocument(theID));
+ Model_Application::getApplication()->getDocument(theID));
// make a copy of all labels
- TDF_Label aSourceRoot =
- boost::dynamic_pointer_cast<Model_Document>(theSource)->document()->Main().Father();
+ TDF_Label aSourceRoot = boost::dynamic_pointer_cast<Model_Document>(theSource)->document()->Main()
+ .Father();
TDF_Label aTargetRoot = aNew->document()->Main().Father();
Handle(TDF_DataSet) aDS = new TDF_DataSet;
aDS->AddLabel(aSourceRoot);
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<const Config_FeatureMessage*>(theMessage);
+ const Config_FeatureMessage* aMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
if (aMsg) {
// proccess the plugin info, load plugin
if (myPlugins.find(aMsg->id()) == myPlugins.end()) {
} else if (theMessage->eventID() == kValidatorEvent) {
const Config_ValidatorMessage* aMsg = dynamic_cast<const Config_ValidatorMessage*>(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");
}
void Model_PluginManager::LoadPluginsInfo()
{
- if (myPluginsInfoLoaded) // nothing to do
+ if (myPluginsInfoLoaded) // nothing to do
return;
// Read plugins information from XML files
*/
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<std::string, std::string> myPlugins;
- std::map<std::string, ModelAPI_Plugin*> myPluginObjs; ///< instances of the already plugins
- std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently
- boost::shared_ptr<ModelAPI_Document> myCurrentDoc; ///< current working document
- bool myCheckTransactions; ///< if true, generates error if document is updated outside of transaction
-public:
+ std::map<std::string, ModelAPI_Plugin*> myPluginObjs; ///< instances of the already plugins
+ std::string myCurrentPluginName; ///< name of the plugin that must be loaded currently
+ boost::shared_ptr<ModelAPI_Document> 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<ModelAPI_Document> rootDocument();
/// Copies the document to the new one wit hthe given id
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> copy(
- boost::shared_ptr<ModelAPI_Document> theSource, std::string theID);
+ boost::shared_ptr<ModelAPI_Document> 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();
void Model_ResultBody::store(const boost::shared_ptr<GeomAPI_Shape>& theShape)
{
- boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(data());
+ boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(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<TopoDS_Shape>();
- if (aShape.IsNull()) return; // null shape inside
+ if (aShape.IsNull())
+ return; // null shape inside
aBuilder.Generated(aShape);
}
boost::shared_ptr<GeomAPI_Shape> Model_ResultBody::shape()
{
- boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(data());
+ boost::shared_ptr<Model_Data> aData = boost::dynamic_pointer_cast<Model_Data>(data());
if (aData) {
TDF_Label& aShapeLab = aData->shapeLab();
Handle(TNaming_NamedShape) aName;
*/
class Model_ResultBody : public ModelAPI_ResultBody
{
- boost::shared_ptr<ModelAPI_Feature> myOwner; ///< owner of this result
-public:
+ boost::shared_ptr<ModelAPI_Feature> myOwner; ///< owner of this result
+ public:
/// Stores the shape (called by the execution method).
MODEL_EXPORT virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape);
/// Returns the shape-result produced by this feature
/// Returns the source feature of this result
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> owner();
-protected:
+ protected:
/// Makes a body on the given feature
Model_ResultBody();
*/
class Model_ResultConstruction : public ModelAPI_ResultConstruction
{
- boost::shared_ptr<ModelAPI_Feature> myOwner; ///< owner of this result
- boost::shared_ptr<GeomAPI_Shape> myShape; ///< shape of this result created "on the fly"
+ boost::shared_ptr<ModelAPI_Feature> myOwner; ///< owner of this result
+ boost::shared_ptr<GeomAPI_Shape> 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<GeomAPI_Shape> theShape);
/// Returns the shape-result produced by this feature
/// 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();
boost::shared_ptr<ModelAPI_Feature> Model_ResultPart::owner()
{
- return boost::shared_ptr<ModelAPI_Feature>(); // return empty pointer
+ return boost::shared_ptr<ModelAPI_Feature>(); // return empty pointer
}
Model_ResultPart::Model_ResultPart()
*/
class Model_ResultPart : public ModelAPI_ResultPart
{
-public:
+ public:
/// Returns the part-document of this result
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Document> partDoc();
/// Part has no stored feature: this method returns NULL
MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> owner();
-protected:
+ protected:
/// makes a result on a temporary feature (an action)
Model_ResultPart();
#include <BRep_Tool.hxx>
#include <GeomAdaptor_Curve.hxx>
-
ResultPtr result(const ObjectPtr theObject)
{
return boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
return TopoDS_Shape();
}
-
bool Model_ResultPointValidator::isValid(const ObjectPtr theObject) const
{
ResultPtr aResult = result(theObject);
return aShape.ShapeType() == TopAbs_VERTEX;
}
-
bool Model_ResultLineValidator::isValid(const ObjectPtr theObject) const
{
ResultPtr aResult = result(theObject);
return false;
}
-
bool Model_ResultArcValidator::isValid(const ObjectPtr theObject) const
{
ResultPtr aResult = result(theObject);
#include <ModelAPI_ResultValidator.h>
#include <ModelAPI_Object.h>
-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
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()
{
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<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
+ const ModelAPI_ObjectUpdatedMessage* aMsg =
+ dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
myInitial = aMsg->objects();
// collect all documents involved into the update
set<boost::shared_ptr<ModelAPI_Document> > aDocs;
set<boost::shared_ptr<ModelAPI_Object> >::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<boost::shared_ptr<ModelAPI_Document> >::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<ModelAPI_Feature>
- ((*aDIter)->object(ModelAPI_Feature::group(), aFIndex, true));
+ for (int aFIndex = 0; aFIndex < aNbFeatures; aFIndex++) {
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(
+ (*aDIter)->object(ModelAPI_Feature::group(), aFIndex, true));
if (aFeature)
updateFeature(aFeature);
}
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<boost::shared_ptr<ModelAPI_Attribute> > aRefs =
- theFeature->data()->attributes(ModelAPI_AttributeReference::type());
+ list<boost::shared_ptr<ModelAPI_Attribute> > aRefs = theFeature->data()->attributes(
+ ModelAPI_AttributeReference::type());
list<boost::shared_ptr<ModelAPI_Attribute> >::iterator aRefsIter = aRefs.begin();
- for(; aRefsIter != aRefs.end(); aRefsIter++) {
- boost::shared_ptr<ModelAPI_Object> aSub =
- boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(*aRefsIter)->value();
+ for (; aRefsIter != aRefs.end(); aRefsIter++) {
+ boost::shared_ptr<ModelAPI_Object> 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<ObjectPtr> aListRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*aRefsIter)->list();
+ for (aRefsIter = aRefs.begin(); aRefsIter != aRefs.end(); aRefsIter++) {
+ list<ObjectPtr> aListRef = boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(*aRefsIter)
+ ->list();
list<ObjectPtr>::iterator aListIter = aListRef.begin();
- for(; aListIter != aListRef.end(); aListIter++) {
+ for (; aListIter != aListRef.end(); aListIter++) {
boost::shared_ptr<ModelAPI_Object> aSub = *aListIter;
if (updateObject(aSub)) {
aMustbeUpdated = true;
static Events_ID EVENT_DISP = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
const std::list<boost::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
- for(; aRIter != aResults.cend(); aRIter++) {
+ for (; aRIter != aResults.cend(); aRIter++) {
boost::shared_ptr<ModelAPI_Result> 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<boost::shared_ptr<ModelAPI_Result> >& aResults = theFeature->results();
std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aRIter = aResults.begin();
- for(; aRIter != aResults.cend(); aRIter++) {
+ for (; aRIter != aResults.cend(); aRIter++) {
if (myInitial.find(*aRIter) != myInitial.end()) {
aMustbeUpdated = true;
break;
bool Model_Update::updateObject(boost::shared_ptr<ModelAPI_Object> theObject)
{
- if (!theObject)
+ if (!theObject)
return false;
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(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<ModelAPI_Result>(theObject);
if (aResult) {
}
if (myInitial.find(theObject) != myInitial.end())
return true;
- return false; // nothing is known
+ return false; // nothing is known
}
std::map<boost::shared_ptr<ModelAPI_Object>, 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<ModelAPI_Feature> theFeature);
#include <ModelAPI_Feature.h>
#include <Events_Error.h>
-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");
}
}
-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<std::string>();
myFeatures[theFeatureID].insert(theID);
}
-void Model_ValidatorsFactory::assignValidator(const std::string& theID,
- const std::string& theFeatureID, const std::string& theAttrID,
- const std::list<std::string>& theArguments)
+void Model_ValidatorsFactory::assignValidator(const std::string& theID,
+ const std::string& theFeatureID,
+ const std::string& theAttrID,
+ const std::list<std::string>& theArguments)
{
// create feature-structures if not exist
- std::map<std::string, std::map<std::string, AttrValidators> >::iterator aFeature =
- myAttrs.find(theFeatureID);
+ std::map<std::string, std::map<std::string, AttrValidators> >::iterator aFeature = myAttrs.find(
+ theFeatureID);
if (aFeature == myAttrs.end()) {
myAttrs[theFeatureID] = std::map<std::string, AttrValidators>();
aFeature = myAttrs.find(theFeatureID);
aFeature->second[theAttrID] = AttrValidators();
}
aFeature->second[theAttrID].insert(
- std::pair<std::string, std::list<std::string> >(theID, theArguments));
+ std::pair<std::string, std::list<std::string> >(theID, theArguments));
}
-void Model_ValidatorsFactory::validators(
- const std::string& theFeatureID, std::list<ModelAPI_Validator*>& theResult ) const
+void Model_ValidatorsFactory::validators(const std::string& theFeatureID,
+ std::list<ModelAPI_Validator*>& theResult) const
{
- std::map<std::string, std::set<std::string> >::const_iterator aFeature =
- myFeatures.find(theFeatureID);
+ std::map<std::string, std::set<std::string> >::const_iterator aFeature = myFeatures.find(
+ theFeatureID);
if (aFeature != myFeatures.cend()) {
std::set<std::string>::const_iterator aValIter = aFeature->second.cbegin();
- for(; aValIter != aFeature->second.cend(); aValIter++) {
+ for (; aValIter != aFeature->second.cend(); aValIter++) {
std::map<std::string, ModelAPI_Validator*>::const_iterator aFound = myIDs.find(*aValIter);
if (aFound == myIDs.end()) {
Events_Error::send(std::string("Validator ") + *aValIter + " was not registered");
}
}
-void Model_ValidatorsFactory::validators(const std::string& theFeatureID,
- const std::string& theAttrID, std::list<ModelAPI_Validator*>& theValidators,
- std::list<std::list<std::string> >& theArguments) const
+void Model_ValidatorsFactory::validators(const std::string& theFeatureID,
+ const std::string& theAttrID,
+ std::list<ModelAPI_Validator*>& theValidators,
+ std::list<std::list<std::string> >& theArguments) const
{
- std::map<std::string, std::map<std::string, AttrValidators> >::const_iterator aFeature =
- myAttrs.find(theFeatureID);
+ std::map<std::string, std::map<std::string, AttrValidators> >::const_iterator aFeature = myAttrs
+ .find(theFeatureID);
if (aFeature != myAttrs.cend()) {
- std::map<std::string, AttrValidators>::const_iterator anAttr =
- aFeature->second.find(theAttrID);
+ std::map<std::string, AttrValidators>::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<std::string, ModelAPI_Validator*>::const_iterator aFound =
- myIDs.find(aValIter->first);
+ for (; aValIter != anAttr->second.cend(); aValIter++) {
+ std::map<std::string, ModelAPI_Validator*>::const_iterator aFound = myIDs.find(
+ aValIter->first);
if (aFound == myIDs.end()) {
Events_Error::send(std::string("Validator ") + aValIter->first + " was not registered");
} else {
}
}
-Model_ValidatorsFactory::Model_ValidatorsFactory() : ModelAPI_ValidatorsFactory()
+Model_ValidatorsFactory::Model_ValidatorsFactory()
+ : ModelAPI_ValidatorsFactory()
{
registerValidator("Model_ResultPointValidator", new Model_ResultPointValidator);
registerValidator("Model_ResultLineValidator", new Model_ResultLineValidator);
registerValidator("Model_FeatureValidator", new Model_FeatureValidator);
}
-
const ModelAPI_Validator* Model_ValidatorsFactory::validator(const std::string& theID) const
{
std::map<std::string, ModelAPI_Validator*>::const_iterator aIt = myIDs.find(theID);
* 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<std::string, ModelAPI_Validator*> myIDs; ///< map from ID to registered validator
+ private:
+ std::map<std::string, ModelAPI_Validator*> myIDs; ///< map from ID to registered validator
/// validators IDs by feature ID
- std::map<std::string, std::set<std::string> > myFeatures;
+ std::map<std::string, std::set<std::string> > myFeatures;
/// set of pairs: validators IDs, list of arguments
typedef std::set<std::pair<std::string, std::list<std::string> > > AttrValidators;
/// validators IDs and arguments by feature and attribute IDs
std::map<std::string, std::map<std::string, AttrValidators> > 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<std::string>& theArguments);
+ MODEL_EXPORT virtual void assignValidator(const std::string& theID,
+ const std::string& theFeatureID,
+ const std::string& theAttrID,
+ const std::list<std::string>& theArguments);
/// Provides a validator for the feature, returns NULL if no validator
- MODEL_EXPORT virtual void validators(const std::string& theFeatureID,
- std::list<ModelAPI_Validator*>& theResult) const;
+ MODEL_EXPORT virtual void validators(const std::string& theFeatureID,
+ std::list<ModelAPI_Validator*>& 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<ModelAPI_Validator*>& theValidators,
- std::list<std::list<std::string> >& theArguments) const;
+ MODEL_EXPORT virtual void validators(const std::string& theFeatureID,
+ const std::string& theAttrID,
+ std::list<ModelAPI_Validator*>& theValidators,
+ std::list<std::list<std::string> >& theArguments) const;
/// Returns registered validator by its Id
virtual const ModelAPI_Validator* validator(const std::string& theID) const;
//MODEL_EXPORT virtual bool validate(
// const boost::shared_ptr<ModelAPI_Feature>& theFeature, const std::string& theAttrID) const;
-protected:
+ protected:
/// Get instance from PluginManager
Model_ValidatorsFactory();
{
///< needed here to emit signal that feature changed on change of the attribute
boost::shared_ptr<ModelAPI_Object> 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<ModelAPI_Object>& theObject)
- {myObject = theObject;}
+ {
+ myObject = theObject;
+ }
/// Returns the owner of this attribute
MODELAPI_EXPORT const boost::shared_ptr<ModelAPI_Object>& 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;
+ }
};
class ModelAPI_AttributeBoolean : public ModelAPI_Attribute
{
-public:
+ public:
/// Defines the double value
MODELAPI_EXPORT virtual void setValue(bool theValue) = 0;
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
class ModelAPI_AttributeDocRef : public ModelAPI_Attribute
{
-public:
+ public:
/// Defines the document referenced from this attribute
MODELAPI_EXPORT virtual void setValue(boost::shared_ptr<ModelAPI_Document> theDoc) = 0;
MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> 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
class ModelAPI_AttributeDouble : public ModelAPI_Attribute
{
-public:
+ public:
/// Defines the double value
MODELAPI_EXPORT virtual void setValue(const double theValue) = 0;
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
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;
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
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;
/// Returns the list of features
MODELAPI_EXPORT virtual std::list<ObjectPtr> list() = 0;
-protected:
+ protected:
/// Objects are created for features automatically
MODELAPI_EXPORT ModelAPI_AttributeRefList()
- {}
+ {
+ }
};
#endif
class ModelAPI_AttributeReference : public ModelAPI_Attribute
{
-public:
+ public:
/// Defines the object referenced from this attribute
MODELAPI_EXPORT virtual void setValue(ObjectPtr theObject) = 0;
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
#include <ModelAPI_Object.h>
#include <ModelAPI_Validator.h>
-
-class ModelAPI_AttributeValidator: public ModelAPI_Validator
+class ModelAPI_AttributeValidator : public ModelAPI_Validator
{
-public:
- virtual bool isValid(const FeaturePtr& theFeature,
- const std::list<std::string>& theArguments,
+ public:
+ virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
const ObjectPtr& theObject) const = 0;
};
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;
/// Returns all attributes ofthe feature of the given type
/// or all attributes if "theType" is empty
virtual std::list<boost::shared_ptr<ModelAPI_Attribute> >
- 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<ModelAPI_Attribute>& theAttr) = 0;
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<ModelAPI_Data> DataPtr;
-
#endif
*/
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
virtual void removeFeature(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
///! Adds a new sub-document by the identifier, or returns existing one if it is already exist
- virtual boost::shared_ptr<ModelAPI_Document>
- subDocument(std::string theDocID) = 0;
+ virtual boost::shared_ptr<ModelAPI_Document>
+ subDocument(std::string theDocID) = 0;
///! Returns the id of the document
virtual const std::string& id() const = 0;
//! \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<ModelAPI_Object>
- object(const std::string& theGroupID, const int theIndex, const bool theHidden = false) = 0;
+ virtual boost::shared_ptr<ModelAPI_Object>
+ 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<ModelAPI_ResultConstruction> createConstruction(
- const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
+ const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
/// Creates a body results
virtual boost::shared_ptr<ModelAPI_ResultBody> createBody(
- const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
+ const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
/// Creates a part results
virtual boost::shared_ptr<ModelAPI_ResultPart> createPart(
- const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
+ const boost::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
//! Returns a feature by result (owner of result)
virtual boost::shared_ptr<ModelAPI_Feature> feature(
- const boost::shared_ptr<ModelAPI_Result>& theResult) = 0;
+ const boost::shared_ptr<ModelAPI_Result>& theResult) = 0;
-protected:
+ protected:
/// Only for SWIG wrapping it is here
MODELAPI_EXPORT ModelAPI_Document()
- {}
+ {
+ }
};
-
//! Pointer on document object
typedef boost::shared_ptr<ModelAPI_Document> DocumentPtr;
-
#endif
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<ObjectPtr> objects() const = 0;
};
/// 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<ModelAPI_Document> document() const = 0;
/// Returns the group where the feature was deleted
- virtual const std::set<std::string >& groups() const = 0;
+ virtual const std::set<std::string>& groups() const = 0;
virtual Events_MessageGroup* newEmpty() = 0;
};
/// 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<ModelAPI_Document>& theDoc, const std::string& theGroup) const = 0;
+ virtual void sendDeleted(const boost::shared_ptr<ModelAPI_Document>& 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);
};
#include <ModelAPI_Document.h>
#include <Events_Loop.h>
-const std::list<boost::shared_ptr<ModelAPI_Result> >& ModelAPI_Feature::results()
+const std::list<boost::shared_ptr<ModelAPI_Result> >& ModelAPI_Feature::results()
{
return myResults;
}
-boost::shared_ptr<ModelAPI_Result> ModelAPI_Feature::firstResult()
+boost::shared_ptr<ModelAPI_Result> ModelAPI_Feature::firstResult()
{
return myResults.empty() ? boost::shared_ptr<ModelAPI_Result>() : *(myResults.begin());
}
-void ModelAPI_Feature::setResult(const boost::shared_ptr<ModelAPI_Result>& theResult)
+void ModelAPI_Feature::setResult(const boost::shared_ptr<ModelAPI_Result>& 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<ModelAPI_Result> aRes = *(myResults.begin());
myResults.erase(myResults.begin());
ModelAPI_EventCreator::get()->sendDeleted(aRes->document(), aRes->groupName());
Events_Loop::loop()->flush(anEvent);
}
-void ModelAPI_Feature::setResult(
- const boost::shared_ptr<ModelAPI_Result>& theResult, const int theIndex)
+void ModelAPI_Feature::setResult(const boost::shared_ptr<ModelAPI_Result>& theResult,
+ const int theIndex)
{
std::list<boost::shared_ptr<ModelAPI_Result> >::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);
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<ModelAPI_Result> aRes = *(myResults.begin());
myResults.erase(myResults.begin());
ModelAPI_EventCreator::get()->sendDeleted(aRes->document(), aRes->groupName());
{
///< list of current results of this feature
std::list<boost::shared_ptr<ModelAPI_Result> > 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;
/// sets the alone result
MODELAPI_EXPORT void setResult(const boost::shared_ptr<ModelAPI_Result>& theResult);
/// sets the result by index (zero based), results before this must be set before
- MODELAPI_EXPORT void setResult(
- const boost::shared_ptr<ModelAPI_Result>& theResult, const int theIndex);
+ MODELAPI_EXPORT void setResult(const boost::shared_ptr<ModelAPI_Result>& 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
#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
*/
class ModelAPI_Object
{
- boost::shared_ptr<ModelAPI_Data> myData; ///< manager of the data model of a feature
- boost::shared_ptr<ModelAPI_Document> myDoc; ///< document this feature belongs to
-public:
+ boost::shared_ptr<ModelAPI_Data> myData; ///< manager of the data model of a feature
+ boost::shared_ptr<ModelAPI_Document> 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<ModelAPI_Data> data() {return myData;}
+ virtual boost::shared_ptr<ModelAPI_Data> data()
+ {
+ return myData;
+ }
/// Returns true if object refers to the same data model instance
virtual bool isSame(const boost::shared_ptr<ModelAPI_Object>& theObject)
- {return theObject.get() == this;}
+ {
+ return theObject.get() == this;
+ }
/// Returns document this feature belongs to
virtual boost::shared_ptr<ModelAPI_Document> 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<ModelAPI_Data> theData)
- {myData = theData;}
+ virtual void setData(boost::shared_ptr<ModelAPI_Data> theData)
+ {
+ myData = theData;
+ }
/// Sets the data manager of an object (document does)
- virtual void setDoc(boost::shared_ptr<ModelAPI_Document> theDoc) {myDoc = theDoc;}
+ virtual void setDoc(boost::shared_ptr<ModelAPI_Document> theDoc)
+ {
+ myDoc = theDoc;
+ }
friend class Model_Document;
};
class MODELAPI_EXPORT ModelAPI_Plugin
{
-public:
+ public:
/// Creates the feature object of this plugin by the feature string ID
virtual boost::shared_ptr<ModelAPI_Feature> 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
{
}
-void ModelAPI_PluginManager::setPluginManager(
- boost::shared_ptr<ModelAPI_PluginManager> theManager)
+void ModelAPI_PluginManager::setPluginManager(boost::shared_ptr<ModelAPI_PluginManager> theManager)
{
MY_MANAGER = theManager;
}
boost::shared_ptr<ModelAPI_PluginManager> 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;
class MODELAPI_EXPORT ModelAPI_PluginManager
{
-public:
+ public:
/// Returns the real implementation (the alone instance per application) of the plugin manager
static boost::shared_ptr<ModelAPI_PluginManager> get();
virtual void setCurrentDocument(boost::shared_ptr<ModelAPI_Document> theDoc) = 0;
/// Copies the document to the new one wit hthe given id
- virtual boost::shared_ptr<ModelAPI_Document> copy(
- boost::shared_ptr<ModelAPI_Document> theSource, std::string theID) = 0;
+ virtual boost::shared_ptr<ModelAPI_Document> copy(boost::shared_ptr<ModelAPI_Document> theSource,
+ std::string theID) = 0;
/// Returns the validators factory: the only one instance per application
virtual ModelAPI_ValidatorsFactory* validators() = 0;
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<ModelAPI_Feature> createFeature(std::string theFeatureID) = 0;
*/
class ModelAPI_Result : public ModelAPI_Object
{
-public:
+ public:
/// Returns the source feature of this result
//virtual boost::shared_ptr<ModelAPI_Feature> owner() = 0;
*/
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<GeomAPI_Shape>& theShape) = 0;
virtual boost::shared_ptr<GeomAPI_Shape> 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
*/
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<GeomAPI_Shape>& shape() = 0;
*/
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
*/
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()
#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
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultConstruction.h>
-
namespace ModelAPI_Tools {
boost::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult)
{
ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(theResult);
- if (aBody) return aBody->shape();
- ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
- if (aConstruct) return aConstruct->shape();
+ if (aBody)
+ return aBody->shape();
+ ResultConstructionPtr aConstruct = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(
+ theResult);
+ if (aConstruct)
+ return aConstruct->shape();
return boost::shared_ptr<GeomAPI_Shape>();
}
-}
\ No newline at end of file
+}
#include <ModelAPI_Result.h>
#include <GeomAPI_Shape.h>
-namespace ModelAPI_Tools
-{
- /// Returns shape from the given Result object
- MODELAPI_EXPORT boost::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult);
-};
+namespace ModelAPI_Tools {
+/// Returns shape from the given Result object
+MODELAPI_EXPORT boost::shared_ptr<GeomAPI_Shape> shape(const ResultPtr& theResult);
+}
+;
-#endif
\ No newline at end of file
+#endif
*/
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
*/
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;
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<std::string>& theArguments) = 0;
+ virtual void assignValidator(const std::string& theID, const std::string& theFeatureID,
+ const std::string& theAttrID,
+ const std::list<std::string>& theArguments) = 0;
/// Provides a validator for the feature, returns NULL if no validator
- virtual void validators(const std::string& theFeatureID,
- std::list<ModelAPI_Validator*>& theResult) const = 0;
+ virtual void validators(const std::string& theFeatureID,
+ std::list<ModelAPI_Validator*>& 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<ModelAPI_Validator*>& theValidators,
- std::list<std::list<std::string> >& theArguments) const = 0;
+ virtual void validators(const std::string& theFeatureID, const std::string& theAttrID,
+ std::list<ModelAPI_Validator*>& theValidators,
+ std::list<std::list<std::string> >& theArguments) const = 0;
/// Returns registered validator by its Id
virtual const ModelAPI_Validator* validator(const std::string& theID) const = 0;
//virtual bool validate(
// const boost::shared_ptr<ModelAPI_Feature>& theFeature, const std::string& theAttrID) const = 0;
-protected:
+ protected:
/// Get instance from PluginManager
- ModelAPI_ValidatorsFactory() {}
+ ModelAPI_ValidatorsFactory()
+ {
+ }
};
#endif
-#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\r
+#define MODULEBASE_H\r
+\r
+#if defined MODULEBASE_EXPORTS\r
+#if defined WIN32\r
+#define MODULEBASE_EXPORT __declspec( dllexport )\r
+#else\r
+#define MODULEBASE_EXPORT\r
+#endif\r
+#else\r
+#if defined WIN32\r
+#define MODULEBASE_EXPORT __declspec( dllimport )\r
+#else\r
+#define MODULEBASE_EXPORT\r
+#endif\r
+#endif\r
+\r
+#endif //MODULEBASE_H\r
\ No newline at end of file
-
#ifndef ModuleBase_Definitions_H
#define ModuleBase_Definitions_H
typedef QList<int> QIntList; //!< list of int values
typedef QList<short> QShortList; //!< list of short int values
typedef QList<double> QDoubleList; //!< list of double values
-typedef QList<FeaturePtr> QFeatureList; //!< List of features
-typedef QList<ResultPtr> QResultList; //!< List of results
-
+typedef QList<FeaturePtr> QFeatureList; //!< List of features
+typedef QList<ResultPtr> QResultList; //!< List of results
-#endif
\ No newline at end of file
+#endif
-#ifndef ModuleBase_IModule_H
-#define ModuleBase_IModule_H
-
-#include <QString>
-#include <QObject>
-
-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<ModuleBase_ModelWidget*>& 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\r
+#define ModuleBase_IModule_H\r
+\r
+#include <QString>\r
+#include <QObject>\r
+\r
+class QAction;\r
+class XGUI_Workshop;\r
+class Config_WidgetAPI;\r
+class ModuleBase_ModelWidget;\r
+\r
+/**\r
+ * Interface to a module\r
+ */\r
+class ModuleBase_IModule : public QObject\r
+{\r
+ public:\r
+ /// Reads description of features from XML file \r
+ virtual void createFeatures() = 0;\r
+\r
+ /// Called on creation of menu item in desktop\r
+ virtual void featureCreated(QAction*) = 0;\r
+\r
+ /// Creates an operation and send it to loop\r
+ /// \param theCmdId the operation name\r
+ virtual void launchOperation(const QString& theCmdId) = 0;\r
+\r
+ /// Called when it is necessary to update a command state (enable or disable it)\r
+ //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;\r
+\r
+ /// Creates custom widgets for property panel\r
+ virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
+ Config_WidgetAPI* theWidgetApi,\r
+ QList<ModuleBase_ModelWidget*>& theModelWidgets)\r
+ {\r
+ return 0;\r
+ }\r
+\r
+ virtual ~ModuleBase_IModule()\r
+ {\r
+ }\r
+ ;\r
+};\r
+\r
+//! This function must return a new module instance.\r
+extern "C" {\r
+typedef ModuleBase_IModule* (*CREATE_FUNC)(XGUI_Workshop*);\r
+}\r
+\r
+#define CREATE_MODULE "createModule"\r
+\r
+#endif //ModuleBase_IModule\r
\ No newline at end of file
#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);
}
}
/*void ModuleBase_IOperation::setModelWidgets(const std::string& theXmlRepresentation,
- QList<ModuleBase_ModelWidget*> theWidgets)
-{
- QList<ModuleBase_ModelWidget*>::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<ModuleBase_ModelWidget*> theWidgets)
+ {
+ QList<ModuleBase_ModelWidget*>::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<ModelAPI_Document> ModuleBase_IOperation::document() const
{
document()->finishOperation();
emit stopped();
-
+
afterCommitOperation();
return true;
}
* Author: nds
*/
-
#ifndef ModuleBase_IOperation_H
#define ModuleBase_IOperation_H
* - 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
// QList<ModuleBase_ModelWidget*> 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
/// 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;
/// 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
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
virtual std::list<ModuleBase_ViewerPrs> 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<ObjectPtr> selectedObjects() const = 0;
/**
- * Returns list of currently selected results
- */
+ * Returns list of currently selected results
+ */
virtual QList<ObjectPtr> selectedPresentations() const = 0;
-
+
//! Returns list of currently selected QModelIndexes
virtual QModelIndexList selectedIndexes() const = 0;
};
-#endif
\ No newline at end of file
+#endif
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<ObjectPtr> selectedObjects() const = 0;
+ virtual QList<ObjectPtr> selectedObjects() const = 0;
//! Returns instance of loaded module
virtual ModuleBase_IModule* module() const = 0;
void selectionChanged();
};
-#endif
\ No newline at end of file
+#endif
#include <QWidget>
-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() : "";
}
return true;
}
-
void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
{
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
*/
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
/// 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
/// \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;
};
#endif
ModuleBase_Operation::ModuleBase_Operation(const QString& theId, QObject* theParent)
-: ModuleBase_IOperation(theId, theParent)
+ : ModuleBase_IOperation(theId, theParent)
{
}
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;
}
void ModuleBase_Operation::commitOperation()
{
- if (myFeature) myFeature->execute();
+ if (myFeature)
+ myFeature->execute();
}
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<ModelAPI_Validator*> aValidators;
- aFactory->validators(aId, aValidators);
- std::list<ModelAPI_Validator*>::const_iterator aIt;
- for (aIt = aValidators.cbegin(); aIt != aValidators.cend(); ++aIt) {
- const ModuleBase_FeatureValidator* aFValidator =
- dynamic_cast<const ModuleBase_FeatureValidator*>(*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<ModelAPI_Validator*> aValidators;
+ aFactory->validators(aId, aValidators);
+ std::list<ModelAPI_Validator*>::const_iterator aIt;
+ for (aIt = aValidators.cbegin(); aIt != aValidators.cend(); ++aIt) {
+ const ModuleBase_FeatureValidator* aFValidator =
+ dynamic_cast<const ModuleBase_FeatureValidator*>(*aIt);
+ if (aFValidator) {
+ if (!aFValidator->isValid(aFeature))
+ return false;
+ }
+ }*/
return true;
}
return false;
{
boost::shared_ptr<ModelAPI_Document> 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<ModuleBase_ModelWidget*> aWidgets = getDescription()->modelWidgets();
- QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
- for (; anIt != aLast; anIt++) {
- (*anIt)->storeValue(aFeature);
- }*/
+ QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
+ for (; anIt != aLast; anIt++) {
+ (*anIt)->storeValue(aFeature);
+ }*/
}
if (theFlushMessage)
}
}
return false;
-}
\ No newline at end of file
+}
* Author: sbh
*/
-
#ifndef ModuleBase_Operation_H
#define ModuleBase_Operation_H
* - 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
/// 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);
/// 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);
/// \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();
/// \returns the created feature
virtual FeaturePtr createFeature(const bool theFlushMessage = true);
-protected:
+ protected:
/// Sets the operation feature
void setFeature(FeaturePtr theFeature);
/// \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
#include <QString>
ModuleBase_OperationDescription::ModuleBase_OperationDescription(const QString& theId)
-: myOperationId(theId)
+ : myOperationId(theId)
{
}
}
/*void ModuleBase_OperationDescription::setModelWidgets(const std::string& theXmlRepresentation,
- const QList<ModuleBase_ModelWidget*>& theWidgets)
-{
- myWidgets.clear();
- QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end();
- for (; anIt != aLast; anIt++)
- myWidgets.push_back(*anIt);
- myXmlRepresentation = theXmlRepresentation;
-}*/
+ const QList<ModuleBase_ModelWidget*>& theWidgets)
+ {
+ myWidgets.clear();
+ QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end();
+ for (; anIt != aLast; anIt++)
+ myWidgets.push_back(*anIt);
+ myXmlRepresentation = theXmlRepresentation;
+ }*/
/*const QList<ModuleBase_ModelWidget*>& ModuleBase_OperationDescription::modelWidgets() const
-{
- return myWidgets;
-}*/
+ {
+ return myWidgets;
+ }*/
const QString& ModuleBase_OperationDescription::xmlRepresentation() const
{
-/*
- * ModuleBase_OperationDescription.h
- *
- * Created on: Apr 2, 2014
- * Author: sbh
- */
-
-#ifndef MODULEBASE_OPERATIONDESCRIPTION_H
-#define MODULEBASE_OPERATIONDESCRIPTION_H
-
-#include <ModuleBase.h>
-#include <ModuleBase_Operation.h>
-
-#include <QObject>
-#include <QString>
-#include <QList>
-
-#include <memory>
-
-//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<ModuleBase_ModelWidget*>& theWidgets);
-
- /// Sets a list of model widgets, according to the operation feature xml definition
- /// \param theWidgets a list of widgets
- //const QList<ModuleBase_ModelWidget*>& 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<ModuleBase_ModelWidget*> myWidgets; /// the list of operation widgets
-};
-
-#endif //ModuleBase_OperationDescription_H
+/*\r
+ * ModuleBase_OperationDescription.h\r
+ *\r
+ * Created on: Apr 2, 2014\r
+ * Author: sbh\r
+ */\r
+\r
+#ifndef MODULEBASE_OPERATIONDESCRIPTION_H\r
+#define MODULEBASE_OPERATIONDESCRIPTION_H\r
+\r
+#include <ModuleBase.h>\r
+#include <ModuleBase_Operation.h>\r
+\r
+#include <QObject>\r
+#include <QString>\r
+#include <QList>\r
+\r
+#include <memory>\r
+\r
+//class ModuleBase_ModelWidget;\r
+\r
+/*!\r
+ * \class ModuleBase_OperationDescription\r
+ *\r
+ */\r
+class MODULEBASE_EXPORT ModuleBase_OperationDescription\r
+{\r
+ public:\r
+ /// Constructor\r
+ /// \param theId - the operation identifier\r
+ ModuleBase_OperationDescription(const QString& theId = "");\r
+ /// Destructor\r
+ virtual ~ModuleBase_OperationDescription();\r
+\r
+ /// Unique name of the operation\r
+ /// \return string name of the operation.\r
+ const QString& operationId() const;\r
+\r
+ /// Returns XML representation of the operation's widget.\r
+ /// \return XML QString\r
+ //const QString& xmlRepresentation() const;\r
+\r
+ /// Returns a short description of operation (will be\r
+ /// inserted in title of property panel)\r
+ const QString& description() const;\r
+\r
+ /// Sets a short description of operation (will be\r
+ /// inserted in title of property panel)\r
+ void setDescription(const QString& theDescription);\r
+\r
+ /// Sets a list of model widgets, according to the operation feature xml definition\r
+ /// \param theWidgets a list of widgets\r
+ //void setModelWidgets(const std::string& theXmlRepresentation,\r
+ // const QList<ModuleBase_ModelWidget*>& theWidgets);\r
+\r
+ /// Sets a list of model widgets, according to the operation feature xml definition\r
+ /// \param theWidgets a list of widgets\r
+ //const QList<ModuleBase_ModelWidget*>& modelWidgets() const;\r
+\r
+ /// Returns XML representation of the operation's widget.\r
+ /// \return XML QString\r
+ const QString& xmlRepresentation() const;\r
+\r
+ /// Sets XML representation of the operation's widget.\r
+ /// \param theXMLRepresentation - XML QString\r
+ void setXmlRepresentation(const QString& theXMLRepresentation);\r
+\r
+ /// Returns true if there are no model widgets\r
+ /// \return the boolean value\r
+ bool hasXmlRepresentation() const;\r
+\r
+ private:\r
+ //!< Next fields could be extracted into a subclass;\r
+ QString myOperationId; /// the operation identifier\r
+ QString myDescription; /// the short description of the opertaion\r
+ QString myXmlRepresentation; /// the xml definition\r
+ //QList<ModuleBase_ModelWidget*> myWidgets; /// the list of operation widgets\r
+};\r
+\r
+#endif //ModuleBase_OperationDescription_H\r
\ No newline at end of file
#include <BRep_Tool.hxx>
#include <GeomAdaptor_Curve.hxx>
-
ResultPtr result(const ObjectPtr theObject)
{
return boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
return TopoDS_Shape();
}
-
bool ModuleBase_ResultPointValidator::isValid(const ObjectPtr theObject) const
{
ResultPtr aResult = result(theObject);
return aShape.ShapeType() == TopAbs_VERTEX;
}
-
bool ModuleBase_ResultLineValidator::isValid(const ObjectPtr theObject) const
{
ResultPtr aResult = result(theObject);
return false;
}
-
bool ModuleBase_ResultArcValidator::isValid(const ObjectPtr theObject) const
{
ResultPtr aResult = result(theObject);
#include <ModelAPI_Validator.h>
#include <ModelAPI_Object.h>
-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
#include <ModelAPI_Validator.h>
-
-class ModuleBase_SelectionValidator: public ModelAPI_Validator
+class ModuleBase_SelectionValidator : public ModelAPI_Validator
{
-public:
+ public:
virtual bool isValid(const ModuleBase_ISelection* theSelection) const = 0;
};
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_Document.h>
-namespace ModuleBase_Tools
-{
+namespace ModuleBase_Tools {
//******************************************************************
// Created: 11 July 2014
// Author: Vitaly Smetannikov
-
#ifndef ModuleBase_Tools_H
#define ModuleBase_Tools_H
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<GeomAPI_Shape> shape(ResultPtr theResult);
+/**
+ * Returns returns a shape if the result has a shape method. Otherwise returns NULL pointer
+ */
+MODULEBASE_EXPORT boost::shared_ptr<GeomAPI_Shape> shape(ResultPtr theResult);
- MODULEBASE_EXPORT FeaturePtr feature(ObjectPtr theObject);
+MODULEBASE_EXPORT FeaturePtr feature(ObjectPtr theObject);
-};
+}
+;
-#endif
\ No newline at end of file
+#endif
*/
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)
{
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;
};
#include <QLayout>
#include <QCheckBox>
-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());
{
}
-QWidget* ModuleBase_WidgetBoolValue::getControl() const
-{
- return myCheckBox;
+QWidget* ModuleBase_WidgetBoolValue::getControl() const
+{
+ return myCheckBox;
}
bool ModuleBase_WidgetBoolValue::storeValue() const
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();
/// \returns the widget
QWidget* getControl() const;
-private:
+ private:
QCheckBox* myCheckBox;
};
-#endif
\ No newline at end of file
+#endif
#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);
{
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);
}
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();
/// 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
#include <QDoubleSpinBox>
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);
}
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));
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);
*/
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
/// \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
ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(const std::string& theXmlRepresentation,
ModuleBase_IWorkshop* theWorkshop)
- : myWorkshop(theWorkshop)
+ : myWorkshop(theWorkshop)
{
myWidgetApi = new Config_WidgetAPI(theXmlRepresentation);
}
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);
}
}
if (aWdgType == WDG_SWITCH) {
ModuleBase_WidgetSwitch* aSwitch = qobject_cast<ModuleBase_WidgetSwitch*>(aWidget);
aSwitch->addPage(aPage, aPageName);
- } else if (aWdgType == WDG_TOOLBOX){
+ } else if (aWdgType == WDG_TOOLBOX) {
QToolBox* aToolbox = qobject_cast<QToolBox*>(aWidget);
aToolbox->addItem(aPage, aPageName);
}
- } while(myWidgetApi->toNextWidget());
+ } while (myWidgetApi->toNextWidget());
}
- } while(myWidgetApi->toNextWidget());
+ } while (myWidgetApi->toNextWidget());
theParent->setLayout(aWidgetLay);
}
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) {
} 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;
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();
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();
}
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
+}
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);
return myModelWidgets;
}
-protected:
+ protected:
//Widgets
QWidget* createWidgetByType(const std::string& theType, QWidget* theParent = NULL);
QWidget* labelControl(QWidget* theParent);
QString qs(const std::string& theStdString) const;
-private:
+ private:
Config_WidgetAPI* myWidgetApi;
- ModuleBase_IWorkshop* myWorkshop;
+ ModuleBase_IWorkshop* myWorkshop;
QList<ModuleBase_ModelWidget*> myModelWidgets;
std::string myParentId;
#include <QLabel>
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);
bool isDone = false;
if (theValue) {
- ModuleBase_WidgetValueFeature* aFeatureValue =
- dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
+ ModuleBase_WidgetValueFeature* aFeatureValue =
+ dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
if (aFeatureValue)
isDone = setObject(aFeatureValue->object());
}
// Check the type of selected object
std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
bool isValid = true;
- for(; aValidator != aValidators.end(); aValidator++) {
- const ModelAPI_ResultValidator* aResValidator =
- dynamic_cast<const ModelAPI_ResultValidator*>(*aValidator);
+ for (; aValidator != aValidators.end(); aValidator++) {
+ const ModelAPI_ResultValidator* aResValidator =
+ dynamic_cast<const ModelAPI_ResultValidator*>(*aValidator);
if (aResValidator) {
isValid = false;
if (aResValidator->isValid(theObject)) {
// Check the acceptability of the object as attribute
aValidator = aValidators.begin();
std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
- for(; aValidator != aValidators.end(); aValidator++, aArgs++) {
- const ModelAPI_AttributeValidator* aAttrValidator =
- dynamic_cast<const ModelAPI_AttributeValidator*>(*aValidator);
+ for (; aValidator != aValidators.end(); aValidator++, aArgs++) {
+ const ModelAPI_AttributeValidator* aAttrValidator =
+ dynamic_cast<const ModelAPI_AttributeValidator*>(*aValidator);
if (aAttrValidator) {
if (!aAttrValidator->isValid(myFeature, *aArgs, theObject)) {
return false;
//if (!aFeature)
// return false;
boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this;
aRef->setObject(myObject);
bool ModuleBase_WidgetFeature::restoreValue()
{
boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
ObjectPtr aObj = aRef->object();
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
*/
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();
/// \return a control list
virtual QList<QWidget*> getControls() const;
-protected:
+ protected:
/// Fill the widget values by given point
/// \param thePoint the point
/// \return the boolean result of the feature set
/// 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
#include <QHBoxLayout>
#include <QLabel>
-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)
{
}
bool isDone = false;
if (theValue) {
- ModuleBase_WidgetValueFeature* aFeatureValue =
- dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
+ ModuleBase_WidgetValueFeature* aFeatureValue =
+ dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
if (aFeatureValue) {
boost::shared_ptr<GeomAPI_Pnt2d> aValuePoint = aFeatureValue->point();
ObjectPtr aObject = aFeatureValue->object();
FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
if (aFeature) {
// find the given point in the feature attributes
- std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes =
- aFeature->data()->attributes(GeomDataAPI_Point2D::type());
- std::list<boost::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
- aLast = anAttiributes.end();
+ std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes = aFeature->data()
+ ->attributes(GeomDataAPI_Point2D::type());
+ std::list<boost::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes
+ .begin(), aLast = anAttiributes.end();
boost::shared_ptr<GeomDataAPI_Point2D> aFPoint;
- for (;anIt!=aLast && !aFPoint; anIt++) {
- boost::shared_ptr<GeomDataAPI_Point2D> aCurPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
+ for (; anIt != aLast && !aFPoint; anIt++) {
+ boost::shared_ptr<GeomDataAPI_Point2D> aCurPoint = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(*anIt);
if (aCurPoint && aCurPoint->pnt()->distance(aValuePoint) < Precision::Confusion())
aFPoint = aCurPoint;
}
// return false;
boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
if (myObject)
aRef->setObject(myObject);
bool ModuleBase_WidgetFeatureOrAttribute::restoreValue()
{
boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
ObjectPtr aObj = aRef->object();
FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
}
bool ModuleBase_WidgetFeatureOrAttribute::setAttribute(
- const boost::shared_ptr<ModelAPI_Attribute>& theAttribute,
- bool theSendEvent)
+ const boost::shared_ptr<ModelAPI_Attribute>& theAttribute, bool theSendEvent)
{
- if (!theAttribute)// || !featureKinds().contains(theAttribute->attributeType().c_str()))
+ if (!theAttribute) // || !featureKinds().contains(theAttribute->attributeType().c_str()))
return false;
myAttribute = theAttribute;
*/
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();
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<ModelAPI_Attribute>& theAttribute,
- bool theSendEvent = true);
+ bool setAttribute(const boost::shared_ptr<ModelAPI_Attribute>& theAttribute, bool theSendEvent =
+ true);
-protected:
- boost::shared_ptr<ModelAPI_Attribute> myAttribute; /// < the attribute
+ protected:
+ boost::shared_ptr<ModelAPI_Attribute> myAttribute; /// < the attribute
};
#endif
#include <climits>
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)),
myXSpin->setMaximum(DBL_MAX);
myXSpin->setToolTip("X");
aGroupLay->addWidget(myXSpin, 0, 1);
-
+
connect(myXSpin, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
}
{
{
bool isDone = false;
if (theValue) {
- ModuleBase_WidgetValueFeature* aFeatureValue =
- dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
+ ModuleBase_WidgetValueFeature* aFeatureValue =
+ dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
if (aFeatureValue) {
boost::shared_ptr<GeomAPI_Pnt2d> aPoint = aFeatureValue->point();
if (aPoint) {
bool ModuleBase_WidgetPoint2D::storeValue() const
{
boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(attributeID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(attributeID()));
ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this;
bool isBlocked = that->blockSignals(true);
bool ModuleBase_WidgetPoint2D::restoreValue()
{
boost::shared_ptr<ModelAPI_Data> aData = myFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(attributeID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(attributeID()));
bool isBlocked = this->blockSignals(true);
myXSpin->setValue(aPoint->x());
{
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);
}
if (myOptionParam.length() == 0)
return false;
boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myOptionParam));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(myOptionParam));
if (aPoint) {
bool isBlocked = this->blockSignals(true);
myXSpin->setValue(aPoint->x());
*/
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();
/// \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<GeomAPI_Pnt2d>& 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
#include <QDoubleSpinBox>
-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");
}
bool isDone = false;
if (theValue) {
- ModuleBase_WidgetValueFeature* aFeatureValue =
- dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
+ ModuleBase_WidgetValueFeature* aFeatureValue =
+ dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
if (aFeatureValue) {
boost::shared_ptr<GeomAPI_Pnt2d> aPnt = aFeatureValue->point();
ObjectPtr aObject = aFeatureValue->object();
return isDone;
}
-void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature, const boost::shared_ptr<GeomAPI_Pnt2d>& thePnt)
+void ModuleBase_WidgetPoint2dDistance::setPoint(FeaturePtr theFeature,
+ const boost::shared_ptr<GeomAPI_Pnt2d>& thePnt)
{
boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aData->attribute(myFirstPntName));
- if (!aPoint) return;
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(myFirstPntName));
+ if (!aPoint)
+ return;
double aRadius = thePnt->distance(aPoint->pnt());
AttributeDoublePtr aReal = aData->real(attributeID());
aReal->setValue(aRadius);
mySpinBox->setValue(aRadius);
}
-}
\ No newline at end of file
+}
// Created: 23 June 2014
// Author: Vitaly Smetannikov
-
#ifndef ModuleBase_WidgetPoint2dDistance_H
#define ModuleBase_WidgetPoint2dDistance_H
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();
/// \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<GeomAPI_Pnt2d>& thePnt);
-private:
+ private:
std::string myFirstPntName;
};
-
-#endif
\ No newline at end of file
+#endif
// Created: 2 June 2014
// Author: Vitaly Smetannikov
-
#include "ModuleBase_WidgetSelector.h"
#include "ModuleBase_IWorkshop.h"
#include <stdexcept>
-
typedef QMap<QString, TopAbs_ShapeEnum> ShapeTypes;
static ShapeTypes MyShapeTypes;
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);
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<ModelAPI_AttributeReference> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(attributeID()));
+ boost::shared_ptr<ModelAPI_AttributeReference> aRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeReference>(aData->attribute(attributeID()));
ObjectPtr aObject = aRef->value();
if (!(aObject && aObject->isSame(mySelectedObject))) {
bool isBlocked = this->blockSignals(true);
mySelectedObject = aRef->value();
- updateSelectionName();
+ updateSelectionName();
this->blockSignals(isBlocked);
return true;
return;
// Check that the selection corresponds to selection type
- if (!isAccepted(aObject)) return;
+ if (!isAccepted(aObject))
+ return;
mySelectedObject = aObject;
if (mySelectedObject) {
{
ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theResult);
boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
- if (!aShapePtr) return false;
+ if (!aShapePtr)
+ return false;
TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
- 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;
}
{
if (mySelectedObject) {
std::string aName = mySelectedObject->data()->name();
-
+
myTextLine->setText(QString::fromStdString(aName));
- } else
+ } else
myTextLine->setText("");
}
{
QWidget* aParent = myContainer->parentWidget();
QList<QWidget*> aChldList = aParent->findChildren<QWidget*>();
- 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);
}
}
while (!aParent->inherits("QDockWidget")) {
aLastPanel = aParent;
aParent = aParent->parentWidget();
- if (!aParent) return;
+ if (!aParent)
+ return;
}
if (aParent->inherits("QDockWidget")) {
QDockWidget* aTabWgt = (QDockWidget*) aParent;
#include <QStringList>
-
class Config_WidgetAPI;
class QWidget;
class QLabel;
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();
/// 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<QWidget*> 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;
static TopAbs_ShapeEnum shapeType(const QString& theType);
- QWidget* myContainer;
- QLabel* myLabel;
- QLineEdit* myTextLine;
+ QWidget* myContainer;
+ QLabel* myLabel;
+ QLineEdit* myTextLine;
QToolButton* myActivateBtn;
ModuleBase_IWorkshop* myWorkshop;
QStringList myShapeTypes;
};
-#endif
\ No newline at end of file
+#endif
#include <QSpacerItem>
ModuleBase_WidgetSwitch::ModuleBase_WidgetSwitch(QWidget* parent)
-: QFrame(parent)
+ : QFrame(parent)
{
myMainLay = new QVBoxLayout(this);
myMainLay->setContentsMargins(2, 4, 2, 2);
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)));
}
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);
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);
}
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();
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;
*/
class MODULEBASE_EXPORT ModuleBase_WidgetValue
{
-public:
+ public:
/// Constructor
ModuleBase_WidgetValue();
/// Destructor
*/
class MODULEBASE_EXPORT ModuleBase_WidgetValueFeature : public ModuleBase_WidgetValue
{
-public:
+ public:
/// Constructor
ModuleBase_WidgetValueFeature();
/// Destructor
/// \return the current point
const boost::shared_ptr<GeomAPI_Pnt2d>& point() const;
-private:
+ private:
ObjectPtr myResult;
boost::shared_ptr<GeomAPI_Pnt2d> myPoint;
};
-
#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()
return LightApp_DataModel::close();
}
-bool NewGeom_DataModel::create( CAM_Study* theStudy )
+bool NewGeom_DataModel::create(CAM_Study* theStudy)
{
return true;
}
return true;
}
-void NewGeom_DataModel::update( LightApp_DataObject* theObj, LightApp_Study* theStudy )
+void NewGeom_DataModel::update(LightApp_DataObject* theObj, LightApp_Study* theStudy)
{
}
-
#ifndef NEWGEOM_DATAMODEL_H
#define NEWGEOM_DATAMODEL_H
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
-
#include "NewGeom_Module.h"
#include "NewGeom_DataModel.h"
#include "NewGeom_OCCSelector.h"
#include <QAction>
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);
void NewGeom_Module::initialize(CAM_Application* theApp)
{
LightApp_Module::initialize(theApp);
-
+
myWorkshop->startApplication();
}
//******************************************************
void NewGeom_Module::windows(QMap<int, int>& 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());
}
//******************************************************
{
bool isDone = LightApp_Module::activateModule(theStudy);
if (isDone) {
- setMenuShown( true );
- setToolShown( true );
+ setMenuShown(true);
+ setToolShown(true);
if (!mySelector) {
ViewManagerList OCCViewManagers;
}
}
myWorkshop->propertyPanel()->hide();
- QtxPopupMgr* aMgr = popupMgr(); // Create popup manager
+ QtxPopupMgr* aMgr = popupMgr(); // Create popup manager
action(myEraseAll)->setEnabled(false);
}
return isDone;
//******************************************************
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);
{
if (theMgr->getType() == OCCViewer_Viewer::Type()) {
OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(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<SUIT_Selector*> aList;
aMgr->selectors(aList);
- foreach(SUIT_Selector* aSel, aList) {
+ foreach(SUIT_Selector* aSel, aList)
+ {
aSel->setEnabled(aSel == aSelector);
}
myProxyViewer->setSelector(aSelector);
//******************************************************
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);
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);
}
//******************************************************
{
myWorkshop->contextMenuMgr()->addViewerItems(theMenu);
LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
-}
\ No newline at end of file
+}
-
#ifndef NewGeom_Module_H
#define NewGeom_Module_H
#include <QStringList>
#include <QMap>
-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<int, int>& theWndMap) const;
- virtual void viewManagers( QStringList& theList) const;
+ virtual void initialize(CAM_Application* theApp);
+ virtual void windows(QMap<int, int>& 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();
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<QAction*> commandList() const;
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;
#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)
{
}
{
}
-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)
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
-
#include "NewGeom_SalomeViewer.h"
#include "NewGeom_OCCSelector.h"
#include <QMouseEvent>
#include <QContextMenuEvent>
-
NewGeom_SalomeViewer::NewGeom_SalomeViewer(QObject* theParent)
-: XGUI_SalomeViewer(theParent), mySelector(0)
+ : XGUI_SalomeViewer(theParent),
+ mySelector(0)
{
}
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()));
}
//**********************************************
if (aVFrame) {
aVFrame->onFitAll();
}
-}
\ No newline at end of file
+}
-
#ifndef NewGeom_SalomeViewer_H
#define NewGeom_SalomeViewer_H
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
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*);
void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
void onKeyRelease(SUIT_ViewWindow*, QKeyEvent*);
-
-private:
+ private:
NewGeom_OCCSelector* mySelector;
};
-#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\r
+#define PARTSET_H\r
+\r
+#if defined PARTSET_EXPORTS\r
+#if defined WIN32\r
+#define PARTSET_EXPORT __declspec( dllexport )\r
+#else\r
+#define PARTSET_EXPORT\r
+#endif\r
+#else\r
+#if defined WIN32\r
+#define PARTSET_EXPORT __declspec( dllimport )\r
+#else\r
+#define PARTSET_EXPORT\r
+#endif\r
+#endif\r
+\r
+#endif //PARTSET_H\r
\ No newline at end of file
#include <QLineEdit>
PartSet_EditLine::PartSet_EditLine(QWidget* theParent)
-: QObject(theParent)
+ : QObject(theParent)
{
myEditor = new QLineEdit(theParent);
myEditor->setWindowFlags(Qt::ToolTip);
/*!
\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
/// \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
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));
{
ModuleBase_Operation* anOperation = myModule->workshop()->operationMgr()->currentOperation();
PartSet_OperationSketchBase* aSketchOp = dynamic_cast<PartSet_OperationSketchBase*>(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<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
- std::set<ObjectPtr > aFeatures = aUpdMsg->objects();
- std::set<ObjectPtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+ const ModelAPI_ObjectUpdatedMessage* aUpdMsg =
+ dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
+ std::set<ObjectPtr> aFeatures = aUpdMsg->objects();
+ std::set<ObjectPtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
for (; anIt != aLast; anIt++) {
aDisplayer->deactivate(*anIt);
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
}
} else if (aType == EVENT_OBJECT_DELETED) {
- const ModelAPI_ObjectDeletedMessage* aDelMsg =
- dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
+ const ModelAPI_ObjectDeletedMessage* aDelMsg =
+ dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
boost::shared_ptr<ModelAPI_Document> aDoc = aDelMsg->document();
std::set<std::string> aGroups = aDelMsg->groups();
std::set<std::string>::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);
}
/*!
\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
/// 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
#include <QDebug>
#endif
-
/*!Create and return new instance of XGUI_Module*/
extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(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()
// myWorkshop->viewer()->activeView());
QAction* aCmd = dynamic_cast<QAction*>(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());
std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
aPreviewOp->initSelection(aSelected, aHighlighted);
- }
+ }
sendOperation(anOperation);
}
void PartSet_Module::onOperationStarted()
{
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
- myWorkshop->operationMgr()->currentOperation());
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(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);
}
}
void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
{
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
- myWorkshop->operationMgr()->currentOperation());
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
+ ->operationMgr()->currentOperation());
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
if (aPreviewOp && (!aView.IsNull())) {
XGUI_Selection* aSelection = myWorkshop->selector()->selection();
void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
{
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
- myWorkshop->operationMgr()->currentOperation());
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
+ ->operationMgr()->currentOperation());
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
if (aPreviewOp && (!aView.IsNull())) {
XGUI_Selection* aSelection = myWorkshop->selector()->selection();
void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
{
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
- myWorkshop->operationMgr()->currentOperation());
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
+ ->operationMgr()->currentOperation());
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
if (aPreviewOp && (!aView.IsNull()))
aPreviewOp->mouseMoved(theEvent, aView);
void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
{
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
- myWorkshop->operationMgr()->currentOperation());
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
+ ->operationMgr()->currentOperation());
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
if (aPreviewOp && (!aView.IsNull())) {
XGUI_Selection* aSelection = myWorkshop->selector()->selection();
{
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
if (!isStop) {
- foreach(ObjectPtr aObject, theFeatures) {
+ foreach(ObjectPtr aObject, theFeatures)
+ {
activateFeature(aObject, false);
}
}
std::list<FeaturePtr> aList = aPrevOp->subFeatures();
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
- std::list<FeaturePtr>::iterator aSFIt;
+ std::list<FeaturePtr>::iterator aSFIt;
for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
std::list<ResultPtr> aResults = (*aSFIt)->results();
std::list<ResultPtr>::iterator aIt;
}
}
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<PartSet_OperationSketchBase*>(aCurOperation);
- if (aPrevOp) {
- std::list<FeaturePtr> aList = aPrevOp->subFeatures();
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
-
- std::list<FeaturePtr>::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<PartSet_OperationSketchBase*>(aCurOperation);
+ if (aPrevOp) {
+ std::list<FeaturePtr> aList = aPrevOp->subFeatures();
+ XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
+
+ std::list<FeaturePtr>::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,
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<PartSet_OperationSketchBase*>(aCurOperation);
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);
}
// connect the operation
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(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<ObjectPtr>&, const bool)),
- this, SLOT(onStopSelection(const QList<ObjectPtr>&, const bool)));
- connect(aPreviewOp, SIGNAL(setSelection(const QList<ObjectPtr>&)),
- this, SLOT(onSetSelection(const QList<ObjectPtr>&)));
+ connect(aPreviewOp, SIGNAL(stopSelection(const QList<ObjectPtr>&, const bool)), this,
+ SLOT(onStopSelection(const QList<ObjectPtr>&, const bool)));
+ connect(aPreviewOp, SIGNAL(setSelection(const QList<ObjectPtr>&)), this,
+ SLOT(onSetSelection(const QList<ObjectPtr>&)));
- connect(aPreviewOp, SIGNAL(closeLocalContext()),
- this, SLOT(onCloseLocalContext()));
+ connect(aPreviewOp, SIGNAL(closeLocalContext()), this, SLOT(onCloseLocalContext()));
PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(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()));
}
}
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<PartSet_OperationSketchBase*>(anOperation);
- if (!aPreviewOp)
- return;
-
- ResultPtr aResult = theFeature->firstResult();
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- if (isDisplay) {
- boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
- if (aSPFeature) {
- PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(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<PartSet_OperationSketchBase*>(anOperation);
+ if (!aPreviewOp)
+ return;
+
+ ResultPtr aResult = theFeature->firstResult();
+ XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ if (isDisplay) {
+ boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
+ boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
+ if (aSPFeature) {
+ PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
+ if (aSketchOp && !aSketchOp->hasSketchPlane())
+ showPlanes();
+ }
+ }
+ else
+ aDisplayer->erase(aResult, false);
+
+ if (isUpdateViewer)
+ aDisplayer->updateViewer();
+ }*/
void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer)
{
std::list<FeaturePtr> aList = aPreviewOp->subFeatures();
std::list<int> aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature());
- std::list<FeaturePtr>::const_iterator anIt = aList.begin(),
- aLast = aList.end();
+ std::list<FeaturePtr>::const_iterator anIt = aList.begin(), aLast = aList.end();
for (; anIt != aLast; anIt++) {
- boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
+ boost::shared_ptr<SketchPlugin_Feature> aSPFeature = boost::dynamic_pointer_cast<
+ SketchPlugin_Feature>(*anIt);
if (!aSPFeature)
continue;
std::list<ResultPtr> aResults = aSPFeature->results();
return;
// if (theFeature->getKind() == SKETCH_KIND) {
- //FeaturePtr aFeature = theFeature;
- //if (XGUI_Tools::isModelObject(aFeature)) {
- // ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(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<ModelAPI_Object>(aFeature);
+ // aFeature = aObject->featureRef();
+ //}
+
+ //if (aFeature) {
+ onLaunchOperation(theFeature->getKind(), theFeature);
+ updateCurrentPreview(theFeature->getKind());
+ //}
// }
}
{
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
- myWorkshop->operationMgr()->currentOperation());
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
+ ->operationMgr()->currentOperation());
if (!aPreviewOp)
return;
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(theAttribute));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ 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<PartSet_OperationFeatureEdit*>(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<ModuleBase_ModelWidget*>& 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<PartSet_OperationFeatureEdit*>(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<ModuleBase_ModelWidget*>& theModelWidgets)
{
if (theType == "sketch-start-label") {
PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, "");
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();
/// 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<ModuleBase_ModelWidget*>& theModelWidgets);
+ virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
+ Config_WidgetAPI* theWidgetApi,
+ QList<ModuleBase_ModelWidget*>& theModelWidgets);
-
-public slots:
+ public slots:
void onFeatureTriggered();
/// SLOT, that is called after the operation is started. Connect on the focus activated signal
void onOperationStarted();
/// \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
/// \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;
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)
{
}
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
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<int> PartSet_OperationFeatureCreate::getSelectionModes(ObjectPtr theFeature) const
return aModes;
}
-void PartSet_OperationFeatureCreate::initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
+void PartSet_OperationFeatureCreate::initSelection(
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
{
myPreSelection = theSelected;
}
myInitFeature = theFeature;
}
-
FeaturePtr PartSet_OperationFeatureCreate::sketch() const
{
return mySketch;
}
-void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
- const std::list<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
+void PartSet_OperationFeatureCreate::mouseReleased(
+ QMouseEvent* theEvent, Handle(V3d_View) theView,
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
{
if (commit()) {
// if the point creation is finished, the next mouse release should commit the modification
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);
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()) {
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) {
{
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);
{
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());
myPreSelection.remove(aPrs);
emit activateNextWidget(myActiveWidget);
}
- }
+ }
if (myInitFeature && myActiveWidget) {
ModuleBase_WidgetPoint2D* aWgt = dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
- if (aWgt && aWgt->initFromPrevious(myInitFeature)) {
+ if (aWgt && aWgt->initFromPrevious(myInitFeature)) {
myInitFeature = FeaturePtr();
emit activateNextWidget(myActiveWidget);
}
restartOperation(feature()->getKind(), FeaturePtr());
}
}
- break;
+ break;
case Qt::Key_Escape: {
if (!commit()) {
abort();
}
}
default:
- break;
+ break;
}
}
void PartSet_OperationFeatureCreate::afterCommitOperation()
{
- PartSet_OperationSketchBase::afterCommitOperation();
+ PartSet_OperationSketchBase::afterCommitOperation();
emit featureConstructed(feature(), FM_Deactivation);
}
{
FeaturePtr aNewFeature = ModuleBase_Operation::createFeature(false);
if (sketch()) {
- boost::shared_ptr<SketchPlugin_Feature> aFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(sketch());
+ boost::shared_ptr<SketchPlugin_Feature> aFeature = boost::dynamic_pointer_cast<
+ SketchPlugin_Feature>(sketch());
aFeature->addSub(aNewFeature);
}
/*!
\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;
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Returns the operation sketch feature
/// \returns the sketch instance
/// \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<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted);
+ virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Gives the current mouse point in the viewer
/// \param thePoint a point clicked in the viewer
/// \param theEvent the mouse event
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
/// \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
/// \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<ModuleBase_ViewerPrs> myPreSelection;
};
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)
{
}
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<int> PartSet_OperationFeatureEdit::getSelectionModes(ObjectPtr theFeature) const
setEditingFeature(theFeature);
}
-
FeaturePtr PartSet_OperationFeatureEdit::sketch() const
{
return mySketch;
}
-void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
- const std::list<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted)
+void PartSet_OperationFeatureEdit::mousePressed(
+ QMouseEvent* theEvent, Handle(V3d_View) theView,
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& 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);
emit featureConstructed(feature(), FM_Deactivation);
bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
- if(aHasShift && !theHighlighted.empty()) {
+ if (aHasShift && !theHighlighted.empty()) {
QList<ObjectPtr> aSelected;
std::list<ModuleBase_ViewerPrs>::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);
}
}
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);
double aDeltaX = aX - aCurX;
double aDeltaY = anY - aCurY;
- boost::shared_ptr<SketchPlugin_Feature> aSketchFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
+ boost::shared_ptr<SketchPlugin_Feature> 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);
myCurPoint.setPoint(aPoint);
}
-void PartSet_OperationFeatureEdit::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
- const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
- const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
+void PartSet_OperationFeatureEdit::mouseReleased(
+ QMouseEvent* theEvent, Handle(V3d_View) theView,
+ const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
+ const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
{
blockSelection(false);
}
-void PartSet_OperationFeatureEdit::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted)
+void PartSet_OperationFeatureEdit::mouseDoubleClick(
+ QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& 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();
}
}
-
void PartSet_OperationFeatureEdit::keyReleased(const int theKey)
{
if (theKey == Qt::Key_Return) {
commit();
- } else
+ } else
PartSet_OperationSketchBase::keyReleased(theKey);
}
if (isBlocked) {
emit setSelection(QList<ObjectPtr>());
emit stopSelection(aFeatureList, true);
- }
- else {
+ } else {
emit stopSelection(aFeatureList, false);
if (isRestoreSelection)
emit setSelection(aFeatureList);
/*!
\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)
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();
/// \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<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted);
+ virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Processes the mouse double click in the point
/// \param theEvent the mouse event
/// \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
/// \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
/// 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
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)
{
}
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<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted)
+void PartSet_OperationFeatureEditMulti::initSelection(
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
if (!theHighlighted.empty()) {
// if there is highlighted object, we check whether it is in the list of selected objects
// the hightlighted object should moved and the selection is skipped. The skipped selection will be
// deselected in the viewer by blockSelection signal in the startOperation method.
bool isSelected = false;
- std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
+ std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected
+ .end();
for (; anIt != aLast && !isSelected; anIt++) {
isSelected = ModelAPI_Feature::feature((*anIt).object()) == feature();
}
myFeatures = theHighlighted;
else
myFeatures = theSelected;
- }
- else
+ } else
myFeatures = theSelected;
}
return mySketch;
}
-void PartSet_OperationFeatureEditMulti::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
- const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted)
+void PartSet_OperationFeatureEditMulti::mousePressed(
+ QMouseEvent* theEvent, Handle(V3d_View) theView,
+ const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
+ const std::list<ModuleBase_ViewerPrs>& 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);
double aDeltaX = aX - aCurX;
double aDeltaY = anY - aCurY;
- boost::shared_ptr<SketchPlugin_Feature> aSketchFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
+ boost::shared_ptr<SketchPlugin_Feature> aSketchFeature = boost::dynamic_pointer_cast<
+ SketchPlugin_Feature>(feature());
aSketchFeature->move(aDeltaX, aDeltaY);
- std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
+ std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures
+ .end();
for (; anIt != aLast; anIt++) {
ObjectPtr aObject = (*anIt).object();
if (!aObject || aObject == feature())
myCurPoint.setPoint(aPoint);
}
-void PartSet_OperationFeatureEditMulti::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
- const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
- const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
+void PartSet_OperationFeatureEditMulti::mouseReleased(
+ QMouseEvent* theEvent, Handle(V3d_View) theView,
+ const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
+ const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
{
if (commit()) {
std::list<ModuleBase_ViewerPrs> aFeatures = myFeatures;
- std::list<ModuleBase_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+ std::list<ModuleBase_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast =
+ aFeatures.end();
for (; anIt != aLast; anIt++) {
ObjectPtr aFeature = (*anIt).object();
if (aFeature) {
emit featureConstructed(aFeature, FM_Deactivation);
- }
+ }
}
}
}
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<ObjectPtr> aFeatureList;
- std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(),
- aLast = myFeatures.end();
+ std::list<ModuleBase_ViewerPrs>::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<ObjectPtr>());
emit stopSelection(aFeatureList, true);
- }
- else {
+ } else {
emit stopSelection(aFeatureList, false);
if (isRestoreSelection) {
emit setSelection(aFeatureList);
{
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
- std::list<FeaturePtr > aFeatures;
- std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
+ std::list<FeaturePtr> aFeatures;
+ std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast =
+ myFeatures.end();
for (; anIt != aLast; anIt++) {
ObjectPtr aFeature = (*anIt).object();
if (!aFeature)
/*!
\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)
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();
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Returns the operation sketch feature
/// \returns the sketch instance
/// \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<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted);
-protected:
+ virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& 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
/// 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
/// Sends the features
void sendFeatures();
-private:
- FeaturePtr mySketch; ///< the sketch feature
- std::list<ModuleBase_ViewerPrs> 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<ModuleBase_ViewerPrs> 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
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)
{
}
return aModes;
}
-
/// Initializes the operation with previously created feature. It is used in sequental operations
void PartSet_OperationSketch::initFeature(FeaturePtr theFeature)
{
const std::list<ModuleBase_ViewerPrs>& theSelected,
const std::list<ModuleBase_ViewerPrs>& 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);
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 {
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);
}
}
boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
if (!aData->isValid())
return std::list<FeaturePtr>();
- boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID()));
+ boost::shared_ptr<ModelAPI_AttributeRefList> aRefList = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID()));
std::list<ObjectPtr> aList = aRefList->list();
std::list<ObjectPtr>::iterator aIt;
std::list<ResultPtr> aResults = aFeature->results();
std::list<ResultPtr>::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));
return hasSketchPlane();
}
-
void PartSet_OperationSketch::startOperation()
{
PartSet_OperationSketchBase::startOperation();
if (feature()) {
boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
AttributeDoublePtr anAttr;
- boost::shared_ptr<GeomDataAPI_Dir> aNormal =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aNormal = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aData->attribute(SketchPlugin_Sketch::NORM_ID()));
aHasPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
}
return aHasPlane;
// 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<GeomAPI_Dir> aTempDir(isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0));
+ boost::shared_ptr<GeomAPI_Dir> aTempDir(
+ isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0));
boost::shared_ptr<GeomAPI_Dir> aYDir(new GeomAPI_Dir(aNormDir->cross(aTempDir)));
boost::shared_ptr<GeomAPI_Dir> aXDir(new GeomAPI_Dir(aYDir->cross(aNormDir)));
- boost::shared_ptr<GeomDataAPI_Point> anOrigin =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ boost::shared_ptr<GeomDataAPI_Point> anOrigin = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
+ aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
anOrigin->setValue(anOrigPnt);
- boost::shared_ptr<GeomDataAPI_Dir> aNormal =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aNormal = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aData->attribute(SketchPlugin_Sketch::NORM_ID()));
aNormal->setValue(aNormDir);
- boost::shared_ptr<GeomDataAPI_Dir> aDirX =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aDirX = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
aDirX->setValue(aXDir);
- boost::shared_ptr<GeomDataAPI_Dir> aDirY =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aDirY = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
aDirY->setValue(aYDir);
boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
flushUpdated();
-
+
emit featureConstructed(feature(), FM_Hide);
emit closeLocalContext();
emit planeSelected(aDir->x(), aDir->y(), aDir->z());
/*!
\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
// 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<ModuleBase_ViewerPrs> myFeatures; ///< the features to apply the edit operation
+ private:
+ std::list<ModuleBase_ViewerPrs> myFeatures; ///< the features to apply the edit operation
};
#endif
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)
{
}
{
}
-boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(
- FeaturePtr theFeature)
+boost::shared_ptr<GeomAPI_Shape> PartSet_OperationSketchBase::preview(FeaturePtr theFeature)
{
- boost::shared_ptr<SketchPlugin_Feature> aFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
+ boost::shared_ptr<SketchPlugin_Feature> aFeature = boost::dynamic_pointer_cast<
+ SketchPlugin_Feature>(theFeature);
if (aFeature) {
ResultPtr aRes = aFeature->firstResult();
ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(aRes);
// 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;
return myFeature;
}
-
-void PartSet_OperationSketchBase::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted)
+void PartSet_OperationSketchBase::mousePressed(
+ QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
}
-void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted)
+void PartSet_OperationSketchBase::mouseReleased(
+ QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
}
void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
{
}
-void PartSet_OperationSketchBase::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted)
+void PartSet_OperationSketchBase::mouseDoubleClick(
+ QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
{
}
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;
}
}
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);
}
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
virtual std::list<int> 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<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted) {}
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted)
+ {
+ }
/// Returns the operation sketch feature
/// \returns the sketch instance
/// \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<ModuleBase_ViewerPrs>& theSelected,
- const std::list<ModuleBase_ViewerPrs>& theHighlighted);
+ const std::list<ModuleBase_ViewerPrs>& theSelected,
+ const std::list<ModuleBase_ViewerPrs>& theHighlighted);
/// Processes the key pressed in the view
/// \param theKey a key value
/// 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
/// Signal about the features should be selected
/// \param theSelected the list of selected presentations
void featureSelected(const std::list<ModuleBase_ViewerPrs>& theSelected);
-
+
/// signal to enable/disable multi selection in the viewer
/// \param theEnabled the boolean state
void multiSelectionEnabled(bool theEnabled);
/// \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<ObjectPtr>& theFeatures, const bool theToStop);
-
+
/// signal to set selection in the viewer
/// \param theFeatures a list of features to be disabled
void setSelection(const QList<ObjectPtr>& theFeatures);
/// 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
boost::shared_ptr<GeomAPI_AISObject> 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());
}
}
}
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);
ModuleBase_Operation* anOperation = theWorkshop->operationMgr()->currentOperation();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- FeaturePtr aSketch;
+ FeaturePtr aSketch;
if (aPreviewOp) {
// create a line
boost::shared_ptr<ModelAPI_Document> 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<SketchPlugin_Feature> aSketch =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(aPreviewOp->sketch());
+ boost::shared_ptr<SketchPlugin_Feature> aSketch = boost::dynamic_pointer_cast<
+ SketchPlugin_Feature>(aPreviewOp->sketch());
aSketch->addSub(aFeature);
PartSet_Tools::setFeaturePoint(aFeature, 100, 100, SketchPlugin_Line::START_ID());
XGUI_Displayer* aDisplayer = theWorkshop->displayer();
boost::shared_ptr<GeomAPI_AISObject> aPrevAIS;
- boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ boost::shared_ptr<SketchPlugin_Feature> aSPFeature = boost::dynamic_pointer_cast<
+ SketchPlugin_Feature>(aFeature);
//boost::shared_ptr<GeomAPI_AISObject> 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<int> aModes;
aModes.push_back(TopAbs_VERTEX);
// 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<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
- Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation(
- aFeature, aSketch,
- aPreview ? aPreview->impl<TopoDS_Shape>() : 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<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
+ Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation(
+ aFeature, aSketch,
+ aPreview ? aPreview->impl<TopoDS_Shape>() : 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<int> aModes;
//aModes.clear();
//aModes.push_back(TopAbs_VERTEX);
//boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
boost::shared_ptr<GeomAPI_AISObject> aPrevAIS;
- boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ boost::shared_ptr<SketchPlugin_Feature> aSPFeature = boost::dynamic_pointer_cast<
+ SketchPlugin_Feature>(aFeature);
//boost::shared_ptr<GeomAPI_AISObject> anAIS = aSPFeature->getAISObject(aPrevAIS);
//if (!anAIS->empty())
theWorkshop->displayer()->display(aFeature, true);
//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();
}
/*!
\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
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
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;
AttributeDoublePtr anAttr;
boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
- boost::shared_ptr<GeomDataAPI_Point> anOrigin =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ boost::shared_ptr<GeomDataAPI_Point> anOrigin = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
+ aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
- boost::shared_ptr<GeomDataAPI_Dir> aX =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
- boost::shared_ptr<GeomDataAPI_Dir> anY =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aX = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> anY = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ 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);
gp_Vec anEyeVec(EyePoint, AtPoint);
anEyeVec.Normalize();
- boost::shared_ptr<GeomDataAPI_Dir> aNormal =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aNormal = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ 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)
boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
- boost::shared_ptr<GeomDataAPI_Point> aC =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
- boost::shared_ptr<GeomDataAPI_Dir> aX =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
- boost::shared_ptr<GeomDataAPI_Dir> aY =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
+ boost::shared_ptr<GeomDataAPI_Point> aC = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
+ aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aX = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aData->attribute(SketchPlugin_Sketch::DIRX_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aY = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aData->attribute(SketchPlugin_Sketch::DIRY_ID()));
- boost::shared_ptr<GeomAPI_XYZ> aSum = aC->pnt()->xyz()->added(
- aX->dir()->xyz()->multiplied(theX))->added(aY->dir()->xyz()->multiplied(theY));
+ boost::shared_ptr<GeomAPI_XYZ> aSum = aC->pnt()->xyz()->added(aX->dir()->xyz()->multiplied(theX))
+ ->added(aY->dir()->xyz()->multiplied(theY));
boost::shared_ptr<GeomAPI_Pnt> aPoint = boost::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum));
thePoint = gp_Pnt(aPoint->x(), aPoint->y(), aPoint->z());
PartSet_Tools::convertTo2D(aPoint, theSketch, theView, aX, anY);
FeaturePtr aFeature;
- std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
+ std::list<ModuleBase_ViewerPrs>::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<SketchPlugin_Feature> aSketchFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(aPrs.object());
+ boost::shared_ptr<SketchPlugin_Feature> aSketchFeature = boost::dynamic_pointer_cast<
+ SketchPlugin_Feature>(aPrs.object());
if (!aSketchFeature)
continue;
double aDelta = aSketchFeature->distanceToPoint(
- boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, anY)));
+ boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, anY)));
if (aMinDelta < 0 || aMinDelta > aDelta) {
aMinDelta = aDelta;
// TODO aDeltaFeature = aPrs.result();
if (!theFeature)
return;
boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(theAttribute));
if (aPoint)
aPoint->setValue(theX, theY);
}
if (!theFeature)
return;
boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- AttributeDoublePtr anAttribute =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(theAttribute));
+ AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ aData->attribute(theAttribute));
if (anAttribute)
anAttribute->setValue(theValue);
}
double aValue;
if (theFeature) {
boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- AttributeDoublePtr anAttribute =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(theAttribute));
+ AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ aData->attribute(theAttribute));
if (anAttribute) {
aValue = anAttribute->value();
isValid = true;
return aFeature;
boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(theAttribute));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(aData->attribute(theAttribute));
if (anAttr) {
aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->object());
if (!theKind.empty() && aFeature && aFeature->getKind() != theKind) {
FeaturePtr aFeature = aDoc->addFeature(SketchPlugin_ConstraintCoincidence::ID());
if (theSketch) {
- boost::shared_ptr<SketchPlugin_Feature> aSketch =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(theSketch);
+ boost::shared_ptr<SketchPlugin_Feature> aSketch = boost::dynamic_pointer_cast<
+ SketchPlugin_Feature>(theSketch);
aSketch->addSub(aFeature);
}
boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef1 =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef1 = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
aRef1->setAttr(thePoint1);
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef2 =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> 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<GeomDataAPI_Point2D> aPoint = featurePoint(theMode);
- boost::shared_ptr<GeomDataAPI_Point2D> aFeaturePoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theFeature->data()->attribute(theAttribute));
+ boost::shared_ptr<GeomDataAPI_Point2D> 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<ModelAPI_Data> aData = theSketch->data();
- boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID()));
+ boost::shared_ptr<ModelAPI_AttributeRefList> aRefList = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefList>(aData->attribute(SketchPlugin_Sketch::FEATURES_ID()));
- std::list<ObjectPtr > aFeatures = aRefList->list();
- std::list<ObjectPtr >::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+ std::list<ObjectPtr> aFeatures = aRefList->list();
+ std::list<ObjectPtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttiributes;
- boost::shared_ptr<GeomAPI_Pnt2d> aClickedPoint = boost::shared_ptr<GeomAPI_Pnt2d>
- (new GeomAPI_Pnt2d(theClickedX, theClickedY));
- for (; anIt != aLast; anIt++)
- {
+ boost::shared_ptr<GeomAPI_Pnt2d> aClickedPoint = boost::shared_ptr<GeomAPI_Pnt2d>(
+ new GeomAPI_Pnt2d(theClickedX, theClickedY));
+ for (; anIt != aLast; anIt++) {
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*anIt);
// find the given point in the feature attributes
anAttiributes = aFeature->data()->attributes(GeomDataAPI_Point2D::type());
std::list<boost::shared_ptr<ModelAPI_Attribute> >::const_iterator anIt = anAttiributes.begin(),
- aLast = anAttiributes.end();
+ aLast = anAttiributes.end();
boost::shared_ptr<GeomDataAPI_Point2D> aFPoint;
- for (;anIt!=aLast && !aFPoint; anIt++) {
- boost::shared_ptr<GeomDataAPI_Point2D> aCurPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
+ for (; anIt != aLast && !aFPoint; anIt++) {
+ boost::shared_ptr<GeomDataAPI_Point2D> aCurPoint = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(*anIt);
if (aCurPoint && aCurPoint->pnt()->distance(aClickedPoint) < Precision::Confusion())
aFPoint = aCurPoint;
}
double aA, aB, aC, aD;
boost::shared_ptr<ModelAPI_Data> aData = theSketch->data();
- boost::shared_ptr<GeomDataAPI_Point> anOrigin =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
- boost::shared_ptr<GeomDataAPI_Dir> aNormal =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+ boost::shared_ptr<GeomDataAPI_Point> anOrigin = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
+ aData->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aNormal = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aData->attribute(SketchPlugin_Sketch::NORM_ID()));
aA = aNormal->x();
aB = aNormal->y();
aC = aNormal->z();
return aPlane;
}
-boost::shared_ptr<GeomAPI_Pnt> PartSet_Tools::point3D(
- boost::shared_ptr<GeomAPI_Pnt2d> thePoint2D,
- FeaturePtr theSketch)
+boost::shared_ptr<GeomAPI_Pnt> PartSet_Tools::point3D(boost::shared_ptr<GeomAPI_Pnt2d> thePoint2D,
+ FeaturePtr theSketch)
{
boost::shared_ptr<GeomAPI_Pnt> aPoint;
if (!theSketch || !thePoint2D)
return aPoint;
- boost::shared_ptr<GeomDataAPI_Point> aC =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
- boost::shared_ptr<GeomDataAPI_Dir> aX =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(theSketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
- boost::shared_ptr<GeomDataAPI_Dir> aY =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(theSketch->data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
+ boost::shared_ptr<GeomDataAPI_Point> aC = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
+ theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aX = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ theSketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aY = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ 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();
}
/*!
\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
/// \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
/// \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
/// \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
/// \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
#include <list>
-
int shapesNbPoints(const ModuleBase_ISelection* theSelection)
{
std::list<ModuleBase_ViewerPrs> aList = theSelection->getSelected();
#include <ModuleBase_ISelection.h>
/*
-* 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
#include <QLabel>
-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);
QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
{
QList<QWidget*> aLst;
- aLst<<myLabel;
+ aLst << myLabel;
return aLst;
}
return myLabel;
}
-
-
void PartSet_WidgetSketchLabel::setOperationsMgr(XGUI_OperationMgr* theMgr)
{
ModuleBase_Operation* aOperation = theMgr->currentOperation();
if (aOperation->inherits("PartSet_OperationSketch")) {
PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(aOperation);
updateLabel(aSketchOpe);
- connect(aSketchOpe, SIGNAL(planeSelected(double, double, double)),
- this, SLOT(onPlaneSelected()));
+ connect(aSketchOpe, SIGNAL(planeSelected(double, double, double)), this,
+ SLOT(onPlaneSelected()));
}
}
myLabel->setText(myText);
myLabel->setToolTip(myTooltip);
}
-}
\ No newline at end of file
+}
#include <ModuleBase_ModelWidget.h>
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
void setOperationsMgr(XGUI_OperationMgr* theMgr);
-private slots:
+ private slots:
void onPlaneSelected();
-private:
+ private:
void updateLabel(PartSet_OperationSketch* theSketchOpe);
QLabel* myLabel;
QString myTooltip;
};
-#endif
\ No newline at end of file
+#endif
boost::shared_ptr<ModelAPI_PluginManager> aPManager = ModelAPI_PluginManager::get();
boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->rootDocument();
- boost::shared_ptr<ModelAPI_ResultPart> aSource; // searching for source document attribute
- for(int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
+ boost::shared_ptr<ModelAPI_ResultPart> aSource; // searching for source document attribute
+ for (int a = aRoot->size(getGroup()) - 1; a >= 0; a--) {
aSource = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(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<ModelAPI_Document> 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);
}
}
* \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()
{
}
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<ModelAPI_ResultPart>(firstResult());
if (!aResult) {
aResult = document()->createPart(data());
setResult(aResult);
}
- boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef =
- aResult->data()->docRef(ModelAPI_ResultPart::DOC_REF());
+ boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aResult->data()->docRef(
+ ModelAPI_ResultPart::DOC_REF());
- if (!aDocRef->value()) { // create a document if not yet created
- boost::shared_ptr<ModelAPI_Document> aPartSetDoc =
- ModelAPI_PluginManager::get()->rootDocument();
+ if (!aDocRef->value()) { // create a document if not yet created
+ boost::shared_ptr<ModelAPI_Document> aPartSetDoc =
+ ModelAPI_PluginManager::get()->rootDocument();
aDocRef->setValue(aPartSetDoc->subDocument(data()->name()));
}
}
-boost::shared_ptr<ModelAPI_Document> PartSetPlugin_Part::documentToAdd() {
+boost::shared_ptr<ModelAPI_Document> PartSetPlugin_Part::documentToAdd()
+{
return ModelAPI_PluginManager::get()->rootDocument();
}
* \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()
{
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();
PARTSETPLUGIN_EXPORT virtual boost::shared_ptr<ModelAPI_Document> 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();
// 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);
if (theFeatureID == "remove") {
return FeaturePtr(new PartSetPlugin_Remove);
}
- // feature of such kind is not found
+ // feature of such kind is not found
return FeaturePtr();
}
#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();
};
boost::shared_ptr<ModelAPI_Document> aRoot = aPManager->rootDocument();
boost::shared_ptr<ModelAPI_Document> aCurrent;
boost::shared_ptr<PartSetPlugin_Part> 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<ModelAPI_ResultPart>(
- 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
* \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()
{
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
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<boost::shared_ptr<GeomAPI_Shape> > aShapes;
// compute a circle point in 3D view
- boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(SketchPlugin_Arc::CENTER_ID()));
- // compute the arc start point
- boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(SketchPlugin_Arc::START_ID()));
- if (aCenterAttr->isInitialized() && aStartAttr->isInitialized()) {
- boost::shared_ptr<GeomAPI_Pnt> aCenter(
- aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::CENTER_ID()));
+ // compute the arc start point
+ boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::START_ID()));
+ if (aCenterAttr->isInitialized() && aStartAttr->isInitialized()) {
+ boost::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
// make a visible point
boost::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
//aShapes.push_back(aCenterPointShape);
- boost::shared_ptr<ModelAPI_ResultConstruction> aConstr1 =
- document()->createConstruction(data(), 0);
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr1 = document()->createConstruction(
+ data(), 0);
aConstr1->setShape(aCenterPointShape);
aConstr1->setIsInHistory(false);
setResult(aConstr1, 0);
-
// make a visible circle
- boost::shared_ptr<GeomDataAPI_Dir> aNDir =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
- aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aNDir = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
if (aHasPlane) {
boost::shared_ptr<GeomAPI_Dir> aNormal = aNDir->dir();
boost::shared_ptr<GeomAPI_Pnt> aStartPoint(aSketch->to3D(aStartAttr->x(), aStartAttr->y()));
// compute and change the arc end point
- boost::shared_ptr<GeomDataAPI_Point2D> anEndAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(
- SketchPlugin_Arc::END_ID()));
- if (anEndAttr->isInitialized())
- {
+ boost::shared_ptr<GeomDataAPI_Point2D> anEndAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Arc::END_ID()));
+ if (anEndAttr->isInitialized()) {
boost::shared_ptr<GeomAPI_Circ2d> aCircleForArc(
- new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt()));
+ new GeomAPI_Circ2d(aCenterAttr->pnt(), aStartAttr->pnt()));
boost::shared_ptr<GeomAPI_Pnt2d> aProjection = aCircleForArc->project(anEndAttr->pnt());
if (aProjection && anEndAttr->pnt()->distance(aProjection) > tolerance)
anEndAttr->setValue(aProjection);
}
boost::shared_ptr<GeomAPI_Pnt> aEndPoint(aSketch->to3D(anEndAttr->x(), anEndAttr->y()));
- boost::shared_ptr<GeomAPI_Shape> aCircleShape =
- GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStartPoint, aEndPoint, aNormal);
+ boost::shared_ptr<GeomAPI_Shape> aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircleArc(
+ aCenter, aStartPoint, aEndPoint, aNormal);
if (aCircleShape) {
- boost::shared_ptr<ModelAPI_ResultConstruction> aConstr2 =
- document()->createConstruction(data(), 1);
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr2 = document()->createConstruction(
+ data(), 1);
aConstr2->setShape(aCircleShape);
aConstr2->setIsInHistory(false);
setResult(aConstr2, 1);
}
}
/*
- boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
- // store the result
- boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
- document()->createConstruction(data());
- aConstr->setShape(aCompound);
- aConstr->setIsInHistory(false);
- setResult(aConstr);
- */
+ boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
+ // store the result
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
+ document()->createConstruction(data());
+ aConstr->setShape(aCompound);
+ aConstr->setIsInHistory(false);
+ setResult(aConstr);
+ */
}
}
}
if (!aData->isValid())
return;
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Arc::CENTER_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::CENTER_ID()));
aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Arc::START_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::START_ID()));
aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY);
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint3 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Arc::END_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint3 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::END_ID()));
aPoint3->setValue(aPoint3->x() + theDeltaX, aPoint3->y() + theDeltaY);
}
double aDelta = 0;
boost::shared_ptr<ModelAPI_Data> aData = data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Arc::CENTER_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::CENTER_ID()));
aDelta = aPoint1->pnt()->distance(thePoint);
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Arc::START_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::START_ID()));
double aDistance = aPoint2->pnt()->distance(thePoint);
if (aDelta < aDistance)
aDelta = aDistance;
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint3 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Arc::END_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint3 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::END_ID()));
aDistance = aPoint3->pnt()->distance(thePoint);
if (aDelta < aDistance)
aDelta = aDistance;
* \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()
{
/// 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();
/// 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
#include <ModelAPI_AttributeDouble.h>
SketchPlugin_Circle::SketchPlugin_Circle()
- : SketchPlugin_Feature()
+ : SketchPlugin_Feature()
{
}
std::list<boost::shared_ptr<GeomAPI_Shape> > aShapes;
// compute a circle point in 3D view
- boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(SketchPlugin_Circle::CENTER_ID()));
- AttributeDoublePtr aRadiusAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
- data()->attribute(SketchPlugin_Circle::RADIUS_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Circle::CENTER_ID()));
+ AttributeDoublePtr aRadiusAttr = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ data()->attribute(SketchPlugin_Circle::RADIUS_ID()));
if (aCenterAttr->isInitialized() && aRadiusAttr->isInitialized()) {
boost::shared_ptr<GeomAPI_Pnt> aCenter(aSketch->to3D(aCenterAttr->x(), aCenterAttr->y()));
// make a visible point
boost::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::point(aCenter);
//aShapes.push_back(aCenterPointShape);
- boost::shared_ptr<ModelAPI_ResultConstruction> aConstr1 =
- document()->createConstruction(data(), 0);
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr1 = document()->createConstruction(
+ data(), 0);
aConstr1->setShape(aCenterPointShape);
aConstr1->setIsInHistory(false);
setResult(aConstr1, 0);
// make a visible circle
- boost::shared_ptr<GeomDataAPI_Dir> aNDir =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aSketch->data()->attribute(
- SketchPlugin_Sketch::NORM_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aNDir = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
if (aHasPlane) {
boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(aNDir->x(), aNDir->y(), aNDir->z()));
// compute the circle radius
double aRadius = aRadiusAttr->value();
- boost::shared_ptr<GeomAPI_Shape> aCircleShape =
- GeomAlgoAPI_EdgeBuilder::lineCircle(aCenter, aNormal, aRadius);
+ boost::shared_ptr<GeomAPI_Shape> aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircle(
+ aCenter, aNormal, aRadius);
aShapes.push_back(aCircleShape);
- boost::shared_ptr<ModelAPI_ResultConstruction> aConstr2 =
- document()->createConstruction(data(), 1);
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr2 = document()->createConstruction(
+ data(), 1);
aConstr2->setShape(aCircleShape);
aConstr2->setIsInHistory(false);
setResult(aConstr2, 1);
}
}
/*
- boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
- // store the result
- boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
- document()->createConstruction(data());
- aConstr->setShape(aCompound);
- aConstr->setIsInHistory(false);
- setResult(aConstr);
- */
+ boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
+ // store the result
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
+ document()->createConstruction(data());
+ aConstr->setShape(aCompound);
+ aConstr->setIsInHistory(false);
+ setResult(aConstr);
+ */
}
}
if (!aData->isValid())
return;
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Circle::CENTER_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Circle::CENTER_ID()));
aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
}
double SketchPlugin_Circle::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
{
boost::shared_ptr<ModelAPI_Data> aData = data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Circle::CENTER_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Circle::CENTER_ID()));
return aPoint->pnt()->distance(thePoint);
}
* \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()
{
}
/// 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();
/// 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
* \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()
{
}
/// 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
#include "SketchPlugin_ConstraintBase.h"
AISObjectPtr SketchPlugin_ConstraintBase::getAISObject(AISObjectPtr thePrevious)
-{
+{
return thePrevious;
}
}
-double SketchPlugin_ConstraintBase::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
+double SketchPlugin_ConstraintBase::distanceToPoint(
+ const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
{
return 0;
}
#include <list>
-
/* Description:
* Each constraint uses a set of parameters. In the SolveSpace library
* these parameters are named "valA", "ptA", "ptB", "entityA", "entityB".
* 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);
/// \param thePoint the point
virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
-protected:
+ protected:
/// \brief Use plugin manager for features creation
- SketchPlugin_ConstraintBase() {}
+ SketchPlugin_ConstraintBase()
+ {
+ }
};
#endif
* 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()
{
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();
//*************************************************************************************
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());
void SketchPlugin_ConstraintDistance::execute()
{
boost::shared_ptr<ModelAPI_Data> aData = data();
- AttributeDoublePtr anAttr_Value =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ AttributeDoublePtr anAttr_Value = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
aData->attribute(SketchPlugin_Constraint::VALUE()));
if (!anAttr_Value->isInitialized()) {
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A =
- getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_A());
- boost::shared_ptr<GeomDataAPI_Point2D> 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<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(
+ aData, SketchPlugin_Constraint::ENTITY_A());
+ boost::shared_ptr<GeomDataAPI_Point2D> 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<SketchPlugin_Line> aLine =
- getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A());
+ if (!aPoint_A && aPoint_B) { //Line and point
+ boost::shared_ptr<SketchPlugin_Line> 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<SketchPlugin_Line> aLine =
- getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B());
- if(aLine)
+ } else if (aPoint_A && !aPoint_B) { // Point and line
+ boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
+ aData, SketchPlugin_Constraint::ENTITY_B());
+ if (aLine)
anAttr_Value->setValue(aLine->distanceToPoint(aPoint_A->pnt()));
}
}
boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
DataPtr aData = data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_A());
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(aData, SketchPlugin_Constraint::ENTITY_B());
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint_A = getFeaturePoint(
+ aData, SketchPlugin_Constraint::ENTITY_A());
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint_B = getFeaturePoint(
+ aData, SketchPlugin_Constraint::ENTITY_B());
boost::shared_ptr<GeomAPI_Pnt2d> aPnt_A;
boost::shared_ptr<GeomAPI_Pnt2d> aPnt_B;
aPnt_A = aPoint_A->pnt();
aPnt_B = aPoint_B->pnt();
} else if (!aPoint_A && aPoint_B) {
- boost::shared_ptr<SketchPlugin_Line> aLine =
- getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A());
+ boost::shared_ptr<SketchPlugin_Line> 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<SketchPlugin_Line> aLine =
- getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B());
+ boost::shared_ptr<SketchPlugin_Line> aLine = getFeatureLine(
+ aData, SketchPlugin_Constraint::ENTITY_B());
if (aLine) {
aPnt_A = aPoint_A->pnt();
aPnt_B = getProjectionPoint(aLine, aPnt_A);
if (!aPnt_A || !aPnt_B)
return thePrevious;
- boost::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
boost::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aPnt_A->x(), aPnt_A->y());
boost::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(aPnt_B->x(), aPnt_B->y());
- boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = aFlyOutAttr->isInitialized() ?
- sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()) :
- boost::shared_ptr<GeomAPI_Pnt>();
+ boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt =
+ aFlyOutAttr->isInitialized() ?
+ sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()) : boost::shared_ptr<GeomAPI_Pnt>();
// value calculation
- boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
+ boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
double aValue = aValueAttr->value();
AISObjectPtr anAIS = thePrevious;
anAIS->createDistance(aPoint1, aPoint2, aFlyoutPnt, aPlane, aValue);
// Set color from preferences
- std::vector<int> aRGB = Config_PropManager::color("Visualization", "distance_color", DISTANCE_COLOR);
+ std::vector<int> aRGB = Config_PropManager::color("Visualization", "distance_color",
+ DISTANCE_COLOR);
anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
return anAIS;
}
if (!aData->isValid())
return;
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
}
return aPointAttr;
FeaturePtr aFeature;
- boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> 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<GeomDataAPI_Point2D>
- (aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
+ aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aFeature->data()->attribute(SketchPlugin_Point::COORD_ID()));
else if (aFeature && aFeature->getKind() == SketchPlugin_Circle::ID())
- aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>
- (aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()));
+ aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()));
else if (anAttr->attr()) {
- aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
+ aPointAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
}
return aPointAttr;
}
//*************************************************************************************
-boost::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData, const std::string& theAttribute)
+boost::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData,
+ const std::string& theAttribute)
{
boost::shared_ptr<SketchPlugin_Line> aLine;
if (!theData)
return aLine;
- boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theData->attribute(theAttribute));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> 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()) {
}
//*************************************************************************************
-boost::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(const boost::shared_ptr<SketchPlugin_Line>& theLine,
- const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
+boost::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
+ const boost::shared_ptr<SketchPlugin_Line>& theLine,
+ const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
{
boost::shared_ptr<ModelAPI_Data> aData = theLine->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Line::START_ID()));
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Line::END_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Line::START_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Line::END_ID()));
GeomAPI_Lin2d aLin2d(aPoint1->x(), aPoint1->y(), aPoint2->x(), aPoint2->y());
return aLin2d.project(thePoint);
* 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()
{
}
/// \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();
SketchPlugin_ConstraintDistance();
};
-
/// Obtain the point object from specified constraint parameter
boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
- const std::string& theAttribute);
-
-boost::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData, const std::string& theAttribute);
+ const std::string& theAttribute);
-boost::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(const boost::shared_ptr<SketchPlugin_Line>& theLine,
- const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
+boost::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData,
+ const std::string& theAttribute);
+boost::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
+ const boost::shared_ptr<SketchPlugin_Line>& theLine,
+ const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
#endif
#include <Config_PropManager.h>
-
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<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> 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<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::START_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aFeature->data()->attribute(SketchPlugin_Line::END_ID()));
double aLenght = aPoint1->pnt()->distance(aPoint2->pnt());
- boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+ boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
aValueAttr->setValue(aLenght);
}
}
boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> 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<GeomDataAPI_Point2D> aFlyOutAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aFlyOutAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
DataPtr aData = aFeature->data();
- boost::shared_ptr<GeomDataAPI_Point2D> aStartPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::START_ID()));
- boost::shared_ptr<GeomDataAPI_Point2D> anEndPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aStartPoint = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::START_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> anEndPoint = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Line::END_ID()));
boost::shared_ptr<GeomAPI_Pnt> aPoint1 = sketch()->to3D(aStartPoint->x(), aStartPoint->y());
- boost::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(anEndPoint->x(), anEndPoint->y());
- boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = aFlyOutAttr->isInitialized() ?
- sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()) :
- boost::shared_ptr<GeomAPI_Pnt>();
+ boost::shared_ptr<GeomAPI_Pnt> aPoint2 = sketch()->to3D(anEndPoint->x(), anEndPoint->y());
+ boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt =
+ aFlyOutAttr->isInitialized() ?
+ sketch()->to3D(aFlyOutAttr->x(), aFlyOutAttr->y()) : boost::shared_ptr<GeomAPI_Pnt>();
// value calculation
- boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+ boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
double aValue = aValueAttr->value();
AISObjectPtr anAIS = thePrevious;
if (!aData->isValid())
return;
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
}
* 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()
{
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();
return thePrevious;
boost::shared_ptr<ModelAPI_Data> aData = data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
- boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
- if (!anAttr1 || !anAttr1->isObject() ||
- !anAttr2 || !anAttr2->isObject())
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> 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<SketchPlugin_Line> aLine1Feature =
- boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+ boost::shared_ptr<SketchPlugin_Line> aLine1Feature =
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
aFeature = ModelAPI_Feature::feature(anAttr2->object());
if (!aFeature)
return thePrevious;
- boost::shared_ptr<SketchPlugin_Line> aLine2Feature =
- boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+ boost::shared_ptr<SketchPlugin_Line> aLine2Feature =
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
if (!aLine1Feature || !aLine2Feature)
return thePrevious;
boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
boost::shared_ptr<GeomAPI_Shape> aLine1, aLine2;
- boost::shared_ptr<ModelAPI_ResultConstruction> aConst1 =
- boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anAttr1->object());
- if (aConst1) aLine1 = aConst1->shape();
- boost::shared_ptr<ModelAPI_ResultConstruction> aConst2 =
- boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anAttr2->object());
- if (aConst2) aLine2 = aConst2->shape();
-
- boost::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConst1 = boost::dynamic_pointer_cast<
+ ModelAPI_ResultConstruction>(anAttr1->object());
+ if (aConst1)
+ aLine1 = aConst1->shape();
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConst2 = boost::dynamic_pointer_cast<
+ ModelAPI_ResultConstruction>(anAttr2->object());
+ if (aConst2)
+ aLine2 = aConst2->shape();
+
+ boost::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
AISObjectPtr anAIS = thePrevious;
anAIS->createParallel(aLine1, aLine2, aFlyoutPnt, aPlane);
// Set color from preferences
- std::vector<int> aRGB = Config_PropManager::color("Visualization", "parallel_color", PARALLEL_COLOR);
+ std::vector<int> aRGB = Config_PropManager::color("Visualization", "parallel_color",
+ PARALLEL_COLOR);
anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
return anAIS;
}
if (!aData->isValid())
return;
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
aPoint->setValue(aPoint->x() + theDeltaX, aPoint->y() + theDeltaY);
}
#include <SketchPlugin_Sketch.h>
#include "SketchPlugin_ConstraintBase.h"
-
#define PARALLEL_COLOR "#ffff00"
/** \class SketchPlugin_ConstraintParallel
* 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()
{
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();
return thePrevious;
boost::shared_ptr<ModelAPI_Data> aData = data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
- boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr2 =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_B()));
- if (!anAttr1 || !anAttr1->isObject() ||
- !anAttr2 || !anAttr2->isObject())
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr1 = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> 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<SketchPlugin_Line> aLine1Feature =
- boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+ boost::shared_ptr<SketchPlugin_Line> aLine1Feature =
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
aFeature = ModelAPI_Feature::feature(anAttr2->object());
if (!aFeature)
return thePrevious;
- boost::shared_ptr<SketchPlugin_Line> aLine2Feature =
- boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
+ boost::shared_ptr<SketchPlugin_Line> aLine2Feature =
+ boost::dynamic_pointer_cast<SketchPlugin_Line>(aFeature);
if (!aLine1Feature || !aLine2Feature)
return thePrevious;
boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
boost::shared_ptr<GeomAPI_Shape> aLine1, aLine2;
- boost::shared_ptr<ModelAPI_ResultConstruction> aConst1 =
- boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anAttr1->object());
- if (aConst1) aLine1 = aConst1->shape();
- boost::shared_ptr<ModelAPI_ResultConstruction> aConst2 =
- boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anAttr2->object());
- if (aConst2) aLine2 = aConst2->shape();
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConst1 = boost::dynamic_pointer_cast<
+ ModelAPI_ResultConstruction>(anAttr1->object());
+ if (aConst1)
+ aLine1 = aConst1->shape();
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConst2 = boost::dynamic_pointer_cast<
+ ModelAPI_ResultConstruction>(anAttr2->object());
+ if (aConst2)
+ aLine2 = aConst2->shape();
AISObjectPtr anAIS = thePrevious;
if (!anAIS)
anAIS->createPerpendicular(aLine1, aLine2, aPlane);
// Set color from preferences
- std::vector<int> aRGB = Config_PropManager::color("Visualization", "perpendicular_color", PERPENDICULAR_COLOR);
+ std::vector<int> aRGB = Config_PropManager::color("Visualization", "perpendicular_color",
+ PERPENDICULAR_COLOR);
anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
return anAIS;
}
if (!aData->isValid())
return;
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
aPoint->setValue(aPoint->x() + theDeltaX, aPoint->y() + theDeltaY);
}
* 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()
{
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();
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<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> 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<ModelAPI_Data> aData = aFeature->data();
if (aFeature->getKind() == SketchPlugin_Circle::ID()) {
- AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>
- (aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
+ AttributeDoublePtr anAttribute = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
if (anAttribute)
aRadius = anAttribute->value();
- }
- else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
- boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
- boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
+ } else if (aFeature->getKind() == SketchPlugin_Arc::ID()) {
+ boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> 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<ModelAPI_AttributeDouble> aValueAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
+ boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE()));
aValueAttr->setValue(aRadius);
}
}
return thePrevious;
boost::shared_ptr<ModelAPI_Data> aData = data();
- boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
if (!anAttr)
return thePrevious;
FeaturePtr aFeature = ModelAPI_Feature::feature(anAttr->object());
return thePrevious;
// Flyout point
- boost::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
if (!aFlyoutAttr->isInitialized())
return thePrevious;
boost::shared_ptr<GeomAPI_Pnt> aFlyoutPnt = sketch()->to3D(aFlyoutAttr->x(), aFlyoutAttr->y());
boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr;
double aRadius;
if (aKind == SketchPlugin_Circle::ID()) {
- aCenterAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Circle::CENTER_ID()));
- AttributeDoublePtr aCircRadius =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
+ aCenterAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Circle::CENTER_ID()));
+ AttributeDoublePtr aCircRadius = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ aData->attribute(SketchPlugin_Circle::RADIUS_ID()));
aRadius = aCircRadius->value();
- }
- else if (aKind == SketchPlugin_Arc::ID()) {
- aCenterAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::CENTER_ID()));
- boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
+ } else if (aKind == SketchPlugin_Arc::ID()) {
+ aCenterAttr = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Arc::CENTER_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Arc::START_ID()));
aRadius = aCenterAttr->pnt()->distance(aStartAttr->pnt());
}
boost::shared_ptr<GeomAPI_Pnt> aCenter = sketch()->to3D(aCenterAttr->x(), aCenterAttr->y());
- boost::shared_ptr<GeomDataAPI_Dir> aNDir =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(sketch()->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aNDir = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ sketch()->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
boost::shared_ptr<GeomAPI_Dir> aNormal = aNDir->dir();
boost::shared_ptr<GeomAPI_Circ> aCircle(new GeomAPI_Circ(aCenter, aNormal, aRadius));
// Value
- boost::shared_ptr<ModelAPI_AttributeDouble> aValueAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
+ boost::shared_ptr<ModelAPI_AttributeDouble> 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)
if (!aData->isValid())
return;
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
FeaturePtr aFeature = ModelAPI_Feature::feature(aRef->object());
if (!aFeature)
return;
aCenterAttrName = SketchPlugin_Circle::CENTER_ID();
else if (aFeature->getKind() == SketchPlugin_Arc::ID())
aCenterAttrName = SketchPlugin_Arc::CENTER_ID();
- boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFeature->data()->attribute(aCenterAttrName));
+ boost::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aFeature->data()->attribute(aCenterAttrName));
boost::shared_ptr<GeomAPI_Pnt2d> 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<GeomDataAPI_Point2D> aFlyoutAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(aData->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
boost::shared_ptr<GeomAPI_Pnt2d> aFlyout = aFlyoutAttr->pnt();
- boost::shared_ptr<ModelAPI_AttributeDouble> aRadius =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
+ boost::shared_ptr<ModelAPI_AttributeDouble> aRadius = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeDouble>(aData->attribute(SketchPlugin_Constraint::VALUE()));
double aScale = aFlyout->distance(aCenter) / aRadius->value();
boost::shared_ptr<GeomAPI_Circ2d> aCircle(new GeomAPI_Circ2d(aCenter, aFlyout));
* 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();
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<SketchPlugin_Sketch> aSketch = boost::
- dynamic_pointer_cast<SketchPlugin_Sketch>(document()->object(ModelAPI_Feature::group(), a));
+ for (int a = 0; a < aSketches && !mySketch; a++) {
+ boost::shared_ptr<SketchPlugin_Sketch> aSketch = boost::dynamic_pointer_cast<
+ SketchPlugin_Sketch>(document()->object(ModelAPI_Feature::group(), a));
if (aSketch) {
- std::list<ObjectPtr> aList =
- aSketch->data()->reflist(SketchPlugin_Sketch::FEATURES_ID())->list();
+ std::list<ObjectPtr> aList = aSketch->data()->reflist(SketchPlugin_Sketch::FEATURES_ID())
+ ->list();
std::list<ObjectPtr>::iterator aSub = aList.begin();
- for(; aSub != aList.end(); aSub++) {
+ for (; aSub != aList.end(); aSub++) {
if ((*aSub)->data()->isEqual(data())) {
mySketch = aSketch.get();
break;
return mySketch;
}
-AISObjectPtr SketchPlugin_Feature::simpleAISObject(
- boost::shared_ptr<ModelAPI_Result> theRes, AISObjectPtr thePrevious)
+AISObjectPtr SketchPlugin_Feature::simpleAISObject(boost::shared_ptr<ModelAPI_Result> theRes,
+ AISObjectPtr thePrevious)
{
- boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
- boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theRes);
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = boost::dynamic_pointer_cast<
+ ModelAPI_ResultConstruction>(theRes);
boost::shared_ptr<GeomAPI_Shape> aPreview;
- if (aConstr) aPreview = aConstr->shape();
+ if (aConstr)
+ aPreview = aConstr->shape();
AISObjectPtr aResult = thePrevious;
if (!aResult)
* \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<ModelAPI_Result> theRes, AISObjectPtr thePrevious);
+ static AISObjectPtr simpleAISObject(boost::shared_ptr<ModelAPI_Result> 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
/// \param thePoint the point
virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& 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
friend class SketchPlugin_Sketch;
-private:
- boost::shared_ptr<GeomAPI_Shape> myPreview; ///< the preview shape
- SketchPlugin_Sketch* mySketch; /// sketch that contains this feature
+ private:
+ boost::shared_ptr<GeomAPI_Shape> myPreview; ///< the preview shape
+ SketchPlugin_Sketch* mySketch; /// sketch that contains this feature
};
#endif
using namespace std;
-
SketchPlugin_Line::SketchPlugin_Line()
- : SketchPlugin_Feature()
+ : SketchPlugin_Feature()
{
}
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<GeomDataAPI_Point2D> aStartAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(SketchPlugin_Line::START_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Line::START_ID()));
// compute an end point in 3D view
- boost::shared_ptr<GeomDataAPI_Point2D> anEndAttr =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(SketchPlugin_Line::END_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> anEndAttr = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(data()->attribute(SketchPlugin_Line::END_ID()));
if (aStartAttr->isInitialized() && anEndAttr->isInitialized()) {
boost::shared_ptr<GeomAPI_Pnt> aStart(aSketch->to3D(aStartAttr->x(), aStartAttr->y()));
boost::shared_ptr<GeomAPI_Pnt> anEnd(aSketch->to3D(anEndAttr->x(), anEndAttr->y()));
// make linear edge
boost::shared_ptr<GeomAPI_Shape> anEdge = GeomAlgoAPI_EdgeBuilder::line(aStart, anEnd);
// store the result
- boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
- document()->createConstruction(data());
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(
+ data());
aConstr->setShape(anEdge);
aConstr->setIsInHistory(false);
setResult(aConstr);
if (!aData->isValid())
return;
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Line::START_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Line::START_ID()));
aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Line::END_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Line::END_ID()));
aPoint2->setValue(aPoint2->x() + theDeltaX, aPoint2->y() + theDeltaY);
}
double aDelta = 0;
boost::shared_ptr<ModelAPI_Data> aData = data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Line::START_ID()));
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Line::END_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Line::START_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint2 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ 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<GeomAPI_Pnt2d> aResult = aLin2d.project(thePoint);
aDelta = aResult->distance(thePoint);
- }
- else { // distance
+ } else { // distance
aDelta = aLin2d.distance(thePoint);
}
* \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()
{
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");
}
/// 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();
/// 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
// 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);
}
{
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
#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();
};
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<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- data()->attribute(SketchPlugin_Point::COORD_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ data()->attribute(SketchPlugin_Point::COORD_ID()));
boost::shared_ptr<GeomAPI_Pnt> aPoint3D(aSketch->to3D(aPoint->x(), aPoint->y()));
// make a visible point
boost::shared_ptr<GeomAPI_Shape> aPointShape = GeomAlgoAPI_PointBuilder::point(aPoint3D);
if (!aData->isValid())
return;
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Point::COORD_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Point::COORD_ID()));
aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);
}
double SketchPlugin_Point::distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
{
boost::shared_ptr<ModelAPI_Data> aData = data();
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aData->attribute(SketchPlugin_Point::COORD_ID()));
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aData->attribute(SketchPlugin_Point::COORD_ID()));
return aPoint->pnt()->distance(thePoint);
}
* \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()
{
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();
/// 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
using namespace std;
-
SketchPlugin_Sketch::SketchPlugin_Sketch()
{
}
data()->addAttribute(SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList::type());
}
-void SketchPlugin_Sketch::execute()
+void SketchPlugin_Sketch::execute()
{
if (!data()->isValid())
- return ;
- boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
- data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
-
- boost::shared_ptr<GeomDataAPI_Point> anOrigin =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
- boost::shared_ptr<GeomDataAPI_Dir> aDirX =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
- boost::shared_ptr<GeomDataAPI_Dir> aDirY =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
- boost::shared_ptr<GeomDataAPI_Dir> aNorm =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+ return;
+ boost::shared_ptr<ModelAPI_AttributeRefList> aRefList = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefList>(data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
+
+ boost::shared_ptr<GeomDataAPI_Point> anOrigin = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
+ data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aDirX = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aDirY = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aNorm = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ data()->attribute(SketchPlugin_Sketch::NORM_ID()));
std::list<ObjectPtr> aFeatures = aRefList->list();
if (aFeatures.empty())
- return ;
+ return;
std::list<ObjectPtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
boost::shared_ptr<SketchPlugin_Feature> aFeature;
- std::list< boost::shared_ptr<GeomAPI_Shape> > aFeaturesPreview;
+ std::list<boost::shared_ptr<GeomAPI_Shape> > aFeaturesPreview;
for (; anIt != aLast; anIt++) {
aFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
if (aFeature) {
const std::list<boost::shared_ptr<ModelAPI_Result> >& aRes = aFeature->results();
std::list<boost::shared_ptr<ModelAPI_Result> >::const_iterator aResIter = aRes.cbegin();
- for(; aResIter != aRes.cend(); aResIter++) {
- boost::shared_ptr<ModelAPI_ResultConstruction> aConstr =
- boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(*aResIter);
+ for (; aResIter != aRes.cend(); aResIter++) {
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = boost::dynamic_pointer_cast<
+ ModelAPI_ResultConstruction>(*aResIter);
if (aConstr) {
boost::shared_ptr<GeomAPI_Shape> aShape = aConstr->shape();
if (aShape)
}
if (aFeaturesPreview.empty())
- return ;
- std::list< boost::shared_ptr<GeomAPI_Shape> > aLoops;
- std::list< boost::shared_ptr<GeomAPI_Shape> > aWires;
+ return;
+ std::list<boost::shared_ptr<GeomAPI_Shape> > aLoops;
+ std::list<boost::shared_ptr<GeomAPI_Shape> > aWires;
GeomAlgoAPI_SketchBuilder::createFaces(anOrigin->pnt(), aDirX->dir(), aDirY->dir(), aNorm->dir(),
aFeaturesPreview, aLoops, aWires);
boost::shared_ptr<GeomAPI_Pnt> SketchPlugin_Sketch::to3D(const double theX, const double theY)
{
- boost::shared_ptr<GeomDataAPI_Point> aC =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
- boost::shared_ptr<GeomDataAPI_Dir> aX =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
- boost::shared_ptr<GeomDataAPI_Dir> aY =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
+ boost::shared_ptr<GeomDataAPI_Point> aC = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
+ data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aX = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ data()->attribute(SketchPlugin_Sketch::DIRX_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aY = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ data()->attribute(SketchPlugin_Sketch::DIRY_ID()));
- boost::shared_ptr<GeomAPI_XYZ> aSum = aC->pnt()->xyz()->added(
- aX->dir()->xyz()->multiplied(theX))->added(aY->dir()->xyz()->multiplied(theY));
+ boost::shared_ptr<GeomAPI_XYZ> aSum = aC->pnt()->xyz()->added(aX->dir()->xyz()->multiplied(theX))
+ ->added(aY->dir()->xyz()->multiplied(theY));
return boost::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum));
}
bool SketchPlugin_Sketch::isPlaneSet()
{
- boost::shared_ptr<GeomDataAPI_Dir> aNormal =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aNormal = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ data()->attribute(SketchPlugin_Sketch::NORM_ID()));
return aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
}
boost::shared_ptr<GeomAPI_Pln> SketchPlugin_Sketch::plane()
{
- boost::shared_ptr<GeomDataAPI_Point> anOrigin =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
- boost::shared_ptr<GeomDataAPI_Dir> aNorm =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+ boost::shared_ptr<GeomDataAPI_Point> anOrigin = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
+ data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aNorm = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ data()->attribute(SketchPlugin_Sketch::NORM_ID()));
if (!anOrigin || !aNorm)
return boost::shared_ptr<GeomAPI_Pln>();
return boost::shared_ptr<GeomAPI_Pln>(new GeomAPI_Pln(anOrigin->pnt(), aNorm->dir()));
}
-void addPlane(double theX, double theY, double theZ, std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes)
+void addPlane(double theX, double theY, double theZ,
+ std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes)
{
boost::shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
boost::shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(theX, theY, theZ));
double aSize = Config_PropManager::integer("Sketch definition", "Size of planes", PLANE_SIZE);
- boost::shared_ptr<GeomAPI_Shape> aFace =
- GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, aSize);
+ boost::shared_ptr<GeomAPI_Shape> aFace = GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal,
+ aSize);
theShapes.push_back(aFace);
}
AISObjectPtr SketchPlugin_Sketch::getAISObject(AISObjectPtr thePrevious)
{
- boost::shared_ptr<GeomDataAPI_Dir> aNorm =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+ boost::shared_ptr<GeomDataAPI_Dir> aNorm = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ data()->attribute(SketchPlugin_Sketch::NORM_ID()));
if (!aNorm || (aNorm->x() == 0 && aNorm->y() == 0 && aNorm->z() == 0)) {
AISObjectPtr aAIS = thePrevious;
if (!aAIS) {
std::list<boost::shared_ptr<GeomAPI_Shape> > aFaces;
- addPlane(1, 0, 0, aFaces); // YZ plane
- addPlane(0, 1, 0, aFaces); // XZ plane
- addPlane(0, 0, 1, aFaces); // XY plane
+ addPlane(1, 0, 0, aFaces); // YZ plane
+ addPlane(0, 1, 0, aFaces); // XZ plane
+ addPlane(0, 0, 1, aFaces); // XY plane
boost::shared_ptr<GeomAPI_Shape> aCompound = GeomAlgoAPI_CompoundBuilder::compound(aFaces);
aAIS = AISObjectPtr(new GeomAPI_AISObject());
aAIS->createShape(aCompound);
- std::vector<int> aRGB = Config_PropManager::color("Sketch definition",
- "planes_color",
- SKETCH_PLANE_COLOR);
+ std::vector<int> 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;
}
* \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()
{
}
/// 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();
/// 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<GeomAPI_Pnt2d>& thePoint) { return 0; };
+ virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
+ {
+ return 0;
+ }
+ ;
/// Converts a 2D sketch space point into point in 3D space
- SKETCHPLUGIN_EXPORT boost::shared_ptr<GeomAPI_Pnt> to3D(
- const double theX, const double theY);
+ SKETCHPLUGIN_EXPORT boost::shared_ptr<GeomAPI_Pnt> 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();
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
#include <ModelAPI_ResultValidator.h>
#include <GeomDataAPI_Point2D.h>
-
-bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature,
+bool SketchPlugin_DistanceAttrValidator::isValid(const FeaturePtr& theFeature,
const std::list<std::string>& theArguments,
const ObjectPtr& theObject) const
{
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
// If the object is not a line then it is accepted
- const ModelAPI_ResultValidator* aLineValidator = dynamic_cast<const ModelAPI_ResultValidator*>(
- aFactory->validator("Model_ResultLineValidator"));
+ const ModelAPI_ResultValidator* aLineValidator =
+ dynamic_cast<const ModelAPI_ResultValidator*>(aFactory->validator("Model_ResultLineValidator"));
if (!aLineValidator->isValid(theObject))
return true;
return false;
}
-
-
//#include <ModuleBase_FeatureValidator.h>
#include <ModelAPI_AttributeValidator.h>
-
-class SketchPlugin_DistanceAttrValidator: public ModelAPI_AttributeValidator
+class SketchPlugin_DistanceAttrValidator : public ModelAPI_AttributeValidator
{
-public:
- virtual bool isValid(const FeaturePtr& theFeature,
- const std::list<std::string>& theArguments,
+ public:
+ virtual bool isValid(const FeaturePtr& theFeature, const std::list<std::string>& theArguments,
const ObjectPtr& theObject) const;
};
-#endif
\ No newline at end of file
+#endif
/// 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,
/// Calculate type of the attribute
static AttrType typeOfAttribute(boost::shared_ptr<ModelAPI_Attribute> theAttribute);
-
-
SketchSolver_Constraint::SketchSolver_Constraint()
- : myConstraint(boost::shared_ptr<SketchPlugin_Constraint>()),
- myType(SLVS_C_UNKNOWN),
- myAttributesList()
+ : myConstraint(boost::shared_ptr<SketchPlugin_Constraint>()),
+ myType(SLVS_C_UNKNOWN),
+ myAttributesList()
{
}
SketchSolver_Constraint::SketchSolver_Constraint(
- boost::shared_ptr<SketchPlugin_Constraint> theConstraint)
- : myConstraint(theConstraint),
- myAttributesList()
+ boost::shared_ptr<SketchPlugin_Constraint> theConstraint)
+ : myConstraint(theConstraint),
+ myAttributesList()
{
myType = getType(myConstraint);
}
-const int& SketchSolver_Constraint::getType(boost::shared_ptr<SketchPlugin_Constraint> theConstraint)
+const int& SketchSolver_Constraint::getType(
+ boost::shared_ptr<SketchPlugin_Constraint> theConstraint)
{
myType = SLVS_C_UNKNOWN;
if (!theConstraint)
const std::string& aConstraintKind = theConstraint->getKind();
// 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<ModelAPI_Attribute> 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<ModelAPI_Attribute> 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,
}
// Constraint for distance between point and another entity
- if (aConstraintKind.compare(SketchPlugin_ConstraintDistance::ID()) == 0)
- {
+ if (aConstraintKind.compare(SketchPlugin_ConstraintDistance::ID()) == 0) {
int aNbPoints = 0;
int aNbEntities = 0;
- for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++)
- {
- boost::shared_ptr<ModelAPI_Attribute> 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<ModelAPI_Attribute> 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;
}
}
// Verify the correctness of constraint arguments
- if (aNbPoints == 2 && aNbEntities ==0)
+ if (aNbPoints == 2 && aNbEntities == 0)
myType = SLVS_C_PT_PT_DISTANCE;
else if (aNbPoints != 1 || aNbEntities != 1)
myType = SLVS_C_UNKNOWN;
}
// Constraint for the given length of a line
- if (aConstraintKind.compare(SketchPlugin_ConstraintLength::ID()) == 0)
- {
+ if (aConstraintKind.compare(SketchPlugin_ConstraintLength::ID()) == 0) {
int aNbLines = 0;
- for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++)
- {
- boost::shared_ptr<ModelAPI_Attribute> anAttr =
- theConstraint->data()->attribute(SketchPlugin_Constraint::ATTRIBUTE(indAttr));
+ for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) {
+ boost::shared_ptr<ModelAPI_Attribute> anAttr = theConstraint->data()->attribute(
+ SketchPlugin_Constraint::ATTRIBUTE(indAttr));
if (typeOfAttribute(anAttr) == LINE)
myAttributesList[aNbLines++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
}
// Constraint for two parallel/perpendicular lines
bool isParallel = (aConstraintKind.compare(SketchPlugin_ConstraintParallel::ID()) == 0);
bool isPerpendicular = (aConstraintKind.compare(SketchPlugin_ConstraintPerpendicular::ID()) == 0);
- 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<ModelAPI_Attribute> 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<ModelAPI_Attribute> anAttr = theConstraint->data()->attribute(
+ SketchPlugin_Constraint::ATTRIBUTE(indAttr));
if (typeOfAttribute(anAttr) == LINE)
myAttributesList[aNbEntities++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
}
}
// Constraint for radius of a circle or an arc of circle
- 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<ModelAPI_Attribute> 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<ModelAPI_Attribute> anAttr = theConstraint->data()->attribute(
+ SketchPlugin_Constraint::ATTRIBUTE(indAttr));
AttrType aType = typeOfAttribute(anAttr);
if (aType == CIRCLE || aType == ARC)
myAttributesList[aNbEntities++] = SketchPlugin_Constraint::ATTRIBUTE(indAttr);
return getType();
}
-
// ================= Auxiliary functions ==============================
AttrType typeOfAttribute(boost::shared_ptr<ModelAPI_Attribute> theAttribute)
{
- boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttrRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
- if (!anAttrRef) return UNKNOWN;
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttrRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefAttr>(theAttribute);
+ if (!anAttrRef)
+ return UNKNOWN;
- if (anAttrRef->isObject())
- {
- ResultConstructionPtr aRC =
- boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anAttrRef->object());
- if (!aRC) return UNKNOWN;
+ if (anAttrRef->isObject()) {
+ ResultConstructionPtr aRC = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(
+ anAttrRef->object());
+ if (!aRC)
+ return UNKNOWN;
if (aRC->shape()->isVertex())
return POINT3D;
- else if (aRC->shape()->isEdge())
- {
- boost::shared_ptr<GeomAPI_Edge> anEdge =
- boost::dynamic_pointer_cast<GeomAPI_Edge>(aRC->shape());
+ else if (aRC->shape()->isEdge()) {
+ boost::shared_ptr<GeomAPI_Edge> anEdge = boost::dynamic_pointer_cast<GeomAPI_Edge>(
+ aRC->shape());
if (anEdge->isLine())
return LINE;
else if (anEdge->isCircle())
else if (anEdge->isArc())
return ARC;
}
- }
- else
- {
+ } else {
const std::string aType = anAttrRef->attr()->attributeType();
if (aType == GeomDataAPI_Point2D::type())
return POINT2D;
*/
class SketchSolver_Constraint
{
-public:
+ public:
SketchSolver_Constraint();
SketchSolver_Constraint(boost::shared_ptr<SketchPlugin_Constraint> theConstraint);
const int& getType(boost::shared_ptr<SketchPlugin_Constraint> 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<std::string>& getAttributes() const
- { return myAttributesList; }
+ {
+ return myAttributesList;
+ }
-private:
+ private:
boost::shared_ptr<SketchPlugin_Constraint> myConstraint;
- int myType;
- std::vector<std::string> myAttributesList;
+ int myType;
+ std::vector<std::string> myAttributesList;
};
#endif
* 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()
{
* \param[in] theEntities list of elements
* \return position of the found element or -1 if the element is not found
*/
-template <typename T>
+template<typename T>
static int Search(const uint32_t& theEntityID, const std::vector<T>& theEntities);
-
// ========================================================
// ========= SketchSolver_ConstraintGroup ===============
// ========================================================
-SketchSolver_ConstraintGroup::
- SketchSolver_ConstraintGroup(boost::shared_ptr<SketchPlugin_Feature> theWorkplane)
- : myID(++myGroupIndexer),
- myParamMaxID(0),
- myEntityMaxID(0),
- myConstrMaxID(0),
- myConstraintMap(),
- myNeedToSolve(false),
- myConstrSolver()
+SketchSolver_ConstraintGroup::SketchSolver_ConstraintGroup(
+ boost::shared_ptr<SketchPlugin_Feature> 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;
// Purpose: verify the group is based on the given workplane
// ============================================================================
bool SketchSolver_ConstraintGroup::isBaseWorkplane(
- boost::shared_ptr<SketchPlugin_Feature> theWorkplane) const
+ boost::shared_ptr<SketchPlugin_Feature> theWorkplane) const
{
return theWorkplane == mySketch;
}
// Purpose: verify are there any entities in the group used by given constraint
// ============================================================================
bool SketchSolver_ConstraintGroup::isInteract(
- boost::shared_ptr<SketchPlugin_Constraint> theConstraint) const
+ boost::shared_ptr<SketchPlugin_Constraint> 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<ModelAPI_AttributeRefAttr> 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())
+ for (int i = 0; i < CONSTRAINT_ATTR_SIZE; i++) {
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> 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<ModelAPI_ResultConstruction>(aCAttrRef->object());
- if (!aRC) continue;
+ if (aCAttrRef->isObject()) { // Obtain a base feature for the object
+ ResultConstructionPtr aRC = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(
+ aCAttrRef->object());
+ if (!aRC)
+ continue;
boost::shared_ptr<ModelAPI_Document> 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<ModelAPI_Attribute> >
- aFeatAttrList = aFeature->data()->attributes(std::string());
- std::list< boost::shared_ptr<ModelAPI_Attribute> >::const_iterator
- aFAIter = aFeatAttrList.begin();
- for ( ; aFAIter != aFeatAttrList.end(); aFAIter++)
+ std::list<boost::shared_ptr<ModelAPI_Attribute> > aFeatAttrList =
+ aFeature->data()->attributes(std::string());
+ std::list<boost::shared_ptr<ModelAPI_Attribute> >::const_iterator aFAIter = aFeatAttrList
+ .begin();
+ for (; aFAIter != aFeatAttrList.end(); aFAIter++)
if (myEntityAttrMap.find(*aFAIter) != myEntityAttrMap.end())
return true;
}
// ============================================================================
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<GeomAPI_XY> 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<GeomAPI_XY> 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<GeomAPI_XY> 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);
// Purpose: create/update the constraint in the group
// ============================================================================
bool SketchSolver_ConstraintGroup::changeConstraint(
- boost::shared_ptr<SketchPlugin_Constraint> theConstraint)
+ boost::shared_ptr<SketchPlugin_Constraint> 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<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::const_iterator
- aConstrMapIter = myConstraintMap.find(theConstraint);
+ std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::const_iterator aConstrMapIter =
+ myConstraintMap.find(theConstraint);
std::vector<Slvs_Constraint>::iterator aConstrIter;
- if (aConstrMapIter != myConstraintMap.end())
- {
+ if (aConstrMapIter != myConstraintMap.end()) {
int aConstrPos = Search(aConstrMapIter->second, myConstraints);
aConstrIter = myConstraints.begin() + aConstrPos;
}
// 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<std::string>& aConstraintAttributes = aConstraint.getAttributes();
// Create constraint parameters
- double aDistance = 0.0; // scalar value of the constraint
- AttributeDoublePtr aDistAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theConstraint->data()->attribute(SketchPlugin_Constraint::VALUE()));
- if (aDistAttr)
- {
+ double aDistance = 0.0; // scalar value of the constraint
+ AttributeDoublePtr aDistAttr = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
+ 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<ModelAPI_AttributeRefAttr> aConstrAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
- theConstraint->data()->attribute(aConstraintAttributes[indAttr])
- );
- if (!aConstrAttr) continue;
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> 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<ModelAPI_ResultConstruction>(aConstrAttr->object());
- if (!aRC) continue;
+ if (aConstrAttr->isObject() && aConstrAttr->object()) {
+ ResultConstructionPtr aRC = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(
+ aConstrAttr->object());
+ if (!aRC)
+ continue;
boost::shared_ptr<ModelAPI_Document> 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<ModelAPI_Data> 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);
// Purpose: create/update the element affected by any constraint
// ============================================================================
Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(
- boost::shared_ptr<ModelAPI_Attribute> theEntity)
+ boost::shared_ptr<ModelAPI_Attribute> theEntity)
{
// If the entity is already in the group, try to find it
- std::map<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::const_iterator
- aEntIter = myEntityAttrMap.find(theEntity);
- std::vector<Slvs_Param>::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<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::const_iterator aEntIter =
+ myEntityAttrMap.find(theEntity);
+ std::vector<Slvs_Param>::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<GeomDataAPI_Point> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(theEntity);
- if (aPoint)
- {
+ boost::shared_ptr<GeomDataAPI_Point> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
+ theEntity);
+ if (aPoint) {
Slvs_hParam aX = changeParameter(aPoint->x(), aParamIter);
Slvs_hParam aY = changeParameter(aPoint->y(), aParamIter);
Slvs_hParam aZ = changeParameter(aPoint->z(), aParamIter);
// Point in 2D
boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theEntity);
- if (aPoint2D)
- {
+ boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theEntity);
+ if (aPoint2D) {
Slvs_hParam aU = changeParameter(aPoint2D->x(), aParamIter);
Slvs_hParam aV = changeParameter(aPoint2D->y(), aParamIter);
}
// Scalar value (used for the distance entities)
- AttributeDoublePtr aScalar =
- boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theEntity);
- if (aScalar)
- {
+ AttributeDoublePtr aScalar = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theEntity);
+ if (aScalar) {
Slvs_hParam aValue = changeParameter(aScalar->value(), aParamIter);
if (isEntExists)
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<FeaturePtr, Slvs_hEntity>::const_iterator
- aEntIter = myEntityFeatMap.find(theEntity);
+ std::map<FeaturePtr, Slvs_hEntity>::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<SketchPlugin_Feature> aFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(theEntity);
- if (aFeature)
- { // Verify the feature by its kind
+ boost::shared_ptr<SketchPlugin_Feature> 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;
// Purpose: create/update the normal of workplane
// ============================================================================
Slvs_hEntity SketchSolver_ConstraintGroup::changeNormal(
- boost::shared_ptr<ModelAPI_Attribute> theDirX,
- boost::shared_ptr<ModelAPI_Attribute> theDirY,
- boost::shared_ptr<ModelAPI_Attribute> theNorm)
+ boost::shared_ptr<ModelAPI_Attribute> theDirX, boost::shared_ptr<ModelAPI_Attribute> theDirY,
+ boost::shared_ptr<ModelAPI_Attribute> theNorm)
{
- boost::shared_ptr<GeomDataAPI_Dir> aDirX =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(theDirX);
- boost::shared_ptr<GeomDataAPI_Dir> aDirY =
- boost::dynamic_pointer_cast<GeomDataAPI_Dir>(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<GeomDataAPI_Dir> aDirX = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(theDirX);
+ boost::shared_ptr<GeomDataAPI_Dir> aDirY = boost::dynamic_pointer_cast<GeomDataAPI_Dir>(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<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::const_iterator
- aEntIter = myEntityAttrMap.find(theNorm);
- std::vector<Slvs_Param>::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<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::const_iterator aEntIter =
+ myEntityAttrMap.find(theNorm);
+ std::vector<Slvs_Param>::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;
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<SketchPlugin_Feature> theSketch)
+bool SketchSolver_ConstraintGroup::addWorkplane(boost::shared_ptr<SketchPlugin_Feature> 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();
bool SketchSolver_ConstraintGroup::updateWorkplane()
{
// Get parameters of workplane
- boost::shared_ptr<ModelAPI_Attribute> aDirX = mySketch->data()->attribute(SketchPlugin_Sketch::DIRX_ID());
- boost::shared_ptr<ModelAPI_Attribute> aDirY = mySketch->data()->attribute(SketchPlugin_Sketch::DIRY_ID());
- boost::shared_ptr<ModelAPI_Attribute> aNorm = mySketch->data()->attribute(SketchPlugin_Sketch::NORM_ID());
- boost::shared_ptr<ModelAPI_Attribute> anOrigin = mySketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID());
+ boost::shared_ptr<ModelAPI_Attribute> aDirX = mySketch->data()->attribute(
+ SketchPlugin_Sketch::DIRX_ID());
+ boost::shared_ptr<ModelAPI_Attribute> aDirY = mySketch->data()->attribute(
+ SketchPlugin_Sketch::DIRY_ID());
+ boost::shared_ptr<ModelAPI_Attribute> aNorm = mySketch->data()->attribute(
+ SketchPlugin_Sketch::NORM_ID());
+ boost::shared_ptr<ModelAPI_Attribute> 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
// Purpose: create/update value of parameter
// ============================================================================
Slvs_hParam SketchSolver_ConstraintGroup::changeParameter(
- const double& theParam,
- std::vector<Slvs_Param>::const_iterator& thePrmIter)
+ const double& theParam, std::vector<Slvs_Param>::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++;
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<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::iterator
- anEntIter = myEntityAttrMap.begin();
- for ( ; anEntIter != myEntityAttrMap.end(); anEntIter++)
+ std::map<boost::shared_ptr<ModelAPI_Attribute>, 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();
// 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<Slvs_hConstraint, Slvs_hConstraint> aConstrMap;
// Add all constraints from theGroup to the current group
- std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::const_iterator
- aConstrIter = theGroup.myConstraintMap.begin();
- for ( ; aConstrIter != theGroup.myConstraintMap.end(); aConstrIter++)
+ std::map<boost::shared_ptr<SketchPlugin_Constraint>, 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<Slvs_hConstraint>::const_iterator aTempConstrIter = theGroup.myTempConstraints.begin();
- for ( ; aTempConstrIter != theGroup.myTempConstraints.end(); aTempConstrIter++)
- {
- std::map<Slvs_hConstraint, Slvs_hConstraint>::iterator aFind = aConstrMap.find(*aTempConstrIter);
+ for (; aTempConstrIter != theGroup.myTempConstraints.end(); aTempConstrIter++) {
+ std::map<Slvs_hConstraint, Slvs_hConstraint>::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<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::const_iterator
- aFeatureIter = theGroup.myEntityAttrMap.begin();
+ else if (!theGroup.myTempPointWhereDragged.empty()) { // Need to create additional transient constraint
+ std::map<boost::shared_ptr<ModelAPI_Attribute>, 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;
}
void SketchSolver_ConstraintGroup::splitGroup(std::vector<SketchSolver_ConstraintGroup*>& theCuts)
{
// Divide constraints and entities into several groups
- std::vector< std::set<Slvs_hEntity> > aGroupsEntities;
- std::vector< std::set<Slvs_hConstraint> > aGroupsConstr;
- int aMaxNbEntities = 0; // index of the group with maximal nuber of elements (this group will be left in the current)
+ std::vector<std::set<Slvs_hEntity> > aGroupsEntities;
+ std::vector<std::set<Slvs_hConstraint> > aGroupsConstr;
+ int aMaxNbEntities = 0; // index of the group with maximal nuber of elements (this group will be left in the current)
std::vector<Slvs_Constraint>::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<int> anIndexes;
// Go through the groupped entities and find even one of entities of current constraint
- std::vector< std::set<Slvs_hEntity> >::iterator aGrEntIter;
- for (aGrEntIter = aGroupsEntities.begin(); aGrEntIter != aGroupsEntities.end(); aGrEntIter++)
- {
+ std::vector<std::set<Slvs_hEntity> >::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)
anIndexes.push_back(aGrEntIter - aGroupsEntities.begin());
}
// Add new group if no one is found
- if (anIndexes.empty())
- {
+ if (anIndexes.empty()) {
std::set<Slvs_hEntity> aNewGrEnt;
for (int i = 0; i < 4; i++)
if (aConstrEnt[i] != 0)
aGroupsConstr.push_back(aNewGrConstr);
if (aNewGrEnt.size() > 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)
aGroupsConstr[anIndexes.front()].insert(aConstrIter->h);
if (aGrEntIter->size() > aGroupsEntities[aMaxNbEntities].size())
aMaxNbEntities = aGrEntIter - aGroupsEntities.begin();
- }
- else
- { // There are found several connected groups, merge them
- std::vector< std::set<Slvs_hEntity> >::iterator aFirstGroup =
- aGroupsEntities.begin() + anIndexes.front();
- std::vector< std::set<Slvs_hConstraint> >::iterator aFirstConstr =
- aGroupsConstr.begin() + anIndexes.front();
+ } else { // There are found several connected groups, merge them
+ std::vector<std::set<Slvs_hEntity> >::iterator aFirstGroup = aGroupsEntities.begin()
+ + anIndexes.front();
+ std::vector<std::set<Slvs_hConstraint> >::iterator aFirstConstr = aGroupsConstr.begin()
+ + anIndexes.front();
std::vector<int>::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));
}
}
if (aGroupsEntities.size() <= 1)
- return ;
+ return;
// Remove the group with maximum elements as it will be left in the current group
aGroupsEntities.erase(aGroupsEntities.begin() + aMaxNbEntities);
// Add new groups of constraints and divide current group
std::vector<SketchSolver_ConstraintGroup*> 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<boost::shared_ptr<SketchPlugin_Constraint>, 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<Slvs_hConstraint> >::const_iterator aGIter = aGroupsConstr.begin();
+ std::map<boost::shared_ptr<SketchPlugin_Constraint>, 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<Slvs_hConstraint> >::const_iterator aGIter = aGroupsConstr.begin();
std::vector<SketchSolver_ConstraintGroup*>::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
aConstrMapIter++;
break;
}
- if (aGIter == aGroupsConstr.end())
- {
+ if (aGIter == aGroupsConstr.end()) {
aConstrMapIter++;
aConstrMapPos++;
}
// ============================================================================
bool SketchSolver_ConstraintGroup::updateGroup()
{
- std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::reverse_iterator
- aConstrIter = myConstraintMap.rbegin();
+ std::map<boost::shared_ptr<SketchPlugin_Constraint>, 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<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::reverse_iterator
- aCopyIter = aConstrIter++;
+ std::map<boost::shared_ptr<SketchPlugin_Constraint>, 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<SketchPlugin_Constraint> > anExtraCopy = myExtraCoincidence;
+ std::set<boost::shared_ptr<SketchPlugin_Constraint> > anExtraCopy = myExtraCoincidence;
myExtraCoincidence.clear();
- std::set< boost::shared_ptr<SketchPlugin_Constraint> >::iterator
- aCIter = anExtraCopy.begin();
- for ( ; aCIter != anExtraCopy.end(); aCIter++)
+ std::set<boost::shared_ptr<SketchPlugin_Constraint> >::iterator aCIter = anExtraCopy.begin();
+ for (; aCIter != anExtraCopy.end(); aCIter++)
if ((*aCIter)->data()->isValid())
changeConstraint(*aCIter);
}
// Purpose: update features of sketch after resolving constraints
// ============================================================================
bool SketchSolver_ConstraintGroup::updateAttribute(
- boost::shared_ptr<ModelAPI_Attribute> theAttribute,
- const Slvs_hEntity& theEntityID)
+ boost::shared_ptr<ModelAPI_Attribute> theAttribute, const Slvs_hEntity& theEntityID)
{
// Search the position of the first parameter of the entity
int anEntPos = Search(theEntityID, myEntities);
// Look over supported types of entities
// Point in 3D
- boost::shared_ptr<GeomDataAPI_Point> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(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<GeomDataAPI_Point> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
+ 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;
// Point in 2D
boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(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<GeomDataAPI_Point2D>(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<ModelAPI_AttributeDouble>(theAttribute);
- if (aScalar)
- {
- if (fabs(aScalar->value() - myParams[aFirstParamPos].val) > tolerance)
- {
+ AttributeDoublePtr aScalar = boost::dynamic_pointer_cast<ModelAPI_AttributeDouble>(theAttribute);
+ if (aScalar) {
+ if (fabs(aScalar->value() - myParams[aFirstParamPos].val) > tolerance) {
aScalar->setValue(myParams[aFirstParamPos].val);
return true;
}
// Purpose: search the entity in this group and update it
// ============================================================================
void SketchSolver_ConstraintGroup::updateEntityIfPossible(
- boost::shared_ptr<ModelAPI_Attribute> theEntity)
+ boost::shared_ptr<ModelAPI_Attribute> 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
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<GeomDataAPI_Point> aPoint =
- boost::dynamic_pointer_cast<GeomDataAPI_Point>(theEntity);
- boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D =
- boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(theEntity);
+ boost::shared_ptr<GeomDataAPI_Point> aPoint = boost::dynamic_pointer_cast<GeomDataAPI_Point>(
+ theEntity);
+ boost::shared_ptr<GeomDataAPI_Point2D> aPoint2D = boost::dynamic_pointer_cast<
+ GeomDataAPI_Point2D>(theEntity);
if (aPoint || aPoint2D)
addTemporaryConstraintWhereDragged(theEntity);
}
// which was moved by user
// ============================================================================
void SketchSolver_ConstraintGroup::addTemporaryConstraintWhereDragged(
- boost::shared_ptr<ModelAPI_Attribute> theEntity)
+ boost::shared_ptr<ModelAPI_Attribute> theEntity)
{
// Find identifier of the entity
- std::map<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::const_iterator
- anEntIter = myEntityAttrMap.find(theEntity);
+ std::map<boost::shared_ptr<ModelAPI_Attribute>, 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<Slvs_hEntity> aDraggedPntID;
aDraggedPntID.insert(myTempPointWDrgdID);
std::list<Slvs_hConstraint>::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<Slvs_hEntity> >::iterator aCoPtIter = myCoincidentPoints.begin();
- for ( ; aCoPtIter != myCoincidentPoints.end(); aCoPtIter++)
- {
+ std::vector<std::set<Slvs_hEntity> >::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<Slvs_hEntity>::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
void SketchSolver_ConstraintGroup::removeTemporaryConstraints()
{
std::list<Slvs_hConstraint>::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;
// Class: SketchSolver_ConstraintGroup
// Purpose: remove constraint and all unused entities
// ============================================================================
-void SketchSolver_ConstraintGroup::removeConstraint(boost::shared_ptr<SketchPlugin_Constraint> theConstraint)
+void SketchSolver_ConstraintGroup::removeConstraint(
+ boost::shared_ptr<SketchPlugin_Constraint> theConstraint)
{
- std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::iterator
- anIterToRemove = myConstraintMap.find(theConstraint);
+ std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::iterator anIterToRemove =
+ myConstraintMap.find(theConstraint);
if (anIterToRemove == myConstraintMap.end())
- return ;
+ return;
Slvs_hConstraint aCnstrToRemove = anIterToRemove->second;
// Remove constraint from the map
// Find unused entities
int aConstrPos = Search(aCnstrToRemove, myConstraints);
std::set<Slvs_hEntity> 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]);
if (aCnstrToRemove == myConstrMaxID)
myConstrMaxID--;
std::vector<Slvs_Constraint>::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<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::iterator
- anEntAttrIter = myEntityAttrMap.begin();
- while (anEntAttrIter != myEntityAttrMap.end())
- {
- if (anEntToRemove.find(anEntAttrIter->second) != anEntToRemove.end())
- {
- std::map<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::iterator
- aRemovedIter = anEntAttrIter;
+ std::map<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::iterator anEntAttrIter =
+ myEntityAttrMap.begin();
+ while (anEntAttrIter != myEntityAttrMap.end()) {
+ if (anEntToRemove.find(anEntAttrIter->second) != anEntToRemove.end()) {
+ std::map<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>::iterator aRemovedIter =
+ anEntAttrIter;
anEntAttrIter++;
myEntityAttrMap.erase(aRemovedIter);
- }
- else anEntAttrIter++;
+ } else
+ anEntAttrIter++;
}
- std::map<FeaturePtr, Slvs_hEntity>::iterator
- anEntFeatIter = myEntityFeatMap.begin();
- while (anEntFeatIter != myEntityFeatMap.end())
- {
- if (anEntToRemove.find(anEntFeatIter->second) != anEntToRemove.end())
- {
- std::map<FeaturePtr, Slvs_hEntity>::iterator
- aRemovedIter = anEntFeatIter;
+ std::map<FeaturePtr, Slvs_hEntity>::iterator anEntFeatIter = myEntityFeatMap.begin();
+ while (anEntFeatIter != myEntityFeatMap.end()) {
+ if (anEntToRemove.find(anEntFeatIter->second) != anEntToRemove.end()) {
+ std::map<FeaturePtr, Slvs_hEntity>::iterator aRemovedIter = anEntFeatIter;
anEntFeatIter++;
myEntityFeatMap.erase(aRemovedIter);
- }
- else anEntFeatIter++;
+ } else
+ anEntFeatIter++;
}
std::set<Slvs_hEntity>::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;
if (aParamPos >= 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)
myEntities.erase(myEntities.begin() + anEntPos);
// Remove entity's ID from the lists of conincident points
- std::vector< std::set<Slvs_hEntity> >::iterator aCoPtIter = myCoincidentPoints.begin();
- for ( ; aCoPtIter != myCoincidentPoints.end(); aCoPtIter++)
+ std::vector<std::set<Slvs_hEntity> >::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<Slvs_hEntity> >::iterator aCoPtIter = myCoincidentPoints.begin();
- std::vector< std::set<Slvs_hEntity> >::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<std::set<Slvs_hEntity> >::iterator aCoPtIter = myCoincidentPoints.begin();
+ std::vector<std::set<Slvs_hEntity> >::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());
aFirstFound = myCoincidentPoints.begin() + aFirstFoundShift;
aCoPtIter = myCoincidentPoints.begin() + aCurrentShift;
continue;
- }
- else
- {
+ } else {
aCoPtIter->insert(isFound[0] ? thePoint2 : thePoint1);
aFirstFound = aCoPtIter;
}
aCoPtIter++;
}
// No points were found, need to create new set
- if (aFirstFound == myCoincidentPoints.end())
- {
+ if (aFirstFound == myCoincidentPoints.end()) {
std::set<Slvs_hEntity> aNewSet;
aNewSet.insert(thePoint1);
aNewSet.insert(thePoint2);
return true;
}
-
// ============================================================================
// Function: updateRelatedConstraints
// Class: SketchSolver_ConstraintGroup
// Purpose: emit the signal to update constraints
// ============================================================================
void SketchSolver_ConstraintGroup::updateRelatedConstraints(
- boost::shared_ptr<ModelAPI_Attribute> theEntity) const
+ boost::shared_ptr<ModelAPI_Attribute> theEntity) const
{
- std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::const_iterator
- aConstrIter = myConstraintMap.begin();
- for ( ; aConstrIter != myConstraintMap.end(); aConstrIter++)
- {
- std::list< boost::shared_ptr<ModelAPI_Attribute> > anAttributes =
- aConstrIter->first->data()->attributes(std::string());
-
- std::list< boost::shared_ptr<ModelAPI_Attribute> >::iterator
- anAttrIter = anAttributes.begin();
- for ( ; anAttrIter != anAttributes.end(); anAttrIter++)
- {
+ std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::const_iterator aConstrIter =
+ myConstraintMap.begin();
+ for (; aConstrIter != myConstraintMap.end(); aConstrIter++) {
+ std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttributes = aConstrIter->first->data()
+ ->attributes(std::string());
+
+ std::list<boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttrIter = anAttributes.begin();
+ for (; anAttrIter != anAttributes.end(); anAttrIter++) {
bool isUpd = (*anAttrIter == theEntity);
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRefAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> 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;
}
void SketchSolver_ConstraintGroup::updateRelatedConstraints(
- boost::shared_ptr<ModelAPI_Feature> theFeature) const
+ boost::shared_ptr<ModelAPI_Feature> theFeature) const
{
- std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::const_iterator
- aConstrIter = myConstraintMap.begin();
- for ( ; aConstrIter != myConstraintMap.end(); aConstrIter++)
- {
- std::list< boost::shared_ptr<ModelAPI_Attribute> > anAttributes =
- aConstrIter->first->data()->attributes(std::string());
-
- std::list< boost::shared_ptr<ModelAPI_Attribute> >::iterator
- anAttrIter = anAttributes.begin();
- for ( ; anAttrIter != anAttributes.end(); anAttrIter++)
- {
- boost::shared_ptr<ModelAPI_AttributeRefAttr> aRefAttr =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIter);
- if (aRefAttr && aRefAttr->isObject() && aRefAttr->object() == theFeature)
- {
+ std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>::const_iterator aConstrIter =
+ myConstraintMap.begin();
+ for (; aConstrIter != myConstraintMap.end(); aConstrIter++) {
+ std::list<boost::shared_ptr<ModelAPI_Attribute> > anAttributes = aConstrIter->first->data()
+ ->attributes(std::string());
+
+ std::list<boost::shared_ptr<ModelAPI_Attribute> >::iterator anAttrIter = anAttributes.begin();
+ for (; anAttrIter != anAttributes.end(); anAttrIter++) {
+ boost::shared_ptr<ModelAPI_AttributeRefAttr> 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;
}
}
-
-
// ========================================================
// ========= Auxiliary functions ===============
// ========================================================
-template <typename T>
+template<typename T>
int Search(const uint32_t& theEntityID, const std::vector<T>& theEntities)
{
int aResIndex = theEntityID <= theEntities.size() ? theEntityID - 1 : 0;
#include <vector>
#include <set>
-
/** \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
/// \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
bool isBaseWorkplane(boost::shared_ptr<SketchPlugin_Feature> theWorkplane) const;
boost::shared_ptr<SketchPlugin_Feature> 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
/** \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<ModelAPI_Attribute> theEntity) const;
- void updateRelatedConstraints(boost::shared_ptr<ModelAPI_Feature> theFeature) const;
+ void updateRelatedConstraints(boost::shared_ptr<ModelAPI_Attribute> theEntity) const;
+ void updateRelatedConstraints(boost::shared_ptr<ModelAPI_Feature> 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.
* \return identifier of changed entity or 0 if entity could not be changed
*/
Slvs_hEntity changeEntity(boost::shared_ptr<ModelAPI_Attribute> theEntity);
- Slvs_hEntity changeEntity(FeaturePtr theEntity);
+ Slvs_hEntity changeEntity(FeaturePtr theEntity);
/** \brief Adds or updates a normal in the group
*
* \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<ModelAPI_Attribute> theAttribute, const Slvs_hEntity& theEntityID);
+ bool updateAttribute(boost::shared_ptr<ModelAPI_Attribute> 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
*/
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
*/
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<Slvs_Param> myParams; ///< List of parameters of the constraints
- Slvs_hParam myParamMaxID; ///< Actual maximal ID of parameters (not equal to myParams size)
- std::vector<Slvs_Entity> 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<Slvs_Param> myParams; ///< List of parameters of the constraints
+ Slvs_hParam myParamMaxID; ///< Actual maximal ID of parameters (not equal to myParams size)
+ std::vector<Slvs_Entity> myEntities; ///< List of entities of the constaints
+ Slvs_hEntity myEntityMaxID; ///< Actual maximal ID of entities (not equal to myEntities size)
std::vector<Slvs_Constraint> 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<Slvs_hParam> myTempPointWhereDragged; ///< Parameters of one of the points which is moved by user
- Slvs_hEntity myTempPointWDrgdID; ///< Identifier of such point
- std::list<Slvs_hConstraint> myTempConstraints; ///< The list of identifiers of temporary constraints (SLVS_C_WHERE_DRAGGED) applied for all other points moved by user
+ std::vector<Slvs_hParam> myTempPointWhereDragged; ///< Parameters of one of the points which is moved by user
+ Slvs_hEntity myTempPointWDrgdID; ///< Identifier of such point
+ std::list<Slvs_hConstraint> 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<SketchPlugin_Feature>
- mySketch; ///< Equivalent to workplane
- std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint>
- myConstraintMap; ///< The map between SketchPlugin and SolveSpace constraints
- std::map<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity>
- myEntityAttrMap; ///< The map between "attribute" parameters of constraints and their equivalent SolveSpace entities
- std::map<FeaturePtr, Slvs_hEntity>
- myEntityFeatMap; ///< The map between "feature" parameters of constraints and their equivalent SolveSpace entities
+ boost::shared_ptr<SketchPlugin_Feature> mySketch; ///< Equivalent to workplane
+ std::map<boost::shared_ptr<SketchPlugin_Constraint>, Slvs_hConstraint> myConstraintMap; ///< The map between SketchPlugin and SolveSpace constraints
+ std::map<boost::shared_ptr<ModelAPI_Attribute>, Slvs_hEntity> myEntityAttrMap; ///< The map between "attribute" parameters of constraints and their equivalent SolveSpace entities
+ std::map<FeaturePtr, Slvs_hEntity> myEntityFeatMap; ///< The map between "feature" parameters of constraints and their equivalent SolveSpace entities
// Conincident items
- std::vector< std::set<Slvs_hEntity> >
- myCoincidentPoints; ///< Stores the lists of identifiers of coincident points (to avoid unnecessary coincidence constraints)
- std::set< boost::shared_ptr<SketchPlugin_Constraint> >
- 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<std::set<Slvs_hEntity> > myCoincidentPoints; ///< Stores the lists of identifiers of coincident points (to avoid unnecessary coincidence constraints)
+ std::set<boost::shared_ptr<SketchPlugin_Constraint> > 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
#include <list>
-
// Initialization of constraint manager self pointer
SketchSolver_ConstraintManager* SketchSolver_ConstraintManager::_self = 0;
/// Global constraint manager object
SketchSolver_ConstraintManager* myManager = SketchSolver_ConstraintManager::Instance();
-
// ========================================================
// ========= 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<const ModelAPI_ObjectUpdatedMessage*>(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<const ModelAPI_ObjectUpdatedMessage*>(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++) {
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*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<SketchPlugin_Feature> aSketch =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ if (aFeatureKind.compare(SketchPlugin_Sketch::ID()) == 0) {
+ boost::shared_ptr<SketchPlugin_Feature> aSketch = boost::dynamic_pointer_cast<
+ SketchPlugin_Feature>(aFeature);
if (aSketch)
changeWorkplane(aSketch);
continue;
}
- boost::shared_ptr<SketchPlugin_Constraint> aConstraint =
- boost::dynamic_pointer_cast<SketchPlugin_Constraint>(aFeature);
+ boost::shared_ptr<SketchPlugin_Constraint> aConstraint = boost::dynamic_pointer_cast<
+ SketchPlugin_Constraint>(aFeature);
if (aConstraint)
changeConstraint(aConstraint);
- else
- {
+ else {
// Sketch plugin features can be only updated
- boost::shared_ptr<SketchPlugin_Feature> aSFeature =
- boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ boost::shared_ptr<SketchPlugin_Feature> aSFeature = boost::dynamic_pointer_cast<
+ SketchPlugin_Feature>(aFeature);
if (aSFeature)
updateEntity(aSFeature);
}
// Solve the set of constraints
resolveConstraints();
- }
- else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED))
- {
- const ModelAPI_ObjectDeletedMessage* aDeleteMsg =
- dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
+ } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
+ const ModelAPI_ObjectDeletedMessage* aDeleteMsg =
+ dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
const std::set<std::string>& aFeatureGroups = aDeleteMsg->groups();
// Find SketchPlugin_Sketch::ID() in groups. The constraint groups should be updated when an object removed from Sketch
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<SketchSolver_ConstraintGroup*>::iterator aGroupIter = myGroups.begin();
std::vector<SketchSolver_ConstraintGroup*> 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++;
// Class: SketchSolver_PluginManager
// Purpose: update workplane by given parameters of the sketch
// ============================================================================
-bool SketchSolver_ConstraintManager::changeWorkplane(boost::shared_ptr<SketchPlugin_Feature> theSketch)
+bool SketchSolver_ConstraintManager::changeWorkplane(
+ boost::shared_ptr<SketchPlugin_Feature> 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<SketchSolver_ConstraintGroup*>::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;
}
// Purpose: create/update the constraint and place it into appropriate group
// ============================================================================
bool SketchSolver_ConstraintManager::changeConstraint(
- boost::shared_ptr<SketchPlugin_Constraint> theConstraint)
+ boost::shared_ptr<SketchPlugin_Constraint> theConstraint)
{
// Search the groups which this constraint touches
std::set<Slvs_hGroup> 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<SketchPlugin_Feature> 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<SketchSolver_ConstraintGroup*>::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<Slvs_hGroup>::const_iterator aGroupsIter = aGroups.begin();
// Search first group
// Append other groups to the first one
std::vector<SketchSolver_ConstraintGroup*>::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;
}
int aShiftOther = anOtherGroupIter - myGroups.begin();
delete *anOtherGroupIter;
myGroups.erase(anOtherGroupIter);
- aFirstGroupIter = myGroups.begin() + aShiftFirst;
+ aFirstGroupIter = myGroups.begin() + aShiftFirst;
anOtherGroupIter = myGroups.begin() + aShiftOther;
}
// Class: SketchSolver_PluginManager
// Purpose: update any element on the sketch, which is used by constraints
// ============================================================================
-void SketchSolver_ConstraintManager::updateEntity(boost::shared_ptr<SketchPlugin_Feature> theFeature)
+void SketchSolver_ConstraintManager::updateEntity(
+ boost::shared_ptr<SketchPlugin_Feature> theFeature)
{
// Create list of attributes depending on type of the feature
std::vector<std::string> anAttrList;
if (aFeatureKind.compare(SketchPlugin_Point::ID()) == 0)
anAttrList.push_back(SketchPlugin_Point::COORD_ID());
// Line
- else if (aFeatureKind.compare(SketchPlugin_Line::ID()) == 0)
- {
+ else if (aFeatureKind.compare(SketchPlugin_Line::ID()) == 0) {
anAttrList.push_back(SketchPlugin_Line::START_ID());
anAttrList.push_back(SketchPlugin_Line::END_ID());
}
// Circle
- else if (aFeatureKind.compare(SketchPlugin_Circle::ID()) == 0)
- {
+ else if (aFeatureKind.compare(SketchPlugin_Circle::ID()) == 0) {
anAttrList.push_back(SketchPlugin_Circle::CENTER_ID());
anAttrList.push_back(SketchPlugin_Circle::RADIUS_ID());
}
// Arc
- else if (aFeatureKind.compare(SketchPlugin_Arc::ID()) == 0)
- {
+ else if (aFeatureKind.compare(SketchPlugin_Arc::ID()) == 0) {
anAttrList.push_back(SketchPlugin_Arc::CENTER_ID());
anAttrList.push_back(SketchPlugin_Arc::START_ID());
anAttrList.push_back(SketchPlugin_Arc::END_ID());
// Check changing of feature's attributes (go through the groups and search usage of the attributes)
std::vector<std::string>::const_iterator anAttrIter;
- for (anAttrIter = anAttrList.begin(); anAttrIter != anAttrList.end(); anAttrIter++)
- {
+ for (anAttrIter = anAttrList.begin(); anAttrIter != anAttrList.end(); anAttrIter++) {
std::vector<SketchSolver_ConstraintGroup*>::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<ModelAPI_Attribute> anAttribute =
- boost::dynamic_pointer_cast<ModelAPI_Attribute>(theFeature->data()->attribute(*anAttrIter));
+ boost::shared_ptr<ModelAPI_Attribute> anAttribute = boost::dynamic_pointer_cast<
+ ModelAPI_Attribute>(theFeature->data()->attribute(*anAttrIter));
(*aGroupIter)->updateEntityIfPossible(anAttribute);
}
}
(*aGroupIter)->updateRelatedConstraints(theFeature);
}
-
// ============================================================================
// Function: findGroups
// Class: SketchSolver_PluginManager
// Purpose: search groups of entities interacting with given constraint
// ============================================================================
void SketchSolver_ConstraintManager::findGroups(
- boost::shared_ptr<SketchPlugin_Constraint> theConstraint,
- std::set<Slvs_hGroup>& theGroupIDs) const
+ boost::shared_ptr<SketchPlugin_Constraint> theConstraint,
+ std::set<Slvs_hGroup>& theGroupIDs) const
{
boost::shared_ptr<SketchPlugin_Feature> 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<SketchSolver_ConstraintGroup*>::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)
// Purpose: search workplane containing given constraint
// ============================================================================
boost::shared_ptr<SketchPlugin_Feature> SketchSolver_ConstraintManager::findWorkplaneForConstraint(
- boost::shared_ptr<SketchPlugin_Constraint> theConstraint) const
+ boost::shared_ptr<SketchPlugin_Constraint> theConstraint) const
{
// Already verified workplanes
- std::set< boost::shared_ptr<SketchPlugin_Feature> > aVerified;
+ std::set<boost::shared_ptr<SketchPlugin_Feature> > aVerified;
std::vector<SketchSolver_ConstraintGroup*>::const_iterator aGroupIter;
- for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++)
- {
+ for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) {
boost::shared_ptr<SketchPlugin_Feature> aWP = (*aGroupIter)->getWorkplane();
if (aVerified.find(aWP) != aVerified.end())
continue;
- boost::shared_ptr<ModelAPI_AttributeRefList> aWPFeatures =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aWP->data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
+ boost::shared_ptr<ModelAPI_AttributeRefList> aWPFeatures = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeRefList>(aWP->data()->attribute(SketchPlugin_Sketch::FEATURES_ID()));
std::list<ObjectPtr> aFeaturesList = aWPFeatures->list();
std::list<ObjectPtr>::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);
}
#include <vector>
#include <set>
-
/** \class SketchSolver_ConstraintManager
* \ingroup DataModel
* \brief Listens the changes of SketchPlugin features and transforms the Constraint
*/
class SketchSolver_ConstraintManager : public Events_Listener
{
-public:
+ public:
/** \brief Main method to create constraint manager
* \return pointer to the singleton
*/
*/
virtual void processEvent(const Events_Message* theMessage);
-protected:
+ protected:
SketchSolver_ConstraintManager();
~SketchSolver_ConstraintManager();
*/
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<SketchPlugin_Constraint> theConstraint,
- std::set<Slvs_hGroup>& theGroupIDs) const;
+ std::set<Slvs_hGroup>& 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<SketchPlugin_Feature> findWorkplaneForConstraint(
- boost::shared_ptr<SketchPlugin_Constraint> theConstraint) const;
+ boost::shared_ptr<SketchPlugin_Constraint> theConstraint) const;
-private:
- static SketchSolver_ConstraintManager* _self; ///< Self pointer to implement singleton functionality
- std::vector<SketchSolver_ConstraintGroup*> myGroups; ///< Groups of constraints
+ private:
+ static SketchSolver_ConstraintManager* _self; ///< Self pointer to implement singleton functionality
+ std::vector<SketchSolver_ConstraintGroup*> myGroups; ///< Groups of constraints
};
#endif
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<Slvs_Param>& 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()];
}
void SketchSolver_Solver::setDraggedParameters(const std::vector<Slvs_hParam>& theDragged)
{
- if (theDragged.size() == 0)
- {
+ if (theDragged.size() == 0) {
myEquationsSystem.dragged[0] = 0;
myEquationsSystem.dragged[1] = 0;
myEquationsSystem.dragged[2] = 0;
void SketchSolver_Solver::setEntities(const std::vector<Slvs_Entity>& 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()];
}
void SketchSolver_Solver::setConstraints(const std::vector<Slvs_Constraint>& 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();
}
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<Slvs_Param>::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;
}
#include <vector>
-
#define SLVS_RESULT_EMPTY_SET -1
// Unknown constraint (for error reporting)
// 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
*/
bool getResult(std::vector<Slvs_Param>& 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
#include <QDebug>
#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;
{
}
-
void XGUI_ActionsMgr::addCommand(QAction* theCmd)
{
QString aId = theCmd->data().toString();
- if(aId.isEmpty()) {
+ if (aId.isEmpty()) {
return;
}
myActions.insert(aId, theCmd);
void XGUI_ActionsMgr::update()
{
- if(myOperationMgr->hasOperation()) {
+ if (myOperationMgr->hasOperation()) {
setAllEnabled(false);
ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
QString anOperationId = anOperation->id();
void XGUI_ActionsMgr::setAllEnabled(bool isEnabled)
{
- foreach(QString eachAction, myActions.keys()) {
+ foreach(QString eachAction, myActions.keys())
+ {
setActionEnabled(eachAction, 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);
}
}
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);
}
}
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);
}
}
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;
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();
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();
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
//! 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.
//! Sets the action with theId to theEnabled state.
void setActionEnabled(const QString& theId, const bool theEnabled);
-private:
+ private:
QMap<QString, QAction*> myActions;
QMap<QString, QStringList> myNestedActions;
QList<QKeySequence> myShortcuts;
#include <QToolButton>
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);
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
#include "XGUI.h"
#include <QWidgetAction>
-
#define MIN_BUTTON_HEIGHT 25
#define MIN_BUTTON_WIDTH 60
* \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);
//! 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;
#ifndef XGUI_Constants_H
#define XGUI_Constants_H
-namespace XGUI
-{
+namespace XGUI {
//! Types of gradient type used in background of Viewer 3d
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
const static char* PROP_PANEL_OK = "property_panel_ok";
const static char* PROP_PANEL_CANCEL = "property_panel_cancel";
-};
+}
+;
#endif
-
#include "XGUI_ContextMenuMgr.h"
#include "XGUI_Workshop.h"
#include "XGUI_ObjectsBrowser.h"
#include <QMenu>
#include <QMdiArea>
-XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent) :
-QObject(theParent), myWorkshop(theParent)
+XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent)
+ : QObject(theParent),
+ myWorkshop(theParent)
{
}
else if (sender() == myWorkshop->viewer()) {
aMenu = viewerMenu();
}
-
+
if (aMenu && (aMenu->actions().size() > 0)) {
aMenu->exec(theEvent->globalPos());
delete aMenu;
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"));
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<ModelAPI_Feature>(aObj);
ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
- if (aResult) hasResult = true;
- if (aFeature) hasFeature = true;
+ if (aResult)
+ hasResult = true;
+ if (aFeature)
+ hasFeature = true;
if (hasFeature && hasResult)
break;
}
//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<ModelAPI_Result>(aObject);
if (aRes && myWorkshop->displayer()->isVisible(aRes)) {
isVisible = true;
}
if (isVisible)
theMenu->addAction(action("HIDE_CMD"));
- else
+ else
theMenu->addAction(action("SHOW_CMD"));
//theMenu->addAction(action("DELETE_CMD"));
}
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*)));
}
-
#ifndef XGUI_ContextMenuMgr_H
#define XGUI_ContextMenuMgr_H
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();
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;
XGUI_Workshop* myWorkshop;
};
-#endif
\ No newline at end of file
+#endif
-
#ifndef XGUI_DataTreeModel_H
#define XGUI_DataTreeModel_H
*/
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
//! 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;
//! 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
#include <set>
-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)
{
}
}
-void XGUI_Displayer::display(ObjectPtr theObject,
- boost::shared_ptr<GeomAPI_AISObject> theAIS, bool isUpdateViewer)
+void XGUI_Displayer::display(ObjectPtr theObject, boost::shared_ptr<GeomAPI_AISObject> theAIS,
+ bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
}
}
-
-
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<GeomAPI_AISObject> anObject = myResult2AISObjectMap[theObject];
- if (anObject) {
+ if (anObject) {
Handle(AIS_InteractiveObject) anAIS = anObject->impl<Handle(AIS_InteractiveObject)>();
if (!anAIS.IsNull()) {
aContext->Remove(anAIS, isUpdateViewer);
myResult2AISObjectMap.erase(theObject);
}
-
/*bool XGUI_Displayer::redisplay(ObjectPtr theObject,
- boost::shared_ptr<GeomAPI_AISObject> theAIS,
- const bool isUpdateViewer)
-{
- bool isCreated = false;
- Handle(AIS_InteractiveObject) anAIS =
- theAIS ? theAIS->impl<Handle(AIS_InteractiveObject)>() : 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<GeomAPI_AISObject> 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<GeomAPI_AISObject> theAIS,
+ const bool isUpdateViewer)
+ {
+ bool isCreated = false;
+ Handle(AIS_InteractiveObject) anAIS =
+ theAIS ? theAIS->impl<Handle(AIS_InteractiveObject)>() : 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<GeomAPI_AISObject> 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)
{
if (aResult) {
boost::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
if (aShapePtr) {
- Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl<Handle(AIS_InteractiveObject)>());
+ Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(
+ aAISObj->impl<Handle(AIS_InteractiveObject)>());
if (!aAISShape.IsNull()) {
aAISShape->Set(aShapePtr->impl<TopoDS_Shape>());
aAISIO = aAISShape;
}
}
-void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult,
- const std::list<int>& theModes, const bool isUpdateViewer)
+void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, const std::list<int>& theModes,
+ const bool isUpdateViewer)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
// Open local context if there is no one
// 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);
if (isVisible(theObject)) {
Handle(AIS_InteractiveContext) aContext = AISContext();
- boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
- Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
- aContext->Deactivate(anAIS);
+ boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
+ Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+ aContext->Deactivate(anAIS);
}
}
if (isVisible(theObject)) {
Handle(AIS_InteractiveContext) aContext = AISContext();
- boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
- Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
- aContext->Activate(anAIS);
+ boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
+ Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+ aContext->Activate(anAIS);
}
}
for (; anIt != aLast; anIt++) {
aFeature = *anIt;
if (isVisible(aFeature))
- anAIS = Handle(AIS_Shape)::DownCast(myResult2AISObjectMap[aFeature]->impl<Handle(AIS_InteractiveObject)>());
+ anAIS = Handle(AIS_Shape)::DownCast(
+ myResult2AISObjectMap[aFeature]->impl<Handle(AIS_InteractiveObject)>());
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();
}
}
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<GeomAPI_AISObject> anObj = myResult2AISObjectMap[aResult];
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<ObjectPtr> aRemoved;
- for (; aFIt != aFLast; aFIt++)
- {
+ for (; aFIt != aFLast; aFIt++) {
ObjectPtr aFeature = (*aFIt).first;
if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) {
boost::shared_ptr<GeomAPI_AISObject> anObj = (*aFIt).second;
- if (!anObj) continue;
+ if (!anObj)
+ continue;
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
if (!anAIS.IsNull()) {
aContext->Remove(anAIS, false);
}
}
}
- std::list<ObjectPtr>::const_iterator anIt = aRemoved.begin(),
- aLast = aRemoved.end();
+ std::list<ObjectPtr>::const_iterator anIt = aRemoved.begin(), aLast = aRemoved.end();
for (; anIt != aLast; anIt++) {
myResult2AISObjectMap.erase(myResult2AISObjectMap.find(*anIt));
}
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<GeomAPI_AISObject> anObj = (*aFIt).second;
- if (!anObj) continue;
+ if (!anObj)
+ continue;
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
if (anAIS != theIO)
continue;
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<GeomAPI_AISObject> theAIS, bool isUpdate)
{
Handle(AIS_InteractiveContext) aContext = AISContext();
*/
class XGUI_EXPORT XGUI_Displayer
{
-public:
+ public:
/// Constructor
/// \param theViewer the viewer
XGUI_Displayer(XGUI_Workshop* theWorkshop);
/// \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<int>& theModes, const bool isUpdateViewer = true);
+ void activateInLocalContext(ObjectPtr theFeature, const std::list<int>& 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
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<ObjectPtr>& theFeatures, bool isUpdateViewer = true);
/// Erase the feature and a shape.
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);
/// \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<GeomAPI_AISObject> theAIS, bool isUpdateViewer = true);
-
+ void display(ObjectPtr theObject, boost::shared_ptr<GeomAPI_AISObject> theAIS,
+ bool isUpdateViewer = true);
+
/// Display the shape and activate selection of sub-shapes
/// \param theFeature a feature instance
/// \param theAIS an AIS object
// 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<ObjectPtr, boost::shared_ptr<GeomAPI_AISObject> > ResultToAISMap;
ResultToAISMap myResult2AISObjectMap;
};
-
#endif
#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));
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<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
+ const ModelAPI_ObjectUpdatedMessage* aUpdMsg =
+ dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
std::set<ObjectPtr> aObjects = aUpdMsg->objects();
std::set<ObjectPtr>::const_iterator aIt;
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<XGUI_PartModel*>::const_iterator aIt;
for (aIt = myPartModels.constBegin(); aIt != myPartModels.constEnd(); ++aIt) {
}
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<const ModelAPI_ObjectDeletedMessage*>(theMessage);
+ const ModelAPI_ObjectDeletedMessage* aUpdMsg =
+ dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
DocumentPtr aDoc = aUpdMsg->document();
std::set<std::string> aGroups = aUpdMsg->groups();
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());
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 {
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<const ModelAPI_ObjectUpdatedMessage*>(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();
}
}
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();
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<ModelAPI_Feature>(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<ModelAPI_Feature>(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);
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();
}
}
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);
}
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))
QModelIndex* aIndex = toSourceModelIndex(theIndex);
const QAbstractItemModel* aModel = aIndex->model();
- if (!isSubModel(aModel))
+ if (!isSubModel(aModel))
return QModelIndex();
if (isPartSubModel(aModel)) {
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())
return rowCount(theParent) > 0;
}
-
QModelIndex* XGUI_DocumentDataModel::toSourceModelIndex(const QModelIndex& theProxy) const
{
QModelIndex* aIndexPtr = static_cast<QModelIndex*>(theProxy.internalPointer());
return aIndexPtr;
}
-
QModelIndex* XGUI_DocumentDataModel::findModelIndex(const QModelIndex& theIndex) const
{
QList<QModelIndex*>::const_iterator aIt;
void XGUI_DocumentDataModel::clearModelIndexes()
{
QList<QModelIndex*>::const_iterator aIt;
- for (aIt = myIndexes.constBegin(); aIt != myIndexes.constEnd(); ++aIt)
+ for (aIt = myIndexes.constBegin(); aIt != myIndexes.constEnd(); ++aIt)
delete (*aIt);
myIndexes.clear();
}
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<const XGUI_FeaturesModel*>(aIndex->model());
return true;
}
-
void XGUI_DocumentDataModel::removeSubModel(int theModelId)
{
XGUI_PartModel* aModel = myPartModels.at(theModelId);
aToRemove.append(i);
}
int aId;
- while(aToRemove.size() > 0) {
+ while (aToRemove.size() > 0) {
aId = aToRemove.last();
delete myIndexes.at(aId);
myIndexes.removeAt(aId);
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
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);
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;
}
}
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();
}
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;
}
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();
-
#ifndef XGUI_DocumentDataModel_H
#define XGUI_DocumentDataModel_H
*/
class XGUI_EXPORT XGUI_DocumentDataModel : public QAbstractItemModel, public Events_Listener
{
- Q_OBJECT
-public:
-
+Q_OBJECT
+ public:
XGUI_DocumentDataModel(QObject* theParent);
virtual ~XGUI_DocumentDataModel();
// 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;
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;
int historyOffset() const;
-
//! Data model of top part of data tree (not parts object)
XGUI_TopDataModel* myModel;
};
-#endif
\ No newline at end of file
+#endif
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);
{
myErrors.append(theError);
refresh();
- if(!isVisible()) {
+ if (!isVisible()) {
show();
raise();
activateWindow();
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;
};
#include <QTabBar>
XGUI_MainMenu::XGUI_MainMenu(XGUI_MainWindow *parent)
- : QWidget(parent), myDesktop(parent)
+ : QWidget(parent),
+ myDesktop(parent)
{
myGeneralPage = new XGUI_MenuGroupPanel(this);
myGeneralPage->setObjectName("Default");
return myDesktop->findChild<XGUI_Workbench*>(theObjName);
}
-
bool XGUI_MainMenu::eventFilter(QObject *theWatched, QEvent *theEvent)
{
if (theWatched == myGeneralPage) {
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()
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;
{
QList<XGUI_Command*> aList = myGeneralPage->features();
XGUI_Workbench* aWbn;
- foreach (aWbn, myWorkbenches) {
+ foreach (aWbn, myWorkbenches)
+ {
aList.append(aWbn->features());
}
return aList;
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;
}
* \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();
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;
void updateFromResources();
-private:
+ private:
XGUI_MainWindow* myDesktop;
QTabWidget* myMenuTabs;
XGUI_MenuGroupPanel* myGeneralPage;
#include <QCloseEvent>
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()));
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)
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);
}
QDockWidget* aDock = qobject_cast<QDockWidget*>(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();
{
QMdiArea* aMdiArea = static_cast<QMdiArea*>(centralWidget());
QList<QMdiSubWindow*> aWindows = aMdiArea->subWindowList();
-
+
QSize aSize = aMdiArea->size();
QRect aRect = aMdiArea->geometry();
const int aOffset = 30;
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;
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);
aMDIWidget->addAction(aAction);
QList<QAction*> aActions = aMDIWidget->actions();
- foreach(QAction* aAct, aActions) {
+ foreach(QAction* aAct, aActions)
+ {
if (aAct->isCheckable())
aAct->setChecked(false);
}
QList<QAction*> aActions = aMDIWidget->actions();
QAction* aDelAct = 0;
- foreach(QAction* aAct, aActions) {
+ foreach(QAction* aAct, aActions)
+ {
if (aAct->text() == aTitle) {
aDelAct = aAct;
break;
QList<QMdiSubWindow*> aWndList = aMdiArea->subWindowList();
QMdiSubWindow* aTargetView = 0;
- foreach(QMdiSubWindow* aWnd, aWndList) {
+ foreach(QMdiSubWindow* aWnd, aWndList)
+ {
if (aWnd->windowTitle() == aWndTitle) {
aWnd->raise();
aWnd->activateWindow();
QMdiArea* aMdiArea = static_cast<QMdiArea*>(centralWidget());
QString aWndTitle = theSubWnd->windowTitle();
QList<QAction*> aActionList = aMdiArea->actions();
- foreach(QAction* aAct, aActionList) {
+ foreach(QAction* aAct, aActionList)
+ {
if (aAct->isCheckable())
aAct->setChecked(aAct->text() == aWndTitle);
}
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();
* \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();
return myViewer;
}
-public slots:
+ public slots:
void showPythonConsole();
void hidePythonConsole();
//! Python console can be a dock widget
void undockPythonConsole();
void createSubWindow();
-
-private slots:
+
+ private slots:
void cascadeWindows();
void onViewCreated(XGUI_ViewWindow* theWindow);
void onDeleteView(XGUI_ViewWindow* theWindow);
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:
#include <iostream>
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);
setFrameShape(QFrame::NoFrame);
}
-
-
void XGUI_MenuGroupPanel::addCommand(XGUI_Command* theAction)
{
myActions.append(theAction);
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,
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;
}
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);
XGUI_Command* feature(const QString& theId) const;
//! Returns list of created commands
- QList<XGUI_Command*> features() const { return myActions; }
+ QList<XGUI_Command*> 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<XGUI_Command*> myActions;
- QWidgetList myActionWidget;
+ QWidgetList myActionWidget;
QGridLayout* myLayout;
int myNewRow;
// 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()));
return myWorkshop->viewer()->AISContext();
}
-
QList<ObjectPtr> XGUI_ModuleConnector::selectedObjects() const
{
return myWorkshop->selector()->selection()->selectedObjects();
ModuleBase_IModule* XGUI_ModuleConnector::module() const
{
return myWorkshop->module();
-}
\ No newline at end of file
+}
#ifndef XGUI_ModuleConnector_H
#define XGUI_ModuleConnector_H
-
#include "XGUI.h"
#include <ModuleBase_Definitions.h>
#include <ModuleBase_IWorkshop.h>
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();
virtual Handle(AIS_InteractiveContext) AISContext() const;
//! Returns list of currently selected data objects
- virtual QList<ObjectPtr> selectedObjects() const;
+ virtual QList<ObjectPtr> 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
#include <QMouseEvent>
#include <QAction>
-
-
XGUI_DataTree::XGUI_DataTree(QWidget* theParent)
- : QTreeView(theParent)
+ : QTreeView(theParent)
{
setHeaderHidden(true);
setModel(new XGUI_DocumentDataModel(this));
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&)));
}
{
}
-XGUI_DocumentDataModel* XGUI_DataTree::dataModel() const
-{
- return static_cast<XGUI_DocumentDataModel*>(model());
+XGUI_DocumentDataModel* XGUI_DataTree::dataModel() const
+{
+ return static_cast<XGUI_DocumentDataModel*>(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();
setExpanded(aIndex, true);
emit activePartChanged(aModel->activePart());
}
- } else
+ } else
QTreeView::mouseDoubleClickEvent(theEvent);
}
//********************************************************************
//********************************************************************
XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent)
- : QWidget(theParent)
+ : QWidget(theParent)
{
QVBoxLayout* aLayout = new QVBoxLayout(this);
aLayout->setContentsMargins(0, 0, 0, 0);
myActiveDocLbl->installEventFilter(this);
aLabelLay->addWidget(myActiveDocLbl);
- aLabelLay->setStretch(1,1);
+ aLabelLay->setStretch(1, 1);
myTreeView = new XGUI_DataTree(this);
aLayout->addWidget(myTreeView);
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
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);
} 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;
+ }
}
}
}
}
//***************************************************
-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);
{
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);
}
{
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;
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();
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);
-
#ifndef XGUI_ObjectsBrowser_H
#define XGUI_ObjectsBrowser_H
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<ObjectPtr> selectedObjects() const { return mySelectedData; }
+ QList<ObjectPtr> 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<ObjectPtr> 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<ObjectPtr> selectedObjects() const { return myObjectsList; }
+ QList<ObjectPtr> selectedObjects() const
+ {
+ return myObjectsList;
+ }
void setObjectsSelected(const QList<ObjectPtr>& 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);
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);
void onSelectionChanged();
-private:
+ private:
void closeDocNameEditing(bool toSave);
//! Internal model
QList<ObjectPtr> myObjectsList;
};
-#endif
\ No newline at end of file
+#endif
#include <QKeyEvent>
XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent)
-: QObject(theParent)
+ : QObject(theParent)
{
// listen to Escape signal to stop the current operation
qApp->installEventFilter(this);
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();
{
ModuleBase_Operation* aCurrentOp = currentOperation();
if (!aCurrentOp || !canStopOperation())
- return false;
+ return false;
aCurrentOp->abort();
return true;
QStringList XGUI_OperationMgr::operationList()
{
QStringList result;
- foreach(ModuleBase_Operation* eachOperation, myOperations) {
+ foreach(ModuleBase_Operation* eachOperation, myOperations)
+ {
result << eachOperation->id();
}
return result;
//
std::list<ModelAPI_Validator*>::iterator it = aValidators.begin();
bool isValid = true;
- for(; it != aValidators.end(); it++) {
+ for (; it != aValidators.end(); it++) {
const ModelAPI_FeatureValidator* aFeatureValidator =
dynamic_cast<const ModelAPI_FeatureValidator*>(*it);
- if (!aFeatureValidator) continue;
+ if (!aFeatureValidator)
+ continue;
if (!aFeatureValidator->isValid(aFeature)) {
isValid = false;
break;
void XGUI_OperationMgr::validateCurrentOperation()
{
- if(!hasOperation())
+ if (!hasOperation())
return;
ModuleBase_Operation* anOperation = currentOperation();
validateOperation(currentOperation());
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
{
bool aCanStart = true;
ModuleBase_Operation* aCurrentOp = currentOperation();
- if (aCurrentOp && !theOperation->isGranted(aCurrentOp))
- {
+ if (aCurrentOp && !theOperation->isGranted(aCurrentOp)) {
if (canStopOperation()) {
aCurrentOp->abort();
} else {
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;
}
}
{
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;
}
{
ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
ModuleBase_Operation* anOperation = currentOperation();
- if (!aSenderOperation || !anOperation || aSenderOperation != anOperation )
+ if (!aSenderOperation || !anOperation || aSenderOperation != anOperation)
return;
myOperations.removeAll(anOperation);
ModuleBase_Operation* aResultOp = 0;
QListIterator<ModuleBase_Operation*> anIt(myOperations);
anIt.toBack();
- while(anIt.hasPrevious())
- {
+ while (anIt.hasPrevious()) {
ModuleBase_Operation* anOp = anIt.previous();
if (anOp) {
aResultOp = anOp;
*/
class XGUI_EXPORT XGUI_OperationMgr : public QObject
{
- Q_OBJECT
-public:
+Q_OBJECT
+ public:
/// Constructor
/// \param theParent the parent
XGUI_OperationMgr(QObject* theParent);
virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
-public slots:
+ public slots:
void validateCurrentOperation();
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
void validateOperation(ModuleBase_Operation* theOperation);
-protected slots:
+ protected slots:
/// Slot that commits the current operation.
void onCommitOperation();
/// Slot that aborts the current operation.
/// \param theWidget an activated widget
void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
-private:
- typedef QList<ModuleBase_Operation*> Operations; ///< definition for a list of operations
- Operations myOperations; ///< a stack of started operations. The active operation is on top,
- // others are suspended and started by the active is finished
+ private:
+ typedef QList<ModuleBase_Operation*> Operations; ///< definition for a list of operations
+ Operations myOperations; ///< a stack of started operations. The active operation is on top,
+ // others are suspended and started by the active is finished
};
#endif
#include <QIcon>
#include <QBrush>
-
//ObjectPtr featureObj(const ObjectPtr& theFeature)
//{
// ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(theFeature);
// 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();
}
int XGUI_TopDataModel::rowCount(const QModelIndex& theParent) const
{
- if (!theParent.isValid())
+ if (!theParent.isValid())
return 3;
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
{
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)
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();
}
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());
}
return ObjectPtr();
}
-
QModelIndex XGUI_TopDataModel::findParent(const ObjectPtr& theObject) const
{
return findGroup(theObject->groupName().c_str());
return aIndex;
}
-
-
//******************************************************************
//******************************************************************
//******************************************************************
XGUI_PartDataModel::XGUI_PartDataModel(QObject* theParent)
- : XGUI_PartModel(theParent)
+ : XGUI_PartModel(theParent)
{
}
-
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<ModelAPI_Object>(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<ModelAPI_Object>(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<ModelAPI_Object>(aObject)->data()->name().c_str();
+ }
+ case ConstructObject: {
+ ObjectPtr aObject = partDocument()->object(ModelAPI_ResultConstruction::group(),
+ theIndex.row());
+ if (aObject)
+ return boost::dynamic_pointer_cast<ModelAPI_Object>(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<ModelAPI_Object>(aObject)->data()->name().c_str();
- }
- case ConstructObject:
- {
- ObjectPtr aObject = partDocument()->object(ModelAPI_ResultConstruction::group(), theIndex.row());
- if (aObject)
- return boost::dynamic_pointer_cast<ModelAPI_Object>(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<ModelAPI_Feature>(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<ModelAPI_Feature>(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();
}
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;
}
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();
}
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();
}
return rowCount(theParent) > 0;
}
-
DocumentPtr XGUI_PartDataModel::partDocument() const
{
DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument();
ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(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();
}
return (partDocument() == theDoc);
}
-
QModelIndex XGUI_PartDataModel::findParent(const ObjectPtr& theObject) const
{
return findGroup(theObject->groupName().c_str());
{
QModelIndex aIndex;
if (theObject) {
- if (part() == theObject)
+ if (part() == theObject)
return aIndex;
std::string aGroup = theObject->groupName();
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);
}
-
#ifndef XGUI_PartDataModel_H
#define XGUI_PartDataModel_H
*/
class XGUI_EXPORT XGUI_TopDataModel : public XGUI_FeaturesModel
{
- Q_OBJECT
-public:
+Q_OBJECT
+ public:
XGUI_TopDataModel(QObject* theParent);
virtual ~XGUI_TopDataModel();
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;
//! 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,
};
-
/**\class XGUI_PartDataModel
* \ingroup GUI
* \brief This is a data model for Object Browser (QTreeView).
*/
class XGUI_PartDataModel : public XGUI_PartModel
{
- Q_OBJECT
-public:
+Q_OBJECT
+ public:
XGUI_PartDataModel(QObject* theParent);
virtual ~XGUI_PartDataModel();
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;
//! 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,
};
-#endif
\ No newline at end of file
+#endif
#include <QApplication>
#include <QDialogButtonBox>
-
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) {
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();
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<QVariant> 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)
{
std::list<std::string>::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) {
}
// 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();
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);
}
}
typedef QPair<QString, QString> XGUI_Pref;
typedef QList<XGUI_Pref> 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;
static void loadCustomProps();
-private:
+ private:
static SUIT_ResourceMgr* myResourceMgr;
};
/// 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
#include <iostream>
#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();
void XGUI_PropertyPanel::cleanContent()
{
- myWidgets.clear();
+ myWidgets.clear();
qDeleteAll(myCustomWidget->children());
}
myWidgets = theWidgets;
if (!theWidgets.empty()) {
- QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end();
+ QList<ModuleBase_ModelWidget*>::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<ModuleBase_WidgetPoint2D*>(*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) {
QPushButton* aCancelBtn = findChild<QPushButton*>(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);
void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
{
- foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
+ foreach(ModuleBase_ModelWidget* eachWidget, myWidgets)
+ {
eachWidget->setFeature(theFeature);
eachWidget->restoreValue();
}
void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget)
{
ModuleBase_ModelWidget* aNextWidget = 0;
- QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(),
- aLast = myWidgets.end();
+ QList<ModuleBase_ModelWidget*>::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;
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();
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
/// \param the attribute of the feature
void storedPoint2D(ObjectPtr theFeature, const std::string& theAttribute);
-private:
+ private:
QWidget* myCustomWidget;
QList<ModuleBase_ModelWidget*> myWidgets;
*/\r
\r
XGUI_AbstractRubberBand::XGUI_AbstractRubberBand(QWidget* theParent)\r
- : QWidget(theParent), myPoints(), myIsClosed(false)\r
+ : QWidget(theParent),\r
+ myPoints(),\r
+ myIsClosed(false)\r
{\r
setAttribute(Qt::WA_TransparentForMouseEvents);\r
#ifndef WIN32\r
setAttribute(Qt::WA_NoSystemBackground);\r
-#endif //WIN32\r setAttribute(Qt::WA_WState_ExplicitShowHide);\r setVisible(false);\r theParent->installEventFilter(this);\r
- setGeometry(QRect(QPoint(0, 0), theParent->size()));\r
+#endif //WIN32\r setAttribute(Qt::WA_WState_ExplicitShowHide);\r setVisible(false);\r theParent->installEventFilter(this);\r setGeometry(QRect(QPoint(0, 0), theParent->size()));\r
}\r
\r
/*!\r
if (p1 == p2)\r
return QRegion();\r
\r
- QLineF n = QLineF(p1, p2).normalVector(); //.unitVector();\r
+ QLineF n = QLineF(p1, p2).normalVector(); //.unitVector();\r
n.setLength(1);\r
n.translate(p1 * -1);\r
QPointF nPoint = n.p2();\r
QRegion r;\r
\r
QVectorIterator<QPoint> it(myPoints);\r
- while(it.hasNext()) {\r
+ while (it.hasNext()) {\r
QPoint p = it.next();\r
if (!it.hasNext())\r
break;\r
{\r
myPoints.clear();\r
myPoints << theRect.topLeft() << theRect.topRight() << theRect.bottomRight()\r
- << theRect.bottomLeft();\r
+ << theRect.bottomLeft();\r
//setMask( QRegion( myPoints ) );\r
updateMask();\r
}\r
void XGUI_RectRubberBand::clearGeometry()\r
{\r
QMutableVectorIterator<QPoint> i(myPoints);\r
- while(i.hasNext()) {\r
+ while (i.hasNext()) {\r
i.next();\r
i.setValue(QPoint(-1, -1));\r
}\r
#include <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
+ \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*);
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();
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();
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
//! \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
//! \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;
virtual XGUI_SalomeViewer* viewer() const = 0;
};
-#endif
\ No newline at end of file
+#endif
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;
void contextMenuRequested(QContextMenuEvent*);
};
-#endif
\ No newline at end of file
+#endif
#include <set>
-
XGUI_Selection::XGUI_Selection(XGUI_Workshop* theWorkshop)
-: myWorkshop(theWorkshop)
+ : myWorkshop(theWorkshop)
{
}
{
return myWorkshop->objectBrowser()->selectedObjects();
}
-
+
QList<ObjectPtr> XGUI_Selection::selectedPresentations() const
{
QList<ObjectPtr> aSelectedList;
return aSelectedList;
}
-
//**************************************************************
-QModelIndexList XGUI_Selection::selectedIndexes() const
-{
+QModelIndexList XGUI_Selection::selectedIndexes() const
+{
return myWorkshop->objectBrowser()->selectedIndexes();
}
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
virtual std::list<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const;
/**
- * Returns list of currently selected objects
- */
+ * Returns list of currently selected objects
+ */
virtual QList<ObjectPtr> selectedObjects() const;
/**
- * Returns list of currently selected results
- */
+ * Returns list of currently selected results
+ */
virtual QList<ObjectPtr> selectedPresentations() const;
-
+
//! Returns list of currently selected QModelIndexes
virtual QModelIndexList selectedIndexes() const;
//! Returns list of currently selected shapes
virtual void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
-private:
+ private:
XGUI_Workshop* myWorkshop;
};
-#endif
\ No newline at end of file
+#endif
#include <ModelAPI_Result.h>
#include <ModelAPI_Object.h>
-
-
-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);
}
//**************************************************************
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()));
}
//**************************************************************
//**************************************************************
/*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<TopoDS_Shape>& 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<TopoDS_Shape>& 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);
+ }
+ }*/
*/
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();
//! 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;
};
#include <iostream>
#include <sstream>
-namespace XGUI_Tools
-{
+namespace XGUI_Tools {
//******************************************************************
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)
//******************************************************************
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();
//******************************************************************
/*FeaturePtr realFeature(const FeaturePtr theFeature)
-{
- if (theFeature->data()) {
- return theFeature;
- } else {
- ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(theFeature);
- return aObject->featureRef();
- }
-}*/
-
+ {
+ if (theFeature->data()) {
+ return theFeature;
+ } else {
+ ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(theFeature);
+ return aObject->featureRef();
+ }
+ }*/
}
\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
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);
}
\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);
}
*/
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);
}
\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);
}
*/
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);
const QGradient* gradient() const;
void setGradient(const QGradient&);
-private:
+ private:
XGUI::BackgroundMode myMode;
XGUI::TextureMode myTextureMode;
QString myFileName;
-
#include "XGUI_ViewPort.h"
#include "XGUI_ViewWindow.h"
#include "XGUI_Viewer.h"
static int sy = 0;
static Standard_Boolean zRotation = Standard_False;
-
/*!
Create native view window for CasCade view [ static ]
*/
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),
if (!mapped(theView)) {
theView->SetWindow(myWindow);
//if (theView != activeView())
- //theView->View()->Deactivate();
+ //theView->View()->Deactivate();
}
/* create static trihedron (16551: EDF PAL 501) */
// 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.
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();
}
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();
}
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();
}
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);
}
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();
void setBackground(const Qtx::BackgroundData& bgData);
- void syncronizeWith( const XGUI_ViewPort* ref );
+ void syncronizeWith(const XGUI_ViewPort* ref);
signals:
void vpChangeBackground(const Qtx::BackgroundData&);
void vpUpdated();
void resized();
-protected:
+ protected:
virtual void paintEvent(QPaintEvent*);
virtual void resizeEvent(QResizeEvent*);
-private:
+ private:
Handle(V3d_View) activeView() const
{
return myActiveView;
"................................", "................................",
"................................", "................................" };
-
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()));
}
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);
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()));
}
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);
//**************************************************************************
//**************************************************************************
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);
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"));
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;
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);
//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()));
}
//****************************************************************
{
}
-
//****************************************************************
void XGUI_ViewWindow::showEvent(QShowEvent* theEvent)
{
if (isMinimized()) {
if (myPicture->isHidden()) {
myViewBar->hide();
- myGripWgt->hide();
+ myGripWgt->hide();
myWindowBar->hide();
myViewPort->hide();
myPicture->show();
QWidget::changeEvent(theEvent);
}
-
-
//****************************************************************
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;
}
}
myViewBar->hide();
myWindowBar->hide();
- myGripWgt->hide();
+ myGripWgt->hide();
}
}
-
//****************************************************************
void XGUI_ViewWindow::onClose()
{
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());
}
//****************************************************************
}
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()));
}
//****************************************************************
bool XGUI_ViewWindow::processWindowControls(QObject *theObj, QEvent *theEvent)
{
- switch(theEvent->type()) {
- case QEvent::MouseButtonPress: {
- QMouseEvent* aEvent = static_cast<QMouseEvent*>(theEvent);
- if ((aEvent->button() == Qt::LeftButton) && (!myMoving)) {
- myMoving = true;
- myMousePnt = aEvent->globalPos();
- return true;
- }
- }
- break;
- case QEvent::MouseButtonRelease: {
- QMouseEvent* aEvent = static_cast<QMouseEvent*>(theEvent);
- if ((aEvent->button() == Qt::LeftButton) && myMoving) {
- myMoving = false;
- return true;
+ switch (theEvent->type()) {
+ case QEvent::MouseButtonPress: {
+ QMouseEvent* aEvent = static_cast<QMouseEvent*>(theEvent);
+ if ((aEvent->button() == Qt::LeftButton) && (!myMoving)) {
+ myMoving = true;
+ myMousePnt = aEvent->globalPos();
+ return true;
+ }
}
- }
- break;
- case QEvent::MouseMove: {
- QMouseEvent* aEvent = static_cast<QMouseEvent*>(theEvent);
- if (myMoving) {
- QMdiSubWindow* aParent = static_cast<QMdiSubWindow*>(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<QMouseEvent*>(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<QMouseEvent*>(theEvent);
+ if (myMoving) {
+ QMdiSubWindow* aParent = static_cast<QMdiSubWindow*>(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;
}
//****************************************************************
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;
}
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);
//****************************************************************
void XGUI_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent)
{
- switch(myOperation) {
- case NOTHING: {
- int prevState = myCurSketch;
- /* if(theEvent->button() == Qt::RightButton) {
- QList<OCCViewer_ViewSketcher*>::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<OCCViewer_ViewSketcher*>::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
{
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<OCCViewer_ViewSketcher*>::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<OCCViewer_ViewSketcher*>::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);
+ }
}
}
}
/*!
- \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);
}
}
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<XGUI_ViewWindow*>(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()));
{
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();
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();
}
/*!
- \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();
}
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
{
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();
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*);
//! 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();
void windowDeactivated();
-protected:
+ protected:
virtual void changeEvent(QEvent* theEvent);
virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
virtual void contextMenuEvent(QContextMenuEvent* theEvent);
-private slots:
+ private slots:
void onClose();
void onMinimize();
void onMaximize();
void updateToolBar();
// void repaintToolBar();
-private:
+ private:
enum WindowState
{
MinimizedState,
myEventStarted = bOn;
}
-private:
+ private:
XGUI_Viewer* myViewer;
QLabel* myPicture;
gp_Pnt mySelectedPoint;
- XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
+ XGUI_RectRubberBand* myRectBand; //!< selection rectangle rubber band
typedef QMap<OperationType, bool> MapOfTransformStatus;
MapOfTransformStatus myStatus;
//******************************************************
/*!
- \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;
};
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_Shape.hxx>
-
#ifdef WIN32
#include <WNT_Window.hxx>
#else
*/
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
}
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;
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
//myZoomingStyle = 0;
QMdiArea* aMDI = myMainWindow->mdiArea();
- connect(aMDI, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(onWindowActivated(QMdiSubWindow*)));
+ connect(aMDI, SIGNAL(subWindowActivated(QMdiSubWindow*)), this,
+ SLOT(onWindowActivated(QMdiSubWindow*)));
}
//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();
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<XGUI_ViewWindow*>(aWnd->widget());
if (aView)
aView->setBackground(aBk);
}
}
-
XGUI_ViewWindow* XGUI_Viewer::activeViewWindow() const
{
if (myActiveView)
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;
void XGUI_Viewer::onViewClosed(QMdiSubWindow* theView)
{
- if ( !theView )
+ if (!theView)
return;
- emit deleteView( static_cast<XGUI_ViewWindow*>(theView->widget()) );
- removeView( theView );
+ emit deleteView(static_cast<XGUI_ViewWindow*>(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);
}
/*!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<XGUI_ViewWindow*>(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<XGUI_ViewWindow*>(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<XGUI_ViewWindow*>(theView->widget());
+ XGUI_ViewWindow* aWindow = dynamic_cast<XGUI_ViewWindow*>(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<QMdiSubWindow*>::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) {
}
/*!
- 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) {
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)
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);
}
}
}
//******************************************************
-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<XGUI_ViewWindow*>(aWnd->widget());
aView->updateEnabledDrawMode();
}
#include <NCollection_List.hxx>
#include <TopoDS_Shape.hxx>
-
class XGUI_MainWindow;
class QMdiSubWindow;
class XGUI_ViewWindow;
* \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);
/// 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
/// 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)
/// 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
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();
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.*/
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;
bool myIsRelative;
double myTrihedronSize;
-
+
QList<QMdiSubWindow*> myViews;
QMdiSubWindow* myActiveView;
#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()) {
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.);
}
}
{
if (myWorkshop->isSalomeMode()) {
myWorkshop->salomeConnector()->viewer()->fitAll();
- }
- else {
+ } else {
XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
if (aViewer->activeViewWindow())
aViewer->activeViewWindow()->viewPort()->fitAll();
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*)));
}
}
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
/// 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*);
void onKeyPress(XGUI_ViewWindow*, QKeyEvent*);
void onKeyRelease(XGUI_ViewWindow*, QKeyEvent*);
-private:
+ private:
XGUI_Workshop* myWorkshop;
};
#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);
};
XGUI_MenuGroupPanel* aGroup = new XGUI_MenuGroupPanel(myChildWidget);
aGroup->setObjectName(theId);
myLayout->addWidget(aGroup);
- if(theId != "Default") {
+ if (theId != "Default") {
addSeparator();
}
myLayout->addStretch();
QList<XGUI_Command*> XGUI_Workbench::features() const
{
QList<XGUI_Command*> aList;
- foreach (XGUI_MenuGroupPanel* aGroup, myGroups) {
+ foreach (XGUI_MenuGroupPanel* aGroup, myGroups)
+ {
aList.append(aGroup->features());
}
return aList;
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);
//! Returns list of created commands
QList<XGUI_Command*> 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();
}
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);
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&)));
}
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?
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;
{
//A message to start feature creation received.
if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED)) {
- const Config_FeatureMessage* aFeatureMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
- if(!aFeatureMsg->isInternal()) {
+ const Config_FeatureMessage* aFeatureMsg =
+ dynamic_cast<const Config_FeatureMessage*>(theMessage);
+ if (!aFeatureMsg->isInternal()) {
addFeature(aFeatureMsg);
}
return;
// Process creation of Part
if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
- const ModelAPI_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
+ const ModelAPI_ObjectUpdatedMessage* aUpdMsg =
+ dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
onFeatureCreatedMsg(aUpdMsg);
return;
}
// Redisplay feature
if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
- const ModelAPI_ObjectUpdatedMessage* aUpdMsg = dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
+ const ModelAPI_ObjectUpdatedMessage* aUpdMsg =
+ dynamic_cast<const ModelAPI_ObjectUpdatedMessage*>(theMessage);
onFeatureRedisplayMsg(aUpdMsg);
return;
}
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<const Config_PointerMessage*>(theMessage);
+ const Config_PointerMessage* aPartSetMsg =
+ dynamic_cast<const Config_PointerMessage*>(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());
void XGUI_Workshop::onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg)
{
std::set<ObjectPtr> aFeatures = theMsg->objects();
- if (myOperationMgr->hasOperation())
- {
+ if (myOperationMgr->hasOperation()) {
FeaturePtr aCurrentFeature = myOperationMgr->currentOperation()->feature();
std::set<ObjectPtr>::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();
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);
}
}
}
ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(*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;
}
{
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();
myPropertyPanel->cleanContent();
aFactory.createWidget(myPropertyPanel->contentWidget());
-
+
QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
ModuleBase_ModelWidget* aWidget;
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();
}
}
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);
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);
{
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) {
//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;
//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;
//******************************************************
bool XGUI_Workshop::onSave()
{
- if(myCurrentDir.isEmpty()) {
+ if (myCurrentDir.isEmpty()) {
return onSaveAs();
}
saveDocument(myCurrentDir);
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;
}
}
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();
}
}
//******************************************************
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;
}
if (mainWindow()) {
QMessageBox::warning(mainWindow(), tr("Error"), err);
} else {
- qWarning( qPrintable( err ));
+ qWarning(qPrintable(err));
}
}
return aModule;
void XGUI_Workshop::updateCommandStatus()
{
QList<QAction*> aCommands;
- if (isSalomeMode()) { // update commands in SALOME mode
+ if (isSalomeMode()) { // update commands in SALOME mode
aCommands = salomeConnector()->commandList();
} else {
XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
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);
}
}
QList<QAction*> XGUI_Workshop::getModuleCommands() const
{
QList<QAction*> 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);
}
}
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();
*/
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(); //<! Invisible by default
+ hidePropertyPanel(); //<! Invisible by default
hideObjectBrowser();
aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(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)));
}
return;
}
}
- }
+ }
aMgr->setCurrentDocument(aMgr->rootDocument());
}
emit salomeViewerSelection();
}
-
//**************************************************************
-XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const
-{
- return mySalomeConnector->viewer();
+XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const
+{
+ return mySalomeConnector->viewer();
}
//**************************************************************
if ((theId == "ACTIVATE_PART_CMD") && (aObjects.size() > 0)) {
ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(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);
QList<ModuleBase_ModelWidget*>::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();
}
//**************************************************************
void XGUI_Workshop::deleteObjects(const QList<ObjectPtr>& 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<ModelAPI_ResultPart>(aObj);
if (aPart) {
DocumentPtr aDoc = aPart->document();
//**************************************************************
void XGUI_Workshop::showObjects(const QList<ObjectPtr>& theList, bool isVisible)
{
- foreach (ObjectPtr aObj, theList) {
+ foreach (ObjectPtr aObj, theList)
+ {
ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObj);
if (aRes) {
if (isVisible) {
return;
QList<QAction*> aActions = getModuleCommands();
- foreach(QAction* aAction, aActions) {
+ foreach(QAction* aAction, aActions)
+ {
QString aId = aAction->data().toString();
std::list<ModelAPI_Validator*> aValidators;
aFactory->validators(aId.toStdString(), aValidators);
std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
- for(; aValidator != aValidators.end(); aValidator++) {
+ for (; aValidator != aValidators.end(); aValidator++) {
if (*aValidator) {
- const ModuleBase_SelectionValidator* aSelValidator =
- dynamic_cast<const ModuleBase_SelectionValidator*>(*aValidator);
+ const ModuleBase_SelectionValidator* aSelValidator =
+ dynamic_cast<const ModuleBase_SelectionValidator*>(*aValidator);
if (aSelValidator) {
aAction->setEnabled(aSelValidator->isValid(aSelection));
}
}
}
-
//**************************************************************
void XGUI_Workshop::registerValidators() const
{
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
}
-
//**************************************************************
void XGUI_Workshop::displayAllResults()
{
#include <QIcon>
#include <QKeySequence>
-
class XGUI_MainWindow;
class XGUI_Command;
class XGUI_Workbench;
* \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();
}
//! 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);
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);
//! Show the given features in 3d Viewer
void showObjects(const QList<ObjectPtr>& 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();
void activateLastPart();
-protected:
+ protected:
//Event-loop processing methods:
void addFeature(const Config_FeatureMessage*);
void connectWithOperation(ModuleBase_Operation* theOperation);
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();
void onStartWaiting();
-private:
+ private:
void initMenu();
void registerValidators() const;
-
ModuleBase_IModule* loadModule(const QString& theModule);
bool activateModule();
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;