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>
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 );
CanvasWindow(QWidget *parent=0, const char *name=0, Qt::WFlags fl=Qt::WType_TopLevel)
constructor.
void addPage()
Adds a page to the canvas.
static void resetFontSize()
Resets the font size to be no larger than 10.
static NTupleController * instance()
Returns the pointer to the singleton instance.
void removeDisplay(PlotterBase *plotter)
Removes the plotter and its view from the canvas.
void setAddedSelected(bool yes)
Sets to flag to make plots in their selected state when added to the canvas.
static const std::string & getDocSuffix()
Returns the suffix for a document.
The base class for the PlotterBase hierarchy.
const QString & getAppKey() const
Returns a reference the application's QSettings key.
virtual void setFitter(QAction *)
Responds to change in fitter settings.
setPointSize(int pointSize)
static const std::string & createOpenFilter()
Creates the open file filter.
virtual void fileCreateNTuple()
Create a new NTuple from selected cut and column.
static PlotTable * s_plot_table
The singleton instance of PlotTable.
virtual void settingFonts()
Sets the font settings.
PlotterBase * selectedPlotter() const
Returns the selected PlotterBase object.
static bool isFitsFile(const std::string &filename)
Returns true if the file filename is a FITS file.
PlotTableEvent class interface.
The class of derived from GroupViewBase, QtViewImp and QCanvasRectangle for drawing a grouped view on...
virtual void groupView()
Group the views.
static bool isTextSuffix(const std::string &suffix)
Returns true if suffix is one corresponding to text NTuple file.
SaveAsImageEvent class interface.
const std::vector< double > & mouseEventData()
Retrieve a vector (x, y, z) points from the next mouse event.
virtual void viewShowPickTable()
Shows the pick table window.
QAction * m_fileSaveAllAction
virtual void fileOpen()
Opens an existing file.
hippodraw::CanvasWindow class interface.
void addPlotDisplay(PlotterBase *plotter, bool select)
Adds a new plot display to the canvas.
void reTilePage()
Re-tiles the current page.
virtual void print()
Prints the canvas.
static bool isDocSuffix(const std::string &suffix)
Returns true if suffix is one corresponding to document file.
void saveAllAs(const std::string &filename)
Saves the document along with its NTuple objects.
virtual void helpAbout()
Brings up standard window showing version, authors, etc.
void autosaveSettings()
Automatically save dock windows and recently opened files.
static const std::string & getTextSuffix()
Returns the suffix for a text data source files.
virtual void openRecentFile(QAction *)
Responds to open recent file.
setFont(const QFont &font, bool informWidgets=FALSE, const char *className=0)
void addFuncDisplay(PlotterBase *plotter, const std::string &s)
Add a text display which displays functions parameters.
virtual void fileExportTextTuple()
arg(long a, int fieldWidth=0, int base=10) const
void removeDisplay(PlotterBase *plotter)
Removes the display from the canvas.
static bool isZippedFitsSuffix(const std::string &suffix)
Returns true if the file filename is a compressed FITS file.
hippodraw::PlotTable class interface
void setCaption()
Sets the Windows title.
virtual void filePrint()
Prints the canvas to a Postscript file.
void inhibitClose(bool yes=true)
If yes is true, sets a flag so that this object will not accept close events.
The class of derived from ViewBase and QCanvasRectangle for drawing on a QCanvas. ...
void saveSelectedImages()
Saves the selected QCanvasItem objects to a image file.
virtual void viewZoomIn()
Enlarges the view of the canvas.
virtual void fileNew()
Creates a new document CanvasWindow.
void notifyObservers()
Notifies observers of a change in CanvasView.
QAction * m_exportTextTuple
virtual void fileSaveAllAs()
Saves the canvas document and its NTuple.
virtual void viewAddPage()
Adds a page to the canvas.
QtView * getViewFor(const PlotterBase *plotter) const
Returns the QtView object that is the Observer of the plotter.
virtual bool closeNoPrompt()
Closes the window.
QString m_changed
The changed status part of the window title.
bool areDataSourcesSaved()
Returns true if all the data sources used by the document have been saved to or read from a file...
QAction * m_viewUnlockAction
virtual void resizeEvent(QResizeEvent *)
Informs the Canvas to re-size as well.
void savePlotAsImage(const PlotterBase *plotter, const std::string &filename)
Saves the plotter as image file.
void setAllowClose(bool yes=true)
Sets the window to allowed to be closed by user without prompting.
virtual void customEvent(QCustomEvent *event)
Responds to QCustomEvents.
void restoreFromSelectCopy()
Restores the selected views from the selection copy.
void reTile()
Re-tiles the canvas.
PlotterBase * selectedPlotter()
Returns the selected plotter.
hippodraw::PlotterBase class interface.
void addTextDisplay(PlotterBase *plotter, const std::string &s, const std::string &text=std::string())
Add a display of text Adds a display of text to that will be associated with plotter.
bool m_hasChanged
The current changed status.
virtual void editReTile()
Re tiles the entire document.
postEvent(QObject *receiver, QEvent *event)
virtual void showEvent(QShowEvent *e)
Informs the application object that the window has been shown.
static bool isRootSuffix(const std::string &suffix)
Returns true if suffix is one corresponding to ROOT DataSource files.
virtual bool getCurrentRangeSaved()
Returns current_range_saved member t.
hippodraw::NTupleController class interface
void newWindow(CanvasWindow *)
Registers the new CanvasWindow and finishes its initialization.
void previousView()
Switches View to the previous view for the selected item on the canvas.
void setIntervalEnabled(bool yes=true)
Sets the display interval feature of all views to enabled if yes is true, otherwise sets the feature ...
virtual void viewZoomOut()
Reduces the view of the canvas.
virtual void editUndo()
Responds to the undo action.
A DataSource class implemented with std::vector to store the column data. ...
void setIntervalEnabled(bool yes=true)
Sets the display interval feature to enabled if yes is true, otherwise sets it to disabled...
QAction * m_editDeleteAction
A derived class of QCustomEvent PlotTable events.
void saveAsImage(const PlotterBase *plotter, const std::string &filename)
Saves the plotter as image file.
virtual void editReTilePage()
Re tiles only the current page.
intp size(numeric::array arr)
virtual void viewLock()
Locks a canvas item.
std::pair< double, double > addTextDisplayAt(PlotterBase *plotter, const std::string &type, const std::string &text, double xrel, double yrel)
Adds a text display at the relative position (xrel, yrel) in the selected item's coordinates.
void setSelectedItem(QCanvasItem *)
Set the selected QCanvasItem.
virtual void settingCanvas()
Sets the canvas settings.
void addTextDisplay(PlotterBase *plotter, const std::string &type)
Adds a textual display to the canvas of type type.
void viewZoomOut()
Reduces the view of the canvas.
void addDisplay(PlotterBase *plotter)
Adds a new plot to the canvas and selects it.
A base class that is the interface between GUI and the XML serialization and deserialization.
virtual void hideEvent(QHideEvent *e)
Informs the application object that the window has been hidden.
static std::string getExportTupleFilename(QWidget *widget)
Returns a filename for exporting a DataSource.
void initFromFile(const std::string &filename)
Initializes this object from contents of file.
void fileSave()
Saves the document.
std::string m_filename
The file name part of the window title.
A concrete window class that contains the canvas and responds to menu item and tool bar events from t...
endsWith(const QString &s, bool cs=TRUE) const
hippodraw::QtFileDialog class interface
virtual void viewZoomReset()
Returns the view of the canvas to normal.
setCentralWidget(QWidget *w)
virtual void ungroupView()
Ungroup the views.
virtual void editClear()
Responds to "Clear" menu item.
virtual void viewShowInspector()
Shows the Inspector window.
void saveAs(const std::string &filename)
Saves the document to the specified file.
virtual void setZoomMode(bool on)
Sets the zoom mode to true or false.
void setAllSelected(bool flag=true)
Select or deselect all views in the window.
PyArray_TYPES type(numeric::array arr)
A derived class of InspectorBase class which is generated by the Qt designer.
void addPlotDisplay(PlotterBase *plotter, bool select)
Creates a QtView object for the display and inserts it onto the canvas in the next available free pla...
virtual void aboutQt()
Brings up Qt's about message box.
void addFuncDisplay(PlotterBase *plotter, const std::string &name)
Adds function textual display to the canvas.
void viewZoomIn()
Enlarges the view of the canvas.
void viewShowPickTable()
Show the pick table.
bool allowClose()
If document has changed and not saved, opens a dialog box for user to choose to save, discard or cancel.
void print(const std::string &filename)
Prints the view to Postscript file without prompting user.
void setPlotMatrix(unsigned int columns, unsigned int rows)
Sets the number of columns and rows of plots on each page.
void setSelected(QtView *view)
Select a specific view in the window.
void nextView()
Switches View to the next view for the selected item on the canvas.
static WindowController * instance()
Returns the application instance.
static QtXMLController * instance()
Returns the pointer to the singleton instance.
void setCurrentRange()
Saves the current range of the selected plotter.
void openFitsTuple(const std::string &filename, QWidget *parent)
Opens a FITS DataSource file.
A derived class of QCustomEvent to handle saving a PlotterBase object as image file events...
NTuple * getPickTable() const
Gets the pick table the selected plotter.
virtual void helpHelp()
Brings up a QAssistant client.
bool setFilenameFromDialog()
Sets the file name of document.
virtual void settingPrinter()
Sets the printer settings.
virtual void setCutMode(QAction *)
Sets the cut mode.
void copyFromPasteboard()
Copies from the pasteboard.
static const std::string & createBrowseFilter()
Creates the open file filter.
A class to handle various file types.
A derived class of PlotTableBase class which is generated by the Qt designer.
QActionGroup * m_recent_files
void clear()
Removes all the QCanvasItem objects from the canvas.
QString m_prefix
The prefix part of the window title.
virtual void fileSaveSelectedImages()
Saves the selected ViewBase object as an image file.
A singleton class that is the interface between GUI and the NTuple objects.
const std::vector< const ViewBase * > & views()
Returns the list of ViewBase objects on the canvas.
QAction * m_editCopyAction
virtual void fileSaveAll()
Saves the canvas document and any NTuple that were not read from or written to a file.
bool areDataSourcesSaved(const std::vector< const ViewBase * > &views)
Returns true if all the NTuple objects used by the views have been saved to or read from a file...
A singleton class for keeping track the window components of HippoDraw.
hippodraw::WindowController class interface
void copySelectedToPasteboard()
Copies selected items to pasteboard.
void createInspector()
Creates the Inspector object and positions it on the desktop.
hippodraw::CanvasView class interface
void setLocked(bool flag)
Sets the selected QCanvasItem to be locked in size and position.
const std::vector< const ViewBase * > & selectedViews() const
Returns temporary list of selected QtView objects on the canvas.
QAction * m_fileSaveSelected
void openRootTuple(const std::string &filename, QWidget *parent)
Opens a ROOT DataSource file.
CanvasView * m_browsed_canvas
The CanvasView object that is being browsed.
virtual void windowActivationChange(bool oldActive)
Informs the application object if this window has become the active one.
static const std::string & createDocumentFilter()
Creates a filter for saving a document.
hippodraw::PlotterEvent class interface
void fillPlotterList(std::vector< PlotterBase * > &plotter_list)
Clears and fills plotter_list with all the PlotterBase objects on the canvas.
std::pair< double, double > addTextDisplayAt(PlotterBase *plotter, const std::string &type, const std::string &text, double xrel, double yrel)
Adds a text display at the relative position (xrel, yrel) in the selected item's coordinates.
bool m_filenameExists
True if filename has been assigned, false if not.
const std::vector< double > & mouseEventData()
Retrieve a vector of (x, y, z) points from the next mouse event.
virtual void viewUnlock()
Unlocks a canvas item.
QtView * getViewFor(const PlotterBase *plotter) const
Returns the QtView object that is the Observer of the plotter.
getSaveFileName(const QString &startWith=QString::null, const QString &filter=QString::null, QWidget *parent=0, const char *name=0, const QString &caption=QString::null, QString *selectedFilter=0, bool resolveSymlinks=TRUE)
critical(QWidget *parent, const QString &caption, const QString &text, int button0, int button1, int button2=0)
virtual void viewShowPlotTable()
Shows the plot table.
const std::vector< const ViewBase * > & views() const
Returns temporary list of all QtView objects on the canvas.
void resizeEvent(QResizeEvent *e)
Re-sizes the QCanvas in response to parent window receiving QResizeEvent.
QAction * m_viewLockAction
static void openTextTuple(const std::string &filename)
Opens a text NTuple file.
void setTitleFileName(const std::string &name)
Sets the file name component of the window's title.
QAction * m_editCutAction
void setCanvas(CanvasView *canvas)
Sets the canvas to be used by the table.
warning(QWidget *parent, const QString &caption, const QString &text, int button0, int button1, int button2=0)
virtual void closeEvent(QCloseEvent *e)
Informs the application object that is window is about to close.
QActionGroup * m_set_fitter
bool m_inhibit_close
A flag set to true if the CanvasWindow should not accept a close event.
static bool isFitsSuffix(const std::string &suffix)
Returns true if suffix is one corresponding to FITS DataSource file.
getOpenFileName(const QString &startWith=QString::null, const QString &filter=QString::null, QWidget *parent=0, const char *name=0, const QString &caption=QString::null, QString *selectedFilter=0, bool resolveSymlinks=TRUE)
CanvasView * getCanvasView()
Returns the CanvasView object.
XmlController * m_xml_controller
The controller object capable of serializing the canvas contents as XML and serializing them...
void setChanged(bool flag=true)
Sets the changed flag.
bool m_allow_close
A flag set to true to allow the window to close without prompting the user.
A derived class of QCustomEvent to handle updates from PlotterBase.
virtual void fileSaveAs()
Saves the document after display a file dialog to the user.
QAction * m_editPasteAction
aboutQt(QWidget *parent, const QString &caption=QString::null)
virtual void editDelete()
Removes selected items from canvas without copying them to the pasteboard.
CanvasView * m_canvas_view
The CanvasView object which is the central widget.
QAction * m_editUndoAction
void setAllSelected(bool flag=true)
Sets selection flag on all QCanvasItem objects.
void clear()
Removes all items from the canvas.
This class implements additional FigureEditor functionality particular to QtView objects.
void deleteSelected(bool paste)
Removes the selected items from canvas and copies them to the pasteboard.
virtual void editCut()
Removes selected items from canvas and add them to the pasteboard.
virtual void fileExit()
Responds to the Quit item in the File menu.
QtFileDialog * m_file_dialog
The open file dialog for this window.
virtual void fileBrowse()
Browse a document file, without opening a window for it.
hippodraw::QtGroupView class interface
DataSourceController class interface.
std::string getSaveDocFilename()
Returns the chosen file name from a save canvas dialog.
void updateActions()
Update Action objects.
hippodraw::Inspector class interface.
virtual void editSelectAll()
Sets all QCanvasItem objects to selected.
getFont(bool *ok, const QFont &initial, QWidget *parent=0, const char *name=0)