From: nds Date: Wed, 15 Mar 2017 04:32:18 +0000 (+0300) Subject: #2027 Sketcher Trim feature - highlight should be cleared when the mouse is moved... X-Git-Tag: V_2.7.0~227^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=409ad39d4655a87a91986bf9927e47bfc08b5341;p=modules%2Fshaper.git #2027 Sketcher Trim feature - highlight should be cleared when the mouse is moved out of segement. Debug tool TInspector replaces VInspector and DFBrowser. --- diff --git a/CMakeCommon/FindDFBrowser.cmake b/CMakeCommon/FindDFBrowser.cmake deleted file mode 100644 index 74e54563a..000000000 --- a/CMakeCommon/FindDFBrowser.cmake +++ /dev/null @@ -1,25 +0,0 @@ -# - Try to find DFBrowser -# Once done this will define -# -# DBROWSER_FOUND - system has DFBrowser -# DFBROWSER_INCLUDE_DIRS - the DFBrowser include directory -# DFBROWSER_LIBRARIES - Link these to use DFBrowser - -#============================================================================= -## Copyright (C) 2014-20xx CEA/DEN, EDF R&D -#============================================================================= - -SET(DFBROWSER_ROOT_DIR $ENV{DFBROWSER_ROOT_DIR} CACHE PATH "Path to the DFBrowser directory") -IF(EXISTS ${DFBROWSER_ROOT_DIR}) - SET(DFBROWSER_INCLUDE_DIR "${DFBROWSER_ROOT_DIR}/include") - SET(DFBROWSER_LIB_DIR "${DFBROWSER_ROOT_DIR}/lib") - - FIND_LIBRARY(DFBrowserAPI DFBrowserAPI "${DFBROWSER_LIB_DIR}") - IF(DFBrowserAPI) - SET(DFBrowserAPI ${DFBrowserAPI}) - MESSAGE(STATUS "DFBrowser found at ${DFBROWSER_ROOT_DIR}") - MESSAGE(STATUS "DFBrowser include dir at ${DFBROWSER_INCLUDE_DIR}") - MESSAGE(STATUS "DFBrowser lib dir at ${DFBROWSER_LIB_DIR}") - ENDIF(DFBrowserAPI) - -ENDIF(EXISTS ${DFBROWSER_ROOT_DIR}) diff --git a/CMakeCommon/FindTInspector.cmake b/CMakeCommon/FindTInspector.cmake new file mode 100644 index 000000000..b55377623 --- /dev/null +++ b/CMakeCommon/FindTInspector.cmake @@ -0,0 +1,29 @@ +# - Try to find TInspector +# Once done this will define +# +# TInspector - system has OCCT tool inspector +# TINSPECTOR_INCLUDE_DIRS - the tool inspector include directory +# TINSPECTOR_LIBRARIES - Link these to use TInspector + +#============================================================================= +## Copyright (C) 2014-20xx CEA/DEN, EDF R&D +#============================================================================= + +SET(TINSPECTOR_ROOT_DIR $ENV{TINSPECTOR_ROOT_DIR} CACHE PATH "Path to the TInspector directory") +IF(EXISTS ${TINSPECTOR_ROOT_DIR}) + SET(TINSPECTOR_INCLUDE_DIR "${TINSPECTOR_ROOT_DIR}/inc") + SET(TINSPECTOR_LIB_DIR "${TINSPECTOR_ROOT_DIR}/lib") + + FIND_LIBRARY(TKTInspector TKTInspector "${TINSPECTOR_LIB_DIR}") + IF(TKTInspector) + SET(TKTInspector ${TKTInspector}) + MESSAGE(STATUS "TInspector is found at ${TINSPECTOR_ROOT_DIR}") + MESSAGE(STATUS "TInspector include dir is ${TINSPECTOR_INCLUDE_DIR}") + MESSAGE(STATUS "TInspector lib dir is ${TINSPECTOR_LIB_DIR}") + + FIND_LIBRARY(TKVInspector TKVInspector "${TINSPECTOR_LIB_DIR}") + SET(TKVInspector ${TKVInspector}) + + ENDIF(TKTInspector) + +ENDIF(EXISTS ${TINSPECTOR_ROOT_DIR}) diff --git a/CMakeCommon/FindVInspector.cmake b/CMakeCommon/FindVInspector.cmake deleted file mode 100644 index c86abdf05..000000000 --- a/CMakeCommon/FindVInspector.cmake +++ /dev/null @@ -1,25 +0,0 @@ -# - Try to find VInspector -# Once done this will define -# -# VINSPECTOR_FOUND - system has VInspector -# VINSPECTOR_INCLUDE_DIRS - the VInspector include directory -# VINSPECTOR_LIBRARIES - Link these to use VInspector - -#============================================================================= -## Copyright (C) 2014-20xx CEA/DEN, EDF R&D -#============================================================================= - -SET(VINSPECTOR_ROOT_DIR $ENV{VINSPECTOR_ROOT_DIR} CACHE PATH "Path to the VInspector directory") -IF(EXISTS $ENV{VINSPECTOR_ROOT_DIR}) - SET(VINSPECTOR_INCLUDE_DIR "$ENV{VINSPECTOR_ROOT_DIR}/include") - SET(VINSPECTOR_LIB_DIR "$ENV{VINSPECTOR_ROOT_DIR}/lib") - - FIND_LIBRARY(VInspectorAPI VInspectorAPI "${VINSPECTOR_LIB_DIR}") - IF(VInspectorAPI) - SET(VInspectorAPI ${VInspectorAPI}) - MESSAGE(STATUS "VInspector found at ${VINSPECTOR_ROOT_DIR}") - MESSAGE(STATUS "VInspector include dir at ${VINSPECTOR_INCLUDE_DIR}") - MESSAGE(STATUS "VInspector lib dir at ${VINSPECTOR_LIB_DIR}") - ENDIF(VInspectorAPI) - -ENDIF(EXISTS $ENV{VINSPECTOR_ROOT_DIR}) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01376442f..73a4f4f0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,7 @@ INCLUDE(FindPython) INCLUDE(FindSalome) INCLUDE(FindCAS) INCLUDE(FindSUIT) -INCLUDE(FindDFBrowser) -INCLUDE(FindVInspector) +INCLUDE(FindTInspector) # Find LibXml2 IF(DEFINED ENV{LIBXML2_ROOT_DIR}) diff --git a/src/Model/CMakeLists.txt b/src/Model/CMakeLists.txt index a737654e0..181a51e75 100644 --- a/src/Model/CMakeLists.txt +++ b/src/Model/CMakeLists.txt @@ -103,11 +103,8 @@ SET(PROJECT_INCLUDES ) -IF(DFBrowserAPI) - SET(PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${DFBrowserAPI}) - SET(PROJECT_INCLUDES ${PROJECT_INCLUDES} ${DFBROWSER_INCLUDE_DIR}) - - ADD_DEFINITIONS(-DDFBROWSER) +IF(TKTInspector) + ADD_DEFINITIONS(-DTINSPECTOR) ENDIF() ADD_DEFINITIONS(-DMODEL_EXPORTS ${CAS_DEFINITIONS}) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 59a3fcf4a..89c596d6d 100755 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -78,7 +78,7 @@ Model_Document::Model_Document(const int theID, const std::string theKind) : myID(theID), myKind(theKind), myIsActive(false), myDoc(new TDocStd_Document("BinOcaf")) // binary OCAF format { -#ifdef DFBROWSER +#ifdef TINSPECTOR CDF_Session::CurrentSession()->Directory()->Add(myDoc); #endif myObjs = new Model_Objects(myDoc->Main()); diff --git a/src/PartSet/PartSet_WidgetFeaturePointSelector.cpp b/src/PartSet/PartSet_WidgetFeaturePointSelector.cpp index ed14ea8d6..78fcaf12a 100644 --- a/src/PartSet/PartSet_WidgetFeaturePointSelector.cpp +++ b/src/PartSet/PartSet_WidgetFeaturePointSelector.cpp @@ -50,7 +50,7 @@ PartSet_WidgetFeaturePointSelector::PartSet_WidgetFeaturePointSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData) -: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData) +: ModuleBase_WidgetShapeSelector(theParent, theWorkshop, theData), myBaseSelected(false) { } @@ -66,51 +66,54 @@ bool PartSet_WidgetFeaturePointSelector::isValidSelection( } //******************************************************************** -void PartSet_WidgetFeaturePointSelector::activateCustom() +bool PartSet_WidgetFeaturePointSelector::activateSelectionAndFilters(bool toActivate) { - ModuleBase_WidgetShapeSelector::activateCustom(); - - myWorkshop->module()->activateCustomPrs(myFeature, - ModuleBase_IModule::CustomizeHighlightedObjects, true); - +#ifdef HIGHLIGHT_STAYS_PROBLEM Handle(AIS_InteractiveContext) aContext = - XGUI_Tools::workshop(myWorkshop)->viewer()->AISContext(); + XGUI_Tools::workshop(myWorkshop)->viewer()->AISContext(); + Quantity_Color aColor; + Handle(Graphic3d_HighlightStyle) aHStyle = aContext->HighlightStyle(); + Handle(Graphic3d_HighlightStyle) aSStyle = aContext->SelectionStyle(); + if (toActivate) { + std::vector aColors; + aColors = Config_PropManager::color("Visualization", "sketch_entity_color", + SKETCH_ENTITY_COLOR); + aColor = Quantity_Color(aColors[0] / 255., aColors[1] / 255., aColors[2] / 255., Quantity_TOC_RGB); - std::vector aColors; - aColors = Config_PropManager::color("Visualization", "sketch_entity_color", - SKETCH_ENTITY_COLOR); - Quantity_Color aColor(aColors[0] / 255., aColors[1] / 255., aColors[2] / 255., Quantity_TOC_RGB); + myHighlightColor = aHStyle->Color(); + mySelectionColor = aSStyle->Color(); -#ifdef HIGHLIGHT_STAYS_PROBLEM - Handle(Graphic3d_HighlightStyle) aHStyle = aContext->HighlightStyle(); - myHighlightColor = aHStyle->Color(); + aHStyle->SetTransparency(0.5f); + } + else { + aColor = myHighlightColor; + } aHStyle->SetColor(aColor); aContext->SetHighlightStyle(aHStyle); - Handle(Graphic3d_HighlightStyle) aSStyle = aContext->SelectionStyle(); - mySelectionColor = aSStyle->Color(); aSStyle->SetColor(aColor); aContext->SetSelectionStyle(aSStyle); + #endif + + return ModuleBase_WidgetShapeSelector::activateSelectionAndFilters(toActivate); } //******************************************************************** -void PartSet_WidgetFeaturePointSelector::deactivate() +void PartSet_WidgetFeaturePointSelector::activateCustom() { - ModuleBase_WidgetShapeSelector::deactivate(); + ModuleBase_WidgetShapeSelector::activateCustom(); - Handle(AIS_InteractiveContext) aContext = - XGUI_Tools::workshop(myWorkshop)->viewer()->AISContext(); + myBaseSelected = false; -#ifdef HIGHLIGHT_STAYS_PROBLEM - Handle(Graphic3d_HighlightStyle) aHStyle = aContext->HighlightStyle(); - aHStyle->SetColor(myHighlightColor); - aContext->SetHighlightStyle(aHStyle); + myWorkshop->module()->activateCustomPrs(myFeature, + ModuleBase_IModule::CustomizeHighlightedObjects, true); +} - Handle(Graphic3d_HighlightStyle) aSStyle = aContext->SelectionStyle(); - aSStyle->SetColor(mySelectionColor); - aContext->SetSelectionStyle(aSStyle); -#endif +//******************************************************************** +void PartSet_WidgetFeaturePointSelector::deactivate() +{ + ModuleBase_WidgetShapeSelector::deactivate(); } //******************************************************************** @@ -120,10 +123,8 @@ void PartSet_WidgetFeaturePointSelector::mouseMoved(ModuleBase_IViewWindow* theW ModuleBase_ISelection* aSelect = myWorkshop->selection(); QList aHighlighted = aSelect->getHighlighted(); - if (!aHighlighted.empty()) { - ModuleBase_ViewerPrsPtr aPrs = aHighlighted.first(); - fillFeature(aPrs, theWindow, theEvent); - } + ModuleBase_ViewerPrsPtr aPrs = !aHighlighted.empty() ? aHighlighted.first() : ModuleBase_ViewerPrsPtr(); + fillFeature(aPrs, theWindow, theEvent); } //******************************************************************** @@ -134,6 +135,7 @@ void PartSet_WidgetFeaturePointSelector::mouseReleased(ModuleBase_IViewWindow* t if (theEvent->button() != Qt::LeftButton) return; + myBaseSelected = true; emit focusOutWidget(this); // we need to deselect base feature for better visibility of selected feature XGUI_Tools::workshop(myWorkshop)->displayer()->clearSelected(false); @@ -146,30 +148,32 @@ bool PartSet_WidgetFeaturePointSelector::fillFeature( QMouseEvent* theEvent) { bool aFilled = false; - if (theSelectedPrs.get() && theSelectedPrs->object().get()) { - ObjectPtr anObject = theSelectedPrs->object(); - gp_Pnt aPnt = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView()); - double aX, anY; - Handle(V3d_View) aView = theWindow->v3dView(); - PartSet_Tools::convertTo2D(aPnt, mySketch, aView, aX, anY); - - std::shared_ptr aRef = - std::dynamic_pointer_cast( - feature()->data()->attribute(SketchPlugin_Trim::BASE_OBJECT())); - aRef->setValue(anObject); - - std::shared_ptr anAttributePoint = - std::dynamic_pointer_cast( - feature()->data()->attribute(SketchPlugin_Trim::ENTITY_POINT())); - anAttributePoint->setValue(aX, anY); - // redisplay AIS presentation in viewer + ObjectPtr anObject; + if (theSelectedPrs.get() && theSelectedPrs->object().get()) + anObject = theSelectedPrs->object(); + + gp_Pnt aPnt = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWindow->v3dView()); + double aX, anY; + Handle(V3d_View) aView = theWindow->v3dView(); + PartSet_Tools::convertTo2D(aPnt, mySketch, aView, aX, anY); + + std::shared_ptr aRef = + std::dynamic_pointer_cast( + feature()->data()->attribute(SketchPlugin_Trim::BASE_OBJECT())); + aRef->setValue(anObject); + + std::shared_ptr anAttributePoint = + std::dynamic_pointer_cast( + feature()->data()->attribute(SketchPlugin_Trim::ENTITY_POINT())); + anAttributePoint->setValue(aX, anY); + // redisplay AIS presentation in viewer #ifndef HIGHLIGHT_STAYS_PROBLEM - // an attempt to clear highlighted item in the viewer: but of OCCT - XGUI_Tools::workshop(myWorkshop)->displayer()->clearSelected(true); + // an attempt to clear highlighted item in the viewer: but of OCCT + XGUI_Tools::workshop(myWorkshop)->displayer()->clearSelected(true); #endif - updateObject(feature()); - aFilled = true; - } + updateObject(feature()); + aFilled = true; + return aFilled; } @@ -179,6 +183,12 @@ QList PartSet_WidgetFeaturePointSelector::getAttributeS return QList(); } +//******************************************************************** +void PartSet_WidgetFeaturePointSelector::updateSelectionName() +{ + if (myBaseSelected) + ModuleBase_WidgetShapeSelector::updateSelectionName(); +} //******************************************************************** bool PartSet_WidgetFeaturePointSelector::setSelection( diff --git a/src/PartSet/PartSet_WidgetFeaturePointSelector.h b/src/PartSet/PartSet_WidgetFeaturePointSelector.h index cfb6329db..56c5105bb 100644 --- a/src/PartSet/PartSet_WidgetFeaturePointSelector.h +++ b/src/PartSet/PartSet_WidgetFeaturePointSelector.h @@ -57,6 +57,10 @@ Q_OBJECT /// \return a boolean value virtual bool isValidSelection(const std::shared_ptr& theValue); + /// Activate or deactivate selection and selection filters + /// \return true if the selection filter of the widget is activated in viewer context + virtual bool activateSelectionAndFilters(bool toActivate); + /// Set sketcher /// \param theSketch a sketcher object void setSketcher(CompositeFeaturePtr theSketch) { mySketch = theSketch; } @@ -101,6 +105,9 @@ protected: /// a shape. If the attribute do not uses the shape, it is empty virtual QList> getAttributeSelection() const; + /// Computes and updates name of selected object in the widget + virtual void updateSelectionName(); + protected: /// The methiod called when widget is activated virtual void activateCustom(); @@ -114,6 +121,7 @@ protected: CompositeFeaturePtr mySketch; Quantity_Color myHighlightColor; Quantity_Color mySelectionColor; + bool myBaseSelected; }; #endif \ No newline at end of file diff --git a/src/SketchPlugin/SketchPlugin_Trim.cpp b/src/SketchPlugin/SketchPlugin_Trim.cpp index d57e409c5..d989afb31 100644 --- a/src/SketchPlugin/SketchPlugin_Trim.cpp +++ b/src/SketchPlugin/SketchPlugin_Trim.cpp @@ -335,7 +335,7 @@ AISObjectPtr SketchPlugin_Trim::getAISObject(AISObjectPtr thePrevious) data()->attribute(SketchPlugin_Trim::BASE_OBJECT())); ObjectPtr aBaseObject = aBaseObjectAttr->value(); if (!aBaseObject.get()) - return anAIS; + return AISObjectPtr(); FeaturePtr aBaseFeature = ModelAPI_Feature::feature(aBaseObjectAttr->value()); // point on feature @@ -348,40 +348,44 @@ AISObjectPtr SketchPlugin_Trim::getAISObject(AISObjectPtr thePrevious) if (myCashedShapes.find(aBaseObject) == myCashedShapes.end()) fillObjectShapes(aBaseObject); + GeomShapePtr aBaseShape; + const std::set& aShapes = myCashedShapes[aBaseObject]; if (!aShapes.empty()) { std::set::const_iterator anIt = aShapes.begin(), aLast = aShapes.end(); for (; anIt != aLast; anIt++) { - GeomShapePtr aBaseShape = *anIt; + GeomShapePtr aShape = *anIt; std::shared_ptr aProjectedPoint; - if (ModelGeomAlgo_Point2D::isPointOnEdge(aBaseShape, anAttributePnt, aProjectedPoint)) { - if (aBaseShape) { - if (!anAIS) - anAIS = AISObjectPtr(new GeomAPI_AISObject); - anAIS->createShape(aBaseShape); - - std::shared_ptr anAuxiliaryAttr = - aBaseFeature->data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID()); - - bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value(); - - std::vector aColor; - aColor = Config_PropManager::color("Visualization", "operation_remove_feature_color", - OPERATION_REMOVE_FEATURE_COLOR()); - double aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH(); - int aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE(); - if (isConstruction) { - aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY(); - aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY(); - } - anAIS->setColor(aColor[0], aColor[1], aColor[2]); - anAIS->setWidth(aWidth); - anAIS->setLineStyle(aLineStyle); - break; - } - } + if (ModelGeomAlgo_Point2D::isPointOnEdge(aShape, anAttributePnt, aProjectedPoint)) + aBaseShape = aShape; + } + } + + if (aBaseShape.get()) { + if (!anAIS) + anAIS = AISObjectPtr(new GeomAPI_AISObject); + anAIS->createShape(aBaseShape); + + std::shared_ptr anAuxiliaryAttr = + aBaseFeature->data()->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID()); + + bool isConstruction = anAuxiliaryAttr.get() != NULL && anAuxiliaryAttr->value(); + std::vector aColor; + aColor = Config_PropManager::color("Visualization", "operation_remove_feature_color", + OPERATION_REMOVE_FEATURE_COLOR()); + double aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH(); + int aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE(); + if (isConstruction) { + aWidth = SketchPlugin_SketchEntity::SKETCH_LINE_WIDTH_AUXILIARY(); + aLineStyle = SketchPlugin_SketchEntity::SKETCH_LINE_STYLE_AUXILIARY(); } + anAIS->setColor(aColor[0], aColor[1], aColor[2]); + // width is extened in several points in order to see this preview over highlight + anAIS->setWidth(aWidth + 2); + anAIS->setLineStyle(aLineStyle); } + else + anAIS = AISObjectPtr(); return anAIS; } diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index 41cb4c2ee..f276b4f7a 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -156,24 +156,16 @@ IF(${HAVE_SALOME}) INCLUDE_DIRECTORIES(${SALOME_KERNEL_INCLUDE}) ENDIF(${HAVE_SALOME}) -IF(VInspectorAPI) - message("VINSPECTOR is defined") - SET(PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${VInspectorAPI}) - SET(PROJECT_INCLUDES ${PROJECT_INCLUDES} ${VINSPECTOR_INCLUDE_DIR}) - - ADD_DEFINITIONS(-DVINSPECTOR) -ENDIF() - IF(NOT ${HAVE_SALOME}) SET(PROJECT_INCLUDES ${PROJECT_INCLUDES} ${APPELEMENTS_INCLUDE_DIR}) ENDIF(NOT ${HAVE_SALOME}) -IF(DFBrowserAPI) - message("DFBROWSER is defined") - SET(PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${DFBrowserAPI}) - SET(PROJECT_INCLUDES ${PROJECT_INCLUDES} ${DFBROWSER_INCLUDE_DIR}) +IF(TKTInspector) + message("TINSPECTOR is defined") + SET(PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${TKTInspector} ${TKVInspector}) + SET(PROJECT_INCLUDES ${PROJECT_INCLUDES} ${TINSPECTOR_INCLUDE_DIR}) - ADD_DEFINITIONS(-DDFBROWSER) + ADD_DEFINITIONS(-DTINSPECTOR) ENDIF() INCLUDE_DIRECTORIES(${PROJECT_INCLUDES}) diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 72025823a..a1fa3c468 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -151,13 +151,9 @@ void XGUI_ContextMenuMgr::createActions() tr("Select parent feature"), aDesktop); addAction("SHOW_FEATURE_CMD", aAction); -#ifdef VINSPECTOR - aAction = ModuleBase_Tools::createAction(QIcon(), tr("Debug Visualization"), aDesktop); - addAction("VINSPECTOR_VIEW", aAction); -#endif -#ifdef DFBROWSER - aAction = ModuleBase_Tools::createAction(QIcon(), tr("DFBrowser"), aDesktop); - addAction("DFBROWSER_VIEW", aAction); +#ifdef TINSPECTOR + aAction = ModuleBase_Tools::createAction(QIcon(), tr("TInspector"), aDesktop); + addAction("TINSPECTOR_VIEW", aAction); #endif buildObjBrowserMenu(); @@ -338,11 +334,8 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("DEFLECTION_CMD")->setEnabled(true); #ifdef _DEBUG - #ifdef VINSPECTOR - action("VINSPECTOR_VIEW")->setEnabled(true); - #endif - #ifdef DFBROWSER - action("DFBROWSER_VIEW")->setEnabled(true); + #ifdef TINSPECTOR + action("TINSPECTOR_VIEW")->setEnabled(true); #endif #endif @@ -578,11 +571,8 @@ void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const } #ifdef _DEBUG if (aSelected == 0) { - #ifdef VINSPECTOR - aActions.append(action("VINSPECTOR_VIEW")); - #endif - #ifdef DFBROWSER - aActions.append(action("DFBROWSER_VIEW")); + #ifdef TINSPECTOR + aActions.append(action("TINSPECTOR_VIEW")); #endif } #endif diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 004f9a967..3970d8b32 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -15,14 +15,6 @@ #include #endif -#ifdef VINSPECTOR -#include -#ifndef HAVE_SALOME -#include -#endif -static bool VInspector_FirstCall = true; -#endif - #include #include #include @@ -67,7 +59,7 @@ static bool VInspector_FirstCall = true; #include #include -#ifdef VINSPECTOR +#ifdef TINSPECTOR #include #endif @@ -136,9 +128,6 @@ XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop) myIsTrihedronActive(true), myViewerBlockedRecursiveCount(0), myIsFirstAISContextUse(true) { - #ifdef VINSPECTOR - myCommunicator = 0; - #endif myCustomPrs = std::shared_ptr(new XGUI_CustomPrs(theWorkshop)); } @@ -270,7 +259,7 @@ bool XGUI_Displayer::display(ObjectPtr theObject, AISObjectPtr theAIS, anAISIO->Attributes()->SetFaceBoundaryDraw( Standard_True ); anAISIO->SetDisplayMode(aDispMode); aContext->Display(anAISIO, aDispMode, 0, false, true, AIS_DS_Displayed); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Display(anAISIO); #endif aDisplayed = true; @@ -300,7 +289,7 @@ bool XGUI_Displayer::erase(ObjectPtr theObject, const bool theUpdateViewer) if (!anAIS.IsNull()) { emit beforeObjectErase(theObject, anObject); aContext->Remove(anAIS, false/*update viewer*/); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Remove(anAIS); #endif aErased = true; @@ -383,7 +372,7 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) #endif aContext->Redisplay(aAISIO, false); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Redisplay(aAISIO); #endif @@ -630,7 +619,7 @@ bool XGUI_Displayer::isActive(ObjectPtr theObject) const TColStd_ListOfInteger aModes; aContext->ActivatedModes(anAIS, aModes); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->ActivatedModes(anAIS, aModes); #endif @@ -646,7 +635,7 @@ void XGUI_Displayer::setSelected(const QList& theValue return; aContext->UnhilightSelected(false); aContext->ClearSelected(false); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->ClearSelected(); #endif NCollection_DataMap> @@ -661,7 +650,7 @@ void XGUI_Displayer::setSelected(const QList& theValue // problem 2: IO is not specified, so the first found owner is selected, as a result // it might belong to another result aContext->AddOrRemoveSelected(aShape, false); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->AddOrRemoveSelected(aShape); #endif #else @@ -686,7 +675,7 @@ void XGUI_Displayer::setSelected(const QList& theValue //aContext->SetSelected(anAIS, false); // The selection in the context was cleared, so the method sets the objects are selected aContext->AddOrRemoveSelected(anAIS, false); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->AddOrRemoveSelected(anAIS); #endif } @@ -706,7 +695,7 @@ void XGUI_Displayer::clearSelected(const bool theUpdateViewer) if (!aContext.IsNull()) { aContext->UnhilightSelected(false);//UnhilightCurrents(false); aContext->ClearSelected(theUpdateViewer); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->ClearSelected(); #endif } @@ -724,7 +713,7 @@ bool XGUI_Displayer::eraseAll(const bool theUpdateViewer) if (!anIO.IsNull()) { emit beforeObjectErase(aObj, aAISObj); aContext->Remove(anIO, false/*update viewer*/); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Remove(anIO); #endif aErased = true; @@ -743,14 +732,14 @@ bool XGUI_Displayer::eraseAll(const bool theUpdateViewer) void deactivateObject(Handle(AIS_InteractiveContext) theContext, Handle(AIS_InteractiveObject) theObject -#ifdef VINSPECTOR - , VInspectorAPI_CallBack* theCallBack +#ifdef TINSPECTOR + , Handle(VInspectorAPI_CallBack) theCallBack #endif ) { if (!theObject.IsNull()) { theContext->Deactivate(theObject); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (theCallBack) theCallBack->Deactivate(theObject); #endif } @@ -763,7 +752,7 @@ void XGUI_Displayer::deactivateTrihedron(const bool theUpdateViewer) const if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron)) { Handle(AIS_Trihedron) aTrie = Handle(AIS_Trihedron)::DownCast(aTrihedron); deactivateObject(aContext, aTrie - #ifdef VINSPECTOR + #ifdef TINSPECTOR , getCallBack() #endif ); @@ -771,38 +760,38 @@ void XGUI_Displayer::deactivateTrihedron(const bool theUpdateViewer) const /// #1136 hidden axis are selected in sketch #ifdef BEFORE_TRIHEDRON_PATCH deactivateObject(aContext, aTrie->XAxis() - #ifdef VINSPECTOR + #ifdef TINSPECTOR , getCallBack() #endif ); deactivateObject(aContext, aTrie->YAxis() - #ifdef VINSPECTOR + #ifdef TINSPECTOR , getCallBack() #endif ); deactivateObject(aContext, aTrie->Axis() - #ifdef VINSPECTOR + #ifdef TINSPECTOR , getCallBack() #endif ); deactivateObject(aContext, aTrie->Position() - #ifdef VINSPECTOR + #ifdef TINSPECTOR , getCallBack() #endif ); deactivateObject(aContext, aTrie->XYPlane() - #ifdef VINSPECTOR + #ifdef TINSPECTOR , getCallBack() #endif ); deactivateObject(aContext, aTrie->XZPlane() - #ifdef VINSPECTOR + #ifdef TINSPECTOR , getCallBack() #endif ); deactivateObject(aContext, aTrie->YZPlane() - #ifdef VINSPECTOR + #ifdef TINSPECTOR , getCallBack() #endif ); @@ -985,7 +974,7 @@ void XGUI_Displayer::activateAIS(const Handle(AIS_InteractiveObject)& theIO, aContext->Activate(theIO, theMode, false); } else aContext->Activate(theIO, theMode, false); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Activate(theIO, theMode); #endif @@ -1022,13 +1011,13 @@ void XGUI_Displayer::deactivateAIS(const Handle(AIS_InteractiveObject)& theIO, if (!aContext.IsNull()) { if (theMode == -1) { aContext->Deactivate(theIO); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Deactivate(theIO); #endif } else { aContext->Deactivate(theIO, theMode); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Deactivate(theIO, theMode); #endif } @@ -1046,25 +1035,6 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const { Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); if (!aContext.IsNull() && myIsFirstAISContextUse/*&& !aContext->HasOpenedContext()*/) { -#ifdef VINSPECTOR - if (VInspector_FirstCall) { - XGUI_Displayer* aDisplayer = (XGUI_Displayer*)this; - - 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 XGUI_Displayer* aDisplayer = (XGUI_Displayer*)this; aDisplayer->myIsFirstAISContextUse = false; //aContext->OpenLocalContext(); @@ -1094,16 +1064,16 @@ bool XGUI_Displayer::displayAIS(AISObjectPtr theAIS, const bool toActivateInSele Handle(AIS_InteractiveObject) anAISIO = theAIS->impl(); if (!aContext.IsNull() && !anAISIO.IsNull()) { aContext->Display(anAISIO, 0/*wireframe*/, 0, false/*update viewer*/, true, AIS_DS_Displayed); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Display(anAISIO); #endif aDisplayed = true; aContext->Deactivate(anAISIO); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Deactivate(anAISIO); #endif aContext->Load(anAISIO); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Load(anAISIO); #endif if (toActivateInSelectionModes) { @@ -1129,7 +1099,7 @@ bool XGUI_Displayer::eraseAIS(AISObjectPtr theAIS, const bool theUpdateViewer) Handle(AIS_InteractiveObject) anAISIO = theAIS->impl(); if (!anAISIO.IsNull() && aContext->IsDisplayed(anAISIO)) { aContext->Remove(anAISIO, false/*update viewer*/); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Remove(anAISIO); #endif aErased = true; @@ -1310,7 +1280,7 @@ bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO, // The result is the selection of the first IO is lost. TColStd_ListOfInteger aTColModes; aContext->ActivatedModes(theIO, aTColModes); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->ActivatedModes(theIO, aTColModes); #endif TColStd_ListIteratorOfListOfInteger itr( aTColModes ); @@ -1332,7 +1302,7 @@ bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO, if (isDeactivated) { // the selection from the previous activation modes should be cleared manually (#26172) //theIO->ClearSelected(); - //#ifdef VINSPECTOR + //#ifdef TINSPECTOR //if (getCallBack()) getCallBack()->ClearSelected(theIO); //#endif #ifndef CLEAR_OUTDATED_SELECTION_BEFORE_REDISPLAY @@ -1355,7 +1325,7 @@ bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO, aContext->SelectionManager()->Load(theIO); } - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Load(theIO); #endif } @@ -1513,7 +1483,7 @@ void XGUI_Displayer::displayTrihedron(bool theToDisplay) const Standard_True /* update viewer*/, Standard_False /* allow decomposition */, AIS_DS_Displayed /* xdisplay status */); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Display(aTrihedron); #endif @@ -1525,7 +1495,7 @@ void XGUI_Displayer::displayTrihedron(bool theToDisplay) const deactivateTrihedron(false); aContext->Erase(aTrihedron); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (getCallBack()) getCallBack()->Remove(aTrihedron); #endif } @@ -1543,24 +1513,6 @@ QIntList XGUI_Displayer::activeSelectionModes() const return aModes; } -#ifdef VINSPECTOR -void XGUI_Displayer::setCommunicator(VInspectorAPI_Communicator* theCommunicator) -{ - myCommunicator = theCommunicator; -} - -void XGUI_Displayer::setVInspectorVisible(const bool theVisible) -{ - if (myCommunicator) - myCommunicator->setVisible(true); -} - -VInspectorAPI_CallBack* XGUI_Displayer::getCallBack() const -{ - return myCommunicator ? myCommunicator->getCallBack() : NULL; -} -#endif - void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) theContext, const NCollection_DataMap>& theShapesToBeSelected) diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 6374f157b..b4398e2e7 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -33,8 +33,7 @@ class ModuleBase_ViewerPrs; class ModelAPI_Feature; class XGUI_Workshop; -#ifdef VINSPECTOR -class VInspectorAPI_Communicator; +#ifdef TINSPECTOR class VInspectorAPI_CallBack; #endif @@ -259,12 +258,10 @@ class XGUI_EXPORT XGUI_Displayer: public QObject /// Selection modes will be returned according to TopAbs_ShapeEnum QIntList activeSelectionModes() const; -#ifdef VINSPECTOR - void setVInspectorVisible(const bool theVisible); - - void setCommunicator(VInspectorAPI_Communicator* theCommunicator); - - VInspectorAPI_CallBack* getCallBack() const; +#ifdef TINSPECTOR + void setCallBack(const Handle(VInspectorAPI_CallBack)& theCallBack) + { myVCallBack = theCallBack; } + Handle(VInspectorAPI_CallBack) getCallBack() const { return myVCallBack; } #endif /// Converts shape type (TopAbs_ShapeEnum) to selection mode /// \param theShapeType a shape type from TopAbs_ShapeEnum @@ -360,8 +357,8 @@ private: protected: /// Reference to workshop XGUI_Workshop* myWorkshop; -#ifdef VINSPECTOR - VInspectorAPI_Communicator* myCommunicator; ///< callback to debug display, show/hide it +#ifdef TINSPECTOR + Handle(VInspectorAPI_CallBack) myVCallBack; #endif /// A container for selection filters Handle(SelectMgr_AndFilter) myAndFilter; diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index df975ca95..6a85f224d 100755 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -26,7 +26,7 @@ #include -#ifdef VINSPECTOR +#ifdef TINSPECTOR #include #endif @@ -66,7 +66,7 @@ void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& the Handle(SelectMgr_EntityOwner) anOwner = theSelectedOwners(i); aContext->AddOrRemoveSelected(anOwner, isUpdateViewer); - #ifdef VINSPECTOR + #ifdef TINSPECTOR if (myWorkshop->displayer()->getCallBack()) myWorkshop->displayer()->getCallBack()->AddOrRemoveSelected(anOwner); #endif diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index a88f5a4ca..baa7594cb 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -107,11 +107,14 @@ #include -#ifdef DFBROWSER +#ifdef TINSPECTOR #include #include -#include -static bool DFBrowser_FirstCall = true; +#include +#include +static TInspector_Communicator* MyTCommunicator; +static Handle(VInspector_CallBack) MyVCallBack; + #endif #ifdef _DEBUG @@ -1372,24 +1375,35 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) } else if (theId == "SHOW_FEATURE_CMD") { highlightFeature(aObjects); } -#ifdef VINSPECTOR - else if (theId == "VINSPECTOR_VIEW") { - displayer()->setVInspectorVisible(true); - } -#endif -#ifdef DFBROWSER - else if (theId == "DFBROWSER_VIEW") { - if (DFBrowser_FirstCall) { - Handle(CDF_Application) anApplication = CDF_Session::CurrentSession()->CurrentApplication(); - DFBrowserAPI_Communicator* aCommunicator = - DFBrowserAPI_Communicator::loadPluginLibrary("TKDFBrowser.dll"); - if (aCommunicator) { - aCommunicator->setApplication(anApplication); +#ifdef TINSPECTOR + else if (theId == "TINSPECTOR_VIEW") { + Handle(CDF_Application) anApplication = CDF_Session::CurrentSession()->CurrentApplication(); + if (!anApplication.IsNull()) + { + if (!MyTCommunicator) + { + MyTCommunicator = new TInspector_Communicator(); + + NCollection_List aParameters; + aParameters.Append(anApplication); Handle(AIS_InteractiveContext) aContext = viewer()->AISContext(); - if (aContext) - aCommunicator->setContext(aContext); + if (!aContext.IsNull()) + aParameters.Append(aContext); + + MyVCallBack = new VInspector_CallBack(); + myDisplayer->setCallBack(MyVCallBack); + #ifndef HAVE_SALOME + AppElements_Viewer* aViewer = mainWindow()->viewer(); + if (aViewer) + aViewer->setCallBack(MyVCallBack); + #endif + aParameters.Append(MyVCallBack); + + MyTCommunicator->init(aParameters); + MyTCommunicator->Activate("TKVInspector"); // to have filled callback by model + MyTCommunicator->Activate("TKDFBrowser"); } - DFBrowser_FirstCall = false; + MyTCommunicator->setVisible(true); } } #endif