00001
00014 #ifdef _MSC_VER
00015 #include "msdevstudio/MSconfig.h"
00016 #endif
00017
00018
00019 #ifdef HAVE_CONFIG_H
00020 #include "config.h"
00021 #endif
00022
00023 #include "FigureEditor.h"
00024
00025 #include "QtView.h"
00026 #include "CanvasWindow.h"
00027 #include "PickTable.h"
00028
00029 #include <qapplication.h>
00030 #include <qcursor.h>
00031 #include <qimage.h>
00032
00033 #if QT_VERSION < 0x040000
00034 #include <qwmatrix.h>
00035 #include <qpaintdevicemetrics.h>
00036 #else
00037
00038 #include <QMouseEvent>
00039 #include <QPixmap>
00040 #include <QResizeEvent>
00041 #include <qmatrix.h>
00042 #include <q3paintdevicemetrics.h>
00043 #endif
00044
00045 #include <qpainter.h>
00046 #include <qprinter.h>
00047 #include <qsettings.h>
00048 #include <qstatusbar.h>
00049
00050 #include <algorithm>
00051 #include <functional>
00052
00053 #include <cmath>
00054 #include <cctype>
00055
00056 #include <cassert>
00057
00058 using std::abs;
00059 using std::bind2nd;
00060 using std::for_each;
00061 using std::mem_fun;
00062 using std::string;
00063 using std::transform;
00064 using std::vector;
00065
00066 namespace {
00067 QPrinter::PageSize indexToPageSize[] =
00068 { QPrinter::A4, QPrinter::B5, QPrinter::Letter,
00069 QPrinter::Legal, QPrinter::Executive,
00070 QPrinter::A0, QPrinter::A1, QPrinter::A2, QPrinter::A3,
00071 QPrinter::A5, QPrinter::A6, QPrinter::A7, QPrinter::A8,
00072 QPrinter::A9, QPrinter::B0, QPrinter::B1,
00073 QPrinter::B10, QPrinter::B2, QPrinter::B3, QPrinter::B4,
00074 QPrinter::B6, QPrinter::B7, QPrinter::B8, QPrinter::B9,
00075 QPrinter::C5E, QPrinter::Comm10E,
00076 QPrinter::DLE, QPrinter::Folio, QPrinter::Ledger,
00077 QPrinter::Tabloid, QPrinter::Custom, QPrinter::NPageSize };
00078
00079 QPrinter::Orientation indexToOrientation[] = { QPrinter::Portrait,
00080 QPrinter::Landscape };
00081 }
00082
00083 QPrinter * FigureEditor::s_printer = 0;
00084 QString FigureEditor::s_app_key ( "/HippoDraw/" );
00085 QString FigureEditor::s_registry ( "/Trolltech" );
00086
00087 FigureEditor::
00088 #if QT_VERSION < 0x040000
00089 FigureEditor ( QCanvas * c, QWidget * parent,
00090 const char * name, Qt::WFlags f)
00091 : QCanvasView ( c, parent, name, f ),
00092 #else
00093 FigureEditor ( Q3Canvas * c, QWidget * parent,
00094 const char * name, Qt::WFlags f)
00095 : Q3CanvasView ( c, parent, name, f ),
00096 #endif
00097 m_scale_factor ( 1.0 )
00098 {
00099 m_zoom_mode = false ;
00100
00101 m_canvas = canvas ();
00102 m_canvas->setUpdatePeriod ( 30 );
00103
00104 if ( s_printer == 0 )
00105 {
00106 initPrinter ();
00107 s_printer->setFullPage ( true );
00108 }
00109
00110 calcPrinterMetrics ();
00111
00112 m_canvas->resize ( m_apage_w, m_apage_h );
00113
00114
00115 QSettings settings;
00116 settings.insertSearchPath ( QSettings::Windows, s_registry );
00117 int pb = settings.readNumEntry ( s_app_key + "Canvas/Margin", 0 );
00118 m_printer_bounds = ( pb == 1 ) ? true : false;
00119 }
00120
00121
00122 void
00123 FigureEditor::
00124 initPrinter ()
00125 {
00126 s_printer = new QPrinter ( );
00127
00128 QSettings settings;
00129 settings.insertSearchPath ( QSettings::Windows, s_registry );
00130
00131 int pagesize
00132 = settings.readNumEntry ( s_app_key + "Printer/PageSize",
00133 QPrinter::Letter );
00134 assert( pagesize < QPrinter::NPageSize );
00135 QPrinter::PageSize size = indexToPageSize [ pagesize ];
00136
00137 int orientation
00138 = settings.readNumEntry( s_app_key + "Printer/Orientation",
00139 QPrinter::Portrait );
00140 assert( orientation == 0 || orientation == 1 );
00141 QPrinter::Orientation orient = indexToOrientation [ orientation ];
00142
00143 s_printer->setOrientation ( orient );
00144 s_printer->setPageSize ( size );
00145 s_printer->setFullPage ( true );
00146 }
00147
00148 void
00149 FigureEditor::
00150 setAppKey ( const std::string & appkey )
00151 {
00152 s_app_key = appkey.c_str();
00153 }
00154
00155 void
00156 FigureEditor::
00157 showPrinterMargins ( bool on )
00158 {
00159
00160 if ( m_printer_bounds == false && on == true )
00161 {
00162 m_printer_bounds = true;
00163
00164 int height = m_canvas -> height();
00165 int y = 0;
00166 while ( y < height )
00167 {
00168 addPageMargin ( 0, y );
00169 y += m_apage_h;
00170 }
00171
00172 }
00173 else if( m_printer_bounds == true && on == false )
00174 {
00175 m_printer_bounds = false;
00176
00177 #if QT_VERSION < 0x040000
00178 QCanvasItemList itemList = m_canvas -> allItems ();
00179
00180 QValueListIterator< QCanvasItem * > iter;
00181 iter = itemList.begin();
00182
00183 while( iter != itemList.end() )
00184 {
00185 QCanvasItem * item = *iter++;
00186 QtView * view = dynamic_cast < QtView * > ( item );
00187
00188 if ( view == 0 )
00189 {
00190 QCanvasRectangle * rect
00191 = dynamic_cast< QCanvasRectangle * >( item );
00192 assert( rect );
00193 delete rect;
00194 }
00195 }
00196 #else
00197 Q3CanvasItemList itemList = m_canvas -> allItems ();
00198
00199 Q3ValueListIterator< Q3CanvasItem * > iter;
00200 iter = itemList.begin();
00201
00202 while( iter != itemList.end() )
00203 {
00204 Q3CanvasItem * item = *iter++;
00205 QtView * view = dynamic_cast < QtView * > ( item );
00206
00207 if ( view == 0 )
00208 {
00209 Q3CanvasRectangle * rect
00210 = dynamic_cast< Q3CanvasRectangle * >( item );
00211 assert( rect );
00212 delete rect;
00213 }
00214 }
00215 #endif
00216 }
00217 }
00218
00219 void
00220 FigureEditor::
00221 addPageMargin ( int x, int y )
00222 {
00223
00224 if ( m_printer_bounds == true )
00225 {
00226 #if QT_VERSION < 0x040000
00227 QCanvasRectangle * rect
00228 = new QCanvasRectangle ( x, y, m_upage_w, m_upage_h, m_canvas );
00229 #else
00230 Q3CanvasRectangle * rect
00231 = new Q3CanvasRectangle ( x, y, m_upage_w, m_upage_h, m_canvas );
00232 #endif
00233
00234 int dx = ( m_apage_w - m_upage_w ) / 2;
00235 int dy = ( m_apage_h - m_upage_h ) / 2;
00236 rect ->moveBy ( dx, dy );
00237
00238 QColor color ( "lightGray" );
00239 QPen pen ( color, 1, Qt::DashLine );
00240 rect -> setPen ( pen );
00241
00242 rect -> show ();
00243 }
00244 }
00245
00249 void
00250 FigureEditor::
00251 calcPrinterMetrics ()
00252 {
00253 QString name = s_printer->printerName();
00254 if ( name.isNull() )
00255 {
00256 if( s_printer -> orientation() == QPrinter::Portrait )
00257 {
00258 m_upage_w = 720;
00259 m_upage_h = 990;
00260 m_apage_w = 816;
00261 m_apage_h = 1054;
00262 }
00263 else
00264 {
00265 m_upage_h = 720;
00266 m_upage_w = 990;
00267 m_apage_h = 816;
00268 m_apage_w = 1054;
00269 }
00270 }
00271 else
00272 {
00273 #if QT_VERSION < 0x040000
00274 QPaintDeviceMetrics metrics ( s_printer );
00275 #else
00276 Q3PaintDeviceMetrics metrics ( s_printer );
00277 #endif
00278 int dpix = metrics.logicalDpiX ();
00279 int dpiy = metrics.logicalDpiY ();
00280
00281 m_apage_w = metrics.widthMM ();
00282 m_apage_h = metrics.heightMM ();
00283
00284 m_apage_w = static_cast < int > ( m_apage_w * dpix / 25.4 );
00285 m_apage_h = static_cast < int > ( m_apage_h * dpiy / 25.4 );
00286
00287 if( s_printer -> orientation() == QPrinter::Landscape )
00288 std::swap( m_apage_w, m_apage_h );
00289
00290 QSize margins = s_printer -> margins ();
00291 m_upage_w = m_apage_w - 2 * margins.width ();
00292 m_upage_h = m_apage_h - 2 * margins.height ();
00293 }
00294 }
00295
00296 bool FigureEditor::isSingleItemSelected () const
00297 {
00298 return ( m_selected_list.size() == 1 );
00299 }
00300
00301 #if QT_VERSION < 0x040000
00302 QCanvasItem *
00303 #else
00304 Q3CanvasItem *
00305 #endif
00306 FigureEditor::
00307 selectedItem () const
00308 {
00309 if ( isSingleItemSelected() )
00310 {
00311 return m_selected_list[0];
00312 }
00313 else
00314 {
00315 return 0;
00316 }
00317 }
00318
00319 #if QT_VERSION < 0x040000
00320 std::vector < QCanvasItem * > &
00321 #else
00322 std::vector < Q3CanvasItem * > &
00323 #endif
00324 FigureEditor::
00325 getSelectedItems ()
00326 {
00327 return m_selected_list;
00328 }
00329
00330 void
00331 FigureEditor::
00332 #if QT_VERSION < 0x040000
00333 addSelectedItem ( QCanvasItem * item )
00334 #else
00335 addSelectedItem ( Q3CanvasItem * item )
00336 #endif
00337 {
00338
00339 if ( ! item->isSelected() )
00340 {
00341 m_selected_list.push_back ( item );
00342 setSelectedFlags();
00343 }
00344
00345 }
00346
00347 void
00348 FigureEditor::
00349 #if QT_VERSION < 0x040000
00350 removeSelectedItem ( QCanvasItem * item )
00351 {
00352 if ( item->isSelected() ) {
00353 vector < QCanvasItem * > ::iterator last
00354 #else
00355 removeSelectedItem ( Q3CanvasItem * item )
00356 {
00357 if ( item->isSelected() ) {
00358 vector < Q3CanvasItem * > ::iterator last
00359 #endif
00360 = std::remove ( m_selected_list.begin(),
00361 m_selected_list.end(), item );
00362 m_selected_list.erase ( last, m_selected_list.end() );
00363 setSelectedFlags();
00364 }
00365 }
00366
00367 QRect FigureEditor::getSelectedBounds () const
00368 {
00369 #ifdef ITERATOR_MEMBER_DEFECT
00370 std::
00371 #endif
00372 #if QT_VERSION < 0x040000
00373 vector < QCanvasItem * > ::const_iterator first
00374 = m_selected_list.begin();
00375 QCanvasItem * item = *first++;
00376 #else
00377 vector < Q3CanvasItem * > ::const_iterator first
00378 = m_selected_list.begin();
00379 Q3CanvasItem * item = *first++;
00380 #endif
00381 QRect rect = item->boundingRect();
00382
00383 while ( first != m_selected_list.end() ) {
00384 item = *first++;
00385 QRect r = item->boundingRect ();
00386 rect |= r;
00387 }
00388
00389 return rect;
00390 }
00391
00392 double
00393 FigureEditor::
00394 maximumZ () const
00395 {
00396 #if QT_VERSION < 0x040000
00397 vector < QCanvasItem * > ::const_iterator first = m_items.begin();
00398 double max_z = (*first++) -> z ();
00399 while ( first != m_items.end () ) {
00400 QCanvasItem * item = *first++;
00401 #else
00402 vector < Q3CanvasItem * > ::const_iterator first = m_items.begin();
00403 double max_z = (*first++) -> z ();
00404 while ( first != m_items.end () ) {
00405 Q3CanvasItem * item = *first++;
00406 #endif
00407 double z = item -> z ();
00408 max_z = std::max ( max_z, z );
00409 }
00410
00411 return max_z;
00412 }
00413
00414 void
00415 FigureEditor::
00416 setUnselectedVisible ( bool yes )
00417 {
00418 #if QT_VERSION < 0x040000
00419 vector < QCanvasItem * > ::iterator first = m_items.begin();
00420 while ( first != m_items.end() ) {
00421 QCanvasItem * item = *first++;
00422 #else
00423 vector < Q3CanvasItem * > ::iterator first = m_items.begin();
00424 while ( first != m_items.end() ) {
00425 Q3CanvasItem * item = *first++;
00426 #endif
00427 if ( item->isSelected() ) continue;
00428 item->setVisible ( yes );
00429 }
00430 }
00431
00432 void
00433 FigureEditor::
00434 #if QT_VERSION < 0x040000
00435 setCollidingSelected ( const QCanvasItem * target )
00436 {
00437 vector < QCanvasItem * > ::iterator first = m_items.begin ();
00438 while ( first != m_items.end () ) {
00439 QCanvasItem * item = *first++;
00440 #else
00441 setCollidingSelected ( const Q3CanvasItem * target )
00442 {
00443 vector < Q3CanvasItem * > ::iterator first = m_items.begin ();
00444 while ( first != m_items.end () ) {
00445 Q3CanvasItem * item = *first++;
00446 #endif
00447 if ( item != target ) {
00448 if ( item -> collidesWith ( target ) ) {
00449 if ( item -> selected () == false ) {
00450 item -> setSelected ( true );
00451 m_selected_list.push_back ( item );
00452 }
00453 }
00454 }
00455 }
00456 }
00457
00458 void
00459 FigureEditor::
00460 setSelectedItems ( bool state )
00461 {
00462 #ifdef ITERATOR_MEMBER_DEFECT
00463 std::
00464 #endif
00465 #if QT_VERSION < 0x040000
00466 vector < QCanvasItem * > ::iterator first = m_selected_list.begin();
00467 while ( first != m_selected_list.end() ) {
00468 QCanvasItem * item = *first++;
00469 #else
00470 vector < Q3CanvasItem * > ::iterator first = m_selected_list.begin();
00471 while ( first != m_selected_list.end() ) {
00472 Q3CanvasItem * item = *first++;
00473 #endif
00474 item->setSelected ( state );
00475 }
00476 }
00477
00478 void FigureEditor::clearSelectedList ()
00479 {
00480 if ( m_selected_list.empty () == true ) return;
00481
00482 setSelectedItems ( false );
00483
00484 m_selected_list.clear();
00485 }
00486
00487 void
00488 FigureEditor::
00489 setAllSelected ( bool yes )
00490 {
00491 #if QT_VERSION < 0x040000
00492 #ifdef MEMFUN1_DEFECT
00493 for_each ( m_items.begin(), m_items.end(),
00494 bind2nd ( mem_fun1 ( &QCanvasItem::setSelected ), yes ) );
00495 #else
00496 for_each ( m_items.begin(), m_items.end(),
00497 bind2nd ( mem_fun ( &QCanvasItem::setSelected ), yes ) );
00498 #endif
00499 #else
00500 #ifdef MEMFUN1_DEFECT
00501 for_each ( m_items.begin(), m_items.end(),
00502 bind2nd ( mem_fun1 ( &Q3CanvasItem::setSelected ), yes ) );
00503 #else
00504 for_each ( m_items.begin(), m_items.end(),
00505 bind2nd ( mem_fun ( &Q3CanvasItem::setSelected ), yes ) );
00506 #endif
00507 #endif
00508 if (yes) {
00509 m_selected_list = m_items;
00510 }
00511 }
00512
00513 void FigureEditor::setSelectedFlags ()
00514 {
00515
00516
00517 setAllSelected ( false );
00518
00519
00520 #if QT_VERSION < 0x040000
00521 vector < QCanvasItem * > :: iterator first = m_selected_list.begin();
00522 while ( first != m_selected_list.end() ) {
00523 QCanvasItem * item = *first++;
00524 #else
00525 vector < Q3CanvasItem * > :: iterator first = m_selected_list.begin();
00526 while ( first != m_selected_list.end() ) {
00527 Q3CanvasItem * item = *first++;
00528 #endif
00529 item->setSelected ( true );
00530 }
00531 }
00532
00533 void
00534 FigureEditor::
00535 #if QT_VERSION < 0x040000
00536 setSelectedItem ( QCanvasItem * item )
00537 #else
00538 setSelectedItem ( Q3CanvasItem * item )
00539 #endif
00540 {
00541
00542 m_selected_list.clear ();
00543 setSelectedFlags ();
00544 addSelectedItem ( item );
00545
00546 double z = maximumZ ();
00547 item -> setZ ( z + 1.0 );
00548
00549 notifyObservers ();
00550 }
00551
00552 void
00553 FigureEditor::
00554 #if QT_VERSION < 0x040000
00555 ensureVisible ( const QCanvasItem * item )
00556 #else
00557 ensureVisible ( const Q3CanvasItem * item )
00558 #endif
00559 {
00560 QRect rect = item->boundingRect ();
00561 int x = 0, y = 0, w = 0, h = 0;
00562 rect.rect( & x, & y, & w, & h );
00563
00564 #if QT_VERSION < 0x040000
00565 QCanvasView::ensureVisible ( x, y, w, h );
00566 #else
00567 Q3CanvasView::ensureVisible ( x, y, w, h );
00568 #endif
00569 }
00570
00571 void
00572 FigureEditor::
00573 setLocked ( bool yes )
00574 {
00575 #if QT_VERSION < 0x040000
00576
00577 const vector < QCanvasItem * > & items = getSelectedItems ();
00578 if ( items.empty () ) return;
00579
00580 #ifdef MEMFUN_DEFECT
00581 vector < QCanvasItem * >:: const_iterator first = items.begin ();
00582 while ( first != items.end () ) {
00583 QCanvasItem * item = *first++;
00584 item->setActive ( yes );
00585 }
00586 #else
00587 #ifdef MEMFUN1_DEFECT
00588 for_each ( items.begin(), items.end(),
00589 bind2nd ( mem_fun1 ( &QCanvasItem::setActive ), yes ) );
00590 #else
00591 for_each ( items.begin(), items.end(),
00592 bind2nd ( mem_fun ( &QCanvasItem::setActive ), yes ) );
00593 #endif
00594 #endif
00595
00596 #else
00597
00598 const vector < Q3CanvasItem * > & items = getSelectedItems ();
00599 if ( items.empty () ) return;
00600
00601 #ifdef MEMFUN_DEFECT
00602 vector < Q3CanvasItem * >:: const_iterator first = items.begin ();
00603 while ( first != items.end () ) {
00604 Q3CanvasItem * item = *first++;
00605 item->setActive ( yes );
00606 }
00607 #else
00608 #ifdef MEMFUN1_DEFECT
00609 for_each ( items.begin(), items.end(),
00610 bind2nd ( mem_fun1 ( &Q3CanvasItem::setActive ), yes ) );
00611 #else
00612 for_each ( items.begin(), items.end(),
00613 bind2nd ( mem_fun ( &Q3CanvasItem::setActive ), yes ) );
00614 #endif
00615 #endif
00616
00617 #endif
00618 }
00619
00623 void
00624 FigureEditor::
00625 #if QT_VERSION < 0x040000
00626 placeGraphOnSelected ( QCanvasRectangle * view )
00627 #else
00628 placeGraphOnSelected ( Q3CanvasRectangle * view )
00629 #endif
00630 {
00631
00632 if ( !isSingleItemSelected() ) return;
00633
00634 #if QT_VERSION < 0x040000
00635 QCanvasItem * sel_item = selectedItem ();
00636 #else
00637 Q3CanvasItem * sel_item = selectedItem ();
00638 #endif
00639 QRect rect = sel_item->boundingRect ();
00640
00641 view->setX ( rect.x() );
00642 view->setY ( rect.y() );
00643 view->setSize ( rect.width(), rect.height () );
00644
00645 view->setCanvas ( m_canvas );
00646 m_items.push_back ( view );
00647 view->setSelected ( true );
00648
00649 view->show ();
00650 }
00651
00655 void FigureEditor::contentsMousePressEvent ( QMouseEvent* e )
00656 {
00657
00658
00659 #if QT_VERSION < 0x040000
00660 if ( e->state() == Qt::ShiftButton &&
00661 e->state() == Qt::ControlButton ) return;
00662 #else
00663 if ( e->state() == Qt::ShiftModifier &&
00664 e->state() == Qt::ControlModifier ) return;
00665 #endif
00666
00667 QPoint p = inverseWorldMatrix().map(e->pos());
00668 #if QT_VERSION < 0x040000
00669 QCanvasItemList l = m_canvas->collisions ( p );
00670 QCanvasItemList::Iterator it = l.begin();
00671 QCanvasItem * selItem = 0;
00672 #else
00673 Q3CanvasItemList l = m_canvas->collisions ( p );
00674 Q3CanvasItemList::Iterator it = l.begin();
00675 Q3CanvasItem * selItem = 0;
00676 #endif
00677 for ( ; it!=l.end(); ++it) {
00678 selItem = *it;
00679 #if QT_VERSION < 0x040000
00680 vector < QCanvasItem * > ::const_iterator first
00681 #else
00682 vector < Q3CanvasItem * > ::const_iterator first
00683 #endif
00684 = std::find ( m_items.begin (), m_items.end (), selItem );
00685 if ( first != m_items.end () ) {
00686 moving_start = p;
00687 zoom_start = p;
00688 break;
00689 }
00690 selItem = 0;
00691 }
00692
00693 if ( !selItem )
00694 {
00695
00696
00697
00698 #if QT_VERSION < 0x040000
00699 if ( e->state() != Qt::ControlButton )
00700 #else
00701 if ( e->state() != Qt::ControlModifier )
00702 #endif
00703 {
00704 m_selected_list.clear();
00705 setSelectedFlags();
00706 whereClicked();
00707 return;
00708 }
00709 else
00710 {
00711 return;
00712 }
00713 }
00714
00715
00716
00717
00718 #if QT_VERSION < 0x040000
00719 if ( e->state() == Qt::ShiftButton )
00720 #else
00721 if ( e->state() == Qt::ShiftModifier )
00722 #endif
00723 {
00724 if ( selItem -> isSelected () ) {
00725 removeSelectedItem ( selItem );
00726 }
00727 else {
00728 addSelectedItem ( selItem );
00729 }
00730 }
00731 #if QT_VERSION < 0x040000
00732 else if ( e->state() == Qt::ControlButton )
00733 #else
00734 else if ( e->state() == Qt::ControlModifier )
00735 #endif
00736 {
00737 m_selected_list.clear();
00738 setSelectedFlags();
00739 addSelectedItem ( selItem );
00740
00741 controlMousePressEvent ();
00742
00743 whereClicked ();
00744 }
00745
00746 else
00747 {
00748 setSelectedItem ( selItem );
00749 whereClicked();
00750 }
00751
00752 if ( e->button() == Qt::RightButton ) {
00753 contentsMouseMoveEvent ( e, 0 );
00754 }
00755
00756 }
00757
00758 void FigureEditor::whereClicked ( )
00759 {
00760
00761 m_whereClicked = invalid;
00762
00763 if ( !isSingleItemSelected() ) return;
00764
00765 m_whereClicked = none;
00766
00767 #if QT_VERSION < 0x040000
00768 QCanvasRectangle * rect
00769 = dynamic_cast <QCanvasRectangle *> ( selectedItem() );
00770 #else
00771 Q3CanvasRectangle * rect
00772 = dynamic_cast <Q3CanvasRectangle *> ( selectedItem() );
00773 #endif
00774
00775
00776 int clickMargin = 10;
00777
00778 QPoint p = moving_start;
00779
00780 if ( ( p.x() < rect->x() + clickMargin ) &&
00781 ( p.y() < rect->y() + clickMargin ) )
00782 {
00783 m_whereClicked = upper_left;
00784 }
00785
00786 if ( ( p.x() < ( rect->x() + (rect->width() / 2) + clickMargin ) ) &&
00787 ( p.x() > ( rect->x() + (rect->width() / 2) - clickMargin ) ) &&
00788 ( p.y() < rect->y() + clickMargin ) )
00789 {
00790 m_whereClicked = upper_middle;
00791 }
00792
00793 if ( ( p.x() > ( rect->x() + rect->width() - clickMargin ) ) &&
00794 ( p.y() < rect->y() + clickMargin ) )
00795 {
00796 m_whereClicked = upper_right;
00797 }
00798
00799 if ( ( p.x() < rect->x() + clickMargin ) &&
00800 ( p.y() < ( rect->y() + (rect->height() / 2) + clickMargin ) ) &&
00801 ( p.y() > ( rect->y() + (rect->height() / 2) - clickMargin ) ) )
00802 {
00803 m_whereClicked = middle_left;
00804 }
00805
00806 if ( ( p.x() > ( rect->x() + rect->width() - clickMargin ) ) &&
00807 ( p.y() < ( rect->y() + (rect->height() / 2) + clickMargin ) ) &&
00808 ( p.y() > ( rect->y() + (rect->height() / 2) - clickMargin ) ) )
00809 {
00810 m_whereClicked = middle_right;
00811 }
00812
00813 if ( ( p.x() < rect->x() + clickMargin ) &&
00814 ( p.y() > rect->y() + rect->height() - clickMargin ) )
00815 {
00816 m_whereClicked = lower_left;
00817 }
00818
00819 if ( ( p.x() < ( rect->x() + (rect->width() / 2) + clickMargin ) ) &&
00820 ( p.x() > ( rect->x() + (rect->width() / 2) - clickMargin ) ) &&
00821 ( p.y() > rect->y() + rect->height() - clickMargin ) )
00822 {
00823 m_whereClicked = lower_middle;
00824 }
00825
00826 if ( ( p.x() > ( rect->x() + rect->width() - clickMargin ) ) &&
00827 ( p.y() > ( rect->y() + rect->height() - clickMargin ) ) )
00828 {
00829 m_whereClicked = lower_right;
00830 }
00831
00832 }
00833
00834 void
00835 FigureEditor::
00836 #if QT_VERSION < 0x040000
00837 removeFromItemList ( QCanvasItem * item )
00838 {
00839 vector < QCanvasItem * > ::iterator last
00840 #else
00841 removeFromItemList ( Q3CanvasItem * item )
00842 {
00843 vector < Q3CanvasItem * > ::iterator last
00844 #endif
00845 = std::remove ( m_items.begin (), m_items.end (), item );
00846 m_items.erase ( last, m_items.end () );
00847 }
00848
00849 void
00850 FigureEditor::
00851 #if QT_VERSION < 0x040000
00852 remove ( QCanvasItem * item )
00853 #else
00854 remove ( Q3CanvasItem * item )
00855 #endif
00856 {
00857 m_selected_list.clear();
00858 removeFromItemList ( item );
00859
00860 delete item;
00861 }
00862
00863 void FigureEditor::clear()
00864 {
00865 #if QT_VERSION < 0x040000
00866 vector < QCanvasItem * >:: iterator it = m_items.begin();
00867 #else
00868 vector < Q3CanvasItem * >:: iterator it = m_items.begin();
00869 #endif
00870 for ( ; it != m_items.end(); ++it ) {
00871 if ( *it ) delete *it;
00872 }
00873
00874 m_items.clear();
00875 m_selected_list.clear();
00876 }
00877
00885 void FigureEditor::contentsMouseMoveEvent ( QMouseEvent * e, double aspect )
00886 {
00887 if ( m_whereClicked == invalid ) return;
00888 if ( !isSingleItemSelected() ) return;
00889
00890 QPoint p = inverseWorldMatrix().map(e->pos());
00891
00892 #if QT_VERSION < 0x040000
00893 QCanvasItem * selItem = selectedItem();
00894 QCanvasRectangle * rect
00895 = dynamic_cast <QCanvasRectangle *> ( selItem );
00896 #else
00897 Q3CanvasItem * selItem = selectedItem();
00898 Q3CanvasRectangle * rect
00899 = dynamic_cast <Q3CanvasRectangle *> ( selItem );
00900 #endif
00901
00902 if ( e->button() == Qt::RightButton ||
00903 e->state() == Qt::RightButton ) {
00904
00905
00906
00907 #if QT_VERSION < 0x040000
00908 CanvasWindow * cw = dynamic_cast < CanvasWindow * > ( parentWidget() );
00909 QStatusBar * sb = cw->statusBar();
00910 #else
00911
00912
00913 #endif
00914 if ( ( p.x() >= rect->x() ) &&
00915 ( p.x() <= rect->x() + rect->width() ) &&
00916 ( p.y() >= rect->y() ) &&
00917 ( p.y() <= rect->y() + rect->height() ) ) {
00918
00919 QtView * qtview = dynamic_cast < QtView * > ( selItem );
00920
00921 vector < double > picked;
00922 qtview -> fillPickedPoint ( p.x(), p.y(), picked );
00923 if ( picked.empty () ) return;
00924
00925 unsigned int size = picked.size();
00926 double datax = picked[1];
00927 double datay = picked[2];
00928 double dataz = 0.0;
00929 if ( size >= 4 ) {
00930 dataz = picked[3];
00931 }
00932
00933 double unscaledDataX = picked[1];
00934 double unscaledDataY = picked[2];
00935 if ( abs ( picked[0] - 1.0 ) < 0.5 ) unscaledDataY = picked[3];
00936
00937
00938 qtview->setCrossX ( unscaledDataX );
00939 qtview->setCrossY ( unscaledDataY );
00940 qtview->setShowCrossHairs ( true );
00941 const QCursor cursor ( Qt::CrossCursor );
00942 QApplication::setOverrideCursor ( cursor, true );
00943 qtview->update(0);
00944
00945 QString qstr = QString
00946 ( "Coordinates are : ( %1, %2, %3 )" )
00947 .arg ( datax )
00948 .arg ( datay )
00949 .arg ( dataz );
00950
00951 #if QT_VERSION < 0x040000
00952 sb->message ( qstr );
00953 #endif
00954 }
00955
00956 return;
00957
00958 }
00959
00960 switch ( m_whereClicked )
00961 {
00962
00963 case none:
00964 if (! (getZoomMode() ) ){
00965 selItem->moveBy(p.x() - moving_start.x(),
00966 p.y() - moving_start.y());
00967 }
00968 break;
00969
00970 case upper_left:
00971
00972 if ( aspect > 0 )
00973 {
00974
00975
00976 double new_h = rect->height() + moving_start.y() - p.y();
00977
00978 double new_w = aspect * ( new_h );
00979
00980 rect->setY ( rect->y() + rect->height() - new_h );
00981
00982 rect->setX ( rect->x() + rect->width() - new_w );
00983
00984 rect->setSize ( static_cast < int > ( new_w ),
00985 static_cast < int > ( new_h ) );
00986 }
00987
00988 else
00989 {
00990 rect->setX ( p.x() );
00991 rect->setY ( p.y() );
00992 rect->setSize ( rect->width() + moving_start.x() - p.x(),
00993 rect->height() + moving_start.y() - p.y() );
00994 }
00995
00996 if ( rect->width() < 0 && rect->height() < 0 )
00997 {
00998 rect->setSize ( 0,0 );
00999 m_whereClicked = lower_right;
01000 rect->setEnabled ( true );
01001 break;
01002 }
01003
01004 if ( rect->width() < 0 )
01005 {
01006 rect->setSize ( 0, rect->height() );
01007 m_whereClicked = upper_right;
01008 rect->setEnabled ( true );
01009 break;
01010 }
01011
01012 if ( rect->height() < 0 )
01013 {
01014 rect->setSize ( rect->width(), 0 );
01015 m_whereClicked = lower_left;
01016 rect->setEnabled ( true );
01017 break;
01018 }
01019
01020 rect->setEnabled ( true );
01021 break;
01022
01023 case upper_middle:
01024
01025 rect->setY ( p.y() );
01026
01027 if ( aspect > 0 )
01028 {
01029 double new_w = aspect * ( rect->height() + moving_start.y()
01030 - p.y() );
01031
01032 double new_x = rect->x() - ( new_w - rect->width() ) / 2.0;
01033
01034 rect->setX ( new_x );
01035
01036 rect->setSize ( static_cast< int > ( new_w ),
01037 rect->height() + moving_start.y() - p.y() );
01038 }
01039 else
01040 {
01041 rect->setSize ( rect->width(),
01042 rect->height() + moving_start.y() - p.y() );
01043 }
01044
01045 if ( rect->height() < 0 )
01046 {
01047 rect->setSize ( rect->width(), 0 );
01048 m_whereClicked = lower_middle;
01049 rect->setEnabled ( true );
01050 break;
01051 }
01052
01053 rect->setEnabled ( true );
01054 break;
01055
01056 case upper_right:
01057
01058 if ( aspect > 0 )
01059 {
01060
01061
01062 double new_h = rect->height() + moving_start.y() - p.y();
01063
01064 double new_w = aspect * ( new_h );
01065
01066 rect->setY ( rect->y() + rect->height() - new_h );
01067
01068 rect->setSize ( static_cast < int > ( new_w ),
01069 static_cast < int > ( new_h ) );
01070 }
01071
01072 else
01073 {
01074 rect->setY ( p.y() );
01075 rect->setSize ( rect->width() + p.x() - moving_start.x(),
01076 rect->height() + moving_start.y() - p.y() );
01077 }
01078
01079 if ( rect->width() < 0 && rect->height() < 0 )
01080 {
01081 rect->setSize ( 0,0 );
01082 m_whereClicked = lower_left;
01083 rect->setEnabled ( true );
01084 break;
01085 }
01086
01087 if ( rect->width() < 0 )
01088 {
01089 rect->setSize ( 0, rect->height() );
01090 m_whereClicked = upper_left;
01091 rect->setEnabled ( true );
01092 break;
01093 }
01094
01095 if ( rect->height() < 0 )
01096 {
01097 rect->setSize ( rect->width(), 0 );
01098 m_whereClicked = lower_right;
01099 rect->setEnabled ( true );
01100 break;
01101 }
01102
01103 rect->setEnabled ( true );
01104 break;
01105
01106 case middle_left:
01107
01108 rect->setX ( p.x() );
01109
01110 if ( aspect > 0 )
01111 {
01112 double new_h = ( rect->width() + moving_start.x()
01113 - p.x() ) / aspect;
01114
01115 double new_y = rect->y() - ( new_h - rect->height() ) / 2.0;
01116
01117 rect->setY ( new_y );
01118
01119 rect->setSize ( rect->width() + moving_start.x() - p.x(),
01120 static_cast < int > ( new_h ) );
01121 }
01122 else
01123 {
01124 rect->setSize ( rect->width() + moving_start.x() - p.x(),
01125 rect->height() );
01126 }
01127
01128 if ( rect->width() < 0 )
01129 {
01130 rect->setSize ( 0, rect->height() );
01131 m_whereClicked = middle_right;
01132 rect->setEnabled ( true );
01133 break;
01134 }
01135
01136 rect->setEnabled ( true );
01137 break;
01138
01139 case middle_right:
01140
01141 if ( aspect > 0 )
01142 {
01143 double new_h = ( rect->width() + p.x()
01144 - moving_start.x() ) / aspect;
01145
01146 double new_y = rect->y() - ( new_h - rect->height() ) / 2.0;
01147
01148 rect->setY ( new_y );
01149
01150 rect->setSize ( rect->width() + p.x() - moving_start.x(),
01151 static_cast < int > ( new_h ) );
01152 }
01153 else
01154 {
01155 rect->setSize ( rect->width() + p.x() - moving_start.x(),
01156 rect->height() );
01157 }
01158
01159 if ( rect->width() < 0 )
01160 {
01161 rect->setSize ( 0, rect->height() );
01162 m_whereClicked = middle_left;
01163 rect->setEnabled ( true );
01164 break;
01165 }
01166
01167 rect->setEnabled ( true );
01168 break;
01169
01170 case lower_left:
01171
01172 if ( aspect > 0 )
01173 {
01174
01175
01176
01177 double new_w = aspect * ( rect->height() + p.y()
01178 - moving_start.y() );
01179
01180 rect->setX ( rect->x() + rect->width() - new_w );
01181
01182 rect->setSize ( static_cast < int > ( new_w ),
01183 rect->height() + p.y() - moving_start.y() );
01184 }
01185
01186 else
01187 {
01188 rect->setX ( p.x() );
01189 rect->setSize ( rect->width() + moving_start.x() - p.x(),
01190 rect->height() + p.y() - moving_start.y() );
01191 }
01192
01193 if ( rect->width() < 0 && rect->height() < 0 )
01194 {
01195 rect->setSize ( 0,0 );
01196 m_whereClicked = upper_right;
01197 rect->setEnabled ( true );
01198 break;
01199 }
01200
01201 if ( rect->width() < 0 )
01202 {
01203 rect->setSize ( 0, rect->height() );
01204 m_whereClicked = lower_right;
01205 rect->setEnabled ( true );
01206 break;
01207 }
01208
01209 if ( rect->height() < 0 )
01210 {
01211 rect->setSize ( rect->width(), 0 );
01212 m_whereClicked = upper_left;
01213 rect->setEnabled ( true );
01214 break;
01215 }
01216
01217 rect->setEnabled ( true );
01218 break;
01219
01220 case lower_middle:
01221
01222 if ( aspect > 0 )
01223 {
01224 double new_w = aspect * ( rect->height() + p.y()
01225 - moving_start.y() );
01226
01227 double new_x = rect->x() - ( new_w - rect->width() ) / 2.0;
01228
01229 rect->setX ( new_x );
01230
01231 rect->setSize ( static_cast < int > ( new_w ),
01232 rect->height() + p.y() - moving_start.y() );
01233 }
01234 else
01235 {
01236 rect->setSize ( rect->width(),
01237 rect->height() + p.y() - moving_start.y() );
01238 }
01239
01240 if ( rect->height() < 0 )
01241 {
01242 rect->setSize ( rect->width(), 0 );
01243 m_whereClicked = upper_middle;
01244 rect->setEnabled ( true );
01245 break;
01246 }
01247
01248 rect->setEnabled ( true );
01249 break;
01250
01251 case lower_right:
01252
01253 if ( aspect > 0 )
01254 {
01255
01256
01257
01258 double new_w = aspect * ( rect->height() + p.y()
01259 - moving_start.y() );
01260
01261 rect->setSize ( static_cast < int > ( new_w ),
01262 rect->height() + p.y() - moving_start.y() );
01263 }
01264
01265 else
01266 {
01267 rect->setSize ( rect->width() + p.x() - moving_start.x(),
01268 rect->height() + p.y() - moving_start.y());
01269 }
01270
01271 if ( rect->width() < 0 && rect->height() < 0 )
01272 {
01273 rect->setSize ( 0,0 );
01274 m_whereClicked = upper_left;
01275 rect->setEnabled ( true );
01276 break;
01277 }
01278
01279 if ( rect->width() < 0 )
01280 {
01281 rect->setSize ( 0, rect->height() );
01282 m_whereClicked = lower_left;
01283 rect->setEnabled ( true );
01284 break;
01285 }
01286
01287 if ( rect->height() < 0 )
01288 {
01289 rect->setSize ( rect->width(), 0 );
01290 m_whereClicked = upper_right;
01291 rect->setEnabled ( true );
01292 break;
01293 }
01294
01295 rect->setEnabled ( true );
01296 break;
01297
01298 default:
01299
01300 break;
01301
01302 }
01303
01304 moving_start = p;
01305
01306 m_canvas->update();
01307
01308 }
01309
01310 void
01311 FigureEditor::
01312 #if QT_VERSION < 0x040000
01313 placeGraph ( QCanvasRectangle * item )
01314 #else
01315 placeGraph ( Q3CanvasRectangle * item )
01316 #endif
01317 {
01318 item -> setX ( 0 );
01319 item -> setY ( 0 );
01320
01321 int margin_x = ( m_apage_w - m_upage_w ) / 2;
01322 int margin_y = ( m_apage_h - m_upage_h ) / 2;
01323
01324 if ( item -> x () < margin_x ) item -> setX ( margin_x + 1 );
01325 if ( item -> y () < margin_y ) item -> setY ( margin_y + 1 );
01326
01327 if ( m_items.empty () ) return;
01328
01329 double deltax = 1.05 * item -> width ();
01330 double deltay = 1.05 * item -> height ();
01331
01332 while ( true ) {
01333 QRect brect = item->boundingRect ();
01334 int top = brect.top () / m_apage_h;
01335 int bot = brect.bottom () / m_apage_h;
01336 if ( top != bot ) {
01337 int new_y = bot * m_apage_h;
01338 new_y += ( m_apage_h - m_upage_h ) / 2;
01339 item->setY ( new_y );
01340 }
01341
01342 #if QT_VERSION < 0x040000
01343 vector < QCanvasItem * >:: iterator it = m_items.begin();
01344 #else
01345 vector < Q3CanvasItem * >:: iterator it = m_items.begin();
01346 #endif
01347 bool collides = false;
01348
01349 for ( ; it != m_items.end(); ++it ) {
01350 if ( (*it)->collidesWith ( item ) ) {
01351 collides = true;
01352 break;
01353 }
01354 }
01355
01356 if ( !collides ) break;
01357
01358 if ( item -> x() + deltax + item -> width () < m_apage_w - margin_x ) {
01359 item -> moveBy ( deltax, 0 );
01360 }
01361 else {
01362 item -> setX ( margin_x + 1 );
01363 item -> moveBy ( 0, deltay );
01364 }
01365
01366 }
01367
01368 }
01369
01370 void
01371 FigureEditor::
01372 #if QT_VERSION < 0x040000
01373 add ( QCanvasItem * item )
01374 #else
01375 add ( Q3CanvasItem * item )
01376 #endif
01377 {
01378 resizeCanvasToFit ( item );
01379
01380 item->setCanvas ( m_canvas );
01381 m_items.push_back ( item );
01382 item->setSelected ( false );
01383
01384 item->show ();
01385 }
01386
01387 void
01388 FigureEditor::
01389 #if QT_VERSION < 0x040000
01390 paste ( QCanvasItem * item )
01391 #else
01392 paste ( Q3CanvasItem * item )
01393 #endif
01394 {
01395 add ( item );
01396
01397 #if QT_VERSION < 0x040000
01398 QCanvasItemList items = item->collisions ( true );
01399 #else
01400 Q3CanvasItemList items = item->collisions ( true );
01401 #endif
01402 if ( items.count() > 0 ) {
01403 item->moveBy ( 10., 10. );
01404 }
01405 }
01406
01407 void
01408 FigureEditor::
01409 #if QT_VERSION < 0x040000
01410 resizeCanvasToFit ( QCanvasItem * item )
01411 #else
01412 resizeCanvasToFit ( Q3CanvasItem * item )
01413 #endif
01414 {
01415 QRect brect = item->boundingRect ();
01416 QPoint p = brect.bottomRight ();
01417 if ( ! m_canvas->onCanvas ( p ) )
01418 {
01419 int new_w = m_canvas->width ();
01420 int old_h = m_canvas->height();
01421 int new_h = old_h + m_apage_h;
01422 m_canvas->resize ( new_w, new_h );
01423 addPageMargin ( 0, old_h );
01424 }
01425 }
01426
01427 void
01428 FigureEditor::
01429 scaleBy ( double factor )
01430 {
01431 m_apage_w = static_cast < int > ( factor * m_apage_w );
01432 m_apage_h = static_cast < int > ( factor * m_apage_h );
01433 m_upage_w = static_cast < int > ( factor * m_upage_w );
01434 m_upage_h = static_cast < int > ( factor * m_upage_h );
01435
01436 m_canvas -> resize ( m_apage_w, m_apage_h );
01437 resizeContents ( m_apage_w, m_apage_h );
01438
01439 m_scale_factor = factor;
01440
01441 if( m_printer_bounds == true )
01442 {
01443 showPrinterMargins ( false );
01444 showPrinterMargins ( true );
01445 }
01446 }
01447
01448 void
01449 FigureEditor::
01450 viewZoomIn ()
01451 {
01452 #if QT_VERSION < 0x040000
01453 QWMatrix matrix = worldMatrix ();
01454 #else
01455 QMatrix matrix = worldMatrix ();
01456 #endif
01457 matrix.scale( 4./3., 4./3. );
01458
01459 setWorldMatrix ( matrix );
01460 }
01461
01462 void
01463 FigureEditor::
01464 viewZoomOut ()
01465 {
01466 #if QT_VERSION < 0x040000
01467 QWMatrix matrix = worldMatrix ();
01468 #else
01469 QMatrix matrix = worldMatrix ();
01470 #endif
01471 matrix.scale( 3./4., 3./4. );
01472
01473 setWorldMatrix ( matrix );
01474 }
01475
01476 void
01477 FigureEditor::
01478 viewZoomReset ()
01479 {
01480 #if QT_VERSION < 0x040000
01481 QWMatrix matrix = worldMatrix ();
01482 #else
01483 QMatrix matrix = worldMatrix ();
01484 #endif
01485 matrix.reset();
01486
01487 setWorldMatrix ( matrix );
01488 }
01489
01490 void
01491 FigureEditor::
01492 savePrinterSettings ()
01493 {
01494 QSettings settings;
01495 settings.insertSearchPath ( QSettings::Windows, s_registry );
01496
01497 QPrinter::PageSize page_size = s_printer -> pageSize ();
01498 settings.writeEntry ( s_app_key + "Printer/PageSize", page_size );
01499
01500 }
01501
01502 void
01503 FigureEditor::
01504 setPrinterSettings ()
01505 {
01506 bool yes = s_printer -> setup ( this );
01507 if ( yes == false ) return;
01508
01509 savePrinterSettings ();
01510 }
01511
01514 void
01515 FigureEditor::
01516 print ()
01517 {
01518 bool yes = s_printer->setup ( this );
01519 if ( yes == false ) return;
01520
01521 print ( s_printer );
01522 }
01523
01524 void
01525 FigureEditor::
01526 print ( const std::string & filename )
01527 {
01528 const QString name = filename.c_str();
01529 s_printer -> setOutputFileName ( name );
01530 s_printer -> setOutputToFile ( true );
01531
01532 print ( s_printer );
01533 }
01534
01535 void
01536 FigureEditor::
01537 print ( QPrinter * printer )
01538 {
01539 calcPrinterMetrics ();
01540
01541 setSelectedItems ( false );
01542 QPainter painter;
01543 painter.begin ( printer );
01544 double scale = 1.0 / m_scale_factor;
01545 painter.scale ( scale, scale );
01546 int page_y = 0;
01547 while ( page_y < m_canvas->height() ) {
01548 const QRect clip ( 0, page_y, m_upage_w, m_upage_h );
01549 #if QT_VERSION < 0x040000
01550 QCanvasItemList items = m_canvas->collisions ( clip );
01551 #else
01552 Q3CanvasItemList items = m_canvas->collisions ( clip );
01553 #endif
01554
01555 if ( items.empty () ) {
01556 page_y += m_apage_h;
01557 painter.translate ( 0, - m_apage_h );
01558 continue;
01559 }
01560 if ( page_y != 0 ) printer->newPage();
01561 page_y += m_apage_h;
01562
01563 bool dbuf = false;
01564
01565 m_canvas->drawArea ( clip, & painter, dbuf );
01566
01567 painter.translate ( 0, - m_apage_h );
01568 }
01569 painter.end();
01570 setSelectedItems ( true );
01571 }
01572
01573 void
01574 FigureEditor::
01575 resizeEvent ( QResizeEvent * e )
01576 {
01577 const QSize & w_size = e->size();
01578
01579
01580 int new_w = std::max<int> ( w_size.width (), m_canvas->width () );
01581 int new_h = std::max<int> ( w_size.height (), m_canvas->height () );
01582
01583 m_canvas->resize ( new_w, new_h );
01584
01585 updateScrollBars ();
01586 }
01587
01588 void
01589 FigureEditor::
01590 addPage ()
01591 {
01592 int old_y = m_canvas->height ();
01593 m_canvas->resize ( m_canvas->width(), old_y + m_apage_h );
01594 addPageMargin ( 0, old_y );
01595
01596 updateScrollBars ();
01597 }
01598
01599 void
01600 FigureEditor::
01601 saveSelectedAsPixmap ( const std::string & filename )
01602 {
01603 QRect rect = getSelectedBounds ();
01604 setSelectedItems ( false );
01605 saveAreaAsPixmap ( rect, filename );
01606 }
01607
01608 void
01609 FigureEditor::
01610 saveAreaAsPixmap ( const QRect & rect, const std::string & filename )
01611 {
01612 QPixmap pixmap ( rect.width(), rect.height() );
01613 QPainter painter;
01614
01615 painter.begin ( &pixmap );
01616 painter.translate ( -rect.x(), -rect.y() );
01617 m_canvas->drawArea ( rect, & painter );
01618 painter.end ();
01619
01620 setSelectedItems ( true );
01621
01622 QString fn ( filename.c_str() );
01623 string::size_type i = filename.find_last_of ( '.' );
01624 string suffix ( filename.substr ( i + 1 ) );
01625 transform ( suffix.begin(), suffix.end(),
01626 suffix.begin(), toupper );
01627 if ( suffix == "JPG" ) suffix = "JPEG";
01628 pixmap.save ( fn, suffix.c_str() );
01629 }
01630
01631
01632 void
01633 FigureEditor::
01634 setZoomMode ( bool flag )
01635 {
01636 m_zoom_mode = flag;
01637 if ( flag )
01638 QApplication::setOverrideCursor( QCursor ( Qt::CrossCursor ) );
01639 else
01640 QApplication::setOverrideCursor( QCursor ( Qt::ArrowCursor ) );
01641 }
01642
01643
01644
01645
01646 bool
01647 FigureEditor::
01648 getZoomMode ( ) const
01649 {
01650 return m_zoom_mode;
01651 }