1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : PVGUI_Trace.h
23 // Author : Vitaly Smetannikov
26 #ifndef __PARAVIS_TRACE_I_H__
27 #define __PARAVIS_TRACE_I_H__
30 #include <QStringList>
33 #include <boost/shared_ptr.hpp>
35 class vtkSMPythonTraceObserver;
40 class proxy_trace_info: public QObject
44 proxy_trace_info(vtkSMProxy* proxy, const QString& proxyGroup, const QString& proxyName);
50 QMap<vtkSMProperty*, QString> Props;
51 QMap<QString, QString> CurrentProps;
52 QMap<QString, QString> ModifiedProps;
53 bool ignore_next_unregister;
56 typedef boost::shared_ptr<proxy_trace_info> proxy_trace_info_ptr;
60 class prop_trace_info: public QObject
64 prop_trace_info(proxy_trace_info_ptr proxyTraceInfo, vtkSMProperty* prop);
70 typedef boost::shared_ptr<prop_trace_info> prop_trace_info_ptr;
74 vtkSMPythonTraceObserver* observer;
76 bool capture_all_properties;
80 vtkSMProxy* active_source_at_start;
81 vtkSMProxy* last_active_source;
83 vtkSMProxy* active_view_at_start;
84 vtkSMProxy* last_active_view;
86 QList<proxy_trace_info_ptr> last_registered_proxies;
87 QList<proxy_trace_info_ptr> registered_proxies;
89 QStringList trace_output;
90 QString trace_output_endblock;
91 QStringList traced_proxy_groups;
92 QStringList ignored_view_properties;
93 QStringList ignored_representation_properties;
97 QString make_name_valid(const QString& theName);
99 void reset_trace_observer();
101 void reset_trace_globals();
103 QString pyvariable_from_proxy_name(const QString& proxy_name);
105 vtkSMPythonTraceObserver* trace_observer();
107 QStringList ignoredViewProperties();
109 QStringList ignoredRepresentationProperties();
111 bool propIsIgnored(const proxy_trace_info_ptr info, const QString& propName);
113 void track_existing_sources();
115 proxy_trace_info_ptr track_existing_source_proxy(vtkSMProxy* proxy, const QString& proxy_name);
117 proxy_trace_info_ptr track_existing_view_proxy(vtkSMProxy* proxy, const QString& proxy_name);
119 proxy_trace_info_ptr track_existing_representation_proxy(vtkSMProxy* proxy, const QString& proxy_name);
121 proxy_trace_info_ptr track_existing_proxy(vtkSMProxy* proxy);
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);
126 void ensure_active_source(const proxy_trace_info_ptr proxy_info);
127 void ensure_active_view(const proxy_trace_info_ptr proxy_info);
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);
132 QString get_source_proxy_registration_name(vtkSMProxy* proxy);
134 QString get_view_proxy_registration_name(vtkSMProxy* proxy);
136 QString get_representation_proxy_registration_name(vtkSMProxy* proxy);
138 QString make_comma_separated_string(QStringList values);
140 QString vector_smproperty_tostring(const proxy_trace_info_ptr proxyInfo,
141 const prop_trace_info_ptr propInfo);
143 QString get_property_value_from_list_domain(const proxy_trace_info_ptr proxyInfo,
144 const prop_trace_info_ptr propInfo);
146 QString proxy_smproperty_tostring(const proxy_trace_info_ptr proxyInfo,
147 const prop_trace_info_ptr propInfo);
149 QString input_smproperty_tostring(const proxy_trace_info_ptr proxyInfo,
150 const prop_trace_info_ptr propInfo);
152 void trace_proxy_rename(const proxy_trace_info_ptr proxy_info, const char* new_name);
154 proxy_trace_info_ptr trace_proxy_registered(vtkSMProxy* proxy,
155 const QString& proxyGroup,
156 const char* proxyName);
158 prop_trace_info_ptr trace_property_modified(proxy_trace_info_ptr info, vtkSMProperty* prop);
161 QList<proxy_trace_info_ptr> sort_proxy_info_by_group(const QList<proxy_trace_info_ptr>& infoList);
165 QString get_trace_string();
167 void save_trace(const QString& fileName);
169 //QString print_trace();
171 void on_proxy_registered(vtkObject* o, unsigned long eid, void* clientdata, void *calldata);
173 void on_proxy_unregistered(vtkObject* o, unsigned long eid, void* clientdata, void *calldata);
175 void on_property_modified(vtkObject* o, unsigned long eid, void* clientdata, void *calldata);
177 void on_update_information(vtkObject* o, unsigned long eid, void* clientdata, void *calldata);
179 void add_observers();
185 void start_trace(bool CaptureAllProperties=false, bool UseGuiName=false, bool Verbose=false);