casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QtDataManager.qo.h
Go to the documentation of this file.
1 //# QtDataManager.qo.h: Qt implementation of viewer data manager widget.
2 //# Copyright (C) 2005
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef QTDATAMANAGER_H_
29 #define QTDATAMANAGER_H_
30 // (Trailing underscore is not a typo -- do not remove it;
31 // QtDataManager.ui.h uses the QTDATAMANAGER_H symbol).
32 
33 
34 #include <casa/aips.h>
35 #include <casa/BasicSL/String.h>
39 
40 #include <graphics/X11/X_enter.h>
41 #include <QDir>
42 #include <QColor>
43 #include <QHash>
44 #include <QWidget>
45 //#dk Be careful to put *.ui.h within X_enter/exit bracket too,
46 //# because they'll have Qt includes.
47 //# E.g. <QApplication> needs the X11 definition of 'Display'
48 #include <display/QtViewer/QtDataManager.ui.h>
49 #include <display/QtViewer/QtDataMgrMsSelect.ui.h>
50 #include <display/QtViewer/VOParam.ui.h>
51 #if ! defined(WITHOUT_DBUS)
52 #include <casaqt/QtDBus/dVO.h>
53 #endif
54 #include <graphics/X11/X_exit.h>
56 #include <QListWidget>
57 #include <set>
58 #include <list>
59 #if defined(__APPLE__)
60 #include <tuple>
61 #define TUPLE std::tuple
62 #else
63 #include <tr1/tuple>
64 #define TUPLE std::tr1::tuple
65 #endif
66 
67 namespace casacore{
68 
69  template <class T> class ImageInterface;
70 }
71 
72 namespace casa { //# NAMESPACE CASA - BEGIN
73 
74  class QtDisplayPanelGui;
75  class QtDisplayPanel;
76  class QtDisplayData;
77 
78  namespace viewer {
79  class Region;
80 
81  namespace dvo {
82  // entry of flexible VO parameters...
83  class param : public QGroupBox, public Ui::VOParam {
84  Q_OBJECT
85  public:
86  param( QListWidget *l, QListWidgetItem *i, QWidget *parent=0 ) : QGroupBox(parent), list(l), item(i) { setupUi(this); }
87  protected:
88  void mousePressEvent ( QMouseEvent * event );
89  private:
90  QListWidget *list;
91  QListWidgetItem *item;
92  };
93  }
94  }
95 
96  class QtDataManager : public QWidget, private Ui::QtDataManager {
97 
98  Q_OBJECT
99 
100  public:
101 
102  typedef std::list<std::pair<QGroupBox*,QLineEdit*> > infofield_list_t;
103 
104  QtDataManager( QtDisplayPanelGui* panel=0, const char* name=0, QWidget* parent=0 );
105  ~QtDataManager();
106 
107  /* casacore::String path() const { return dir_.path().toStdString(); } */
108 
109  void updateDirectory(const std::string &);
110 
111  void showTab( std::string );
112  void clearRegionMap();
113 
114  signals:
115 
117 
118 
119  protected:
120 
121  void showEvent( QShowEvent *event );
122  void enterEvent( QEvent *event );
123  void showDisplayButtons(int,const QString &name=QString((const char *)0));
124  void hideDisplayButtons();
125  QColor getDirColor(int);
126  QStringList analyseFITSImage(QString path);
127  bool isQualImg(const QString &extexpr);
128 
129 
130  std::string guimethod_to_iamethod( const QString & );
131 
134  };
137  };
138 
139  QHash<int, QString> dataType_;
140  QHash<QString, int> uiDataType_;
141  QHash<QString, int> displayType_;
142  QHash<QString, int> uiDisplayType_;
144 
147  /* infofield_list_t img_ifields; */
148 
149  public slots:
150 
151  void updateDisplayDatas(QtDisplayData* qdd=0, bool autoRegister=true);
152 
153  protected slots:
154 
155  void handle_region_update(viewer::Region*,std::string);
156 
157  void createButtonClicked();
158  void clickItem(QTreeWidgetItem* item);
159  void expandItem(QTreeWidgetItem* item);
160  void changeItemSelection();
161  void returnPressed();
162  void buildDirTree( std::string newdir="" );
163  void lelGotFocus_();
164  void load_regions_clicked( );
165 
166  // Restore viewer state to existing panel.
167  // Use the first empty panel, or if none, the first panel.
168  void restoreToOld_();
169 
170  // Create new display panel, restore viewer state to it.
171  void restoreToNew_();
172 
173  // Restore viewer state to given panel.
174  void restoreTo_(QtDisplayPanel* dp);
175 
176 
178 
179  void leaveopenButtonClicked( bool checked );
180  void showlelButtonClicked( bool checked );
181  void showSliceButtonClicked( bool checked );
182 
183  void changeTabContext(int);
184 
185  void img_output_target_changed(const QString &s="");
188  }
189 
190  void region_ds9_csys_disable(bool);
191  void region_output_target_changed(const QString &s="");
194  }
195 
196  void img_do_output( );
197  void region_do_output( );
198 
199  void region_item_state_change(QTreeWidgetItem*,int);
200  void region_selection_change( viewer::Region *rgn, bool selected );
201 
202 #if ! defined(WITHOUT_DBUS)
203 #ifdef WITH_VO
204  //--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
205  // VO controls...
206  //--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
207  void addVOParam( );
208  void removeVOParam( );
209  //--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
210 #endif
211 #endif
212 
213  private slots:
214  void enable_disable_slice( const QString & );
215  void enable_disable_regrid( bool );
216  private:
217 
218  typedef std::map<QString,QtDisplayData*> display_data_map_t;
220 
221  typedef std::map<QTreeWidgetItem*,viewer::Region*> treeitem_map_t;
223  typedef std::map<viewer::Region*,QTreeWidgetItem*> region_map_t;
225 
226  struct validation_msg {
228  enum valid_t { VALID, INVALID, WARN };
229  validation_msg( const QString &s, output_format_t f, valid_t v, const QString &m ) : path(s), output_format(f), valid(v), msg(m) { }
231  validation_msg( ) : path(/* QString::Null */), output_format(CASA), valid(INVALID), msg(/* QString::Null */) {
232  fprintf( stderr, "HERE<3>:::: " );
233  }
235  path = o.path;
237  valid = o.valid;
238  msg = o.msg;
239  return *this;
240  }
241  QString canonical_path( const QString & );
242  QString path;
245  QString msg;
246  };
247 
248  validation_msg output_validation( const QString &, const QString &, validation_msg::output_format_t ) const;
249 
250  class tab_state {
251  public:
252  typedef void (QtDataManager::*notify_func_t)( const std::string &, tab_state & );
253  tab_state( ) : dir_entry_(0), tree_(0), dir_(new QDir), notify_func_(0),
254  info_frame_(0), info_fields_(0), dtree_(0),
256  dir_->setFilter( QDir::AllDirs | QDir::Files);
257  dir_->setSorting(QDir::Name);
258  }
263  error_func_(o.error_func_) { }
264  tab_state( QLineEdit *le, QTreeWidget *t, std::set<int> s, QFrame *info_frame=0,
265  infofield_list_t *info_fields=0, notify_func_t f=0,
266  QTreeWidget *d=0, QLineEdit *on=0, notify_func_t oerr=0 ) :
267  filtered_types_(s), dir_entry_(le), tree_(t), dir_(new QDir),
268  notify_func_(f), info_frame_(info_frame), info_fields_(info_fields),
269  dtree_(d), output_name_line_(on), error_func_(oerr) {
270  dir_->setFilter( QDir::AllDirs | QDir::Files);
271  dir_->setSorting(QDir::Name);
272  }
273  const std::set<int> &filter( ) const {
274  return filtered_types_;
275  }
276  void updateDir( ) {
277  if ( dir_entry_ ) {
278  dir_entry_->setText(dir_->currentPath( ));
279  }
280  }
281 
282  void notify( QtDataManager *mgr, const std::string &s ) {
283  if ( notify_func_ ) (mgr->*notify_func_)(s,*this);
284  }
285  void notifyErr( QtDataManager *mgr, const std::string &s ) {
286  if ( error_func_ ) (mgr->*error_func_)(s,*this);
287  }
288 
289  QTreeWidget *tree( ) {
290  return tree_;
291  }
292  QFrame *infoFrame( ) {
293  return info_frame_;
294  }
296  return info_fields_;
297  }
298 
299  QTreeWidget *dtree( ) {
300  return dtree_;
301  }
302  QLineEdit *outFileLine( ) {
303  return output_name_line_;
304  }
305 
306  std::shared_ptr<QDir> dir( ) {
307  return dir_;
308  }
309  QLineEdit *dirline( ) {
310  return dir_entry_;
311  }
312  std::string dirStr( ) const {
313  return dir_entry_->text( ).toStdString( );
314  }
315  private:
316  std::set<int> filtered_types_;
317  QLineEdit *dir_entry_;
318  QTreeWidget *tree_;
319  std::shared_ptr<QDir> dir_;
321  QFrame *info_frame_;
323 
324  QTreeWidget *dtree_;
325  QLineEdit *output_name_line_;
327 
328  };
329 
330  void update_regrid_options( );
331  void update_slice_options( int ddtp,const QString &name );
332  void fill_image_info( const std::string &/*path*/ );
333 
334  QWidget *parent_;
336  Ui::QtDataMgrMsSelect *ms_selection;
337 
338  // avoid setting the export type more than once
341 
342  // connection to rc file
344 
345  typedef std::map<int,tab_state> tab_info_map_t;
347  void init_tab_info( );
348 
349  void load_tab_notify( const std::string &value, tab_state & );
350 
351  void update_dd_list( tab_state &ts );
352  void image_tab_notify( const std::string &value, tab_state & );
353  void image_tab_error( const std::string &value, tab_state & );
354 
355  void update_region_list( tab_state &ts );
356  void region_tab_notify( const std::string &value, tab_state & );
357  void region_tab_error( const std::string &value, tab_state & );
358 
359  bool export_to_fits(casacore::ImageInterface<float> *img, std::string outFile);
361  void getSpectralCoordFlags(const casacore::ImageInterface<float>* img, bool &preferVelocity, bool &opticalVelocity, bool &preferWavelength, bool &preferAirWavelength);
362 
364 
367 #if ! defined(WITHOUT_DBUS)
368 #ifdef WITH_VO
369  void setupVO( );
370  // returns true if everything is OK...
371  bool updateVOstatus( );
372  QPushButton *new_vo_dismiss_button( QTableWidgetItem*, QString, QString );
373  bool collect_vo_parameters( double &ra, double &dec, double &ra_size, double &dec_size, QVariantMap &params );
374  void vo_flag_missing_param( QLineEdit *widget );
375  // (enabled, gui label, vo parameter name,vo parameter default,entry box)
376  typedef TUPLE<bool,QString,QString,QString,viewer::dvo::param*> vo_param_t;
377  std::vector<vo_param_t> voparameters;
378  edu::nrao::casa::dVO dvo;
379  std::set<QWidget*> dvo_missing_parameters;
380 
381  std::map<QString,int> vo_label2col;
382  std::vector<QString> vo_urls;
383  std::vector<QString> vo_labels;
384  std::vector<QString> vo_labels_tip;
385 
386  QColor vo_default_bg;
387  struct dvo_working_item {
388  int id;
389  unsigned int count;
390  bool operator<( const dvo_working_item &other ) const { return id < other.id; }
391  operator int( ) const { return id; }
392  dvo_working_item( int i ) : id(i), count(0) { }
393  dvo_working_item( QDBusPendingReply<int> i ) : id(i), count(0) { }
394  // set find etc. yeilds constant iterators (even though changes to
395  // the set item may have no effect on set ordering...)
396  void increment( ) const { ((dvo_working_item*)this)->count += 1; }
397  };
398  std::set<dvo_working_item> dvo_working_set;
399  QPushButton *vo_current_action;
400 
401  void vo_clear_status_delayed( int seconds );
402  void vo_action_with_timeout( int id, int seconds, QString msg );
403  bool vo_action_with_timeout_active( ) const { return vo_action_timeout->isActive( ); }
404  void vo_action_with_timeout_reset( ) {
405  if ( vo_action_with_timeout_active( ) ) vo_action_timeout->start( );
406  }
407  void vo_action_with_timeout_complete( );
408 
409  private slots:
410 
411  void vo_service_select( const QString &service ) { vo_selected_service = service; }
412  void vo_selection_changed( );
413 
414  void vo_clear_table( ) {
415  vo_table->clear( );
416  vo_table->setRowCount( 0 );
417  vo_init_columns( );
418  vo_label2col.clear( );
419  vo_urls.clear( );
420  vo_labels.clear( );
421  vo_labels_tip.clear( );
422  }
423  void vo_launch_query( );
424  void vo_fetch_data( );
425  void vo_clear_param( );
426  void vo_query_begin( int, const QString&, const QtStringMap& );
427  void vo_query_complete( int, const QString&, const QtStringMap& );
428  void vo_query_description( int, const QString&, const QtStringMap& );
429  void vo_query_row( int, const QString&, const QtStringMap& );
430  void vo_error( int, const QString&, const QString& );
431  void vo_dismiss_row( );
432  void vo_fetch_complete( int, QString );
433  void vo_fetch_progress(int,QString,double,double,double,double);
434 
435  void vo_clear_status( );
436  void vo_disable_actions( );
437  void vo_enable_actions( );
438  void vo_action_timed_out( );
439 
440  private:
441  void error( const QString &msg ) {
442  vo_status->setStyleSheet("color: red");
443  vo_status->setText( msg );
444  }
445  void status( const QString &msg ) {
446  vo_status->setStyleSheet("color: black");
447  vo_status->setText( msg );
448  }
449  void warning( const QString &msg ) {
450  vo_status->setStyleSheet("color: orange");
451  vo_status->setText( msg );
452  }
453 
454  void vo_init_columns( ) {
455  vo_table->setColumnCount( 2 );
456  vo_table->setColumnWidth(0,30);
457  QTableWidgetItem *first = new QTableWidgetItem( "" );
458  vo_table->setHorizontalHeaderItem(0,first);
459  QTableWidgetItem *second = new QTableWidgetItem( "1" );
460  vo_table->setHorizontalHeaderItem(1,second);
461  }
462 
463  QDoubleValidator *ra_val;
464  QDoubleValidator *dec_val;
465  QDoubleValidator *ra_size_val;
466  QDoubleValidator *dec_size_val;
467 
468  QTimer *vo_action_timeout;
469  int vo_action_timeout_id;
470  QString vo_action_timeout_msg;
471  bool vo_actions_are_enabled;
472 
473  std::map<QString,QString> vo_service_name_to_url;
474  QString vo_selected_service;
475  std::vector<int> vo_selected_rows;
476 
477  friend void lambda_dsoc_test_pre_( QtDataManager& );
478 #endif
479 #endif
480  };
481 
482 } //# NAMESPACE CASA - END
483 
484 #endif
QString canonical_path(const QString &)
void expandItem(QTreeWidgetItem *item)
validation_msg(const QString &s, output_format_t f, valid_t v, const QString &m)
void update_region_list(tab_state &ts)
Ui::QtDataMgrMsSelect * ms_selection
Contains common enums, constants, and methods for DS9 files.
Definition: DS9FileReader.h:41
QMap< QString, QString > QtStringMap
Definition: QtDBusMeta.h:32
region_map_t region_to_treeitem
QHash< QString, int > uiDataType_
void region_ds9_csys_disable(bool)
struct Node * first
Definition: malloc.h:330
QtDataManager(QtDisplayPanelGui *panel=0, const char *name=0, QWidget *parent=0)
void region_tab_notify(const std::string &value, tab_state &)
void region_output_target_changed(bool)
treeitem_map_t treeitem_to_region
infofield_list_t load_ifields
QColor getDirColor(int)
void region_tab_error(const std::string &value, tab_state &)
void buildDirTree(std::string newdir="")
QListWidgetItem * item
void updateDirectory(const std::string &)
void img_output_target_changed(const QString &s="")
QtDisplayPanelGui * panel_
bool export_to_casa(casacore::ImageInterface< float > *img, casacore::String outFile)
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
QString last_image_extension_tweak_string
avoid setting the export type more than once
QHash< int, QString > dataType_
void region_selection_change(viewer::Region *rgn, bool selected)
void handle_region_update(viewer::Region *, std::string)
void fill_image_info(const std::string &)
void notify(QtDataManager *mgr, const std::string &s)
display_data_map_t display_datas
void(QtDataManager::* notify_func_t)(const std::string &, tab_state &)
validation_msg operator=(const validation_msg &o)
validation_msg(const validation_msg &o)
void leaveopenButtonClicked(bool checked)
All regions are specified in &quot;linear coordinates&quot;, not &quot;pixel coordinates&quot;.
Definition: Region.qo.h:147
void showlelButtonClicked(bool checked)
validation_msg output_validation(const QString &, const QString &, validation_msg::output_format_t) const
const std::set< int > & filter() const
void region_item_state_change(QTreeWidgetItem *, int)
tab_state(QLineEdit *le, QTreeWidget *t, std::set< int > s, QFrame *info_frame=0, infofield_list_t *info_fields=0, notify_func_t f=0, QTreeWidget *d=0, QLineEdit *on=0, notify_func_t oerr=0)
std::string path(const std::string &name)
std::map< QString, QtDisplayData * > display_data_map_t
casacore::Casarc & rc
connection to rc file
QHash< QString, int > uiDisplayType_
viewer::SlicerGen * slice_gen
void enterEvent(QEvent *event)
QStringList analyseFITSImage(QString path)
void restoreToOld_()
Restore viewer state to existing panel.
The main display window for the Qt version of the viewer.
void notifyErr(QtDataManager *mgr, const std::string &s)
bool operator<(const HeaderItemInfo &left, const HeaderItemInfo &right)
This class provides a priori image information derived from the image itself.
std::map< QTreeWidgetItem *, viewer::Region * > treeitem_map_t
std::shared_ptr< QDir > dir()
std::map< viewer::Region *, QTreeWidgetItem * > region_map_t
void update_regrid_options()
QVector< int > exportTypes_
void region_output_target_changed(const QString &s="")
param(QListWidget *l, QListWidgetItem *i, QWidget *parent=0)
void changeTabContext(int)
QHash< QString, int > displayType_
void tableReadErrorSignal(casacore::String msg)
void clickItem(QTreeWidgetItem *item)
const Double second
Time interval [T]:
void load_tab_notify(const std::string &value, tab_state &)
std::string guimethod_to_iamethod(const QString &)
QString last_region_extension_tweak_string
void image_tab_notify(const std::string &value, tab_state &)
void showEvent(QShowEvent *event)
void image_tab_error(const std::string &value, tab_state &)
void showTab(std::string)
void restoreToNew_()
Create new display panel, restore viewer state to it.
std::shared_ptr< QDir > dir_
void showDDCreateError_(casacore::String)
void enable_disable_regrid(bool)
infofield_list_t * infoFields()
viewer::ImageProperties image_properties
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void enable_disable_slice(const QString &)
bool isQualImg(const QString &extexpr)
bool export_to_fits(casacore::ImageInterface< float > *img, std::string outFile)
void showDisplayButtons(int, const QString &name=QString((const char *) 0))
void mousePressEvent(QMouseEvent *event)
entry of flexible VO parameters...
void restoreTo_(QtDisplayPanel *dp)
Restore viewer state to given panel.
void update_slice_options(int ddtp, const QString &name)
void update_dd_list(tab_state &ts)
void showSliceButtonClicked(bool checked)
void updateDisplayDatas(QtDisplayData *qdd=0, bool autoRegister=true)
tab_info_map_t tab_info
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
std::map< int, tab_state > tab_info_map_t
void getSpectralCoordFlags(const casacore::ImageInterface< float > *img, bool &preferVelocity, bool &opticalVelocity, bool &preferWavelength, bool &preferAirWavelength)
std::list< std::pair< QGroupBox *, QLineEdit * > > infofield_list_t
void img_output_target_changed(bool)
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42