ModuleBase_SelectionValidator.h
ModuleBase_ISelection.h
ModuleBase_ViewerPrs.h
+ ModuleBase_Tools.h
)
SET(PROJECT_SOURCES
ModuleBase_WidgetPoint2dDistance.cpp
ModuleBase_WidgetValue.cpp
ModuleBase_WidgetValueFeature.cpp
+ ModuleBase_Tools.cpp
)
SET(PROJECT_LIBRARIES
/**
* Returns list of features currently selected in 3d viewer
*/
- virtual QFeatureList selectedFeatures() const = 0;
+ virtual QList<ObjectPtr> selectedObjects() const = 0;
+
+ /**
+ * Returns list of currently selected results
+ */
+ virtual QResultList selectedResults() const = 0;
//! Returns list of currently selected QModelIndexes
virtual QModelIndexList selectedIndexes() const = 0;
myAttributeID = theData ? theData->widgetId() : "";
}
-bool ModuleBase_ModelWidget::isInitialized(FeaturePtr theFeature) const
+bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const
{
- return theFeature->data()->attribute(attributeID())->isInitialized();
+ return theObject->data()->attribute(attributeID())->isInitialized();
}
bool ModuleBase_ModelWidget::focusTo()
virtual bool setValue(ModuleBase_WidgetValue* theValue) { return false; };
/// Returns the state whether the attribute of the feature is initialized
- /// \param theFeature a model feature to be checked
+ /// \param theObject a model feature to be checked
/// \return the boolean result
- bool isInitialized(FeaturePtr theFeature) const;
+ bool isInitialized(ObjectPtr theObject) const;
/// Saves the internal parameters to the given feature
- /// \param theFeature a model feature to be changed
- virtual bool storeValue(FeaturePtr theFeature) const = 0;
+ /// \param theObject a model feature to be changed
+ virtual bool storeValue(ObjectPtr theObject) const = 0;
- virtual bool restoreValue(FeaturePtr theFeature) = 0;
+ virtual bool restoreValue(ObjectPtr theObject) = 0;
/// Set focus to the first control of the current widget. The focus policy of the control is checked.
/// If the widget has the NonFocus focus policy, it is skipped.
return myCheckBox;
}
-bool ModuleBase_WidgetBoolValue::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetBoolValue::storeValue(ObjectPtr theObject) const
{
- DataPtr aData = theFeature->data();
+ DataPtr aData = theObject->data();
boost::shared_ptr<ModelAPI_AttributeBoolean> aBool = aData->boolean(attributeID());
if (aBool->value() != myCheckBox->isChecked()) {
return true;
}
-bool ModuleBase_WidgetBoolValue::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetBoolValue::restoreValue(ObjectPtr theObject)
{
- DataPtr aData = theFeature->data();
+ DataPtr aData = theObject->data();
boost::shared_ptr<ModelAPI_AttributeBoolean> aRef = aData->boolean(attributeID());
bool isBlocked = myCheckBox->blockSignals(true);
virtual ~ModuleBase_WidgetBoolValue();
/// Saves the internal parameters to the given feature
- /// \param theFeature a model feature to be changed
- virtual bool storeValue(FeaturePtr theFeature) const;
+ /// \param theObject a model feature to be changed
+ virtual bool storeValue(ObjectPtr theObject) const;
- virtual bool restoreValue(FeaturePtr theFeature);
+ virtual bool restoreValue(ObjectPtr theObject);
/// Returns list of widget controls
/// \return a control list
{
}
-bool ModuleBase_WidgetDoubleValue::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetDoubleValue::storeValue(ObjectPtr theObject) const
{
- DataPtr aData = theFeature->data();
+ DataPtr aData = theObject->data();
AttributeDoublePtr aReal = aData->real(attributeID());
if (aReal->value() != mySpinBox->value()) {
aReal->setValue(mySpinBox->value());
return true;
}
-bool ModuleBase_WidgetDoubleValue::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetDoubleValue::restoreValue(ObjectPtr theObject)
{
- DataPtr aData = theFeature->data();
+ DataPtr aData = theObject->data();
AttributeDoublePtr aRef = aData->real(attributeID());
bool isBlocked = mySpinBox->blockSignals(true);
virtual ~ModuleBase_WidgetDoubleValue();
/// Saves the internal parameters to the given feature
- /// \param theFeature a model feature to be changed
- virtual bool storeValue(FeaturePtr theFeature) const;
+ /// \param theObject a model feature to be changed
+ virtual bool storeValue(ObjectPtr theObject) const;
- virtual bool restoreValue(FeaturePtr theFeature);
+ virtual bool restoreValue(ObjectPtr theObject);
/// Returns list of widget controls
/// \return a control list
bool ModuleBase_WidgetFeature::setFeature(const FeaturePtr& theFeature)
{
- if (!theFeature || !myFeatureKinds.contains(theFeature->getKind().c_str()))
+ if (!myFeatureKinds.contains(theFeature->getKind().c_str()))
return false;
myFeature = theFeature;
return true;
}
-bool ModuleBase_WidgetFeature::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetFeature::storeValue(ObjectPtr theObject) const
{
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+ if (!aFeature)
+ return false;
+ boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this;
- aRef->setFeature(myFeature);
- theFeature->execute();
+ aRef->setObject(myFeature);
+ aFeature->execute();
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
return true;
}
-bool ModuleBase_WidgetFeature::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetFeature::restoreValue(ObjectPtr theObject)
{
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+ boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
- myFeature = aRef->feature();
- myEditor->setText(myFeature ? myFeature->data()->name().c_str() : "");
- return true;
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
+ if (aFeature) {
+ myFeature = aFeature;
+ myEditor->setText(myFeature ? myFeature->data()->name().c_str() : "");
+ return true;
+ }
+ return false;
}
QWidget* ModuleBase_WidgetFeature::getControl() const
/// Saves the internal parameters to the given feature
/// \param theFeature a model feature to be changed
- virtual bool storeValue(FeaturePtr theFeature) const;
+ virtual bool storeValue(ObjectPtr theObject) const;
- virtual bool restoreValue(FeaturePtr theFeature);
+ virtual bool restoreValue(ObjectPtr theObject);
/// Returns the internal parent wiget control, that can be shown anywhere
/// \returns the widget
/// Fill the widget values by given point
/// \param thePoint the point
/// \return the boolean result of the feature set
- bool setFeature(const FeaturePtr& theFeature);
+ bool setFeature(const FeaturePtr& theObject);
/// Returns current widget feature
/// \return the feature
- const FeaturePtr& feature() const { return myFeature; }
+ const FeaturePtr feature() const { return myFeature; }
/// Returns the widget editor
/// \return the editor
ModuleBase_WidgetFeatureOrAttribute* that = (ModuleBase_WidgetFeatureOrAttribute*) this;
if (feature())
- aRef->setFeature(feature());
+ aRef->setObject(feature());
else if (myAttribute)
aRef->setAttr(myAttribute);
boost::shared_ptr<ModelAPI_AttributeRefAttr> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aData->attribute(attributeID()));
- FeaturePtr aFeature = aRef->feature();
- setFeature(aFeature);
- myAttribute = aRef->attr();
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aRef->object());
+ if (aFeature) {
+ setFeature(aFeature);
+ myAttribute = aRef->attr();
- std::string aText = "";
- if (aFeature)
- aText = aFeature->data()->name().c_str();
- else if (myAttribute)
- aText = myAttribute->attributeType().c_str();
+ std::string aText = "";
+ if (aFeature)
+ aText = aFeature->data()->name().c_str();
+ else if (myAttribute)
+ aText = myAttribute->attributeType().c_str();
- editor()->setText(aText.c_str());
- return true;
+ editor()->setText(aText.c_str());
+ return true;
+ }
+ return false;
}
bool ModuleBase_WidgetFeatureOrAttribute::setAttribute(const boost::shared_ptr<ModelAPI_Attribute>& theAttribute)
emit valuesChanged();
}
-bool ModuleBase_WidgetPoint2D::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetPoint2D::storeValue(ObjectPtr theObject) const
{
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+ boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(attributeID()));
return true;
}
-bool ModuleBase_WidgetPoint2D::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetPoint2D::restoreValue(ObjectPtr theObject)
{
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+ boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(attributeID()));
return ModuleBase_ModelWidget::eventFilter(theObject, theEvent);
}
-bool ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
+bool ModuleBase_WidgetPoint2D::initFromPrevious(ObjectPtr theObject)
{
if (myOptionParam.length() == 0)
return false;
- boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+ boost::shared_ptr<ModelAPI_Data> aData = theObject->data();
boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myOptionParam));
if (aPoint) {
this->blockSignals(isBlocked);
emit valuesChanged();
- emit storedPoint2D(theFeature, myOptionParam);
+ emit storedPoint2D(theObject, myOptionParam);
return true;
}
return false;
virtual bool setValue(ModuleBase_WidgetValue* theValue);
/// Saves the internal parameters to the given feature
- /// \param theFeature a model feature to be changed
- virtual bool storeValue(FeaturePtr theFeature) const;
+ /// \param theObject a model feature to be changed
+ virtual bool storeValue(ObjectPtr theObject) const;
- virtual bool restoreValue(FeaturePtr theFeature);
+ virtual bool restoreValue(ObjectPtr theObject);
/// Returns the internal parent wiget control, that can be shown anywhere
/// \returns the widget
/// \param theEvent the processed event
virtual bool eventFilter(QObject *theObject, QEvent *theEvent);
- bool initFromPrevious(FeaturePtr theFeature);
+ bool initFromPrevious(ObjectPtr theObject);
signals:
/// Signal about the point 2d set to the feature
/// \param the feature
/// \param the attribute of the feature
- void storedPoint2D(FeaturePtr theFeature, const std::string& theAttribute);
+ void storedPoint2D(ObjectPtr theObject, const std::string& theAttribute);
protected:
/// Fill the widget values by given point
}
//********************************************************************
-bool ModuleBase_WidgetSelector::storeValue(FeaturePtr theFeature) const
+bool ModuleBase_WidgetSelector::storeValue(ObjectPtr theObject) const
{
- DataPtr aData = theFeature->data();
+ DataPtr aData = theObject->data();
boost::shared_ptr<ModelAPI_AttributeReference> aRef =
boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(attributeID()));
- FeaturePtr aFeature = aRef->value();
- if (!(aFeature && aFeature->isSame(mySelectedObject))) {
+ ObjectPtr aObject = aRef->value();
+ if (!(aObject && aObject->isSame(mySelectedObject))) {
aRef->setValue(mySelectedObject);
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
}
}
//********************************************************************
-bool ModuleBase_WidgetSelector::restoreValue(FeaturePtr theFeature)
+bool ModuleBase_WidgetSelector::restoreValue(ObjectPtr theObject)
{
- DataPtr aData = theFeature->data();
+ DataPtr aData = theObject->data();
boost::shared_ptr<ModelAPI_AttributeReference> aRef = aData->reference(attributeID());
bool isBlocked = this->blockSignals(true);
virtual ~ModuleBase_WidgetSelector();
/// Saves the internal parameters to the given feature
- /// \param theFeature a model feature to be changed
- virtual bool storeValue(FeaturePtr theFeature) const;
+ /// \param theObject a model feature to be changed
+ virtual bool storeValue(ObjectPtr theObject) const;
- virtual bool restoreValue(FeaturePtr theFeature);
+ virtual bool restoreValue(ObjectPtr theObject);
/// Returns the internal parent wiget control, that can be shown anywhere
/// \returns the widget
void enableOthersControls(bool toEnable) const;
void updateSelectionName();
void raisePanel() const;
- bool isAccepted(const ObjectPtr theFeature) const;
+ bool isAccepted(const ObjectPtr theObject) const;
static TopAbs_ShapeEnum shapeType(const QString& theType);
#include <ModelAPI_Document.h>
static double myTestDelta;
-static FeaturePtr myTestFeature;
+static ResultPtr myTestObject;
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
void PartSet_TestOCC::testSelection(XGUI_Workshop* theWorkshop)
{
- if (!myTestFeature) {
+ if (!myTestObject) {
PartSet_TestOCC::createTestLine(theWorkshop);
PartSet_TestOCC::moveMouse(theWorkshop->viewer()->AISContext(),
theWorkshop->viewer()->activeView());
PartSet_TestOCC::changeTestLine(theWorkshop);
}
- boost::shared_ptr<GeomAPI_AISObject> anIO = theWorkshop->displayer()->getAISObject(myTestFeature);
+ 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());
//aModes.push_back(TopAbs_VERTEX);
//aModes.push_back(TopAbs_EDGE);
//aDisplayer->activateInLocalContext(aFeature, aModes, true);
- myTestFeature = aFeature;
+ myTestObject = aFeature;
QFeatureList aFeatureList;
- aFeatureList.append(myTestFeature);
+ aFeatureList.append(myTestObject);
aDisplayer->setSelected(aFeatureList, true);
}
}
void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop)
{
// change the line
- if (!myTestFeature)
+ if (!myTestObject)
return;
- FeaturePtr aFeature = myTestFeature;
+ FeaturePtr aFeature = myTestObject;
myTestDelta = myTestDelta - 50;
double aDelta = myTestDelta;
//aDisplayer->activateInLocalContext(aFeature, aModes, true);
/*QFeatureList aFeatureList;
- aFeatureList.append(myTestFeature);
+ aFeatureList.append(myTestObject);
theWorkshop->displayer()->setSelected(aFeatureList, true);*/
theWorkshop->displayer()->updateViewer();
#include <ModelAPI_Data.h>
#include <ModelAPI_AttributeDocRef.h>
#include <ModelAPI_Object.h>
+#include <ModelAPI_ResultPart.h>
#include <QAction>
#include <QContextMenuEvent>
{
QMenu* aMenu = new QMenu();
XGUI_SelectionMgr* aSelMgr = myWorkshop->selector();
- QList<ObjectPtr> aFeatures = aSelMgr->selection()->selectedObjects();
- if (aFeatures.size() == 1) {
+ QList<ObjectPtr> aObjects = aSelMgr->selection()->selectedObjects();
+ if (aObjects.size() == 1) {
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
- FeaturePtr aFeature = aFeatures.first();
+ ObjectPtr aObject = aObjects.first();
//Process Feature
- if (aFeature) {
- if (aFeature->getKind() == PARTSET_PART_KIND) {
- ObjectPtr aObject = boost::dynamic_pointer_cast<ModelAPI_Object>(aFeature);
- DocumentPtr aFeaDoc = aObject->featureRef()->data()->docRef("PartDocument")->value();
+ if (aObject) {
+ ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
+ if (aPart) {
+ DocumentPtr aFeaDoc = aPart->document();
if (aMgr->currentDocument() == aFeaDoc)
aMenu->addAction(action("DEACTIVATE_PART_CMD"));
else
aMenu->addAction(action("ACTIVATE_PART_CMD"));
} else {
- aMenu->addAction(action("EDIT_CMD"));
-
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- if (aDisplayer->isVisible(aFeature))
- aMenu->addAction(action("HIDE_CMD"));
- else
- aMenu->addAction(action("SHOW_CMD"));
+ ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+ if (aResult) {
+ aMenu->addAction(action("EDIT_CMD"));
+
+ XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ if (aDisplayer->isVisible(aResult))
+ aMenu->addAction(action("HIDE_CMD"));
+ else
+ aMenu->addAction(action("SHOW_CMD"));
+ }
}
aMenu->addAction(action("DELETE_CMD"));
aMenu->addSeparator();
#include <ModelAPI_Document.h>
#include <ModelAPI_Feature.h>
+#include <ModelAPI_ResultPart.h>
#include <QAbstractItemModel>
#include <QColor>
#include "XGUI.h"
#include <ModuleBase_Definitions.h>
+#include <ModelAPI_ResultPart.h>
-#include <QAbstractItemModel>
#include <Events_Listener.h>
+#include <QAbstractItemModel>
#include <QList>
class ModelAPI_Document;
Qt::ItemFlags flags(const QModelIndex& theIndex) const;
- //! Returns Feature object by the given Model index.
- //! Returns 0 if the given index is not index of a feature
+ //! Returns an object by the given Model index.
+ //! Returns 0 if the given index is not index of an object
ObjectPtr object(const QModelIndex& theIndex) const;
- QModelIndex featureIndex(const ObjectPtr theFeature) const;
+ QModelIndex objectIndex(const ObjectPtr theObject) const;
- //! Returns QModelIndex which corresponds to the given feature if this is a part
- //! If the feature is not found then index is not valid
- QModelIndex partIndex(const ObjectPtr& theFeature) const;
+ //! Returns QModelIndex which corresponds to the given part
+ //! If the object is not found then index is not valid
+ QModelIndex partIndex(const ResultPartPtr& thePart) const;
//! Activates a part data model if the index is a Part node index.
//! Returns true if active part changed.
bool activatedIndex(const QModelIndex& theIndex);
- //! Retrurns Feature which corresponds to active part
- ObjectPtr activePart() const;
+ //! Retrurns active part
+ ResultPartPtr activePart() const;
//! Retrurns QModelIndex of active part
QModelIndex activePartIndex() const { return myActivePartIndex; }
XGUI_DocumentDataModel* aModel = dataModel();
QModelIndexList::const_iterator aIt;
for (aIt = aIndexes.constBegin(); aIt != aIndexes.constEnd(); ++aIt) {
- FeaturePtr aFeature = aModel->feature(*aIt);
+ ObjectPtr aFeature = aModel->feature(*aIt);
if (aFeature)
mySelectedData.append(aFeature);
}
QLineEdit* aEditor = dynamic_cast<QLineEdit*>(theEditor);
if (aEditor) {
QString aRes = aEditor->text();
- FeaturePtr aFeature = mySelectedData.first();
+ ObjectPtr aFeature = mySelectedData.first();
PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
aMgr->rootDocument()->startOperation();
if (!XGUI_Tools::isModelObject(aFeature))
aLabelWgt->setFrameShadow(myTreeView->frameShadow());
connect(myTreeView, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
- connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(onActivePartChanged(FeaturePtr)));
- connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SIGNAL(activePartChanged(FeaturePtr)));
+ 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(FeaturePtr());
+ onActivePartChanged(ObjectPtr());
// Create internal actions
QAction* aAction = new QAction(QIcon(":pictures/rename_edit.png"), tr("Rename"), this);
}
//***************************************************
-void XGUI_ObjectsBrowser::onActivePartChanged(FeaturePtr thePart)
+void XGUI_ObjectsBrowser::onActivePartChanged(ObjectPtr thePart)
{
QPalette aPalet = myActiveDocLbl->palette();
if (thePart) {
myTreeView->setExpanded(myDocModel->activePartIndex(), false);
}
myDocModel->deactivatePart();
- onActivePartChanged(FeaturePtr());
- emit activePartChanged(FeaturePtr());
+ onActivePartChanged(ObjectPtr());
+ emit activePartChanged(ObjectPtr());
}
} else {
// End of editing by mouse click
}
//***************************************************
-void XGUI_ObjectsBrowser::activatePart(const FeaturePtr& thePart)
+void XGUI_ObjectsBrowser::activatePart(const ObjectPtr& thePart)
{
if (thePart) {
QModelIndex aIndex = myDocModel->partIndex(thePart);
myTreeView->setExpanded(aIndex, true);
onActivePartChanged(myDocModel->feature(aIndex));
} else {
- onActivePartChanged(FeaturePtr());
+ onActivePartChanged(ObjectPtr());
}
}
} else {
if (aIndex.isValid()) {
myDocModel->activatedIndex(aIndex);
myTreeView->setExpanded(aIndex, false);
- onActivePartChanged(FeaturePtr());
+ onActivePartChanged(ObjectPtr());
}
}
}
//***************************************************
void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent)
{
- myFeaturesList = myTreeView->selectedFeatures();
- bool toEnable = myFeaturesList.size() > 0;
+ myObjectsList = myTreeView->selectedFeatures();
+ bool toEnable = myObjectsList.size() > 0;
foreach(QAction* aCmd, actions()) {
aCmd->setEnabled(toEnable);
}
//***************************************************
void XGUI_ObjectsBrowser::onLabelContextMenuRequested(const QPoint& thePnt)
{
- myFeaturesList.clear();
+ myObjectsList.clear();
//Empty feature pointer means that selected root document
- myFeaturesList.append(FeaturePtr());
+ myObjectsList.append(ObjectPtr());
foreach(QAction* aCmd, actions()) {
aCmd->setEnabled(true);
//***************************************************
void XGUI_ObjectsBrowser::onEditItem()
{
- if (myFeaturesList.size() > 0) {
- FeaturePtr aFeature = myFeaturesList.first();
+ if (myObjectsList.size() > 0) {
+ ObjectPtr aFeature = myObjectsList.first();
if (aFeature) { // Selection happens in TreeView
// Find index which corresponds the feature
QModelIndex aIndex;
foreach(QModelIndex aIdx, selectedIndexes()) {
- FeaturePtr aFea = dataModel()->feature(aIdx);
- if (dataModel()->feature(aIdx)->isSame(aFeature)) {
+ ObjectPtr aFea = dataModel()->object(aIdx);
+ if (dataModel()->object(aIdx)->isSame(aFeature)) {
aIndex = aIdx;
break;
}
//***************************************************
void XGUI_ObjectsBrowser::onSelectionChanged()
{
- myFeaturesList = myTreeView->selectedFeatures();
+ myObjectsList = myTreeView->selectedObjects();
emit selectionChanged();
}
}
//***************************************************
-void XGUI_ObjectsBrowser::setFeaturesSelected(const QFeatureList& theFeatures)
+void XGUI_ObjectsBrowser::setObjectsSelected(const QList<ObjectPtr>& theObjects)
{
QList<QModelIndex> theIndexes;
QItemSelectionModel* aSelectModel = myTreeView->selectionModel();
aSelectModel->clear();
- foreach(FeaturePtr aFeature, theFeatures) {
- QModelIndex aIndex = myDocModel->featureIndex(aFeature);
+ foreach(ObjectPtr aFeature, theObjects) {
+ QModelIndex aIndex = myDocModel->objectIndex(aFeature);
if (aIndex.isValid()) {
aSelectModel->select(aIndex, QItemSelectionModel::Select);
}
XGUI_DataTree(QWidget* theParent);
virtual ~XGUI_DataTree();
- //! Returns list of currently selected features
- QList<ObjectPtr> selectedFeatures() const { return mySelectedData; }
+ //! Returns list of currently selected objects
+ QList<ObjectPtr> selectedObjects() const { return mySelectedData; }
XGUI_DocumentDataModel* dataModel() const;
signals:
//! Emited when selection is changed
void selectionChanged();
- void activePartChanged(FeaturePtr thePart);
+ void activePartChanged(ObjectPtr thePart);
//! Emited on context menu request
void contextMenuRequested(QContextMenuEvent* theEvent);
//! Returns Model which provides access to data objects
XGUI_DocumentDataModel* dataModel() const { return myDocModel; }
- //! Returns list of currently selected features
+ //! Returns list of currently selected objects
QList<ObjectPtr> selectedObjects() const { return myObjectsList; }
- void setFeaturesSelected(const QFeatureList& theFeatures);
+ void setObjectsSelected(const QList<ObjectPtr>& theObjects);
//! Returns currently selected indexes
QModelIndexList selectedIndexes() const { return myTreeView->selectionModel()->selectedIndexes(); }
XGUI_DataTree* treeView() const { return myTreeView; }
//! Activates currently selected part. Signal activePartChanged will not be sent
- void activatePart(const FeaturePtr& thePart);
+ void activatePart(const ObjectPtr& thePart);
void rebuildDataTree();
void selectionChanged();
//! Emited when current active document is changed
- void activePartChanged(FeaturePtr thePart);
+ void activePartChanged(ObjectPtr thePart);
//! Emited on context menu request
void contextMenuRequested(QContextMenuEvent* theEvent);
virtual bool eventFilter(QObject* obj, QEvent* theEvent);
private slots:
- void onActivePartChanged(FeaturePtr thePart);
+ void onActivePartChanged(ObjectPtr thePart);
void onContextMenuRequested(QContextMenuEvent* theEvent);
void onLabelContextMenuRequested(const QPoint& thePnt);
virtual QModelIndex findGroup(const std::string& theGroup) const;
//! Return a Part object
- virtual ObjectPtr part() const;
+ virtual ResultPartPtr part() const;
private:
/// Returns a list of viewer selected presentations
/// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
/// \return list of presentations
- std::list<ModuleBase_ViewerPrs> getSelected(int theShapeTypeToSkip = -1) const;
+ virtual std::list<ModuleBase_ViewerPrs> getSelected(int theShapeTypeToSkip = -1) const;
/// Returns a list of viewer highlited presentations
/// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build
/// \return list of presentations
- std::list<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const;
+ virtual std::list<ModuleBase_ViewerPrs> getHighlighted(int theShapeTypeToSkip = -1) const;
/**
* Returns list of currently selected objects
*/
- QList<ObjectPtr> selectedObjects() const;
+ virtual QList<ObjectPtr> selectedObjects() const;
/**
* Returns list of currently selected results
*/
- QResultList selectedResults() const;
+ virtual QResultList selectedResults() const;
//! Returns list of currently selected QModelIndexes
- QModelIndexList selectedIndexes() const;
+ virtual QModelIndexList selectedIndexes() const;
//! Returns list of currently selected AIS objects
- void selectedAISObjects(AIS_ListOfInteractive& theList) const;
+ virtual void selectedAISObjects(AIS_ListOfInteractive& theList) const;
//! Returns list of currently selected shapes
- void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
+ virtual void selectedShapes(NCollection_List<TopoDS_Shape>& theList) const;
private:
XGUI_Workshop* myWorkshop;
#include <ModelAPI_PluginManager.h>
#include <ModelAPI_AttributeDocRef.h>
#include <ModelAPI_Data.h>
+#include <ModelAPI_Result.h>
+#include <ModelAPI_Object.h>
//**************************************************************
void XGUI_SelectionMgr::onObjectBrowserSelection()
{
- QFeatureList aFeatures = myWorkshop->objectBrowser()->selectedFeatures();
+ QList<ObjectPtr> aObjects = myWorkshop->objectBrowser()->selectedObjects();
+ QResultList aResults;
+ foreach(ObjectPtr aObject, aObjects) {
+ ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aObject);
+ if (aRes)
+ aResults.append(aRes);
+ }
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
- aDisplayer->setSelected(aFeatures);
+ aDisplayer->setSelected(aResults);
emit selectionChanged();
}
//**************************************************************
void XGUI_SelectionMgr::onViewerSelection()
{
- QFeatureList aFeatures;
+ QList<ObjectPtr> aFeatures;
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive();
- FeaturePtr aFeature = myWorkshop->displayer()->getFeature(anIO);
- if (aFeature)
- aFeatures.append(aFeature);
+ ResultPtr aResult = myWorkshop->displayer()->getResult(anIO);
+ if (aResult)
+ aFeatures.append(aResult);
}
- myWorkshop->objectBrowser()->setFeaturesSelected(aFeatures);
+ myWorkshop->objectBrowser()->setObjectsSelected(aFeatures);
emit selectionChanged();
}