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