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