#include <ModelAPI_Tools.h>
#include <ModelAPI_Session.h>
#include <ModelAPI_Events.h>
+#include <ModelAPI_Folder.h>
#include <ModelGeomAlgo_Point2D.h>
}
void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature,
- bool& hasParameter, bool& hasCompositeOwner, bool& hasResultInHistory)
+ bool& hasParameter, bool& hasCompositeOwner, bool& hasResultInHistory,
+ bool& hasFolder)
{
hasResult = false;
hasFeature = false;
hasParameter = false;
hasCompositeOwner = false;
hasResultInHistory = false;
+ hasFolder = false;
foreach(ObjectPtr aObj, theObjects) {
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ FolderPtr aFolder = std::dynamic_pointer_cast<ModelAPI_Folder>(aObj);
ResultParameterPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aResult);
hasResult |= (aResult.get() != NULL);
hasFeature |= (aFeature.get() != NULL);
+ hasFolder |= (aFolder.get() != NULL);
hasParameter |= (aConstruction.get() != NULL);
if (hasFeature)
hasCompositeOwner |= (ModelAPI_Tools::compositeOwner(aFeature) != NULL);
hasResultInHistory = aFeature.get() && aFeature->isInHistory();
}
- if (hasFeature && hasResult && hasParameter && hasCompositeOwner)
+ if (hasFeature && hasResult && hasParameter && hasCompositeOwner && hasFeature)
break;
}
}
/// \param hasParameter will be set to true if list contains Parameter objects
/// \param hasCompositeOwner will be set to true if list contains Sub-Feature objects
/// \param hasResultInHistory will be set to true if one of result is in history
+/// \param hasFolder will be set to true if one of folder is in the list
MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult,
bool& hasFeature, bool& hasParameter, bool& hasCompositeOwner,
- bool& hasResultInHistory);
+ bool& hasResultInHistory, bool& hasFolder);
/// Sets the default coeffient into the driver calculated accordingly the shape type.
/// It provides 1.e-4 for results of construction type
bool hasParameter = false;
bool hasCompositeOwner = false;
bool hasResultInHistory = false;
+ bool hasFolder = false;
ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter,
- hasCompositeOwner, hasResultInHistory);
+ hasCompositeOwner, hasResultInHistory, hasFolder);
ModuleBase_Operation* aCurrentOp = myWorkshop->currentOperation();
if (aSelected == 1) {
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultField.h>
+#include "ModelAPI_Folder.h"
#include <Config_DataModelReader.h>
XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent)
: QObject(theParent),
myWorkshop(theParent),
- mySeparator(0)
+ mySeparator1(0), mySeparator2(0)
{
}
aDesktop);
addAction("WIREFRAME_CMD", aAction);
- mySeparator = ModuleBase_Tools::createAction(QIcon(), "", aDesktop);
- mySeparator->setSeparator(true);
+ mySeparator1 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop);
+ mySeparator1->setSeparator(true);
+
+ mySeparator2 = ModuleBase_Tools::createAction(QIcon(), "", aDesktop);
+ mySeparator2->setSeparator(true);
//mySelectActions = new QActionGroup(this);
//mySelectActions->setExclusive(true);
addAction("TINSPECTOR_VIEW", aAction);
#endif
+ // Features folders actions
+ aAction = ModuleBase_Tools::createAction(QIcon(),
+ tr("Insert a folder before"), aDesktop);
+ addAction("INSERT_FOLDER_CMD", aAction);
+
+
buildObjBrowserMenu();
buildViewerMenu();
}
bool hasParameter = false;
bool hasCompositeOwner = false;
bool hasResultInHistory = false;
+ bool hasFolder = false;
ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter,
- hasCompositeOwner, hasResultInHistory);
+ hasCompositeOwner, hasResultInHistory, hasFolder);
//Process Feature
if (aSelected == 1) {
ObjectPtr aObject = aObjects.first();
action("CLEAN_HISTORY_CMD")->setEnabled(true);
action("SHOW_RESULTS_CMD")->setEnabled(hasFeature);
+ action("INSERT_FOLDER_CMD")->setEnabled(hasFeature);
action("SHOW_FEATURE_CMD")->setEnabled(hasResult && hasResultInHistory);
}
aList.append(action("SHOW_CMD"));
aList.append(action("HIDE_CMD"));
aList.append(action("SHOW_ONLY_CMD"));
- aList.append(mySeparator);
+ aList.append(mySeparator1);
aList.append(action("RENAME_CMD"));
aList.append(action("COLOR_CMD"));
aList.append(action("DEFLECTION_CMD"));
aList.clear();
aList.append(action("WIREFRAME_CMD"));
aList.append(action("SHADING_CMD"));
- aList.append(mySeparator); // this separator is not shown as this action is added after show only
+ aList.append(mySeparator1); // this separator is not shown as this action is added after show only
// qt list container contains only one instance of the same action
aList.append(action("SHOW_CMD"));
aList.append(action("HIDE_CMD"));
aList.append(action("SHOW_ONLY_CMD"));
- aList.append(mySeparator);
+ aList.append(mySeparator2);
aList.append(action("RENAME_CMD"));
aList.append(action("COLOR_CMD"));
aList.append(action("DEFLECTION_CMD"));
aList.append(action("RENAME_CMD"));
aList.append(action("SHOW_RESULTS_CMD"));
aList.append(action("MOVE_CMD"));
- aList.append(mySeparator);
+ aList.append(mySeparator1);
+ aList.append(action("INSERT_FOLDER_CMD"));
+ aList.append(mySeparator2);
aList.append(action("CLEAN_HISTORY_CMD"));
aList.append(action("DELETE_CMD"));
myObjBrowserMenus[ModelAPI_Feature::group()] = aList;
aList.clear();
aList.append(action("RENAME_CMD"));
- aList.append(mySeparator);
+ aList.append(mySeparator1);
aList.append(action("CLEAN_HISTORY_CMD"));
aList.append(action("DELETE_CMD"));
myObjBrowserMenus[ModelAPI_ResultParameter::group()] = aList;
//-------------------------------------
+
+ aList.clear();
+ aList.append(action("DELETE_CMD"));
+ myObjBrowserMenus[ModelAPI_Folder::group()] = aList;
+
}
void XGUI_ContextMenuMgr::buildViewerMenu()
// Result construction menu
aList.append(action("HIDE_CMD"));
aList.append(action("SHOW_ONLY_CMD"));
- aList.append(mySeparator);
+ aList.append(mySeparator1);
aList.append(action("COLOR_CMD"));
aList.append(action("DEFLECTION_CMD"));
#ifdef USE_TRANSPARENCY
aList.clear();
aList.append(action("WIREFRAME_CMD"));
aList.append(action("SHADING_CMD"));
- aList.append(mySeparator);
+ aList.append(mySeparator1);
aList.append(action("HIDE_CMD"));
aList.append(action("SHOW_ONLY_CMD"));
- aList.append(mySeparator);
+ aList.append(mySeparator2);
aList.append(action("COLOR_CMD"));
aList.append(action("DEFLECTION_CMD"));
#ifdef USE_TRANSPARENCY
} else if (aSelected > 1) {
aActions.append(action("WIREFRAME_CMD"));
aActions.append(action("SHADING_CMD"));
- aActions.append(mySeparator);
+ aActions.append(mySeparator1);
aActions.append(action("SHOW_CMD"));
aActions.append(action("HIDE_CMD"));
aActions.append(action("SHOW_ONLY_CMD"));
- aActions.append(mySeparator);
+ aActions.append(mySeparator2);
//aActions.append(action("MOVE_CMD"));
aActions.append(action("COLOR_CMD"));
aActions.append(action("DEFLECTION_CMD"));
//QActionGroup* mySelectActions;
- QAction* mySeparator;
+ QAction* mySeparator1;
+ QAction* mySeparator2;
};
#endif
#include <ModelAPI_ResultCompSolid.h>
#include <ModelAPI_ResultField.h>
#include <ModelAPI_Tools.h>
+#include <ModelAPI_Folder.h>
#include <Config_FeatureMessage.h>
#include <Config_DataModelReader.h>
// Insert new object
int aRow = aRootDoc->size(aObjType) - 1;
if (aRow != -1) {
- if (aObjType == aRootType) {
+ if ((aObjType == aRootType) || (aObjType == ModelAPI_Folder::group())) {
insertRow(aRow + aNbFolders + 1);
} else {
int aFolderId = myXMLReader->rootFolderId(aObjType);
}
}
}
- int aRow = aDoc->index(aObject);
+ int aRow = aDoc->index(aObject, true);
if (aRow != -1) {
int aNbSubFolders = foldersCount(aDoc.get());
- if (aObjType == aSubType) {
+ if ((aObjType == aSubType) || (aObjType == ModelAPI_Folder::group())) {
// List of objects under document root
insertRow(aRow + aNbSubFolders, aDocRoot);
} else {
{
std::string aType = theObject->groupName();
DocumentPtr aDoc = theObject->document();
- int aRow = aDoc->index(theObject);
+ int aRow = aDoc->index(theObject, true);
if (aRow == -1) {
// it could be a part of complex object
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
}
SessionPtr aSession = ModelAPI_Session::get();
DocumentPtr aRootDoc = aSession->moduleDocument();
- if (aDoc == aRootDoc && myXMLReader->rootType() == aType) {
+ if (aDoc == aRootDoc &&
+ ((myXMLReader->rootType() == aType) || (aType == ModelAPI_Folder::group()))) {
// The object from root document
aRow += foldersCount();
- } else if (myXMLReader->subType() == aType) {
+ } else if ((myXMLReader->subType() == aType) || (aType == ModelAPI_Folder::group())) {
// The object from sub document
aRow += foldersCount(aDoc.get());
}
}
}
} else {
- ModelAPI_Object* aObj =
- dynamic_cast<ModelAPI_Object*>((ModelAPI_Entity*)theIndex.internalPointer());
+ ObjectPtr aObj = object(theIndex);
if (aObj) {
switch (theRole) {
case Qt::DisplayRole:
{
if (aObj->groupName() == ModelAPI_ResultParameter::group()) {
- ModelAPI_ResultParameter* aParam = dynamic_cast<ModelAPI_ResultParameter*>(aObj);
+ ResultParameterPtr aParam = std::dynamic_pointer_cast<ModelAPI_ResultParameter>(aObj);
AttributeDoublePtr aValueAttribute =
aParam->data()->real(ModelAPI_ResultParameter::VALUE());
QString aVal = QString::number(aValueAttribute->value());
}
QString aSuffix;
if (aObj->groupName() == myXMLReader->subType()) {
- ResultPartPtr aPartRes = getPartResult(aObj);
+ ResultPartPtr aPartRes = getPartResult(aObj.get());
if (aPartRes.get()) {
if (aPartRes->partDoc().get() == NULL)
aSuffix = " (Not loaded)";
return aObj->data()->name().c_str() + aSuffix;
}
case Qt::DecorationRole:
- return ModuleBase_IconFactory::get()->getIcon(object(theIndex));
+ {
+ if (aObj->groupName() == ModelAPI_Folder::group())
+ return QIcon(":pictures/features_folder.png");
+ else
+ return ModuleBase_IconFactory::get()->getIcon(aObj);
+ }
}
} else {
switch (theRole) {
int aNbItems = 0;
std::string aType = myXMLReader->rootType();
if (!aType.empty())
- aNbItems = aRootDoc->size(aType);
+ aNbItems = aRootDoc->size(aType, true);
return aNbFolders + aNbItems;
}
int aNbSubItems = 0;
std::string aSubType = myXMLReader->subType();
if (!aSubType.empty())
- aNbSubItems = aSubDoc->size(aSubType);
+ aNbSubItems = aSubDoc->size(aSubType, true);
return aNbSubItems + aNbSubFolders;
} else {
// Check for composite object
else { // return object under root index
std::string aType = myXMLReader->rootType();
int aObjId = theRow - aNbFolders;
- if (aObjId < aRootDoc->size(aType)) {
- ObjectPtr aObj = aRootDoc->object(aType, aObjId);
+ if (aObjId < aRootDoc->size(aType, true)) {
+ ObjectPtr aObj = aRootDoc->object(aType, aObjId, true);
aIndex = objectIndex(aObj, theColumn);
}
}
if (aId == 0) { // return object index inside of first level of folders
std::string aType = myXMLReader->rootFolderType(aParentPos);
if (theRow < aRootDoc->size(aType)) {
- ObjectPtr aObj = aRootDoc->object(aType, theRow);
+ ObjectPtr aObj = aRootDoc->object(aType, theRow, true);
aIndex = objectIndex(aObj, theColumn);
}
} else {
} else {
// this is an object under sub document root
std::string aType = myXMLReader->subType();
- ObjectPtr aObj = aSubDoc->object(aType, theRow - aNbSubFolders);
+ ObjectPtr aObj = aSubDoc->object(aType, theRow - aNbSubFolders, true);
aIndex = objectIndex(aObj, theColumn);
}
} else {
DocumentPtr aRootDoc = aSession->moduleDocument();
DocumentPtr aSubDoc = aObj->document();
if (aSubDoc == aRootDoc) {
- if (aType == myXMLReader->rootType())
+ if ((aType == myXMLReader->rootType()) || (aType == ModelAPI_Folder::group()))
return QModelIndex();
else {
// return first level of folder index
return createIndex(aFolderId, 1, (void*)Q_NULLPTR);
}
} else {
- if (aType == myXMLReader->subType())
+ if ((aType == myXMLReader->subType()) || (aType == ModelAPI_Folder::group()))
return findDocumentRootIndex(aSubDoc.get());
else {
// return first level of folder index
ObjectPtr aObj;
ResultPartPtr aPartRes;
for (int i = 0; i < aNb; i++) {
- aObj = aRootDoc->object(ModelAPI_Feature::group(), i);
+ aObj = aRootDoc->object(ModelAPI_Feature::group(), i, true);
aPartRes = getPartResult(aObj.get());
if (aPartRes.get() && (aPartRes->partDoc().get() == theDoc)) {
int aRow = i;
setViewerSelectionMode(TopAbs_EDGE);
} else if (theId == "SELECT_FACE_CMD") {
setViewerSelectionMode(TopAbs_FACE);
+ } else if (theId == "INSERT_FOLDER_CMD") {
+ insertFeatureFolder();
} else if (theId == "SELECT_RESULT_CMD") {
//setViewerSelectionMode(-1);
//IMP: an attempt to use result selection with other selection modes
bool hasParameter = false;
bool hasCompositeOwner = false;
bool hasResultInHistory = false;
+ bool hasFolder = false;
ModuleBase_Tools::checkObjects(anObjects, hasResult, hasFeature, hasParameter, hasCompositeOwner,
- hasResultInHistory);
- if (!(hasFeature || hasParameter))
+ hasResultInHistory, hasFolder);
+ if (!(hasFeature || hasParameter || hasFolder))
return;
// delete objects
objectBrowser()->blockSignals(aBlocked);
}
}
+
+void XGUI_Workshop::insertFeatureFolder()
+{
+ QObjectPtrList aObjects = mySelector->selection()->selectedObjects();
+ if (aObjects.isEmpty())
+ return;
+ ObjectPtr aObj = aObjects.first();
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+ if (aFeature.get() == NULL)
+ return;
+ SessionPtr aMgr = ModelAPI_Session::get();
+ DocumentPtr aDoc = aMgr->activeDocument();
+
+ aMgr->startOperation();
+ aDoc->addFolder(aFeature);
+ aMgr->finishOperation();
+
+ //myObjectBrowser->rebuildDataTree();
+}
/// Display results from a group
void displayGroupResults(DocumentPtr theDoc, std::string theGroup);
+ /// Insert folder object before currently selected feature
+ void insertFeatureFolder();
+
private 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.
<file>pictures/eyeopen.png</file>
<file>pictures/transparency.png</file>
+ <file>pictures/features_folder.png</file>
</qresource>
</RCC>