+}
+
+//******************************************************
+int XGUI_DataModel::folderId(std::string theType, ModelAPI_Document* theDoc)
+{
+ SessionPtr aSession = ModelAPI_Session::get();
+ ModelAPI_Document* aDoc = theDoc;
+ if (aDoc == 0)
+ aDoc = aSession->moduleDocument().get();
+
+ bool aUseSubDoc = (aDoc != aSession->moduleDocument().get());
+
+ int aRes = -1;
+ if (aUseSubDoc) {
+ int aId = myXMLReader.subFolderId(theType);
+ aRes = aId;
+ for (int i = 0; i < aId; i++) {
+ if (!myXMLReader.subShowEmpty(i)) {
+ if (aDoc->size(myXMLReader.subFolderType(i)) == 0)
+ aRes--;
+ }
+ }
+ } else {
+ int aId = myXMLReader.rootFolderId(theType);
+ aRes = aId;
+ for (int i = 0; i < aId; i++) {
+ if (!myXMLReader.rootShowEmpty(i)) {
+ if (aDoc->size(myXMLReader.rootFolderType(i)) == 0)
+ aRes--;
+ }
+ }
+ }
+ return aRes;
+}