#include <FigureEditor.h>
Inheritance diagram for FigureEditor:
Sanket B. Malde <sanket@stanford.edu>
Engineers at Trolltech who wrote examples/canvas
Definition at line 64 of file FigureEditor.h.
Public Member Functions | |
void | add (QCanvasItem *item) |
Adds the item to the canvas. | |
void | addPage () |
Adds a page to the canvas. | |
void | addSelectedItem (QCanvasItem *item) |
Add an item to the selected list. | |
canvas () const | |
void | clear () |
Removes all items from canvas and destroy them. | |
drawContents (QPainter *p, int cx, int cy, int cw, int ch) | |
void | ensureVisible (const QCanvasItem *item) |
Scrolls the canvas, if needed, so the QCanvasItem item is visible. | |
FigureEditor (QCanvas *, QWidget *parent=0, const char *name=0, Qt::WFlags f=0) | |
The constructor. | |
std::vector< QCanvasItem * > & | getSelectedItems () |
Return the vector of selected items. | |
bool | getZoomMode () const |
Returns the bool indicating whether zoom mode is enabled or not. | |
inverseWorldMatrix () const | |
bool | isSingleItemSelected () const |
Returns true if just one item is selected, else returns false. | |
void | paste (QCanvasItem *item) |
Adds the item to the canvas. | |
void | placeGraph (QCanvasRectangle *) |
Moves the QCanvasRectangle object to place on the canvas where it will not collide with existing QCanvasItem object and not be off the usable page area. | |
virtual void | print (const std::string &filename) |
Prints the view to Postscript file filename. | |
virtual void | print () |
Prints the view to the printer. | |
void | remove (QCanvasItem *item) |
Removes the item from the canvas and destroys it. | |
void | removeSelectedItem (QCanvasItem *item) |
Removes an item from the selection list. | |
void | resizeEvent (QResizeEvent *e) |
Resizes the QCanvas in response to parent window receiving QResizeEvent. | |
void | scaleBy (double factor) |
Scales the size of the images by factor. | |
QCanvasItem * | selectedItem () const |
Returns the selected QCanvasItem. | |
void | setAllSelected (bool flag=true) |
Sets selection flag on all QCanvasItem objects. | |
setCanvas (QCanvas *canvas) | |
void | setLocked (bool flag) |
Sets the selected QCanvasItem to be locked in size and position. | |
void | setPrinterSettings () |
Set the default printer settings. | |
void | setSelectedFlags () |
Set the selected flags. | |
void | setSelectedItem (QCanvasItem *) |
Set the selected QCanvasItem. | |
setWorldMatrix (const QWMatrix &wm) | |
void | setZoomMode (bool flag) |
Sets the zoom mode to flag. | |
void | showPrinterMargins (bool on) |
Sets showing the printer margins on or off. | |
sizeHint () const | |
virtual void | viewShowPickTable ()=0 |
Show the pick table. | |
void | viewZoomIn () |
Enlarges the view of the canvas. | |
void | viewZoomOut () |
Reduces the view of the canvas. | |
void | viewZoomReset () |
Returns the view to normal size. | |
worldMatrix () const | |
Static Public Member Functions | |
static void | setAppKey (const std::string &) |
Sets the QSettings application key. | |
Protected Types | |
enum | Location { none, invalid, upper_left, upper_middle, upper_right, middle_left, middle_right, lower_left, lower_middle, lower_right } |
Possible locations where on a QCanvasItem the mouse cursor was when clicked. More... | |
Protected Member Functions | |
void | addPageMargin (int x, int y) |
Adds page margin. | |
void | calcPrinterMetrics () |
Calculate the size of a page by using the printer metrics. | |
void | clearSelectedList () |
De-selects all items, making the selection list empty. | |
void | contentsMouseMoveEvent (QMouseEvent *, double aspect) |
Moves or resizes the selected QCanvasItem object. | |
virtual void | contentsMousePressEvent (QMouseEvent *) |
virtual void | controlMousePressEvent ()=0 |
Handles details of mouse press event with shift key pressed. | |
QRect | getSelectedBounds () const |
Returns a QRect that enclosed the selected QCanvasItem objects. | |
void | initPrinter () |
Initializes the printer settings from the saved settings. | |
double | maximumZ () const |
Returns the largest Z value of all the items on the canvas. | |
virtual void | notifyObservers ()=0 |
Notifies Observer objects, if any, that something has changed. | |
void | placeGraphOnSelected (QCanvasRectangle *item) |
Adds the item on top of the currently selected item. | |
void | print (QPrinter *printer) |
Prints the view to the printer. | |
void | removeFromItemList (QCanvasItem *item) |
Removes the item from list of items on the canvas. | |
void | resizeCanvasToFit (QCanvasItem *item) |
Resizes the canvas if necessary so that the item is on the canvas. | |
void | saveAreaAsPixmap (const QRect &area, const std::string &filename) |
Saves the area area as pixmap to file filename. | |
void | savePrinterSettings () |
Saves the printer setting with QSettings. | |
void | saveSelectedAsPixmap (const std::string &filename) |
Save the selected objects as Pixmap image file filename. | |
void | setCollidingSelected (const QCanvasItem *target) |
Sets all QCanvasItems that collide with target to selected state. | |
void | setSelectedItems (bool state) |
Sets the selected items to selection state state. | |
void | setUnselectedVisible (bool yes) |
Sets the unselected items to visible or not. | |
void | whereClicked () |
Finds which knob on the selected item was clicked. | |
Protected Attributes | |
int | m_apage_h |
The actual Page height in Postscript points. | |
int | m_apage_w |
The actual Page width in Postscript points. | |
QCanvas * | m_canvas |
The canvas object. | |
std::vector< QCanvasItem * > | m_items |
The list of view items on the canvas. | |
bool | m_printer_bounds |
A flag to indicate if rectangle display usable printer boundary should be displayed or not. | |
double | m_scale_factor |
The scale factor. | |
std::vector< QCanvasItem * > | m_selected_list |
The list of currently selected QCanvasItem objects. | |
int | m_upage_h |
The usable Page height in Postscript points. | |
int | m_upage_w |
The usable Page width in Postscript points. | |
Location | m_whereClicked |
Location where the mouse cursor clicked the object. | |
bool | m_zoom_mode |
Set to true if zoom Mode is enabled. | |
QPoint | moving_start |
The starting point of a mouse drag. | |
QPoint | zoom_start |
The starting point of a mouse drag.for zoom. | |
Static Protected Attributes | |
static QString | s_app_key |
The QSettings application key for searching for setting. | |
static QPrinter * | s_printer = 0 |
The single QPrinter instance. | |
static QString | s_registry |
The QSettings Windows registry key. |
|
Possible locations where on a QCanvasItem the mouse cursor was when clicked.
Definition at line 191 of file FigureEditor.h. |
|
The constructor.
Definition at line 89 of file FigureEditor.cxx. References QSettings::insertSearchPath(), and QSettings::readNumEntry(). |
|
Adds the item to the canvas. Expands the canvas' size if necessary. Definition at line 1373 of file FigureEditor.cxx. Referenced by CanvasView::addView(), and CanvasView::initFrom(). |
|
Adds a page to the canvas.
Definition at line 1590 of file FigureEditor.cxx. References addPageMargin(), QCanvas::height(), m_apage_h, m_canvas, QCanvas::resize(), and QCanvas::width(). Referenced by CanvasWindow::viewAddPage(). |
|
Adds page margin. Adds an indication of the page's margin. Only the contents inside the margin is printable. Definition at line 221 of file FigureEditor.cxx. References m_apage_h, m_apage_w, m_canvas, m_printer_bounds, m_upage_h, and m_upage_w. Referenced by addPage(), and showPrinterMargins(). |
|
Add an item to the selected list.
Definition at line 333 of file FigureEditor.cxx. Referenced by contentsMousePressEvent(), CanvasView::pasteViews(), and setSelectedItem(). |
|
Calculate the size of a page by using the printer metrics. The size of a printable page is calculated on the basis that one pixel will become one Postscript point. A QPaintDeviceMetrics object is created to find the actual and usable size of a page in millimeters which is then converted to Postscript Points. Definition at line 251 of file FigureEditor.cxx. References QSize::height(), QString::isNull(), m_apage_h, m_apage_w, m_upage_h, m_upage_w, QPrinter::printerName(), s_printer, std::swap(), and QSize::width(). Referenced by print(). |
|
Removes all items from canvas and destroy them.
Reimplemented in CanvasView. Definition at line 863 of file FigureEditor.cxx. References m_items, and m_selected_list. Referenced by CanvasView::clear(). |
|
De-selects all items, making the selection list empty.
Definition at line 478 of file FigureEditor.cxx. References m_selected_list, and setSelectedItems(). Referenced by CanvasView::pasteViews(). |
|
Moves or resizes the selected QCanvasItem object. The is moved if one of its knobs was selected, otherwise, it is resized. If aspect is non zero, then keeps its aspect ratio is kept while resizing. Definition at line 885 of file FigureEditor.cxx. References std::abs(), QMouseEvent::button(), getZoomMode(), invalid, QCanvasView::inverseWorldMatrix(), isSingleItemSelected(), lower_left, lower_middle, lower_right, m_canvas, m_whereClicked, QStatusBar::message(), middle_left, middle_right, moving_start, none, QMouseEvent::pos(), selectedItem(), QtViewImp::setCrossX(), QtViewImp::setCrossY(), QApplication::setOverrideCursor(), QtView::setShowCrossHairs(), num_util::size(), QMouseEvent::state(), QCanvas::update(), QtView::update(), upper_left, upper_middle, upper_right, QPoint::x(), and QPoint::y(). Referenced by CanvasView::contentsMouseMoveEvent(), and contentsMousePressEvent(). |
|
Reimplemented in CanvasView. Definition at line 655 of file FigureEditor.cxx. References addSelectedItem(), QMouseEvent::button(), QCanvas::collisions(), contentsMouseMoveEvent(), controlMousePressEvent(), std::find(), QCanvasView::inverseWorldMatrix(), m_canvas, m_items, m_selected_list, moving_start, QMouseEvent::pos(), removeSelectedItem(), setSelectedFlags(), setSelectedItem(), QMouseEvent::state(), whereClicked(), and zoom_start. Referenced by CanvasView::contentsMousePressEvent(). |
|
Handles details of mouse press event with shift key pressed.
Implemented in CanvasView. Referenced by contentsMousePressEvent(). |
|
Scrolls the canvas, if needed, so the QCanvasItem item is visible.
Definition at line 555 of file FigureEditor.cxx. References QCanvasItem::boundingRect(), and QRect::rect(). Referenced by CanvasView::addView(). |
|
Returns a QRect that enclosed the selected QCanvasItem objects.
Definition at line 367 of file FigureEditor.cxx. References m_selected_list. Referenced by CanvasView::saveSelectedAsEps(), and saveSelectedAsPixmap(). |
|
Return the vector of selected items.
Definition at line 325 of file FigureEditor.cxx. References m_selected_list. Referenced by CanvasView::saveSelectedImages(), and setLocked(). |
|
Returns the bool indicating whether zoom mode is enabled or not.
Definition at line 1648 of file FigureEditor.cxx. References m_zoom_mode. Referenced by contentsMouseMoveEvent(), CanvasView::contentsMouseMoveEvent(), and CanvasView::contentsMouseReleaseEvent(). |
|
Initializes the printer settings from the saved settings. If setting have not been saved, set the default values. Definition at line 124 of file FigureEditor.cxx. References indexToOrientation, indexToPageSize, QSettings::insertSearchPath(), QSettings::readNumEntry(), s_app_key, s_printer, s_registry, QPrinter::setFullPage(), QPrinter::setOrientation(), QPrinter::setPageSize(), and num_util::size(). |
|
Returns true if just one item is selected, else returns false.
Definition at line 296 of file FigureEditor.cxx. References m_selected_list. Referenced by contentsMouseMoveEvent(), CanvasView::contentsMouseMoveEvent(), CanvasView::contentsMouseReleaseEvent(), selectedItem(), CanvasView::viewShowPickTable(), and whereClicked(). |
|
Returns the largest Z value of all the items on the canvas.
Definition at line 394 of file FigureEditor.cxx. References m_items, std::max(), and setUnselectedVisible(). Referenced by setSelectedItem(). |
|
Notifies Observer objects, if any, that something has changed.
Implemented in CanvasView. Referenced by setSelectedItem(). |
|
Adds the item to the canvas. This method differs from add in that it displaces the item by a fixed amount before adding. Definition at line 1390 of file FigureEditor.cxx. Referenced by CanvasView::pasteViews(). |
|
Moves the QCanvasRectangle object to place on the canvas where it will not collide with existing QCanvasItem object and not be off the usable page area.
Definition at line 1313 of file FigureEditor.cxx. References QRect::bottom(), and QRect::top(). Referenced by CanvasView::addFromPasteboard(), and CanvasView::addPlotDisplay(). |
|
Adds the item on top of the currently selected item.
Definition at line 626 of file FigureEditor.cxx. References QRect::height(), QRect::width(), QRect::x(), and QRect::y(). |
|
Prints the view to Postscript file filename.
Reimplemented in CanvasView. Definition at line 1526 of file FigureEditor.cxx. |
|
Prints the view to the printer. Presents the Print dialog to user and then prints the view to the selected printer. Reimplemented in CanvasView. Definition at line 1516 of file FigureEditor.cxx. References s_printer, and QPrinter::setup(). Referenced by print(), and CanvasView::print(). |
|
Prints the view to the printer.
Definition at line 1537 of file FigureEditor.cxx. References QPainter::begin(), calcPrinterMetrics(), QCanvas::collisions(), QCanvas::drawArea(), QPainter::end(), m_apage_h, m_canvas, m_scale_factor, m_upage_h, m_upage_w, QPrinter::newPage(), QPainter::scale(), setSelectedItems(), and QPainter::translate(). |
|
Removes the item from the canvas and destroys it.
Definition at line 852 of file FigureEditor.cxx. Referenced by CanvasView::deleteSelected(), CanvasView::removeDisplay(), and CanvasView::removeSelected(). |
|
Removes the item from list of items on the canvas.
Definition at line 837 of file FigureEditor.cxx. References std::remove(). Referenced by CanvasView::reTilePage(). |
|
Removes an item from the selection list.
Definition at line 350 of file FigureEditor.cxx. References QCanvasItem::isSelected(), and std::remove(). Referenced by contentsMousePressEvent(). |
|
Resizes the canvas if necessary so that the item is on the canvas. Changes the height by one page size while keeping the width constant. Definition at line 1410 of file FigureEditor.cxx. References QRect::bottomRight(). |
|
Resizes the QCanvas in response to parent window receiving QResizeEvent. The QCanvas may grow in size, but is never made smaller by this method. Definition at line 1575 of file FigureEditor.cxx. References QCanvas::height(), QSize::height(), m_canvas, QCanvas::resize(), QResizeEvent::size(), QCanvas::width(), and QSize::width(). Referenced by CanvasWindow::resizeEvent(). |
|
Saves the area area as pixmap to file filename.
Definition at line 1610 of file FigureEditor.cxx. References QPainter::begin(), QCanvas::drawArea(), QPainter::end(), QRect::height(), m_canvas, QPixmap::save(), setSelectedItems(), QPainter::translate(), QRect::width(), QRect::x(), and QRect::y(). Referenced by CanvasView::savePlotAsImage(), and saveSelectedAsPixmap(). |
|
Saves the printer setting with QSettings.
Definition at line 1492 of file FigureEditor.cxx. References QSettings::insertSearchPath(), s_app_key, s_printer, s_registry, and QSettings::writeEntry(). Referenced by setPrinterSettings(). |
|
Save the selected objects as Pixmap image file filename.
Definition at line 1601 of file FigureEditor.cxx. References getSelectedBounds(), saveAreaAsPixmap(), and setSelectedItems(). Referenced by CanvasView::saveSelectedImages(). |
|
Scales the size of the images by factor. The factor might be modified to ensure we see at least a page in single glance of the canvas. Definition at line 1429 of file FigureEditor.cxx. References m_apage_h, m_apage_w, m_canvas, m_printer_bounds, m_scale_factor, m_upage_h, m_upage_w, and showPrinterMargins(). |
|
Returns the selected QCanvasItem.
Definition at line 307 of file FigureEditor.cxx. References isSingleItemSelected(), and m_selected_list. Referenced by contentsMouseMoveEvent(), CanvasView::contentsMouseMoveEvent(), CanvasView::contentsMouseReleaseEvent(), CanvasView::viewShowPickTable(), and whereClicked(). |
|
Sets selection flag on all QCanvasItem objects.
Definition at line 489 of file FigureEditor.cxx. References std::bind2nd(), std::for_each(), m_items, m_selected_list, std::mem_fun(), and QCanvasItem::setSelected(). Referenced by CanvasWindow::editSelectAll(), CanvasWindow::setAllSelected(), and setSelectedFlags(). |
|
Sets the QSettings application key.
Definition at line 150 of file FigureEditor.cxx. References s_app_key. |
|
Sets all QCanvasItems that collide with target to selected state.
Definition at line 435 of file FigureEditor.cxx. References m_items, m_selected_list, and setSelectedItems(). Referenced by CanvasView::saveSelectedImages(). |
|
Sets the selected QCanvasItem to be locked in size and position.
Definition at line 573 of file FigureEditor.cxx. References std::bind2nd(), std::for_each(), getSelectedItems(), std::mem_fun(), and QCanvasItem::setActive(). Referenced by CanvasWindow::viewLock(), and CanvasWindow::viewUnlock(). |
|
Set the default printer settings.
Definition at line 1504 of file FigureEditor.cxx. References s_printer, and savePrinterSettings(). |
|
Set the selected flags.
Definition at line 513 of file FigureEditor.cxx. References m_selected_list, and setAllSelected(). Referenced by contentsMousePressEvent(), CanvasView::saveSelectedImages(), and setSelectedItem(). |
|
Set the selected QCanvasItem. This is called only when just one item is selected. Definition at line 536 of file FigureEditor.cxx. References addSelectedItem(), m_selected_list, maximumZ(), notifyObservers(), and setSelectedFlags(). Referenced by CanvasView::addView(), contentsMousePressEvent(), and CanvasWindow::setSelected(). |
|
Sets the selected items to selection state state. For each QCanvasItem in the selection list, set their selection state to state. Does not alter the selection list. Definition at line 460 of file FigureEditor.cxx. References m_selected_list. Referenced by clearSelectedList(), print(), saveAreaAsPixmap(), saveSelectedAsPixmap(), and setCollidingSelected(). |
|
Sets the unselected items to visible or not.
Definition at line 416 of file FigureEditor.cxx. References m_items. Referenced by maximumZ(), and CanvasView::saveSelectedImages(). |
|
Sets the zoom mode to flag.
Definition at line 1634 of file FigureEditor.cxx. References m_zoom_mode, and QApplication::setOverrideCursor(). |
|
Sets showing the printer margins on or off.
Definition at line 157 of file FigureEditor.cxx. References addPageMargin(), m_apage_h, m_canvas, and m_printer_bounds. Referenced by scaleBy(), and CanvasView::setup(). |
|
Show the pick table.
Implemented in CanvasView. |
|
Enlarges the view of the canvas.
Definition at line 1450 of file FigureEditor.cxx. References QCanvasView::setWorldMatrix(), and QCanvasView::worldMatrix(). Referenced by CanvasWindow::viewZoomIn(). |
|
Reduces the view of the canvas.
Definition at line 1464 of file FigureEditor.cxx. References QCanvasView::setWorldMatrix(), and QCanvasView::worldMatrix(). Referenced by CanvasWindow::viewZoomOut(). |
|
Returns the view to normal size.
Definition at line 1478 of file FigureEditor.cxx. References QCanvasView::setWorldMatrix(), and QCanvasView::worldMatrix(). |
|
Finds which knob on the selected item was clicked.
Definition at line 758 of file FigureEditor.cxx. References invalid, isSingleItemSelected(), lower_left, lower_middle, lower_right, m_whereClicked, middle_left, middle_right, moving_start, none, selectedItem(), upper_left, upper_middle, upper_right, QPoint::x(), and QPoint::y(). Referenced by contentsMousePressEvent(). |
|
The actual Page height in Postscript points.
Definition at line 76 of file FigureEditor.h. Referenced by addPage(), addPageMargin(), calcPrinterMetrics(), print(), CanvasView::reTilePage(), scaleBy(), CanvasView::setup(), and showPrinterMargins(). |
|
The actual Page width in Postscript points.
Definition at line 73 of file FigureEditor.h. Referenced by addPageMargin(), calcPrinterMetrics(), CanvasView::reTilePage(), scaleBy(), and CanvasView::setup(). |
|
The canvas object. Although one can always retrieve the canvas object by calling the canvas() member function, it is convenient to have this as a data member. Definition at line 171 of file FigureEditor.h. Referenced by addPage(), addPageMargin(), contentsMouseMoveEvent(), contentsMousePressEvent(), print(), resizeEvent(), CanvasView::reTilePage(), saveAreaAsPixmap(), scaleBy(), CanvasView::setVisibleNonViews(), showPrinterMargins(), and CanvasView::views(). |
|
The list of view items on the canvas. This list is a subset of the one kept by the QCanvas object,That one doesn't seem to maintain the order that items were inserted while this one does. Also, only application items are added to this list, not page decorations.
Definition at line 152 of file FigureEditor.h. Referenced by clear(), contentsMousePressEvent(), maximumZ(), CanvasView::reTile(), setAllSelected(), setCollidingSelected(), and setUnselectedVisible(). |
|
A flag to indicate if rectangle display usable printer boundary should be displayed or not.
Definition at line 94 of file FigureEditor.h. Referenced by addPageMargin(), CanvasView::saveSettings(), scaleBy(), CanvasView::setup(), and showPrinterMargins(). |
|
The scale factor. The factor by which drawing has been reduced so that a canvas page fits in the window. This factor should be applied in inverse before printing. Definition at line 82 of file FigureEditor.h. |
|
The list of currently selected QCanvasItem objects.
Definition at line 178 of file FigureEditor.h. Referenced by clear(), clearSelectedList(), contentsMousePressEvent(), CanvasView::controlMousePressEvent(), getSelectedBounds(), getSelectedItems(), isSingleItemSelected(), CanvasView::saveSelectedImages(), selectedItem(), CanvasView::selectedViews(), setAllSelected(), setCollidingSelected(), setSelectedFlags(), setSelectedItem(), and setSelectedItems(). |
|
The usable Page height in Postscript points.
Definition at line 139 of file FigureEditor.h. Referenced by addPageMargin(), CanvasView::calcDefaultSize(), calcPrinterMetrics(), print(), scaleBy(), and CanvasView::setup(). |
|
The usable Page width in Postscript points.
Definition at line 136 of file FigureEditor.h. Referenced by addPageMargin(), CanvasView::addPlotDisplay(), CanvasView::calcDefaultSize(), calcPrinterMetrics(), print(), scaleBy(), and CanvasView::setup(). |
|
Location where the mouse cursor clicked the object.
Definition at line 197 of file FigureEditor.h. Referenced by contentsMouseMoveEvent(), CanvasView::contentsMouseReleaseEvent(), and whereClicked(). |
|
Set to
Definition at line 86 of file FigureEditor.h. Referenced by getZoomMode(), and setZoomMode(). |
|
The starting point of a mouse drag.
Definition at line 184 of file FigureEditor.h. Referenced by contentsMouseMoveEvent(), contentsMousePressEvent(), and whereClicked(). |
|
The QSettings application key for searching for setting. The initial value is "HippoDraw", but may be changed by Starkey. Referenced by initPrinter(), CanvasView::initSettings(), savePrinterSettings(), CanvasView::saveSettings(), and setAppKey(). |
|
The single QPrinter instance.
Definition at line 83 of file FigureEditor.cxx. Referenced by calcPrinterMetrics(), initPrinter(), print(), savePrinterSettings(), CanvasView::saveSettings(), setPrinterSettings(), and CanvasView::setup(). |
|
The QSettings Windows registry key. The key is the same as used for by Trolltech for their Qt applications Referenced by initPrinter(), CanvasView::initSettings(), savePrinterSettings(), and CanvasView::saveSettings(). |
|
The starting point of a mouse drag.for zoom.
Definition at line 187 of file FigureEditor.h. Referenced by CanvasView::contentsMouseMoveEvent(), contentsMousePressEvent(), and CanvasView::contentsMouseReleaseEvent(). |