#include "XGUI_DocumentDataModel.h"
#include "XGUI_PartDataModel.h"
+#include "XGUI_Workshop.h"
#include <ModelAPI_PluginManager.h>
#include <ModelAPI_Document.h>
#include <Events_Loop.h>
+#include <Config_FeatureMessage.h>
#include <QIcon>
#include <QString>
void XGUI_DocumentDataModel::processEvent(const Events_Message* theMessage)
{
// Created object event *******************
- if (QString(theMessage->eventID().eventText()) == EVENT_FEATURE_CREATED) {
+ if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_CREATED)) {
const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
boost::shared_ptr<ModelAPI_Feature> aFeature = aUpdMsg->feature();
boost::shared_ptr<ModelAPI_Document> aDoc = aFeature->document();
}
// Deleted object event ***********************
- } else if (QString(theMessage->eventID().eventText()) == EVENT_FEATURE_DELETED) {
+ } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED)) {
const Model_FeatureDeletedMessage* aUpdMsg = dynamic_cast<const Model_FeatureDeletedMessage*>(theMessage);
boost::shared_ptr<ModelAPI_Document> aDoc = aUpdMsg->document();
}
// Deleted object event ***********************
- } else if (QString(theMessage->eventID().eventText()) == EVENT_FEATURE_UPDATED) {
- const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
- boost::shared_ptr<ModelAPI_Feature> aFeature = aUpdMsg->feature();
- boost::shared_ptr<ModelAPI_Document> aDoc = aFeature->document();
+ } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED)) {
+ //const Model_FeatureUpdatedMessage* aUpdMsg = dynamic_cast<const Model_FeatureUpdatedMessage*>(theMessage);
+ //boost::shared_ptr<ModelAPI_Feature> aFeature = aUpdMsg->feature();
+ //boost::shared_ptr<ModelAPI_Document> aDoc = aFeature->document();
+ // TODO: Identify the necessary index by the modified feature
QModelIndex aIndex;
emit dataChanged(aIndex, aIndex);
else
return QVariant();
case Qt::DecorationRole:
- {
- std::string aType = aFeature->getKind();
- if (aType.compare("Point") == 0)
- return QIcon(":pictures/point_ico.png");
- if (aType.compare("Part") == 0)
- return QIcon(":pictures/part_ico.png");
- if (aType.compare("Sketch") == 0)
- return QIcon(":icons/sketch.png");
- }
+ return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
case Qt::ToolTipRole:
return tr("Feature object");
default:
//! List of saved QModelIndexes created by sub-models
QList<QModelIndex*> myIndexes;
+
};
#endif
\ No newline at end of file
#include "XGUI_PartDataModel.h"
+#include "XGUI_Workshop.h"
#include <ModelAPI_PluginManager.h>
#include <ModelAPI_Document.h>
// return an Icon
switch (theIndex.internalId()) {
case ParamsFolder:
- return QIcon(":pictures/params_folder.png");
+ return QIcon(":pictures/params_folder.png");
case ConstructFolder:
- return QIcon(":pictures/constr_folder.png");
+ return QIcon(":pictures/constr_folder.png");
case ConstructObject:
- return QIcon(":pictures/point_ico.png");
+ {
+ FeaturePtr aFeature = myDocument->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ if (aFeature)
+ return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
+ }
}
break;
if (aFeature)
return aFeature->data()->getName().c_str();
}
+ case HistoryObject:
+ {
+ boost::shared_ptr<ModelAPI_Feature> aFeature =
+ featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
+ if (aFeature)
+ return aFeature->data()->getName().c_str();
+ }
}
break;
case Qt::DecorationRole:
case BodiesFolder:
return QIcon(":pictures/constr_folder.png");
case ConstructObject:
- return QIcon(":pictures/point_ico.png");
+ {
+ FeaturePtr aFeature = featureDocument()->feature(CONSTRUCTIONS_GROUP, theIndex.row());
+ if (aFeature)
+ return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
+ }
+ case HistoryObject:
+ {
+ boost::shared_ptr<ModelAPI_Feature> aFeature =
+ featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
+ if (aFeature)
+ return QIcon(XGUI_Workshop::featureIcon(aFeature->getKind()));
+ }
}
break;
case Qt::ToolTipRole:
return 0;
switch (parent.internalId()) {
case MyRoot:
- return 3;
+ return 3 + featureDocument()->size(FEATURES_GROUP);
case ParamsFolder:
return featureDocument()->size(PARAMETERS_GROUP);
case ConstructFolder:
case 1:
return createIndex(1, 0, (qint32) ConstructFolder);
case 2:
- return createIndex(1, 0, (qint32) BodiesFolder);
+ return createIndex(2, 0, (qint32) BodiesFolder);
+ default:
+ return createIndex(theRow, theColumn, (qint32) HistoryObject);
}
case ParamsFolder:
return createIndex(theRow, 0, (qint32) ParamObject);
case ParamsFolder:
case ConstructFolder:
case BodiesFolder:
+ case HistoryObject:
return createIndex(0, 0, (qint32) MyRoot);
case ParamObject:
return createIndex(0, 0, (qint32) ParamsFolder);
{
switch (theIndex.internalId()) {
case MyRoot:
- return myDocument->feature(PARTS_GROUP, myId);
+ if (theIndex.row() < 3)
+ return myDocument->feature(PARTS_GROUP, myId);
+ else
+ return featureDocument()->feature(FEATURES_GROUP, theIndex.row() - 3);
case ParamsFolder:
case ConstructFolder:
return FeaturePtr();
ConstructFolder,
ConstructObject,
BodiesFolder,
- BodieswObject
+ BodieswObject,
+ HistoryObject
};
};
#include <dlfcn.h>
#endif
+
+QMap<QString, QString> XGUI_Workshop::myIcons;
+
+QString XGUI_Workshop::featureIcon(const std::string& theId)
+{
+ QString aId(theId.c_str());
+ if (myIcons.contains(aId))
+ return myIcons[aId];
+ return QString();
+}
+
XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
: QObject(),
myCurrentFile(QString()),
#endif
return;
}
+ // Remember features icons
+ myIcons[QString(theMessage->id().c_str())] = QString(theMessage->icon().c_str());
+
//Find or create Workbench
QString aWchName = QString::fromStdString(theMessage->workbenchId());
QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
XGUI_ViewerProxy* viewer() const { return myViewerProxy; }
+ //! Returns icon name according to feature Id
+ static QString featureIcon(const std::string& theId);
+
+
signals:
void salomeViewerSelection();
XGUI_SalomeConnector* mySalomeConnector;
XGUI_ErrorDialog* myErrorDlg;
XGUI_ViewerProxy* myViewerProxy;
+
+ static QMap<QString, QString> myIcons;
+
};
#endif