Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CanvasWindow.cxx

Go to the documentation of this file.
00001 
00014 #ifdef HAVE_CONFIG_H
00015 #include "config.h"
00016 #endif
00017 
00018 #include "CanvasWindow.h"
00019 
00020 #include "CanvasView.h"
00021 #include "QtFileDialog.h"
00022 #include "PlotTable.h"
00023 #include "PlotTableEvent.h"
00024 #include "QtView.h"
00025 #include "SaveAsImageEvent.h"
00026 #include "WindowController.h"
00027 
00028 #include "plotters/PlotterBase.h"
00029 #include "datasrcs/NTupleController.h"
00030 #include "qtxml/QtXMLController.h"
00031 
00032 #include <qapplication.h>
00033 #if QT_VERSION < 0x040000
00034 #include <qaction.h>
00035 #else
00036 //Added by the Qt porting tool:
00037 #include <QCloseEvent>
00038 #include <QCustomEvent>
00039 #include <QHideEvent>
00040 #include <QResizeEvent>
00041 #include <QShowEvent>
00042 #include <q3action.h>
00043 #endif
00044 
00045 #include <qmessagebox.h>
00046 #include <qfontdialog.h>
00047 
00048 #include <algorithm>
00049 
00050 #include <cassert>
00051 
00052 using std::exception;
00053 using std::list;
00054 using std::string;
00055 using std::vector;
00056 
00057 PlotTable * CanvasWindow::s_plot_table = 0;
00058 
00064 #if QT_VERSION < 0x040000
00065 CanvasWindow::CanvasWindow ( QWidget * parent,
00066                              const char * name,
00067                              Qt::WFlags fl )
00068   : CanvasWindowBase ( parent, name, fl ),
00069 #else
00070 CanvasWindow::CanvasWindow ( QWidget * parent )
00071   : Q3MainWindow ( parent ),
00072 #endif
00073     m_file_dialog ( 0 ),
00074     m_prefix ( "HippoDraw - Canvas " ),
00075     m_filename ( "UNTITLED" ),
00076     m_changed (" - Not Saved " ),
00077     m_hasChanged ( false ),
00078     m_inhibit_close ( false ),
00079     m_allow_close ( false ),
00080     m_filenameExists ( false )
00081 {
00082 #if QT_VERSION < 0x040000
00083   QCanvas * canvas = new QCanvas ();
00084 #else
00085   setupUi ( this );
00086   Q3Canvas * canvas = new Q3Canvas ();
00087 #endif
00088 
00089   m_xml_controller = QtXMLController::instance ();
00090   m_canvas_view = new CanvasView ( canvas, this );
00091   setCentralWidget ( m_canvas_view );
00092 
00093   resize ( sizeHint () ) ;
00094 
00095   WindowController * controller = WindowController::instance ();
00096   controller->newWindow ( this );
00097 
00098   setCaption ();
00099   m_file_dialog = new QtFileDialog ( QString::null, // starting dir
00100                                      this, // parent
00101                                      "Save file as", // internal name
00102                                      true ); // modal
00103 }
00104 
00105 void
00106 CanvasWindow::
00107 resetFontSize ()
00108 {
00109   QFont font = QApplication::font ();
00110   int size = font.pointSize ();
00111   if ( size > 10 ) {
00112     font.setPointSize ( 10 );
00113     QApplication::setFont ( font, true );
00114   }
00115 }
00116 
00117 CanvasWindow::CanvasWindow ( const CanvasWindow & )
00118 {
00119   assert ( false );
00120 }
00121 
00122 CanvasWindow::~CanvasWindow()
00123 {
00124 #if QT_VERSION < 0x040000
00125   QCanvas * canvas = m_canvas_view->canvas();
00126 #else
00127   Q3Canvas * canvas = m_canvas_view->canvas();
00128 #endif
00129 
00130   delete m_canvas_view;
00131   delete canvas;
00132 }
00133 
00134 void
00135 CanvasWindow::
00136 customEvent ( QCustomEvent * event )
00137 {
00138   SaveAsImageEvent * image_event
00139     = dynamic_cast < SaveAsImageEvent * > ( event );
00140 
00141   if ( image_event != 0 ) {
00142     const PlotterBase * plotter = image_event -> plotter ();
00143     const string & filename = image_event -> filename ();
00144     m_canvas_view -> savePlotAsImage ( plotter, filename );
00145     return;
00146   }
00147 
00148   PlotTableEvent * ptevent = dynamic_cast < PlotTableEvent * > ( event );
00149   if ( ptevent != 0 ) {
00150     int type = ptevent -> type();
00151 
00152     if ( type == PlotTableEvent::Copy ) {
00153       m_canvas_view -> addFromPasteboard ();
00154       return;
00155     }
00156 
00157     if ( type == PlotTableEvent::Close ) {
00158       if ( m_browsed_canvas != 0 ) {
00159         delete m_browsed_canvas;
00160       }
00161       s_plot_table -> setBrowserMode ( false );
00162       return;
00163     }
00164   }
00165 }
00166 
00167 void CanvasWindow::windowActivationChange ( bool oldActive )
00168 {
00169   QWidget::windowActivationChange ( oldActive );
00170 
00171   if ( isActiveWindow () == true ) {
00172     WindowController * wc = WindowController::instance ();
00173     if ( wc -> currentCanvas ( ) != this ) {
00174       wc -> setCurrentCanvas ( this );
00175       updateActions ();
00176       m_canvas_view -> notifyObservers ();
00177     }
00178   }
00179 }
00180 
00181 void
00182 CanvasWindow::
00183 setAllowClose ( bool yes )
00184 {
00185   m_allow_close = yes;
00186 }
00187 
00191 bool CanvasWindow::allowClose ( )
00192 {
00193   if ( m_allow_close ||
00194        m_hasChanged == false ) return true;
00195 
00196   bool _allowClose = true;
00197   const string & app_name = m_canvas_view -> applicationName ();
00198 
00199   QString message;
00200   QString fn = m_filename.c_str();
00201   message = QString("The document,\n%1\n").arg ( fn );
00202   message.append("contains unsaved changes.\n\n");
00203   message.append("Do you want to save the document before closing it?");
00204 
00205   int retval
00206     = QMessageBox::information ( this,
00207                                  app_name.c_str(),
00208                                  message,
00209                                  "&Save", "&Discard", "Cancel");
00210 
00211   switch (retval)
00212     {
00213     case 0: // save
00214       fileSave ();
00215       _allowClose = true;
00216       break;
00217 
00218     case 1:
00219       _allowClose = true;
00220       break;
00221 
00222     case 2:
00223       _allowClose = false;
00224       break;
00225 
00226     default:
00227       _allowClose = false;
00228       break;
00229     }
00230 
00231   return _allowClose;
00232 }
00233 
00234 bool
00235 CanvasWindow::closeNoPrompt ( )
00236 {
00237   m_allow_close = true;
00238 
00239   return QWidget::close ( true );
00240 }
00241 
00242 void CanvasWindow::closeEvent ( QCloseEvent * e )
00243 {
00244   if ( m_allow_close ) {
00245     e -> accept ();
00246     WindowController::instance() -> aboutToClose ( this );
00247     return;
00248   }
00249 
00250   if ( allowClose () == false ) {
00251     e->ignore ();
00252     return;
00253   }
00254 
00255   if ( m_inhibit_close == true ) {
00256     const string & app_name = m_canvas_view -> applicationName ();
00257 
00258     QString message ( "Closing the only document window will also " );
00259     message.append ( "terminate the application.\n\n"
00260                      "Do you want to quit?" );
00261     int retval = QMessageBox::information ( this,
00262                                             app_name.c_str(),
00263                                             message,
00264                                             QMessageBox::Yes,
00265                                             QMessageBox::No |
00266                                             QMessageBox::Default |
00267                                             QMessageBox::Escape,
00268                                             Qt::NoButton );
00269 
00270     switch (retval)
00271       {
00272       case QMessageBox::Yes: // save
00273         break;
00274 
00275       case QMessageBox::No:
00276         e->ignore();
00277         return;
00278         break;
00279 
00280       default:
00281         e->ignore();
00282         return;
00283         break;
00284       }
00285   }
00286 
00287   e->accept ();
00288   WindowController::instance() -> aboutToClose ( this );
00289 }
00290 
00291 void CanvasWindow::hideEvent ( QHideEvent * )
00292 {
00293   WindowController::instance () -> hasBeenHidden ( this );
00294 }
00295 
00296 void CanvasWindow::showEvent ( QShowEvent * )
00297 {
00298   WindowController::instance () -> unHide ( this );
00299 }
00300 
00301 void CanvasWindow::inhibitClose ( bool flag )
00302 {
00303   m_inhibit_close = flag;
00304 }
00305 
00306 void CanvasWindow::setChanged ( bool flag )
00307 {
00308   WindowController * controller = WindowController::instance ();
00309   controller -> updateActions ();
00310 
00311  if ( m_hasChanged == flag ) return;
00312 
00313   if ( flag == true ) {
00314     m_changed = "   not saved";
00315   }
00316   else {
00317     m_changed = "   saved";
00318   }
00319   m_hasChanged = flag;
00320   setCaption ();
00321 
00322 }
00323 
00324 void CanvasWindow::updateActions ()
00325 {
00326   XmlController * controller = QtXMLController::instance ();
00327   bool no = controller -> isPasteboardEmpty ();
00328   m_editPasteAction -> setEnabled ( ! no );
00329 
00330   const std::vector < const ViewBase * > & views
00331     = m_canvas_view->selectedViews ();
00332   bool yes = ! views.empty ();
00333 
00334   m_fileSaveSelected->setEnabled ( yes );
00335   m_editClearAction->setEnabled ( yes );
00336   m_editCutAction->setEnabled ( yes );
00337   m_editCopyAction->setEnabled ( yes );
00338   m_editDeleteAction -> setEnabled ( yes );
00339   m_editUndoAction->setEnabled ( yes );
00340   m_viewLockAction->setEnabled ( yes );
00341   m_viewUnlockAction->setEnabled ( yes );
00342   if ( yes == false ) return;
00343 
00344   bool one_locked = false;
00345   bool one_unlocked = false;
00346   std::vector < const ViewBase * >:: const_iterator first = views.begin ();
00347   while ( first != views.end () ) {
00348     const QtView * view = dynamic_cast < const QtView * > ( *first++ );
00349     //
00350     bool locked = view->isActive ();
00351     one_locked |= locked;
00352     one_unlocked |= ! locked;
00353   }
00354   m_viewLockAction->setEnabled ( one_unlocked );
00355   m_viewUnlockAction->setEnabled ( one_locked );
00356 }
00357 
00361 void
00362 CanvasWindow::
00363 filePrint()
00364 {
00365   m_canvas_view->print ();
00366 }
00367 
00368 void CanvasWindow::editCopy ()
00369 {
00370   m_canvas_view->copySelectedToPasteboard ();
00371 
00372   WindowController * controller = WindowController::instance ();
00373   controller -> updateActions();
00374 }
00375 
00376 void
00377 CanvasWindow::
00378 editClear ()
00379 {
00380   QString message ( "The clear operation can not be undone.\n\n" );
00381   message.append ( "Are you sure you want to remove all canvas items?" );
00382   int retval
00383     = QMessageBox::warning ( this,
00384                              "Warning",
00385                              message,
00386                              QMessageBox::Yes,
00387                              QMessageBox::No );
00388   if ( retval != QMessageBox::Yes ) return;
00389 
00390   clear ();
00391 
00392   WindowController * controller = WindowController::instance ();
00393   controller -> updateActions();
00394 }
00395 
00396 void CanvasWindow::editCut ()
00397 {
00398   m_canvas_view->deleteSelected ( true );  // copy to pasteboard and delete
00399 
00400   WindowController * controller = WindowController::instance ();
00401   controller -> updateActions();
00402 }
00403 
00404 void CanvasWindow::editDelete ()
00405 {
00406   m_canvas_view->deleteSelected ( false );  // just delete
00407 
00408   WindowController * controller = WindowController::instance ();
00409   controller -> updateActions();
00410 }
00411 
00412 void
00413 CanvasWindow::
00414 editReTile ()
00415 {
00416   m_canvas_view->reTile ();
00417 }
00418 
00419 void
00420 CanvasWindow::
00421 editReTilePage ()
00422 {
00423   m_canvas_view->reTilePage ();
00424 }
00425 
00426 void
00427 CanvasWindow::
00428 editUndo ()
00429 {
00430   m_canvas_view->restoreFromSelectCopy ();
00431 
00432   m_canvas_view->notifyObservers();
00433 }
00434 
00435 /* virtual */
00436 void CanvasWindow::editPaste ()
00437 {
00438   m_canvas_view->copyFromPasteboard ();
00439 }
00440 
00441 void
00442 CanvasWindow::
00443 editSelectAll ()
00444 {
00445   m_canvas_view->setAllSelected ( true );
00446 
00447   WindowController * controller = WindowController::instance ();
00448   controller -> updateActions();
00449 }
00450 
00451 void CanvasWindow::fileNew ()
00452 {
00453   CanvasWindow * window = new CanvasWindow ();
00454   WindowController::instance () -> newWindow ( window );
00455   window->setCaption ();
00456   window->show ();
00457 }
00458 
00459 void
00460 CanvasWindow::
00461 on_fileBrowse_actived()
00462 {
00463   m_file_dialog -> createBrowseFilter ();
00464 
00465   int retval = m_file_dialog -> exec ();
00466 
00467   if ( retval == QDialog::Accepted ) {
00468     QString filename = m_file_dialog -> selectedFile ();
00469     QString s = filename.stripWhiteSpace ();
00470     const string fn = s.latin1();
00471 
00472     string::size_type pos = fn.find_last_of ( '.' );
00473     const string suffix = fn.substr ( pos );
00474 
00475     if ( m_file_dialog -> isDocSuffix ( suffix ) ) {
00476       QCanvas * canvas = new QCanvas ();
00477       CanvasView * m_browsed_canvas = new CanvasView ( canvas, this );
00478       m_browsed_canvas -> initFromFile ( fn );
00479       if ( s_plot_table == 0 ) {
00480         s_plot_table = new PlotTable ();
00481       }
00482       s_plot_table -> setBrowserMode ( true, this );
00483       s_plot_table -> setCanvas ( m_browsed_canvas );
00484       s_plot_table -> show ();
00485     }
00486   }
00487 }
00488 
00495 void
00496 CanvasWindow::
00497 on_fileOpen_activated ()
00498 {
00499   m_file_dialog -> createOpenFilter ();
00500 
00501   int retval = m_file_dialog -> exec ();
00502 
00503   if ( retval == QDialog::Accepted ) {
00504     QString filename = m_file_dialog -> selectedFile ();
00505     QString s = filename.stripWhiteSpace ();
00506     const string fn = s.latin1();
00507 
00508     string::size_type pos = fn.find_last_of ( '.' );
00509     const string suffix = fn.substr ( pos );
00510 
00511     if ( m_file_dialog -> isDocSuffix ( suffix ) ) {
00512       CanvasWindow * window = new CanvasWindow ();
00513       try {
00514         window -> initFromFile ( fn );
00515       }
00516       catch ( exception & e ) {
00517         m_file_dialog -> openFileError ( filename.latin1() , e );
00518         window -> setChanged ( false );
00519         window -> close ();
00520       }
00521       return;
00522     }
00523 
00524     else if ( m_file_dialog -> isTextSuffix ( suffix ) ) {
00525       m_file_dialog -> openTextTuple ( fn );
00526     }
00527 #ifdef HAVE_ROOT
00528     else if ( m_file_dialog -> isRootSuffix ( suffix ) ) {
00529       m_file_dialog -> openRootTuple ( fn );
00530       m_canvas_view -> notifyObservers ();
00531       return;
00532     }
00533 #endif
00534 
00535 #ifdef HAVE_CFITSIO
00536     else if ( m_file_dialog -> isFitsSuffix ( suffix ) ) {
00537       m_file_dialog -> openFitsTuple ( fn );
00538       m_canvas_view -> notifyObservers ();
00539       return;
00540     }
00541     else {
00542       bool yes = m_file_dialog -> isFitsFile ( fn );
00543       if ( yes ) {
00544         m_file_dialog -> openFitsTuple ( fn );
00545         m_canvas_view -> notifyObservers ();
00546         return;
00547       }
00548     }
00549 #endif
00550     // if all else fails, try text file
00551     m_file_dialog -> openTextTuple ( fn );
00552 
00553     m_canvas_view -> notifyObservers ();
00554   }
00555 }
00556 
00557 void
00558 CanvasWindow::
00559 initFromFile ( const std::string & filename )
00560 {
00561   m_canvas_view -> initFromFile ( filename );
00562   setTitleFileName ( filename );
00563   setChanged ( false );
00564 
00565   show();
00566 }
00567 
00568 void
00569 CanvasWindow::
00570 clear()
00571 {
00572   m_canvas_view->clear();
00573 }
00574 
00575 void CanvasWindow::resizeEvent ( QResizeEvent * e )
00576 {
00577   m_canvas_view->resizeEvent ( e );
00578 
00579   QWidget::resizeEvent ( e );
00580 }
00581 
00582 void CanvasWindow::viewAddPage()
00583 {
00584   m_canvas_view->addPage ();
00585 }
00586 
00587 bool CanvasWindow::areDataSourcesSaved ()
00588 {
00589   const vector < const ViewBase * > & views = m_canvas_view->views ();
00590   bool yes = m_xml_controller->areDataSourcesSaved ( views );
00591 
00592   if ( yes == false ) {
00593     const string & app_name = m_canvas_view -> applicationName ();
00594 
00595     QString menutext = m_exportTextTuple->menuText();
00596     QString message;
00597     message += "Document can not be saved.\n\n"
00598       "It uses data sources that were neither\n"
00599       "read from nor saved to a file.\n\n";
00600     message += "Use File menu: \"";
00601     message += menutext;
00602     message += "\"\n";
00603     message += "to save the data sources first, or\n";
00604     message += "use the File menu: \"";
00605     menutext = m_fileSaveAllAction->menuText();
00606     message += menutext;
00607     message += "\".";
00608 
00609     QMessageBox::critical ( this, // parent
00610                             app_name.c_str(), // caption
00611                             message,
00612                             QMessageBox::Ok,
00613                             Qt::NoButton );
00614   }
00615 
00616   return yes;
00617 }
00618 
00619 void CanvasWindow::fileSave()
00620 {
00621   bool yes = areDataSourcesSaved ();
00622   if ( ! yes ) return;
00623 
00624   if ( m_filenameExists )
00625     {
00626       if ( m_hasChanged )
00627         {
00628           QString message ( "Document file exists\n\n" );
00629           message.append ( "Over-write existing file?" );
00630           int retval
00631             = QMessageBox::warning ( this,
00632                                      "Warning",
00633                                      message,
00634                                      QMessageBox::Yes,
00635                                      QMessageBox::No );
00636           if ( retval != QMessageBox::Yes ) return;
00637           saveAs ( m_filename );
00638         }
00639     }
00640   else
00641     {
00642       fileSaveAs ();
00643     }
00644 }
00645 
00646 bool
00647 CanvasWindow::
00648 setFilenameFromDialog ()
00649 {
00650   m_filename = m_file_dialog -> getSaveDocFilename ();
00651 
00652   m_filenameExists = m_filename.empty () ? false : true;
00653 
00654   return m_filenameExists;
00655 }
00656 
00657 void CanvasWindow::fileSaveAs()
00658 {
00659   bool yes = areDataSourcesSaved ();
00660   if ( ! yes ) return;
00661 
00662 bool ok = setFilenameFromDialog ();
00663   if ( ! ok ) return;
00664 
00665   saveAs ( m_filename );
00666 }
00667 
00668 
00669 void
00670 CanvasWindow::
00671 fileSaveAll()
00672 {
00673   if ( m_filenameExists == false ) {
00674     fileSaveAllAs ();
00675     return;
00676   }
00677   saveAllAs ( m_filename );
00678 }
00679 
00680 void
00681 CanvasWindow::
00682 fileSaveAllAs()
00683 {
00684   bool ok = setFilenameFromDialog ();
00685   if ( ! ok ) return;
00686   saveAllAs ( m_filename );
00687 }
00688 
00691 void
00692 CanvasWindow::
00693 saveAllAs ( const std::string & filename )
00694 {
00695   const string & suffix = m_file_dialog -> getDocSuffix ();
00696   string::size_type pos = filename.find ( suffix );
00697   string prefix = filename.substr ( 0, pos );
00698   NTupleController * controller = NTupleController::instance ();
00699 
00700   const string & data_suffix = QtFileDialog::getTextSuffix ();
00701   controller -> saveNTuples ( prefix, data_suffix );
00702   saveAs ( filename );
00703 }
00704 
00705 void CanvasWindow::fileSaveSelectedImages ()
00706 {
00707   m_canvas_view->saveSelectedImages ();
00708 }
00709 
00710 void CanvasWindow::fileSaveSelectedImages ( const std::string & filename )
00711 {
00712    m_canvas_view->saveSelectedImages(filename);
00713 }
00714 
00715 void
00716 CanvasWindow::
00717 saveAs ( const std::string & filename )
00718 {
00719   m_canvas_view -> saveAs ( filename );
00720 
00721   setTitleFileName ( filename );
00722   setChanged ( false );
00723   setCaption ();
00724 }
00725 
00726 CanvasView *
00727 CanvasWindow::
00728 getCanvasView ()
00729 {
00730   return m_canvas_view;
00731 }
00732 
00733 void
00734 CanvasWindow::
00735 fileExportTextTuple ()
00736 {
00737   const string & data_suffix = QtFileDialog::getTextSuffix ();
00738   m_canvas_view -> exportTextTuple ( data_suffix );
00739 }
00740 
00741 void
00742 CanvasWindow::
00743 on_fileExit_activated()
00744 {
00745   bool ok = WindowController::instance () -> okToQuit();
00746 
00747   if ( ok ) qApp->quit ();
00748 }
00749 
00750 void CanvasWindow::viewZoomIn()
00751 {
00752   m_canvas_view->viewZoomIn ();
00753 }
00754 
00755 void CanvasWindow::viewZoomOut()
00756 {
00757   m_canvas_view->viewZoomOut ();
00758 }
00759 
00760 void
00761 CanvasWindow::
00762 viewZoomReset()
00763 {
00764   m_canvas_view -> viewZoomReset ();
00765 }
00766 
00767 void
00768 CanvasWindow::
00769 viewLock ()
00770 {
00771   m_canvas_view->setLocked ( true );
00772   updateActions ();
00773 }
00774 
00775 void
00776 CanvasWindow::
00777 viewUnlock ()
00778 {
00779   m_canvas_view->setLocked ( false );
00780   updateActions ();
00781 }
00782 
00783 void CanvasWindow::helpAbout()
00784 {
00785   m_canvas_view -> helpAbout ();
00786 }
00787 
00788 void
00789 CanvasWindow::
00790 on_aboutQt_activated()
00791 {
00792   QMessageBox::aboutQt ( this );
00793 }
00794 
00795 void CanvasWindow::setCaption ()
00796 {
00797   QString fn = m_filename.c_str();
00798   QWidget::setCaption ( m_prefix + fn + m_changed );
00799 
00800 }
00801 
00802 void
00803 CanvasWindow::
00804 setTitleFileName ( const std::string & name )
00805 {
00806   m_filename = name;
00807   m_filenameExists = true;
00808 }
00809 
00810 void
00811 CanvasWindow::
00812 addTextDisplay ( PlotterBase * plotter,
00813                  const std::string & s )
00814 {
00815   m_canvas_view->addTextDisplay ( plotter, s );
00816 }
00817 
00818 void
00819 CanvasWindow::
00820 addTextDisplay ( PlotterBase * plotter,
00821                  const std::string & type,
00822                  const std::string & text)
00823 {
00824   m_canvas_view->addTextDisplay ( plotter, type, text );
00825 }
00826 
00827 std::pair<double, double>
00828 CanvasWindow::
00829 addTextDisplayAt ( PlotterBase * plotter,
00830                    const std::string & type,
00831                    const std::string & text,
00832                    double xrel, double yrel )
00833 {
00834    return m_canvas_view->addTextDisplayAt( plotter, type, text, xrel, yrel );
00835 }
00836 
00837 void
00838 CanvasWindow::
00839 addFuncDisplay ( PlotterBase * plotter, const std::string & s )
00840 {
00841   m_canvas_view->addFuncDisplay ( plotter, s );
00842 }
00843 
00844 void
00845 CanvasWindow::
00846 addPlotDisplay ( PlotterBase * plotter )
00847 {
00848   m_canvas_view->addPlotDisplay ( plotter );
00849 }
00850 
00851 void CanvasWindow::addPlotDisplay ( PlotterBase * plotter, bool sel )
00852 {
00853   m_canvas_view->addPlotDisplay ( plotter, sel );
00854 }
00855 
00856 void CanvasWindow::addDisplay ( PlotterBase * plotter )
00857 {
00858   m_canvas_view->addPlotDisplay ( plotter );
00859 }
00860 
00863 void
00864 CanvasWindow::
00865 removeDisplay ( PlotterBase * plotter )
00866 {
00867   m_canvas_view->removeDisplay ( plotter );
00868 }
00869 
00872 PlotterBase * CanvasWindow::selectedPlotter ()
00873 {
00874   return m_canvas_view->selectedPlotter ();
00875 }
00876 
00877 const vector < const ViewBase * > & CanvasWindow::views ()
00878 {
00879   return m_canvas_view->views ();
00880 }
00881 
00882 void
00883 CanvasWindow::
00884 fillPlotterList ( std::vector < PlotterBase * > & plotters )
00885 {
00886   m_canvas_view -> fillPlotterList ( plotters );
00887 }
00888 
00889 QtView *
00890 CanvasWindow::
00891 getViewFor ( const PlotterBase * plotter ) const
00892 {
00893   return m_canvas_view->getViewFor ( plotter );
00894 }
00895 
00896 void CanvasWindow::setIntervalEnabled ( bool yes )
00897 {
00898   m_canvas_view->setIntervalEnabled ( yes );
00899 }
00900 
00901 void
00902 CanvasWindow::
00903 viewShowInspector ()
00904 {
00905   m_canvas_view -> showInspector ();
00906 }
00907 
00908 void
00909 CanvasWindow::
00910 viewShowPlotTable ()
00911 {
00912   if ( s_plot_table == 0 ) {
00913     s_plot_table = new PlotTable ();
00914   }
00915   s_plot_table->setCanvas ( m_canvas_view );
00916   s_plot_table->show();
00917 }
00918 
00919 void
00920 CanvasWindow::
00921 viewShowPickTable ()
00922 {
00923   m_canvas_view->viewShowPickTable();
00924 }
00925 
00926 void
00927 CanvasWindow::
00928 savePlotAsImage ( const PlotterBase * plotter,
00929                   const std::string & filename )
00930 {
00931   SaveAsImageEvent * event = new SaveAsImageEvent ( plotter, filename );
00932   QApplication::postEvent ( this, event );
00933 }
00934 
00935 void
00936 CanvasWindow::
00937 saveAsImage ( const PlotterBase * plotter,
00938               const std::string & filename )
00939 {
00940   qApp -> lock ();
00941   m_canvas_view -> savePlotAsImage ( plotter, filename );
00942   qApp -> unlock ();
00943 }
00944 
00945 void
00946 CanvasWindow::
00947 savePlotAsImageImmediate ( const PlotterBase * plotter,
00948                            const std::string & filename )
00949 {
00950   m_canvas_view -> savePlotAsImage ( plotter, filename );
00951 }
00952 
00953 void
00954 CanvasWindow::
00955 setAllSelected ( bool flag )
00956 {
00957    m_canvas_view->setAllSelected( flag );
00958 }
00959 
00960 void
00961 CanvasWindow::
00962 setSelected ( QtView * view )
00963 {
00964    m_canvas_view->setSelectedItem( view );
00965 }
00966 
00967 void 
00968 CanvasWindow::
00969 previousView ( )
00970 {
00971   if ( ! ( selectedPlotter() ->getCurrentRangeSaved () ) )
00972     m_canvas_view -> setCurrentRange () ;
00973 
00974   m_canvas_view ->selectedPlotter () -> nextView (false );
00975   m_canvas_view -> canvas () -> update();
00976 }
00977 
00978 void 
00979 CanvasWindow::
00980 nextView ( )
00981 {
00982   if ( ! ( selectedPlotter() ->getCurrentRangeSaved () ) )
00983     m_canvas_view -> setCurrentRange () ;
00984 
00985   m_canvas_view ->selectedPlotter () -> nextView ( true );
00986   m_canvas_view -> canvas () -> update();
00987 }
00988 
00989 
00990 void
00991 CanvasWindow::
00992 setZoomMode ( )
00993 {
00994   if (  dynamic_cast<FigureEditor *> (m_canvas_view ) -> getZoomMode () )
00995      dynamic_cast<FigureEditor * >  (m_canvas_view ) -> setZoomMode ( false );
00996   else  dynamic_cast<FigureEditor * > (m_canvas_view ) -> setZoomMode ( true );
00997 }
00998 
00999 const std::vector<double> &
01000 CanvasWindow::
01001 mouseEventData()
01002 {
01003    return m_canvas_view->mouseEventData();
01004 }
01005 
01006 void
01007 CanvasWindow::
01008 settingPrinter()
01009 {
01010   m_canvas_view -> setPrinterSettings ();
01011 }
01012 
01013 void
01014 CanvasWindow::
01015 settingCanvas()
01016 {
01017   m_canvas_view -> setup ();
01018 }
01019 
01020 void
01021 CanvasWindow::
01022 settingFonts()
01023 {
01024   bool ok;
01025 
01026   // From the Qt documentation - "The usual way to use QFontDialog class is
01027   // to call one of the static convenience functions"
01028   QFont font
01029     = QFontDialog::getFont ( &ok, QFont( "Helvetica [Cronyx]", 10), this);
01030 
01031   m_canvas_view -> setFonts( font );
01032 }
01033 
01034 void
01035 CanvasWindow::
01036 print ( const std::string & filename )
01037 {
01038   m_canvas_view -> print ( filename );
01039 }
01040 
01041 void
01042 CanvasWindow::
01043 setPlotMatrix ( unsigned int columns, unsigned int rows )
01044 {
01045   m_canvas_view -> setPlotMatrix ( columns, rows );
01046   m_canvas_view -> reTile ();
01047 }
01048 
01049 void
01050 CanvasWindow::
01051 setAddedSelected ( bool yes )
01052 {
01053   m_canvas_view -> setAddedSelected ( yes );
01054 }

Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3