myGroupId = "";
myWorkbenchId = "";
+ myPluginLibrary = "";
+
+ myInternal = false;
+ myUseInput = false;
+ myNestedFeatures = "";
}
const std::string& Config_FeatureMessage::icon() const
return myUseInput;
}
+bool Config_FeatureMessage::isInternal() const
+{
+ return myInternal;
+}
+
void Config_FeatureMessage::setUseInput(bool isUseInput)
{
myUseInput = isUseInput;
}
+void Config_FeatureMessage::setInternal(bool isInternal)
+{
+ myInternal = isInternal;
+}
+
const std::string& Config_FeatureMessage::nestedFeatures() const
{
return myNestedFeatures;
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
std::string myNestedFeatures;\r
\r
public:\r
CONFIG_EXPORT const std::string& pluginLibrary() const;\r
CONFIG_EXPORT const std::string& nestedFeatures() const;\r
CONFIG_EXPORT bool isUseInput() const;\r
+ CONFIG_EXPORT bool isInternal() const;\r
\r
CONFIG_EXPORT void setIcon(const std::string& icon);\r
CONFIG_EXPORT void setId(const std::string& id);\r
CONFIG_EXPORT void setPluginLibrary(const std::string& thePluginLibrary);\r
CONFIG_EXPORT void setNestedFeatures(const std::string& theNestedFeatures);\r
CONFIG_EXPORT void setUseInput(bool isUseInput);\r
+ CONFIG_EXPORT void setInternal(bool isInternal);\r
};\r
\r
#endif // CONFIG_MESSAGE_H\r
#include <libxml/xmlstring.h>
#include <string>
+#include <algorithm>
#ifdef _DEBUG
#include <iostream>
void Config_FeatureReader::fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFtMessage)
{
outFtMessage.setId(getProperty(theRoot, _ID));
+ outFtMessage.setPluginLibrary(myLibraryName);
+ outFtMessage.setNestedFeatures(getProperty(theRoot, FEATURE_NESTED));
+ bool isFtInternal = isInternalFeature(theRoot);
+ outFtMessage.setInternal(isFtInternal);
+ if(isFtInternal) {
+ //Internal feature has no visual representation.
+ return;
+ }
outFtMessage.setText(getProperty(theRoot, FEATURE_TEXT));
outFtMessage.setTooltip(getProperty(theRoot, FEATURE_TOOLTIP));
outFtMessage.setIcon(getProperty(theRoot, FEATURE_ICON));
outFtMessage.setKeysequence(getProperty(theRoot, FEATURE_KEYSEQUENCE));
outFtMessage.setGroupId(myLastGroup);
outFtMessage.setWorkbenchId(myLastWorkbench);
- outFtMessage.setPluginLibrary(myLibraryName);
- outFtMessage.setNestedFeatures(getProperty(theRoot, FEATURE_NESTED));
+}
+
+bool Config_FeatureReader::isInternalFeature(xmlNodePtr theRoot)
+{
+ std::string prop = getProperty(theRoot, FEATURE_INTERNAL);
+ std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower);
+ if(prop.empty() || prop == "false" || prop == "0") {
+ return false;
+ }
+ return true;
}
bool processChildren(xmlNodePtr aNode);
void fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFeatureMessage);
+ bool isInternalFeature(xmlNodePtr theRoot);
private:
std::string myLastWorkbench;
const static char* FEATURE_ICON = "icon";
const static char* FEATURE_KEYSEQUENCE = "keysequence";
const static char* FEATURE_NESTED = "nested";
+const static char* FEATURE_INTERNAL = "internal";
const static char* SOURCE_FILE = "path";
void Config_ModuleReader::loadLibrary(const std::string theLibName)
{
-#ifdef _DEBUG
- std::cout << "Config_ModuleReader::loading library... " << theLibName.c_str() << std::endl;
-#endif
std::string aFileName = library(theLibName);
if (aFileName.empty())
return;
<feature id="Point" text="Point" tooltip="Create a new point" icon=":icons/point.png">
<source path="point_widget.xml"/>
</feature>
- <feature id="Axis" text="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence=""/>
- <feature id="Plane" text="Plane" tooltip="Create a new plane" icon=":icons/plane.png" keysequence=""/>
+ <feature id="Axis" text="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence="" internal="true"/>
+ <feature id="Plane" text="Plane" tooltip="Create a new plane" icon=":icons/plane.png" keysequence="" internal="true"/>
</group>
</workbench>
</plugin>
boost::shared_ptr<ModelAPI_PluginManager> ModelAPI_PluginManager::get()
{
if (!MY_MANAGER) { // import Model library that implements this interface of ModelAPI
- #ifdef _DEBUG
- std::cout << "ModelAPI_PluginManager::get: " << "Model library has not been loaded from xml." << std::endl;
- #endif
Config_ModuleReader::loadLibrary("Model");
}
return MY_MANAGER;
<label text="Select a plane on which to create a sketch" tooltip="Select a plane on which to create a sketch"/>
<!--icon=":pictures/x_point.png"-->
</feature>
- <feature id="SketchPoint" text="Point" tooltip="Create a new point" icon=":icons/point.png" />
+ <feature id="SketchPoint" text="Point" tooltip="Create a new point" icon=":icons/point.png"/>
<feature id="SketchLine" text="Line" tooltip="Create a new line" icon=":icons/line.png">
<point_selector id="StartPoint" title="Start point" tooltip="Start point of the line"/>
<point_selector id="EndPoint" title="End point" tooltip="End point of the line"/>
</feature>
- <feature id="SketchConstraintCoincidence" text="Points coincidence" tooltip="Create constraint for the coincidence of two points" icon="" />
+ <feature id="SketchConstraintCoincidence" text="Points coincidence" tooltip="Create constraint for the coincidence of two points" internal="1"/>
</group>
</workbench>
</plugin>
XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
: QObject(),
- myCurrentFile(QString()),
+ myCurrentDir(QString()),
myPartSetModule(NULL),
mySalomeConnector(theConnector),
myPropertyPanel(0),
static Events_ID aFeatureLoadedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED);
if (theMessage->eventID() == aFeatureLoadedId) {
const Config_FeatureMessage* aFeatureMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
- addFeature(aFeatureMsg);
+ if(!aFeatureMsg->isInternal()) {
+ addFeature(aFeatureMsg);
+ }
return;
}
// Process creation of Part
return;
}
aDoc->close();
- myCurrentFile = "";
+ myCurrentDir = "";
}
//show file dialog, check if readable and open
- myCurrentFile = QFileDialog::getExistingDirectory(mainWindow());
- if(myCurrentFile.isEmpty())
+ myCurrentDir = QFileDialog::getExistingDirectory(mainWindow());
+ if(myCurrentDir.isEmpty())
return;
- QFileInfo aFileInfo(myCurrentFile);
+ QFileInfo aFileInfo(myCurrentDir);
if(!aFileInfo.exists() || !aFileInfo.isReadable()) {
QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to open the file."));
- myCurrentFile = "";
+ myCurrentDir = "";
return;
}
QApplication::setOverrideCursor(Qt::WaitCursor);
- aDoc->load(myCurrentFile.toLatin1().constData());
+ aDoc->load(myCurrentDir.toLatin1().constData());
QApplication::restoreOverrideCursor();
updateCommandStatus();
}
//******************************************************
void XGUI_Workshop::onSave()
{
- if(myCurrentFile.isEmpty()) {
+ if(myCurrentDir.isEmpty()) {
onSaveAs();
return;
}
- saveDocument(myCurrentFile);
+ saveDocument(myCurrentDir);
updateCommandStatus();
}
//******************************************************
void XGUI_Workshop::onSaveAs()
{
- QString aTemp = myCurrentFile;
- myCurrentFile = QFileDialog::getSaveFileName(mainWindow());
- if(myCurrentFile.isEmpty()) {
- myCurrentFile = aTemp;
+ QFileDialog dialog(mainWindow());
+ dialog.setWindowTitle(tr("Select directory to save files..."));
+ dialog.setFileMode(QFileDialog::Directory);
+ dialog.setFilter(tr("Folders (*)"));
+ dialog.setOptions(QFileDialog::HideNameFilterDetails | QFileDialog::ShowDirsOnly);
+ dialog.setViewMode(QFileDialog::Detail);
+
+ if(!dialog.exec()) {
return;
}
- QFileInfo aFileInfo(myCurrentFile);
- if(aFileInfo.exists() && !aFileInfo.isWritable()) {
- QMessageBox::critical(myMainWindow, tr("Warning"), tr("Unable to save the file."));
- return;
+ QString aTempDir = dialog.selectedFiles().first();
+ QDir aDir(aTempDir);
+ if(aDir.exists() && !aDir.entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries).isEmpty()) {
+ int answer = QMessageBox::question(myMainWindow,
+ QString(),
+ tr("The folder already contains some files, save anyway?"),
+ QMessageBox::Save|QMessageBox::Cancel);
+ if(answer == QMessageBox::Cancel)
+ return;
}
+ myCurrentDir = aTempDir;
onSave();
}
// Creates Dock widgets: Object browser and Property panel
void createDockWidgets();
- QString myCurrentFile;
XGUI_MainWindow* myMainWindow;
XGUI_Module* myPartSetModule;
XGUI_ObjectsBrowser* myObjectBrowser;
XGUI_ViewerProxy* myViewerProxy;
XGUI_ContextMenuMgr* myContextMenuMgr;
+ QString myCurrentDir;
static QMap<QString, QString> myIcons;
};