return MY_SHAPE->IsEqual(theShape->impl<TopoDS_Shape>()) == Standard_True;
}
+bool GeomAPI_Shape::isSame(const std::shared_ptr<GeomAPI_Shape> theShape) const
+{
+ if (!theShape.get())
+ return false;
+ if (isNull())
+ return theShape->isNull();
+ if (theShape->isNull())
+ return false;
+
+ return MY_SHAPE->IsSame(theShape->impl<TopoDS_Shape>()) == Standard_True;
+}
+
bool GeomAPI_Shape::isVertex() const
{
const TopoDS_Shape& aShape = const_cast<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
GEOMAPI_EXPORT
virtual bool isEqual(const std::shared_ptr<GeomAPI_Shape> theShape) const;
+ /// Returns whether the shapes are same
+ GEOMAPI_EXPORT
+ virtual bool isSame(const std::shared_ptr<GeomAPI_Shape> theShape) const;
+
/// Returns whether the shape is a vertex
GEOMAPI_EXPORT
virtual bool isVertex() const;
std::map<ResultPtr, std::list<std::shared_ptr<GeomAPI_Shape> > >::iterator aContext =
myCash.find(theContext);
if (aContext != myCash.end()) {
- // iterate shapes because "isEqual" method must be called for each shape
+ // iterate shapes because "isSame" method must be called for each shape
std::list<std::shared_ptr<GeomAPI_Shape> >::iterator aShapes = aContext->second.begin();
for(; aShapes != aContext->second.end(); aShapes++) {
if (!theSubShape.get()) {
if (!aShapes->get())
return true;
} else {
- if (theSubShape->isEqual(*aShapes))
+ // we need to call here isSame instead of isEqual to do not check shapes orientation
+ if (theSubShape->isSame(*aShapes))
return true;
}
}
return true;
}
} else {
- if (aValue->isEqual(theSubShape)) // shapes are equal
+ // we need to call here isSame instead of isEqual to do not check shapes orientation
+ if (aValue->isSame(theSubShape)) // shapes are equal
return true;
}
}
ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParent,
ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData)
-: ModuleBase_WidgetSelector(theParent, theWorkshop, theData)
+: ModuleBase_WidgetSelector(theParent, theWorkshop, theData),
+ myIsSetSelectionBlocked(false)
{
QGridLayout* aMainLay = new QGridLayout(this);
ModuleBase_Tools::adjustMargins(aMainLay);
bool ModuleBase_WidgetMultiSelector::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
const bool theToValidate)
{
+ if (myIsSetSelectionBlocked)
+ return false;
+
AttributeSelectionListPtr aSelectionListAttr;
if (attribute()->attributeType() == ModelAPI_AttributeSelectionList::typeId())
aSelectionListAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(attribute());
//emit valuesChanged();
//}
+ // Restore selection in the viewer by the attribute selection list
+ // it is possible that diring selection attribute filling, selection in Object Browser
+ // is changed(some items were removed/added) and as result, selection in the viewer
+ // differs from the selection come to this method. By next rows, we restore selection
+ // in the viewer according to content of selection attribute. Case is Edge selection in Group
+ myIsSetSelectionBlocked = true;
+ static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
+ ModelAPI_EventCreator::get()->sendUpdated(myFeature, anEvent);
+ Events_Loop::loop()->flush(anEvent);
+ myIsSetSelectionBlocked = false;
+
if (aSelectionListAttr.get())
aSelectionListAttr->cashValues(false);
/// A flag to clear selection by click in empty place in the viewer
bool myIsNeutralPointClear;
+
+ /// A flag to block set selection perform if the method is in process
+ bool myIsSetSelectionBlocked;
};
#endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */
#endif
#ifdef VINSPECTOR
-#include <VInspectorAPI_PluginMgr.h>
-#include <VInspectorAPI_Communicator.h>
+#include <VInspectorAPI_Communicator.hxx>
#ifndef HAVE_SALOME
#include <AppElements_MainWindow.h>
#endif
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
#ifdef VINSPECTOR
-#include <VInspectorAPI_CallBack.h>
+#include <VInspectorAPI_CallBack.hxx>
#endif
#include <Events_Loop.h>
#ifdef VINSPECTOR
if (VInspector_FirstCall) {
XGUI_Displayer* aDisplayer = (XGUI_Displayer*)this;
- VInspectorAPI_Communicator* aCommunicator = VInspectorAPI_PluginMgr::activateVInspector(
- "VInspector.dll", aContext);
- aDisplayer->setCommunicator(aCommunicator);
- #ifndef HAVE_SALOME
- AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
- if (aViewer)
- aViewer->setCallBack(aCommunicator->getCallBack());
- #endif
+
+ VInspectorAPI_Communicator* aCommunicator =
+ VInspectorAPI_Communicator::loadPluginLibrary("TKVInspector.dll");
+ if (aCommunicator) {
+ aCommunicator->setContext(aContext);
+
+ aDisplayer->setCommunicator(aCommunicator);
+ #ifndef HAVE_SALOME
+ AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+ if (aViewer)
+ aViewer->setCallBack(aCommunicator->getCallBack());
+ #endif
+ }
VInspector_FirstCall = false;
}
#endif
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
if (!BROwnr.IsNull() && BROwnr->HasShape()) {
const TopoDS_Shape& aShape = BROwnr->Shape();
- if (!aShape.IsNull() && theShapesToBeSelected.IsBound(aShape)) {
- Handle(AIS_InteractiveObject) anOwnerPresentation =
- Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
- NCollection_Map<Handle(AIS_InteractiveObject)> aPresentations =
- theShapesToBeSelected.Find(aShape);
- if (aPresentations.Contains(anOwnerPresentation)) {
- theContext->AddOrRemoveSelected(anOwner);
- anOwner->SetSelected (Standard_True);
+ if (aShape.IsNull())
+ continue;
+
+ NCollection_DataMap<TopoDS_Shape,
+ NCollection_Map<Handle(AIS_InteractiveObject)> >::Iterator aShapeIt(theShapesToBeSelected);
+ for (; aShapeIt.More(); aShapeIt.Next()) {
+ if (aShapeIt.Key().IsSame(aShape)) {
+ const TopoDS_Shape& aParameterShape = aShapeIt.Key();
+ // isSame should be used here as it does not check orientation of shapes
+ // despite on isEqual of shapes or IsBound for shape in QMap
+ // orientation is different for Edges shapes in model and owner even if this is one shape
+ if (aParameterShape.IsSame(aShape)) {
+ Handle(AIS_InteractiveObject) anOwnerPresentation =
+ Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
+ NCollection_Map<Handle(AIS_InteractiveObject)> aPresentations =
+ theShapesToBeSelected.Find(aParameterShape);
+ if (aPresentations.Contains(anOwnerPresentation)) {
+ theContext->AddOrRemoveSelected(anOwner);
+ anOwner->SetSelected (Standard_True);
+ }
+ }
}
}
}
fillPresentation(aPrs, anOwner);
aPresentations.push_back(aPrs);
}
- else { // TODO: check why the entity owner is null here, case is selection point on a line
- Handle(AIS_InteractiveObject) anIO = aContext->DetectedInteractive();
- ModuleBase_ViewerPrsPtr aPrs(new ModuleBase_ViewerPrs());
- aPrs->setInteractive(anIO);
-
- ObjectPtr aResult = aDisplayer->getObject(anIO);
- // we should not check the appearance of this feature because there can be some selected
- // shapes for one feature
- aPrs->setObject(aResult);
- TopoDS_Shape aShape = aContext->DetectedShape();
- if (!aShape.IsNull()) {
- std::shared_ptr<GeomAPI_Shape> aGeomShape =
- std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
- aGeomShape->setImpl(new TopoDS_Shape(aShape));
- aPrs->setShape(aGeomShape);
- }
- aPresentations.push_back(aPrs);
- }
}
return aPresentations;
}
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
#ifdef VINSPECTOR
-#include <VInspectorAPI_CallBack.h>
+#include <VInspectorAPI_CallBack.hxx>
#endif
XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent)