]> SALOME platform Git repositories - modules/paravis.git/blob - src/PVGUI/PVGUI_Trace.h
Salome HOME
Merge from BR_PARAVIS_DEV 29Dec09
[modules/paravis.git] / src / PVGUI / PVGUI_Trace.h
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : PVGUI_Trace.h
23 //  Author : Vitaly Smetannikov
24 //  Module : PARAVIS
25 //
26 #ifndef __PARAVIS_TRACE_I_H__
27 #define __PARAVIS_TRACE_I_H__
28
29 #include <QString>
30 #include <QStringList>
31 #include <QList>
32 #include <QMap>
33 #include <boost/shared_ptr.hpp>
34
35 class vtkSMPythonTraceObserver;
36 class vtkSMProxy;
37 class vtkSMProperty;
38 class vtkObject;
39
40 class proxy_trace_info: public QObject
41 {
42   Q_OBJECT
43 public:
44   proxy_trace_info(vtkSMProxy* proxy, const QString& proxyGroup, const QString& proxyName);
45
46   vtkSMProxy*            Proxy;
47   QString                Group;
48   QString                ProxyName;
49   QString                PyVariable;
50   QMap<vtkSMProperty*, QString> Props;
51   QMap<QString, QString> CurrentProps;
52   QMap<QString, QString> ModifiedProps;
53   bool                   ignore_next_unregister;
54 };
55
56 typedef boost::shared_ptr<proxy_trace_info> proxy_trace_info_ptr;
57
58
59
60 class prop_trace_info: public QObject
61 {
62   Q_OBJECT
63 public:
64   prop_trace_info(proxy_trace_info_ptr proxyTraceInfo, vtkSMProperty* prop);
65
66   vtkSMProperty* Prop;
67   QString        PyVariable;
68 };
69
70 typedef boost::shared_ptr<prop_trace_info>  prop_trace_info_ptr;
71
72 struct trace_globals
73 {
74   vtkSMPythonTraceObserver* observer;
75   bool observer_active;
76   bool capture_all_properties;
77   bool use_gui_name;
78   bool verbose;
79
80   vtkSMProxy* active_source_at_start;
81   vtkSMProxy* last_active_source;
82
83   vtkSMProxy*   active_view_at_start;
84   vtkSMProxy*   last_active_view;
85
86   QList<proxy_trace_info_ptr> last_registered_proxies;
87   QList<proxy_trace_info_ptr> registered_proxies;
88
89   QStringList        trace_output;
90   QString            trace_output_endblock;
91   QStringList        traced_proxy_groups;
92   QStringList        ignored_view_properties;
93   QStringList        ignored_representation_properties;
94 };
95
96
97 QString make_name_valid(const QString& theName);
98
99 void reset_trace_observer();
100
101 void reset_trace_globals();
102
103 QString pyvariable_from_proxy_name(const QString& proxy_name);
104
105 vtkSMPythonTraceObserver* trace_observer();
106
107 QStringList ignoredViewProperties();
108
109 QStringList ignoredRepresentationProperties();
110
111 bool propIsIgnored(const proxy_trace_info_ptr info, const QString& propName);
112
113 void track_existing_sources();
114
115 proxy_trace_info_ptr track_existing_source_proxy(vtkSMProxy* proxy, const QString& proxy_name);
116
117 proxy_trace_info_ptr track_existing_view_proxy(vtkSMProxy* proxy, const QString& proxy_name);
118
119 proxy_trace_info_ptr track_existing_representation_proxy(vtkSMProxy* proxy, const QString& proxy_name);
120
121 proxy_trace_info_ptr track_existing_proxy(vtkSMProxy* proxy);
122
123 proxy_trace_info_ptr get_proxy_info(const QString& p, bool search_existing=true);
124 proxy_trace_info_ptr get_proxy_info(vtkSMProxy* p, bool search_existing=true);
125
126 void ensure_active_source(const proxy_trace_info_ptr proxy_info);
127 void ensure_active_view(const proxy_trace_info_ptr proxy_info);
128
129 proxy_trace_info_ptr get_input_proxy_info_for_rep(const proxy_trace_info_ptr rep_info);
130 proxy_trace_info_ptr get_view_proxy_info_for_rep(const proxy_trace_info_ptr rep_info);
131
132 QString get_source_proxy_registration_name(vtkSMProxy* proxy);
133
134 QString get_view_proxy_registration_name(vtkSMProxy* proxy);
135
136 QString get_representation_proxy_registration_name(vtkSMProxy* proxy);
137
138 QString make_comma_separated_string(QStringList values);
139
140 QString vector_smproperty_tostring(const proxy_trace_info_ptr proxyInfo, 
141                                    const prop_trace_info_ptr propInfo);
142
143 QString get_property_value_from_list_domain(const proxy_trace_info_ptr proxyInfo, 
144                                             const prop_trace_info_ptr propInfo);
145
146 QString proxy_smproperty_tostring(const proxy_trace_info_ptr proxyInfo, 
147                                   const prop_trace_info_ptr propInfo);
148
149 QString input_smproperty_tostring(const proxy_trace_info_ptr proxyInfo, 
150                                   const prop_trace_info_ptr propInfo);
151
152 void trace_proxy_rename(const proxy_trace_info_ptr proxy_info, const char* new_name);
153
154 proxy_trace_info_ptr trace_proxy_registered(vtkSMProxy* proxy, 
155                                          const QString& proxyGroup, 
156                                          const char* proxyName);
157
158 prop_trace_info_ptr trace_property_modified(proxy_trace_info_ptr info, vtkSMProperty* prop);
159
160
161 QList<proxy_trace_info_ptr> sort_proxy_info_by_group(const QList<proxy_trace_info_ptr>& infoList);
162
163 void append_trace();
164
165 QString get_trace_string();
166
167 void save_trace(const QString& fileName);
168
169 //QString print_trace();
170
171 void on_proxy_registered(vtkObject* o, unsigned long eid, void* clientdata, void *calldata);
172
173 void on_proxy_unregistered(vtkObject* o, unsigned long eid, void* clientdata, void *calldata);
174
175 void on_property_modified(vtkObject* o, unsigned long eid, void* clientdata, void *calldata);
176
177 void on_update_information(vtkObject* o, unsigned long eid, void* clientdata, void *calldata);
178
179 void add_observers();
180
181 void clear_trace();
182
183 void stop_trace();
184
185 void start_trace(bool CaptureAllProperties=false, bool UseGuiName=false, bool Verbose=false);
186
187
188 #endif