From: nds Date: Fri, 9 Dec 2016 04:48:49 +0000 (+0300) Subject: Correction for additional debug information X-Git-Tag: before_porting_8.2.0~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b912c517a85602b2e6e2045262d4ac1d7152fbfd;p=modules%2Fshaper.git Correction for additional debug information --- diff --git a/src/Model/Model_Application.cpp b/src/Model/Model_Application.cpp index ac84508a2..875e1537f 100644 --- a/src/Model/Model_Application.cpp +++ b/src/Model/Model_Application.cpp @@ -9,12 +9,6 @@ #include -#ifdef DFBROWSER -#include - -static bool FirstCall = true; -#endif - IMPLEMENT_STANDARD_HANDLE(Model_Application, TDocStd_Application) IMPLEMENT_STANDARD_RTTIEXT(Model_Application, TDocStd_Application) @@ -23,14 +17,6 @@ static Handle_Model_Application TheApplication = new Model_Application; //======================================================================= Handle(Model_Application) Model_Application::getApplication() { -#ifdef DFBROWSER - if (FirstCall) { - DFBrowserAPI_Communicator* aCommunicator = - DFBrowserAPI_Communicator::loadPluginLibrary("DFBrowser.dll"); - aCommunicator->setApplication(TheApplication); - FirstCall = false; - } -#endif return TheApplication; } diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index ca942c29c..c140d618c 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -140,6 +140,13 @@ IF(NOT ${HAVE_SALOME}) SET(PROJECT_INCLUDES ${PROJECT_INCLUDES} ${APPELEMENTS_INCLUDE_DIR}) ENDIF(NOT ${HAVE_SALOME}) +IF(EXISTS ${DFBROWSER_ROOT_DIR}) + SET(PROJECT_LIBRARIES ${PROJECT_LIBRARIES} ${DFBrowserAPI}) + SET(PROJECT_INCLUDES ${PROJECT_INCLUDES} ${DFBROWSER_INCLUDE_DIR}) + + ADD_DEFINITIONS(-DDFBROWSER) +ENDIF() + INCLUDE_DIRECTORIES(${PROJECT_INCLUDES}) LINK_DIRECTORIES($ENV{PYTHON_LIB_DIR}) diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 5ec4d3f08..72025823a 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -45,7 +45,6 @@ #include #include - XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent) : QObject(theParent), myWorkshop(theParent), @@ -152,6 +151,15 @@ 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); +#endif + buildObjBrowserMenu(); buildViewerMenu(); } @@ -329,6 +337,16 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() if (myWorkshop->canChangeDeflection()) action("DEFLECTION_CMD")->setEnabled(true); + #ifdef _DEBUG + #ifdef VINSPECTOR + action("VINSPECTOR_VIEW")->setEnabled(true); + #endif + #ifdef DFBROWSER + action("DFBROWSER_VIEW")->setEnabled(true); + #endif + #endif + + ModuleBase_IModule* aModule = myWorkshop->module(); if (aModule) aModule->updateObjectBrowserMenu(myActions); @@ -558,6 +576,16 @@ void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const aActions.append(action("CLEAN_HISTORY_CMD")); aActions.append(action("DELETE_CMD")); } +#ifdef _DEBUG + if (aSelected == 0) { + #ifdef VINSPECTOR + aActions.append(action("VINSPECTOR_VIEW")); + #endif + #ifdef DFBROWSER + aActions.append(action("DFBROWSER_VIEW")); + #endif + } +#endif theMenu->addActions(aActions); addFeatures(theMenu); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index b90a936c6..0d718aae1 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -58,6 +58,10 @@ #include #include +#ifdef VINSPECTOR +#include +#endif + #include #include @@ -117,6 +121,9 @@ XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop) : myWorkshop(theWorkshop), myNeedUpdate(false), myIsTrihedronActive(true), myViewerBlockedRecursiveCount(0) { + #ifdef VINSPECTOR + myContextCallBack = 0; + #endif myCustomPrs = std::shared_ptr(new XGUI_CustomPrs(theWorkshop)); } @@ -248,6 +255,9 @@ 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 + if (myContextCallBack) myContextCallBack->Display(anAISIO); + #endif aDisplayed = true; emit objectDisplayed(theObject, theAIS); @@ -275,6 +285,9 @@ bool XGUI_Displayer::erase(ObjectPtr theObject, const bool theUpdateViewer) if (!anAIS.IsNull()) { emit beforeObjectErase(theObject, anObject); aContext->Remove(anAIS, false/*update viewer*/); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->Remove(anAIS); + #endif ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::erase -- Remove"); aErased = true; } @@ -363,6 +376,9 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) aContext->Deactivate(aAISIO, 0); #endif + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->Redisplay(aAISIO); + #endif ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::redisplay -- Redisplay"); if (aNeedToRestoreSelection) @@ -409,6 +425,9 @@ void XGUI_Displayer::deactivate(ObjectPtr theObject, const bool theUpdateViewer) deactivateAIS(anAIS); // the selection from the previous activation modes should be cleared manually (#26172) aContext->LocalContext()->ClearOutdatedSelection(anAIS, true); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->ClearOutdatedSelection(anAIS); + #endif ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::deactivate -- ClearOutdatedSelection"); if (theUpdateViewer) @@ -608,6 +627,10 @@ bool XGUI_Displayer::isActive(ObjectPtr theObject) const TColStd_ListOfInteger aModes; aContext->ActivatedModes(anAIS, aModes); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->ActivatedModes(anAIS, aModes); + #endif + return aModes.Extent() > 0; } @@ -621,6 +644,9 @@ void XGUI_Displayer::setSelected(const QList& theValue if (aContext->HasOpenedContext()) { aContext->UnhilightSelected(false); aContext->ClearSelected(false); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->ClearSelected(); + #endif NCollection_DataMap> aShapesToBeSelected; @@ -633,6 +659,9 @@ 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 + if (myContextCallBack) myContextCallBack->AddOrRemoveSelected(aShape); + #endif #else NCollection_Map aPresentations; if (aShapesToBeSelected.IsBound(aShape)) @@ -655,6 +684,9 @@ 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 + if (myContextCallBack) myContextCallBack->AddOrRemoveSelected(anAIS); + #endif } } } @@ -687,6 +719,9 @@ void XGUI_Displayer::clearSelected(const bool theUpdateViewer) if (!aContext.IsNull()) { aContext->UnhilightCurrents(false); aContext->ClearSelected(theUpdateViewer); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->ClearSelected(); + #endif } } @@ -702,6 +737,9 @@ bool XGUI_Displayer::eraseAll(const bool theUpdateViewer) if (!anIO.IsNull()) { emit beforeObjectErase(aObj, aAISObj); aContext->Remove(anIO, false/*update viewer*/); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->Remove(anIO); + #endif aErased = true; } } @@ -719,10 +757,16 @@ bool XGUI_Displayer::eraseAll(const bool theUpdateViewer) void deactivateObject(Handle(AIS_InteractiveContext) theContext, Handle(AIS_InteractiveObject) theObject, +#ifdef VINSPECTOR + VInspectorAPI_CallBack* theCallBack, +#endif const bool theClear = true) { if (!theObject.IsNull()) { theContext->Deactivate(theObject); + #ifdef VINSPECTOR + if (theCallBack) theCallBack->Deactivate(theObject); + #endif ModuleBase_Tools::selectionInfo(theContext, "XGUI_Displayer::deactivateObject -- Deactivate"); //if (theClear) { //theObject->ClearSelected(); @@ -737,19 +781,19 @@ void XGUI_Displayer::deactivateTrihedron(const bool theUpdateViewer) const Handle(AIS_InteractiveContext) aContext = AISContext(); if (!aTrihedron.IsNull() && aContext->IsDisplayed(aTrihedron)) { Handle(AIS_Trihedron) aTrie = Handle(AIS_Trihedron)::DownCast(aTrihedron); - deactivateObject(aContext, aTrie); + deactivateObject(aContext, aTrie, myContextCallBack); /// #1136 hidden axis are selected in sketch /// workaround for Cascade: there is a crash in AIS_LocalContext::ClearOutdatedSelection /// for Position AIS object in SelectionModes. - deactivateObject(aContext, aTrie->XAxis()); - deactivateObject(aContext, aTrie->YAxis()); - deactivateObject(aContext, aTrie->Axis()); - deactivateObject(aContext, aTrie->Position()); + deactivateObject(aContext, aTrie->XAxis(), myContextCallBack); + deactivateObject(aContext, aTrie->YAxis(), myContextCallBack); + deactivateObject(aContext, aTrie->Axis(), myContextCallBack); + deactivateObject(aContext, aTrie->Position(), myContextCallBack); - deactivateObject(aContext, aTrie->XYPlane()); - deactivateObject(aContext, aTrie->XZPlane()); - deactivateObject(aContext, aTrie->YZPlane()); + deactivateObject(aContext, aTrie->XYPlane(), myContextCallBack); + deactivateObject(aContext, aTrie->XZPlane(), myContextCallBack); + deactivateObject(aContext, aTrie->YZPlane(), myContextCallBack); if (theUpdateViewer) updateViewer(); @@ -929,6 +973,9 @@ void XGUI_Displayer::activateAIS(const Handle(AIS_InteractiveObject)& theIO, aContext->Activate(theIO, theMode, false); } else aContext->Activate(theIO, theMode, false); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->Activate(theIO, theMode); + #endif // the fix from VPA for more suitable selection of sketcher lines if (theIO->Width() > 1) { @@ -962,10 +1009,18 @@ void XGUI_Displayer::deactivateAIS(const Handle(AIS_InteractiveObject)& theIO, { Handle(AIS_InteractiveContext) aContext = AISContext(); if (!aContext.IsNull()) { - if (theMode == -1) + if (theMode == -1) { aContext->Deactivate(theIO); - else + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->Deactivate(theIO); + #endif + } + else { aContext->Deactivate(theIO, theMode); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->Deactivate(theIO, theMode); + #endif + } ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::deactivateAIS -- Deactivate"); #ifdef DEBUG_DEACTIVATE_AIS @@ -1008,9 +1063,18 @@ 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 + if (myContextCallBack) myContextCallBack->Display(anAISIO); + #endif aDisplayed = true; aContext->Deactivate(anAISIO); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->Deactivate(anAISIO); + #endif aContext->Load(anAISIO); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->Load(anAISIO); + #endif if (toActivateInSelectionModes) { if (aContext->HasOpenedContext()) { if (myActiveSelectionModes.size() == 0) @@ -1036,6 +1100,9 @@ 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 + if (myContextCallBack) myContextCallBack->Remove(anAISIO); + #endif ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::eraseAIS -- Remove"); aErased = true; } @@ -1215,6 +1282,9 @@ 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 + if (myContextCallBack) myContextCallBack->ActivatedModes(theIO, aTColModes); + #endif TColStd_ListIteratorOfListOfInteger itr( aTColModes ); QIntList aModesActivatedForIO; bool isDeactivated = false; @@ -1232,7 +1302,13 @@ 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 + if (myContextCallBack) myContextCallBack->ClearSelected(theIO); + #endif aContext->LocalContext()->ClearOutdatedSelection(theIO, true); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->ClearOutdatedSelection(theIO); + #endif ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::activate -- ClearSelected/ClearOutdatedSelection"); // For performance issues @@ -1244,6 +1320,9 @@ bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO, // loading the interactive object allowing the decomposition if (aTColModes.IsEmpty()) { aContext->Load(theIO, -1, true); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->Load(theIO); + #endif } // trihedron AIS check should be after the AIS loading. @@ -1397,6 +1476,9 @@ void XGUI_Displayer::displayTrihedron(bool theToDisplay) const Standard_True /* update viewer*/, Standard_False /* allow decomposition */, AIS_DS_Displayed /* xdisplay status */); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->Display(aTrihedron); + #endif if (!isTrihedronActive()) deactivateTrihedron(false); @@ -1408,6 +1490,9 @@ void XGUI_Displayer::displayTrihedron(bool theToDisplay) const // the selection from the previous activation modes should be cleared manually (#26172) aContext->Erase(aTrihedron); + #ifdef VINSPECTOR + if (myContextCallBack) myContextCallBack->Remove(aTrihedron); + #endif } updateViewer(); @@ -1423,8 +1508,20 @@ QIntList XGUI_Displayer::activeSelectionModes() const return aModes; } +#ifdef VINSPECTOR +void XGUI_Displayer::setCallBack(VInspectorAPI_CallBack* theCallBack) +{ + myContextCallBack = theCallBack; +} + +VInspectorAPI_CallBack* XGUI_Displayer::getCallBack() const +{ + return myContextCallBack; +} +#endif + void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) theContext, - const NCollection_DataMap>& theShapesToBeSelected) { Handle(AIS_LocalContext) aLContext = theContext->LocalContext(); diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index ea3af4c2c..8ff49c78b 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -33,6 +33,10 @@ class ModuleBase_ViewerPrs; class ModelAPI_Feature; class XGUI_Workshop; +#ifdef VINSPECTOR +class VInspectorAPI_CallBack; +#endif + /**\class XGUI_Displayer * \ingroup GUI * \brief Displayer. Provides mechanizm of display/erase of objects in the viewer @@ -254,7 +258,13 @@ class XGUI_EXPORT XGUI_Displayer: public QObject /// Selection modes will be returned according to TopAbs_ShapeEnum QIntList activeSelectionModes() const; +#ifdef VINSPECTOR + /// Sets callback to debug display + /// \param theCallBack a callback instance + void setCallBack(VInspectorAPI_CallBack* theCallBack); + VInspectorAPI_CallBack* getCallBack() const; +#endif /// Converts shape type (TopAbs_ShapeEnum) to selection mode /// \param theShapeType a shape type from TopAbs_ShapeEnum static int getSelectionMode(int theShapeType); @@ -350,7 +360,9 @@ private: protected: /// Reference to workshop XGUI_Workshop* myWorkshop; - +#ifdef VINSPECTOR + VInspectorAPI_CallBack* myContextCallBack; ///< callback to debug display +#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 b4a2bbc5f..894198d3d 100755 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -26,6 +26,10 @@ #include +#ifdef VINSPECTOR +#include +#endif + XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) : QObject(theParent), myWorkshop(theParent) @@ -63,6 +67,10 @@ void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& the continue; aContext->AddOrRemoveSelected(anOwner, isUpdateViewer); + #ifdef VINSPECTOR + if (myWorkshop->displayer()->getCallBack()) + myWorkshop->displayer()->getCallBack()->AddOrRemoveSelected(anOwner); + #endif } } ModuleBase_Tools::selectionInfo(aContext, diff --git a/src/XGUI/XGUI_ViewerProxy.cpp b/src/XGUI/XGUI_ViewerProxy.cpp index 770494651..1b9e3fb0e 100644 --- a/src/XGUI/XGUI_ViewerProxy.cpp +++ b/src/XGUI/XGUI_ViewerProxy.cpp @@ -12,14 +12,6 @@ #include #endif -#ifdef VINSPECTOR -#include -#include - -static bool FirstCall = true; - -#endif - #include #include @@ -49,15 +41,6 @@ Handle(AIS_InteractiveContext) XGUI_ViewerProxy::AISContext() const #else aContext = myWorkshop->mainWindow()->viewer()->AISContext(); #endif - -#ifdef VINSPECTOR - if (FirstCall) { - VInspectorAPI_PluginMgr::activateVInspector("VInspector.dll", aContext); - FirstCall = false; - } -#endif - - return aContext; } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 47bfd5355..d80fcaf25 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -103,6 +103,18 @@ #include +#ifdef VINSPECTOR +#include +#include +static bool VInspector_FirstCall = true; +#endif + +#ifdef DFBROWSER +#include +#include +static bool DFBrowser_FirstCall = true; +#endif + #ifdef _DEBUG #include #include @@ -1337,6 +1349,33 @@ void XGUI_Workshop::onContextMenuCommand(const QString& theId, bool isChecked) } else if (theId == "SHOW_FEATURE_CMD") { highlightFeature(aObjects); } +#ifdef VINSPECTOR + else if (theId == "VINSPECTOR_VIEW") { + if (VInspector_FirstCall) { + VInspectorAPI_Communicator* aCommunicator = VInspectorAPI_PluginMgr::activateVInspector( + "VInspector.dll", viewer()->AISContext()); + displayer()->setCallBack(aCommunicator->getCallBack()); + #ifndef HAVE_SALOME + AppElements_Viewer* aViewer = mainWindow()->viewer(); + if (aViewer) + aViewer->setCallBack(aCommunicator->getCallBack()); + #endif + VInspector_FirstCall = false; + } + } +#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("DFBrowser.dll"); + aCommunicator->setApplication(anApplication); + DFBrowser_FirstCall = false; + } + } +#endif } //**************************************************************