36 #include <qapplication.h>
37 #if QT_VERSION < 0x040000
41 #include <QtGui/QCloseEvent>
42 #include <QtCore/QCustomEvent>
43 #include <QtGui/QHideEvent>
44 #include <QtGui/QResizeEvent>
45 #include <QtGui/QShowEvent>
49 #include <qmessagebox.h>
50 #include <qfontdialog.h>
61 using namespace hippodraw;
70 #if QT_VERSION < 0x040000
80 m_prefix (
"HippoDraw - Canvas " ),
81 m_filename (
"UNTITLED" ),
82 m_changed (
" - Not Saved " ),
83 m_hasChanged ( false ),
84 m_inhibit_close ( false ),
85 m_allow_close ( false ),
86 m_filenameExists ( false )
89 #if QT_VERSION < 0x040000
92 Q3Canvas * canvas =
new Q3Canvas ();
100 resize ( sizeHint () ) ;
110 #if QT_VERSION < 0x040000
113 QMenu * fitter_menu =
PopupMenu -> addMenu (
"Fitter" );
116 while ( first != actions.end() ) {
118 fitter_menu -> addAction ( action );
137 #if QT_VERSION < 0x040000
165 if ( image_event != 0 ) {
166 const PlotterBase * plotter = image_event -> plotter ();
167 const string & filename = image_event -> filename ();
175 if ( plotter == 0 ) {
185 if ( ptevent != 0 ) {
207 if ( isActiveWindow () ==
true ) {
209 if ( wc -> currentCanvas ( ) !=
this ) {
210 wc -> setCurrentCanvas (
this );
232 bool _allowClose =
true;
233 const string & app_name =
m_canvas_view -> applicationName ();
235 QString message (
"The document,\n" );
237 message +=
"\ncontains unsaved changes.\n\n"
238 "Do you want to save the document before closing it?";
244 "&Save",
"&Discard",
"Cancel");
291 const string & app_name =
m_canvas_view -> applicationName ();
293 QString message (
"Closing the only document window will also\n"
294 "terminate the application.\n\n"
295 "Do you want to quit?" );
301 QMessageBox::Default |
307 case QMessageBox::Yes:
310 case QMessageBox::No:
347 if ( flag ==
true ) {
360 bool no = controller -> isPasteboardEmpty ();
363 const std::vector < const ViewBase * > &
views
365 bool yes = ! views.empty ();
378 if ( yes ==
false )
return;
382 if (views.size() == 1) {
391 bool one_locked =
false;
392 bool one_unlocked =
false;
393 std::vector < const ViewBase * >:: const_iterator first = views.begin ();
394 while ( first != views.end () ) {
395 const QtView * view = dynamic_cast <
const QtView * > ( *first++ );
402 bool locked = view->isActive ();
403 one_locked |= locked;
404 one_unlocked |= ! locked;
432 QString message (
"The clear operation can not be undone.\n\n" );
433 message.
append (
"Are you sure you want to remove all canvas items?" );
440 if ( retval != QMessageBox::Yes )
return;
526 #if QT_VERSION < 0x040000
529 = Q3FileDialog::getOpenFileName ( QString::null,
534 "Choose document file to browse" );
535 if ( filename != QString::null ) {
537 const string fn = s.
latin1();
539 string::size_type pos = fn.find_last_of (
'.' );
540 const string suffix = fn.substr ( pos );
543 #if QT_VERSION < 0x040000
546 Q3Canvas * canvas =
new Q3Canvas ();
567 #if QT_VERSION < 0x040000
570 = Q3FileDialog::getOpenFileName ( QString::null,
575 "Choose file to open" );
576 if ( filename != QString::null ) {
578 const string fn = s.
latin1();
581 string::size_type pos = fn.find_last_of (
'.' );
582 if ( pos != string::npos ) {
583 suffix = fn.substr ( pos );
597 catch ( exception & e ) {
598 QString message (
"Attempt to read file\n" );
601 message +=
"' led to error:\n";
692 if ( yes ==
false ) {
693 const string & app_name =
m_canvas_view -> applicationName ();
696 QString message (
"Document can not be saved.\n\n"
697 "It uses data sources that were neither\n"
698 "read from nor saved to a file.\n\n"
699 "Use File menu: \"" );
702 "to save the data sources first, or\n"
703 "use the File menu: \"";
728 QString message (
"Document file exists\n\n" );
729 message.
append (
"Over-write existing file?" );
736 if ( retval != QMessageBox::Yes )
return;
755 #if QT_VERSION < 0x040000
758 = Q3FileDialog::getSaveFileName ( QString::null,
763 "Save canvas to ..." );
765 if ( filename == QString::null )
return string();
768 if ( filename.
endsWith ( suffix.c_str() ) ==
false ) {
769 filename += suffix.c_str();
775 bool yes = info.
exists ();
776 if ( yes ==
false )
break;
778 string message (
"File exists. \n\n" );
779 message +=
"Over write existing file?";
785 if ( result == QMessageBox::Yes )
break;
787 string name = filename.
latin1();
841 string::size_type pos = filename.find ( suffix );
842 string prefix = filename.substr ( 0, pos );
846 controller -> saveNTuples ( prefix, data_suffix );
884 const string tuple_name = inspector -> getSelectedDataSourceName ();
887 if (fn.empty()==
true)
return;
890 string::size_type pos = fn.find_last_of (
'.' );
891 const string suffix = fn.substr ( pos );
926 message.
append(
"is not supported.\n\n");
927 message.
append(
"Please use Text ntuple (.tnt)\n");
928 message.
append(
"or FITS file (.fits).");
931 QString (
"Unsupported file type"),
1003 const string & app_name =
m_canvas_view -> applicationName ();
1004 QString message (
"The application was built without\n"
1005 "built-in help support" );
1014 controller -> openAssistant ();
1041 const std::string & s )
1049 const std::string &
type,
1050 const std::string & text)
1055 std::pair<double, double>
1058 const std::string &
type,
1059 const std::string & text,
1060 double xrel,
double yrel )
1152 const std::string & filename )
1161 const std::string & filename )
1187 if (currentPlotter) {
1202 if (currentPlotter) {
1220 const std::vector<double> &
1281 QString name = action -> menuText ();
1298 else if ( action ==
m_cut2 )
1300 else if ( action ==
m_cut3 )
1340 QString filename = action -> menuText ();
1342 const string fn = filename.
latin1();
1343 string::size_type pos = fn.find_last_of (
'.' );
1344 const string suffix = fn.substr ( pos );
1349 action -> setToggleAction (
false );
1350 action -> setToggleAction (
true );
1357 action -> setToggleAction (
false );
1358 action -> setToggleAction (
true );
1365 action -> setToggleAction (
false );
1366 action -> setToggleAction (
true );
1374 action -> setToggleAction (
false );
1375 action -> setToggleAction (
true );