Hurricane Design Viewer


CellViewer.h
1 // -*- C++ -*-
2 //
3 // This file is part of the Coriolis Software.
4 // Copyright (c) UPMC 2008-2018, All Rights Reserved
5 //
6 // +-----------------------------------------------------------------+
7 // | H U R R I C A N E |
8 // | V L S I B a c k e n d D a t a - B a s e |
9 // | |
10 // | Author : Jean-Paul CHAPUT |
11 // | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
12 // | =============================================================== |
13 // | C++ Header : "./hurricane/viewer/CellViewer.h" |
14 // +-----------------------------------------------------------------+
15 
16 
17 #pragma once
18 #include <list>
19 #include <map>
20 #include <functional>
21 #include <boost/any.hpp>
22 #include <QIcon>
23 #include <QMainWindow>
24 class QEvent;
25 class QKeyEvent;
26 class QAction;
27 class QMenu;
28 class QPrinter;
29 #include "hurricane/Commons.h"
30 #include "hurricane/Observer.h"
31 #include "hurricane/Name.h"
32 #include "hurricane/Occurrence.h"
33 #include "hurricane/viewer/MoveCommand.h"
34 #include "hurricane/viewer/ZoomCommand.h"
35 #include "hurricane/viewer/RulerCommand.h"
36 #include "hurricane/viewer/SelectCommand.h"
37 #include "hurricane/viewer/HierarchyCommand.h"
38 #include "hurricane/viewer/CellWidget.h"
39 
40 
41 namespace Hurricane {
42 
43 
44  class Cell;
45 //class MapView;
46  class GotoWidget;
47  class MousePositionWidget;
48  class ControllerWidget;
49  class ScriptWidget;
50  class CellViewer;
51 
52 
53 // -------------------------------------------------------------------
54 // Class : "CellObserver".
55 
56  // class CellObserver : public Observer<CellViewer> {
57  // public:
58  // inline CellObserver ( CellViewer* );
59  // virtual void notify ( unsigned int flags );
60  // private:
61  // CellObserver ( const CellObserver& );
62  // };
63 
64 
65  // inline CellObserver::CellObserver ( CellViewer* owner )
66  // : Observer<CellViewer>(owner)
67  // { }
68 
69 
70 // -------------------------------------------------------------------
71 // Class : "CellViewer".
72 
73  class CellViewer : public QMainWindow {
74  Q_OBJECT;
75 
76  public:
77  enum { CellHistorySize = 10 };
78  enum Flag { InCellChange = 0x0001 };
79  enum FunctionFlag { NoFlags = 0x0000
80  , TopMenu = 0x0001 };
81  private:
82  typedef std::map< const QString, boost::any > ActionLut;
83  typedef bool (QWidget::* SlotMethod)();
84  public:
85  static void notify ( CellViewer*, unsigned int flags );
86  public:
87  CellViewer ( QWidget* parent=NULL );
88  virtual ~CellViewer ();
89  inline bool isToolInterrupted () const;
90  QMenu* createDebugMenu ();
91  bool hasMenu ( const QString& path ) const;
92  bool hasMenuAction ( const QString& path ) const;
93  QAction* getMenuAction ( const QString& path ) const;
94  QAction* addMenu ( const QString& path
95  , std::string text
96  , unsigned int flags=NoFlags
97  );
98  bool addToMenu ( const QString& path
99  , QString beforePath="" );
100  QAction* addToMenu ( const QString& path
101  , std::string text
102  , std::string textTip
103  , std::function< void() >
104  , QIcon icon=QIcon()
105  , QString beforePath="" );
106  QAction* addToMenu ( const QString& path
107  , std::string text
108  , std::string textTip
109  , std::string scriptPath
110  , QString beforePath="" );
111  QAction* addToMenu ( QString path
112  , QString text
113  , QString textTip
114  , const QKeySequence& shortCut
115  , QIcon icon =QIcon()
116  , QString beforePath="" );
117  inline void setEnableRedrawInterrupt ( bool );
118  inline void setApplicationName ( const QString& );
119  inline void setDbuMode ( int );
120  inline Observer<CellViewer>* getCellObserver ();
121  Cell* getCell () const;
122  virtual void setCell ( Cell* );
123  void renameCell ( const char* );
124  virtual Cell* getCellFromDb ( const char* );
125  inline CellWidget* getCellWidget ();
126  inline const CellWidget* getCellWidget () const;
127  inline ControllerWidget* getControllerWidget ();
128  void setAnonNetSelectable ( bool );
129  void select ( Occurrence& );
130  void unselect ( Occurrence& );
131  void unselectAll ();
132  inline void setLayerVisible ( const Name& layer, bool visible );
133  void reframe ( const Box& , bool historyEnable=true );
134  void runScript ( QString scriptPath );
135  virtual CellViewer* vcreate () const;
136  virtual std::string _getString () const;
137  public slots:
138  void doAction ();
139  void doGoto ();
140  void changeSelectionMode ();
141  void setShowSelection ( bool );
142  void setCumulativeSelection ( bool );
143  void setState ( shared_ptr<CellWidget::State>& );
144  void removeHistory ( Cell* );
145  void openHistoryCell ();
146  void openDesignBlob ();
147  void saveDesignBlob ();
148  void printDisplay ();
149  void print ( QPrinter* );
150  void imageDisplay ();
151  void raiseToolInterrupt ();
152  void clearToolInterrupt ();
153  void runScriptWidget ();
154  void runStressScript ();
155  inline void emitCellAboutToChange ();
156  inline void emitCellChanged ();
157  inline void emitCellPreModificated ();
158  inline void emitCellPostModificated ();
159  signals:
160  void cellLoadedFromDisk ( Cell* );
161  void showSelectionToggled ( bool );
162  void stateChanged ( shared_ptr<CellWidget::State>& );
163  void redrawCellWidget ();
164  void cellPreModificated ();
165  void cellPostModificated ();
166  protected:
167  void createMenus ();
168  void refreshTitle ();
169  void refreshHistory ();
170  void rebuildHistory ();
171  private:
172  QString _getAbsWidgetPath ( const QString& relPath ) const;
173  QAction* _getParentMenu ( const QString& ) const;
174  void _runScript ( QString scriptPath );
175 
176  protected:
177  static QString _prefixWPath;
178  Observer<CellViewer> _cellObserver;
179  QString _applicationName;
180  QAction* _openAction;
181  QAction* _cellHistoryAction[CellHistorySize];
182  QAction* _showSelectionAction;
183  QMenu* _debugMenu;
184  ActionLut _actionCallbacks;
185  // MapView* _mapView;
186  MousePositionWidget* _mousePosition;
187  ControllerWidget* _controller;
188  ScriptWidget* _script;
189  GotoWidget* _goto;
190  CellWidget* _cellWidget;
191  MoveCommand _moveCommand;
192  ZoomCommand _zoomCommand;
193  RulerCommand _rulerCommand;
194  SelectCommand _selectCommand;
195  HierarchyCommand _hierarchyCommand;
196  list< shared_ptr<CellWidget::State> >
197  _cellHistory;
198  bool _firstShow;
199  bool _toolInterrupt;
200  unsigned int _flags;
201  UpdateState _updateState;
202  QString _pyScriptName;
203  };
204 
205 
206 // Inline Functions.
207  inline bool CellViewer::isToolInterrupted () const { return _toolInterrupt; }
208  inline Observer<CellViewer>* CellViewer::getCellObserver () { return &_cellObserver; }
209  inline CellWidget* CellViewer::getCellWidget () { return _cellWidget; }
210  inline const CellWidget* CellViewer::getCellWidget () const { return _cellWidget; }
211  inline ControllerWidget* CellViewer::getControllerWidget () { return _controller; }
212  inline void CellViewer::setApplicationName ( const QString& name ) { _applicationName = name; }
213  inline void CellViewer::setLayerVisible ( const Name& layer, bool visible ) { _cellWidget->setLayerVisible(layer,visible); }
214  inline void CellViewer::emitCellAboutToChange () { _flags |= InCellChange; emit cellPreModificated(); }
215  inline void CellViewer::emitCellChanged () { _flags &= ~InCellChange; emit cellPostModificated(); }
216  inline void CellViewer::emitCellPreModificated () { emit cellPreModificated(); }
217  inline void CellViewer::emitCellPostModificated () { emit cellPostModificated(); }
218 
219  inline void CellViewer::setEnableRedrawInterrupt ( bool state )
220  { _cellWidget->setEnableRedrawInterrupt(state); }
221 
222  inline void CellViewer::setDbuMode ( int mode )
223  { _cellWidget->setDbuMode(mode); }
224 
225 
226 } // Hurricane namespace.
227 
228 
229 GETSTRING_POINTER_SUPPORT(Hurricane::CellViewer)
230 IOSTREAM_POINTER_SUPPORT(Hurricane::CellViewer)
A simple top level window embedding the CellWidget.
Definition: CellViewer.h:73
virtual Cell * getCellFromDb(const char *)
ControllerWidget * getControllerWidget()
Definition: CellViewer.h:211
CellWidget * getCellWidget()
Definition: CellViewer.h:209
void setEnableRedrawInterrupt(bool)
Definition: CellViewer.h:219
void unselect(Occurrence &)
virtual void setCell(Cell *)
void setAnonNetSelectable(bool)
CellViewer(QWidget *parent=NULL)
void setApplicationName(const QString &)
Definition: CellViewer.h:212
void select(Occurrence &)
bool isToolInterrupted() const
Definition: CellViewer.h:207
void renameCell(const char *)
void setLayerVisible(const Name &layer, bool visible)
Definition: CellViewer.h:213
Cell * getCell() const
The Widget to display a Cell.
Definition: CellWidget.h:82


Generated by doxygen 1.9.1 on Thu Aug 11 2022 Return to top of page
Hurricane Design Viewer Copyright © 2008-2020 Sorbonne Universite All rights reserved