]> SALOME platform Git repositories - modules/geom.git/blob - src/DependencyTree/DependencyTree.cxx
Salome HOME
Correct checking objects.
[modules/geom.git] / src / DependencyTree / DependencyTree.cxx
1 // Copyright (C) 2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include <GraphicsView_Object.h>
21
22 #include "DependencyTree.h"
23 #include "DependencyTree_ViewModel.h"
24
25 #include <QGraphicsItem>
26 #include <QPolygonF>
27 #include <QPointF>
28 #include <QMenu>
29 #include <QPen>
30 #include <QFont>
31 #include <QString>
32 #include <QGraphicsPolygonItem>
33 #include <QGraphicsSimpleTextItem>
34 #include <QWidgetAction>
35 #include <QSpinBox>
36 #include <QLabel>
37 #include <QCheckBox>
38
39 #include <QtxActionToolMgr.h>
40
41 #include "DependencyTree_View.h"
42 #include <DependencyTree_Selector.h>
43
44 #include <GraphicsView_Viewer.h>
45 #include <GraphicsView_ViewFrame.h>
46 #include <GraphicsView_Scene.h>
47
48 #include <SUIT_Session.h>
49 #include <SUIT_ViewManager.h>
50 #include <SUIT_SelectionMgr.h>
51 #include <SalomeApp_Application.h>
52
53
54 #include <QList>
55 #include <QGraphicsView>
56
57
58 #include <iostream>
59 DependencyTree::DependencyTree()
60 {
61           SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
62           SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
63             if ( !app ) return;
64
65             LightApp_SelectionMgr* mySelMgr = app->selectionMgr();
66
67             SUIT_ViewManager *svm = app->getViewManager(GraphicsView_Viewer::Type(), false );
68
69             if(!svm) {
70               myView = new DependencyTree_View();
71               DependencyTree_ViewModel* ViewModel = new DependencyTree_ViewModel(GraphicsView_Viewer::Type(), myView);
72               SUIT_ViewManager *svm = app->createViewManager( ViewModel );
73               new DependencyTree_Selector( ViewModel,
74                          ( SUIT_SelectionMgr*)mySelMgr );
75               SUIT_ViewWindow* svw = svm->getActiveView();
76               GraphicsView_ViewFrame* aViewFrame = 0;
77               if (!svw) svw = svm->createViewWindow();
78               if (svw) aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>(svw);
79
80               myView->init( aViewFrame );
81               svm->setTitle("DEPENDENCY_TREE");
82             }
83             else {
84           if( DependencyTree_ViewModel* viewModel = dynamic_cast<DependencyTree_ViewModel*>( svm->getViewModel() ) )
85                 if( DependencyTree_View* view = dynamic_cast<DependencyTree_View*>( viewModel->getActiveViewPort() ) ) {
86                   svm->getActiveView()->setFocus();
87                   view->updateModel();
88                 }
89             }
90
91
92 }
93
94 DependencyTree::~DependencyTree()
95 {
96 }