Statistics
| Branch: | Revision:

root / src / tkenv / modinsp.h @ e1750c09

History | View | Annotate | Download (5.63 KB)

1
//==========================================================================
2
//  MODINSP.H - part of
3
//
4
//                     OMNeT++/OMNEST
5
//            Discrete System Simulation in C++
6
//
7
//==========================================================================
8

    
9
/*--------------------------------------------------------------*
10
  Copyright (C) 1992-2008 Andras Varga
11
  Copyright (C) 2006-2008 OpenSim Ltd.
12

13
  This file is distributed WITHOUT ANY WARRANTY. See the file
14
  `license' for details on this and other legal matters.
15
*--------------------------------------------------------------*/
16

    
17
#ifndef __MODINSP_H
18
#define __MODINSP_H
19

    
20
#include <map>
21
#include <tk.h>
22
#include "csimplemodule.h"
23
#include "cchannel.h"
24
#include "cgate.h"
25
#include "cmessage.h"
26
#include "cpar.h"
27
#include "carray.h"
28
#include "coutvector.h"
29
#include "cstatistic.h"
30
#include "cdensityestbase.h"
31
#include "cdisplaystring.h"
32
#include "cqueue.h"
33
#include "ccompoundmodule.h"
34
#include "cchannel.h"
35
#include "cdataratechannel.h"
36

    
37
#include "intxtypes.h"
38
#include "logbuffer.h"
39
#include "inspector.h"
40
#include "envirbase.h"
41
#include "graphlayouter.h"
42

    
43
NAMESPACE_BEGIN
44

    
45

    
46
class TModuleWindow : public TInspector
47
{
48
   protected:
49
      char textWidget[128];
50
      std::set<int> excludedModuleIds;
51
   public:
52
      TModuleWindow(cObject *obj,int typ,const char *geom,void *dat=NULL);
53
      virtual void createWindow();
54
      virtual void update();
55

    
56
      virtual void printLastLineOf(const LogBuffer& logBuffer);
57
      virtual void redisplay(const LogBuffer& logBuffer);
58

    
59
      virtual int inspectorCommand(Tcl_Interp *interp, int argc, const char **argv);
60

    
61
      static void printLastLineOf(Tcl_Interp *interp, const char *textWidget, const LogBuffer& logBuffer, const std::set<int>& excludedModuleIds);
62
      static void redisplay(Tcl_Interp *interp, const char *textWidget, const LogBuffer& logBuffer, cModule *mod, const std::set<int>& excludedModuleIds);
63
};
64

    
65

    
66
class TGraphicalModWindow : public TInspector
67
{
68
   protected:
69
      char canvas[128];
70
      bool needs_redraw;
71
      int32 random_seed;
72
      bool not_drawn;
73

    
74
      struct Point {int x,y;};
75
      typedef std::map<cModule*,Point> PositionMap;
76
      PositionMap submodPosMap;  // recalculateLayout() fills this map
77

    
78
   protected:
79
      void drawSubmodule(Tcl_Interp *interp, cModule *submod, int x, int y, const char *scaling);
80
      void drawEnclosingModule(Tcl_Interp *interp, cModule *parentmodule, const char *scaling);
81
      void drawConnection(Tcl_Interp *interp, cGate *gate);
82

    
83
   public:
84
      TGraphicalModWindow(cObject *obj,int typ,const char *geom,void *dat=NULL);
85
      ~TGraphicalModWindow();
86
      virtual void createWindow();
87
      virtual void update();
88
      virtual int inspectorCommand(Tcl_Interp *interp, int argc, const char **argv);
89

    
90
      bool needsRedraw() {return needs_redraw;}
91

    
92
      // implementations of inspector commands:
93
      virtual int getSubmoduleCount(Tcl_Interp *interp, int argc, const char **argv);
94
      virtual int getSubmodQ(Tcl_Interp *interp, int argc, const char **argv);
95
      virtual int getSubmodQLen(Tcl_Interp *interp, int argc, const char **argv);
96

    
97
      // helper for layouting code
98
      void getSubmoduleCoords(cModule *submod, bool& explicitcoords, bool& obeyslayout,
99
                                               int& x, int& y, int& sx, int& sy);
100

    
101
      // does full layouting, stores results in submodPosMap
102
      virtual void recalculateLayout();
103

    
104
      // updates submodPosMap (new modules, changed display strings, etc.)
105
      virtual void refreshLayout();
106

    
107
      // drawing methods:
108
      virtual void relayoutAndRedrawAll();
109
      virtual void redrawAll();
110

    
111
      virtual void redrawModules();
112
      virtual void redrawMessages();
113
      virtual void redrawNextEventMarker();
114
      virtual void updateSubmodules();
115

    
116
      // notifications from envir:
117
      virtual void submoduleCreated(cModule *newmodule);
118
      virtual void submoduleDeleted(cModule *module);
119
      virtual void connectionCreated(cGate *srcgate);
120
      virtual void connectionDeleted(cGate *srcgate);
121
      virtual void displayStringChanged();
122
      virtual void displayStringChanged(cModule *submodule);
123
      virtual void displayStringChanged(cGate *gate);
124
      virtual void bubble(cModule *mod, const char *text);
125
};
126

    
127
//
128
// *** Note: the following inspectors have been replaced with TGenericObjectInspector ***
129
//
130
// class TCompoundModInspector: public TInspector
131
// {
132
//    protected:
133
//       bool deep;
134
//       bool simpleonly;
135
//    public:
136
//       TCompoundModInspector(cObject *obj,int typ,const char *geom,void *dat=NULL);
137
//       virtual void createWindow();
138
//       virtual void update();
139
//       virtual void writeBack();
140
// };
141
//
142
// class TSimpleModInspector: public TInspector
143
// {
144
//    public:
145
//       TSimpleModInspector(cObject *obj,int typ,const char *geom,void *dat=NULL);
146
//       virtual void createWindow();
147
//       virtual void update();
148
//       virtual void writeBack();
149
// };
150
//
151
// class TGateInspector: public TInspector
152
// {
153
//    public:
154
//       TGateInspector(cObject *obj,int typ,const char *geom,void *dat=NULL);
155
//       virtual void createWindow();
156
//       virtual void update();
157
//       virtual void writeBack();
158
// };
159
//
160

    
161
class TGraphicalGateWindow : public TInspector
162
{
163
   protected:
164
      char canvas[128];
165
   public:
166
      TGraphicalGateWindow(cObject *obj,int typ,const char *geom,void *dat=NULL);
167
      virtual void createWindow();
168
      virtual void update();
169
      virtual int inspectorCommand(Tcl_Interp *interp, int argc, const char **argv);
170

    
171
      virtual int redraw(Tcl_Interp *interp, int argc, const char **argv);
172

    
173
      // notifications from envir:
174
      virtual void displayStringChanged(cGate *gate);
175
};
176

    
177
NAMESPACE_END
178

    
179

    
180
#endif