ImageView.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   This is a view displaying an image or portion of an image in a box.   *
00004  *                                                                         *
00005  *   Author:    Graeme van der Vlugt                                       *
00006  *   Copyright: Imetric 3D GmbH                                            *
00007  *   Year:      2004                                                       *
00008  *                                                                         *
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU Library General Public License as       *
00012  *   published by the Free Software Foundation; either version 2 of the    *
00013  *   License, or (at your option) any later version.                       *
00014  *   for detail see the LICENCE text file.                                 *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "PreCompiled.h"
00019 #ifndef _PreComp_
00020 # include <QAction>
00021 # include <QApplication>
00022 # include <QMenu>
00023 # include <QMouseEvent>
00024 # include <QSlider>
00025 # include <QStatusBar>
00026 # include <QToolBar>
00027 # include <cmath>
00028 #endif
00029 
00030 #include "ImageView.h"
00031 #include "GLImageBox.h"
00032 #include "../App/ImageBase.h"
00033 #include "XpmImages.h"
00034 
00035 using namespace ImageGui;
00036 
00037 
00038 /* TRANSLATOR ImageGui::ImageView */
00039 
00040 ImageView::ImageView(QWidget* parent)
00041   : MDIView(0, parent)
00042 {
00043   // enable mouse tracking when moving even if no buttons are pressed
00044   setMouseTracking(true);
00045 
00046   // enable the mouse events
00047   _mouseEventsEnabled = true; 
00048 
00049   // Create the default status bar for displaying messages
00050   EnableStatusBar(true);
00051 
00052   // Create an OpenGL widget for displaying images
00053   _pGLImageBox = new GLImageBox(this);
00054   setCentralWidget(_pGLImageBox);
00055 
00056   _currMode = nothing;
00057   _currX = 0;
00058   _currY = 0;
00059 
00060   // Create the actions, menus and toolbars
00061   createActions();
00062 
00063   // connect other slots
00064   connect(_pGLImageBox, SIGNAL(drawGraphics()), this, SLOT(drawGraphics()));
00065 }
00066 
00067 ImageView::~ImageView()
00068 {
00069   // No need to delete _pGLImageBox or other widgets as this gets done automatically by QT
00070 }
00071 
00072 // Create the action groups, actions, menus and toolbars
00073 void ImageView::createActions()
00074 {
00075   // Create actions
00076   _pFitAct = new QAction(this);
00077   _pFitAct->setText(tr("&Fit image"));
00078   _pFitAct->setIcon(QPixmap(image_stretch));
00079   _pFitAct->setStatusTip(tr("Stretch the image to fit the view"));
00080   connect(_pFitAct, SIGNAL(triggered()), this, SLOT(fitImage()));
00081 
00082   _pOneToOneAct = new QAction(this);
00083   _pOneToOneAct->setText(tr("&1:1 scale"));
00084   _pOneToOneAct->setIcon(QPixmap(image_oneToOne));
00085   _pOneToOneAct->setStatusTip(tr("Display the image at a 1:1 scale"));
00086   connect(_pOneToOneAct, SIGNAL(triggered()), this, SLOT(oneToOneImage()));
00087 
00088   // Create the menus and add the actions
00089   _pContextMenu = new QMenu(this);
00090   _pContextMenu->addAction(_pFitAct);
00091   _pContextMenu->addAction(_pOneToOneAct);
00092 
00093   // Create the toolbars and add the actions
00094   _pStdToolBar = this->addToolBar(tr("Standard"));
00095   _pStdToolBar->addAction(_pFitAct);
00096   _pStdToolBar->addAction(_pOneToOneAct);
00097 }
00098 
00099 // Enable or disable the status bar
00100 void ImageView::EnableStatusBar(bool Enable)
00101 {
00102   if (Enable == true)
00103   {
00104     // Create the default status bar for displaying messages and disable the gripper
00105     _statusBarEnabled = true;
00106     statusBar()->setSizeGripEnabled( false );
00107     statusBar()->showMessage(tr("Ready..."));
00108   }
00109   else
00110   {
00111     // Delete the status bar
00112     _statusBarEnabled = false;
00113     QStatusBar *pStatusBar = statusBar();
00114     delete pStatusBar;
00115   }
00116 }
00117 
00118 // Enable or disable the toolbar
00119 void ImageView::EnableToolBar(bool Enable)
00120 {
00121   _pStdToolBar->setShown(Enable);
00122 }
00123 
00124 // Enable or disable the mouse events
00125 void ImageView::EnableMouseEvents(bool Enable)
00126 {
00127         _mouseEventsEnabled = Enable;
00128 }
00129 
00130 // Enable (show) or disable (hide) the '1:1' action
00131 // Current state (zoom, position) is left unchanged
00132 void ImageView::EnableOneToOneAction(bool Enable)
00133 {
00134   _pOneToOneAct->setVisible(Enable);
00135 }
00136 
00137 // Enable (show) or disable (hide) the 'fit image' action
00138 // Current state (zoom, position) is left unchanged
00139 void ImageView::EnableFitImageAction(bool Enable)
00140 {
00141   _pFitAct->setVisible(Enable);
00142 }
00143 
00144 // Slot function to fit (stretch/shrink) the image to the view size
00145 void ImageView::fitImage()
00146 {
00147   _pGLImageBox->stretchToFit();
00148 }
00149 
00150 
00151 // Slot function to display the image at a 1:1 scale"
00152 void ImageView::oneToOneImage()
00153 {
00154   _pGLImageBox->setNormal();
00155   _pGLImageBox->redraw();
00156    updateStatusBar();
00157 }
00158 
00159 // Show the original colors (no enhancement)
00160 // but image will be scaled for the number of significant bits
00161 // (i.e if 12 significant bits (in 16-bit image) a value of 4095 will be shown as white)
00162 void ImageView::showOriginalColors()
00163 {
00164   _pGLImageBox->clearColorMap();
00165   _pGLImageBox->redraw();
00166 }
00167 
00168 // Create a color map
00169 // (All red entries come first, then green, then blue, then alpha)
00170 // returns 0 for OK, -1 for memory allocation error
00171 // numRequestedEntries ... requested number of map entries (used if not greater than system maximum or 
00172 //                         if not greater than the maximum number of intensity values in the current image).
00173 //                         Pass zero to use the maximum possible. Always check the actual number of entries
00174 //                         created using getNumColorMapEntries() after a call to this method.
00175 // Initialise ... flag to initialise the map to a linear scale or not
00176 int ImageView::createColorMap(int numEntriesReq, bool Initialise)
00177 {
00178     return (_pGLImageBox->createColorMap(numEntriesReq, Initialise));
00179 }
00180 
00181 // Gets the number of entries in the color map (number of entries for each color)
00182 int ImageView::getNumColorMapEntries() const
00183 {
00184     return (_pGLImageBox->getNumColorMapEntries());
00185 }
00186 
00187 // Clears the color map
00188 void ImageView::clearColorMap()
00189 {
00190     _pGLImageBox->clearColorMap();
00191 }
00192 
00193 // Sets a color map RGBA value
00194 // (All red entries come first, then green, then blue, then alpha)
00195 // index ... index of color map RGBA entry
00196 // red ... intensity value for this red entry (range 0 to 1)
00197 // green ... intensity value for this green entry (range 0 to 1)
00198 // blue ... intensity value for this blue entry (range 0 to 1)
00199 // alpha ... intensity value for this alpha entry (range 0 to 1)
00200 int ImageView::setColorMapRGBAValue(int index, float red, float green, float blue, float alpha)
00201 {
00202     return (_pGLImageBox->setColorMapRGBAValue(index, red, green, blue, alpha));
00203 }
00204 
00205 // Sets a color map red value
00206 // (All red entries come first, then green, then blue, then alpha)
00207 // index ... index of color map red entry
00208 // value ... intensity value for this red entry (range 0 to 1)
00209 int ImageView::setColorMapRedValue(int index, float value)
00210 {
00211     return (_pGLImageBox->setColorMapRedValue(index, value));
00212 }
00213 
00214 // Sets a color map green value
00215 // (All red entries come first, then green, then blue, then alpha)
00216 // index ... index of color map green entry
00217 // value ... intensity value for this green entry (range 0 to 1)
00218 int ImageView::setColorMapGreenValue(int index, float value)
00219 {
00220     return (_pGLImageBox->setColorMapGreenValue(index, value));
00221 }
00222 
00223 // Sets a color map blue value
00224 // (All red entries come first, then green, then blue, then alpha)
00225 // index ... index of color map blue entry
00226 // value ... intensity value for this blue entry (range 0 to 1)
00227 int ImageView::setColorMapBlueValue(int index, float value)
00228 {
00229     return (_pGLImageBox->setColorMapBlueValue(index, value));
00230 }
00231 
00232 // Sets a color map alpha value
00233 // (All red entries come first, then green, then blue, then alpha)
00234 // index ... index of color map alpha entry
00235 // value ... intensity value for this alpha entry (range 0 to 1)
00236 int ImageView::setColorMapAlphaValue(int index, float value)
00237 {
00238     return (_pGLImageBox->setColorMapAlphaValue(index, value));
00239 }
00240 
00241 // Clears the image data
00242 void ImageView::clearImage()
00243 {
00244     _pGLImageBox->clearImage();
00245     _pGLImageBox->redraw(); // clears view
00246         updateStatusBar();
00247 }
00248 
00249 // Load image by copying the pixel data
00250 // The image object inside this view object will take ownership of the copied pixel data
00251 // (the source image is still controlled by the caller)
00252 // If numSigBitsPerSample = 0 then the full range is assumed to be significant
00253 // displayMode ... controls the initial display of the image, one of:
00254 //                      IV_DISPLAY_NOCHANGE  ... no change to view settings when displaying a new image
00255 //                      IV_DISPLAY_FITIMAGE  ... fit-image when displaying a new image (other settings remain the same)
00256 //                      IV_DISPLAY_RESET     ... reset settings when displaying a new image (image will be displayed at 1:1 scale with no color map)
00257 // Returns:
00258 //               0 for OK
00259 //              -1 for invalid color format
00260 //              -2 for memory allocation error
00261 int ImageView::createImageCopy(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample, int displayMode)
00262 {
00263     int ret = _pGLImageBox->createImageCopy(pSrcPixelData, width, height, format, numSigBitsPerSample, displayMode);
00264     showOriginalColors();
00265         updateStatusBar();
00266     return ret;
00267 }
00268 
00269 // Make the image object inside this view object point to another image source
00270 // If takeOwnership is false then:
00271 //      This object will not own (control) or copy the pixel data
00272 //      (the source image is still controlled by the caller)
00273 // Else if takeOwnership is true then:
00274 //      This object will take ownership (control) of the pixel data
00275 //      (the source image is not (should not be) controlled by the caller anymore)
00276 //      In this case the memory must have been allocated with the new operator (because this class will use the delete operator)
00277 // If numSigBitsPerSample = 0 then the full range is assumed to be significant
00278 // displayMode ... controls the initial display of the image, one of:
00279 //                      IV_DISPLAY_NOCHANGE  ... no change to view settings when displaying a new image
00280 //                      IV_DISPLAY_FITIMAGE  ... fit-image when displaying a new image (other settings remain the same)
00281 //                      IV_DISPLAY_RESET     ... reset settings when displaying a new image (image will be displayed at 1:1 scale with no color map)
00282 // Returns:
00283 //               0 for OK
00284 //              -1 for invalid color format
00285 int ImageView::pointImageTo(void* pSrcPixelData, unsigned long width, unsigned long height, int format, unsigned short numSigBitsPerSample, bool takeOwnership, int displayMode)
00286 {
00287     int ret = _pGLImageBox->pointImageTo(pSrcPixelData, width, height, format, numSigBitsPerSample, takeOwnership, displayMode);
00288     showOriginalColors();
00289         updateStatusBar();
00290     return ret;
00291 }
00292 
00293 // Mouse press event
00294 void ImageView::mousePressEvent(QMouseEvent* cEvent)
00295 {
00296    if (_mouseEventsEnabled == true)
00297    {
00298       // Mouse event coordinates are relative to top-left of image view (including toolbar!)
00299       // Get current cursor position relative to top-left of image box
00300       QPoint offset = _pGLImageBox->pos();
00301       int box_x = cEvent->x() - offset.x();
00302       int box_y = cEvent->y() - offset.y();
00303       _currX = box_x;
00304       _currY = box_y;
00305       switch(cEvent->buttons())
00306       {
00307           case Qt::MidButton:
00308               _currMode = panning;
00309               this->setCursor(QCursor(Qt::ClosedHandCursor));
00310               startDrag();
00311               break;
00312           //case Qt::LeftButton | Qt::MidButton:
00313           //    _currMode = zooming;
00314           //    break;
00315           case Qt::LeftButton:
00316               if (cEvent->modifiers() & Qt::ShiftModifier)
00317                   _currMode = addselection;
00318               else
00319                 _currMode = selection;
00320               break;
00321           case Qt::RightButton:
00322                _pContextMenu->exec(cEvent->globalPos());
00323               break;
00324           default:
00325               _currMode = nothing;
00326       }
00327    }
00328 }
00329 
00330 void ImageView::mouseDoubleClickEvent(QMouseEvent* cEvent)
00331 {
00332    if (_mouseEventsEnabled == true)
00333    {
00334        // Mouse event coordinates are relative to top-left of image view (including toolbar!)
00335        // Get current cursor position relative to top-left of image box
00336        QPoint offset = _pGLImageBox->pos();
00337        int box_x = cEvent->x() - offset.x();
00338        int box_y = cEvent->y() - offset.y();
00339        _currX = box_x;
00340        _currY = box_y;
00341        if(cEvent->button() == Qt::MidButton)
00342        {
00343            double icX = _pGLImageBox->WCToIC_X(_currX);
00344            double icY = _pGLImageBox->WCToIC_Y(_currY);
00345            //int pixX = (int)floor(icX + 0.5);
00346            //int pixY = (int)floor(icY + 0.5);
00347            _pGLImageBox->setZoomFactor(_pGLImageBox->getZoomFactor(), true, (int)floor(icX + 0.5), (int)floor(icY + 0.5));
00348            _pGLImageBox->redraw();
00349                    updateStatusBar();
00350        }
00351    }
00352 }
00353 
00354 // Mouse move event
00355 void ImageView::mouseMoveEvent(QMouseEvent* cEvent)
00356 {
00357     QApplication::flush();
00358 
00359    // Mouse event coordinates are relative to top-left of image view (including toolbar!)
00360    // Get current cursor position relative to top-left of image box
00361    QPoint offset = _pGLImageBox->pos();
00362    int box_x = cEvent->x() - offset.x();
00363    int box_y = cEvent->y() - offset.y();
00364    if (_mouseEventsEnabled == true)
00365    {
00366        switch(_currMode)
00367        {
00368            case nothing:
00369                break;
00370            case panning:
00371                _pGLImageBox->relMoveWC(box_x - dragStartWCx, box_y - dragStartWCy);
00372                break;
00373            case zooming:
00374                zoom(_currX, _currY, box_x, box_y);
00375                break;
00376            default:
00377                break;
00378        }
00379    }
00380    _currX = box_x;
00381    _currY = box_y;
00382 
00383    // Update the status bar
00384    updateStatusBar();
00385 }
00386 
00387 // Mouse release event
00388 void ImageView::mouseReleaseEvent(QMouseEvent* cEvent)
00389 {
00390    if (_mouseEventsEnabled == true)
00391    {
00392        // Mouse event coordinates are relative to top-left of image view (including toolbar!)
00393        // Get current cursor position relative to top-left of image box
00394        QPoint offset = _pGLImageBox->pos();
00395        int box_x = cEvent->x() - offset.x();
00396        int box_y = cEvent->y() - offset.y();
00397        switch(_currMode)
00398        {
00399            case selection:
00400                select(box_x, box_y);
00401                break;
00402            case addselection:
00403                addSelect(box_x, box_y);
00404                break;
00405            case panning:
00406                this->unsetCursor();
00407                break;
00408            default:
00409                break;
00410        }
00411        _currMode = nothing;
00412    }
00413 }
00414 
00415 // Mouse wheel event
00416 void ImageView::wheelEvent(QWheelEvent * cEvent)
00417 {
00418    if (_mouseEventsEnabled == true)
00419    {
00420        // Mouse event coordinates are relative to top-left of image view (including toolbar!)
00421        // Get current cursor position relative to top-left of image box
00422        QPoint offset = _pGLImageBox->pos();
00423        int box_x = cEvent->x() - offset.x();
00424        int box_y = cEvent->y() - offset.y();
00425 
00426        // Zoom around centrally displayed image point
00427        int numTicks = cEvent->delta() / 120;
00428        int ICx, ICy;
00429        _pGLImageBox->getCentrePoint(ICx, ICy);
00430        _pGLImageBox->setZoomFactor(_pGLImageBox->getZoomFactor() / pow(2.0, (double)numTicks), true, ICx, ICy);
00431        _pGLImageBox->redraw();
00432        _currX = box_x;
00433        _currY = box_y;
00434 
00435        // Update the status bar
00436        updateStatusBar();
00437    }
00438 }
00439 
00440 void ImageView::showEvent (QShowEvent * e)
00441 {
00442     _pGLImageBox->setFocus();
00443 }
00444 
00445 // Update the status bar with the image parameters for the current mouse position
00446 void ImageView::updateStatusBar()
00447 {
00448     if (_statusBarEnabled == true)
00449         {
00450         // Create the text string to display in the status bar
00451         QString txt = createStatusBarText();
00452 
00453         // Update status bar with new text
00454         statusBar()->showMessage(txt);
00455         }
00456 }
00457 
00458 // Create the text to display in the status bar.
00459 // Gets called by updateStatusBar()
00460 // Override this function in a derived class to add your own text
00461 QString ImageView::createStatusBarText()
00462 {
00463     // Get some image parameters
00464     //unsigned short numImageSamples = _pGLImageBox->getImageNumSamplesPerPix();
00465     double zoomFactor = _pGLImageBox->getZoomFactor();
00466     double icX = _pGLImageBox->WCToIC_X(_currX);
00467     double icY = _pGLImageBox->WCToIC_Y(_currY);
00468     int pixX = (int)floor(icX + 0.5);
00469     int pixY = (int)floor(icY + 0.5);
00470     int colorFormat = _pGLImageBox->getImageFormat();
00471 
00472    // Create text for status bar
00473     QString txt;
00474     if ((colorFormat == IB_CF_GREY8) || 
00475         (colorFormat == IB_CF_GREY16) || 
00476         (colorFormat == IB_CF_GREY32))
00477     {
00478         double grey_value;
00479         if (_pGLImageBox->getImageSample(pixX, pixY, 0, grey_value) == 0)
00480             txt = QString::fromAscii("x,y = %1,%2  |  %3 = %4  |  %5 = %6")
00481                   .arg(icX,0,'f',2).arg(icY,0,'f',2)
00482                   .arg(tr("grey")).arg((int)grey_value)
00483                   .arg(tr("zoom")).arg(zoomFactor,0,'f',1);
00484         else
00485             txt = QString::fromAscii("x,y = %1  |  %2 = %3")
00486                   .arg(tr("outside image")).arg(tr("zoom")).arg(zoomFactor,0,'f',1);
00487     }
00488     else if ((colorFormat == IB_CF_RGB24) || 
00489              (colorFormat == IB_CF_RGB48))
00490     {
00491         double red, green, blue;
00492         if ((_pGLImageBox->getImageSample(pixX, pixY, 0, red) != 0) ||
00493             (_pGLImageBox->getImageSample(pixX, pixY, 1, green) != 0) ||
00494             (_pGLImageBox->getImageSample(pixX, pixY, 2, blue) != 0))
00495             txt = QString::fromAscii("x,y = %1  |  %2 = %3")
00496                   .arg(tr("outside image")).arg(tr("zoom")).arg(zoomFactor,0,'f',1);
00497         else
00498             txt = QString::fromAscii("x,y = %1,%2  |  rgb = %3,%4,%5  |  %6 = %7")
00499                   .arg(icX,0,'f',2).arg(icY,0,'f',2)
00500                   .arg((int)red).arg((int)green).arg((int)blue)
00501                   .arg(tr("zoom")).arg(zoomFactor,0,'f',1);
00502     }
00503     else if ((colorFormat == IB_CF_BGR24) || 
00504              (colorFormat == IB_CF_BGR48))
00505     {
00506         double red, green, blue;
00507         if ((_pGLImageBox->getImageSample(pixX, pixY, 0, blue) != 0) ||
00508             (_pGLImageBox->getImageSample(pixX, pixY, 1, green) != 0) ||
00509             (_pGLImageBox->getImageSample(pixX, pixY, 2, red) != 0))
00510             txt = QString::fromAscii("x,y = %1  |  %2 = %3")
00511                   .arg(tr("outside image")).arg(tr("zoom")).arg(zoomFactor,0,'f',1);
00512         else
00513             txt = QString::fromAscii("x,y = %1,%2  |  rgb = %3,%4,%5  |  %6 = %7")
00514                   .arg(icX,0,'f',2).arg(icY,0,'f',2)
00515                   .arg((int)red).arg((int)green).arg((int)blue)
00516                   .arg(tr("zoom")).arg(zoomFactor,0,'f',1);
00517     }
00518     else if ((colorFormat == IB_CF_RGBA32) || 
00519              (colorFormat == IB_CF_RGBA64))
00520     {
00521         double red, green, blue, alpha;
00522         if ((_pGLImageBox->getImageSample(pixX, pixY, 0, red) != 0) ||
00523             (_pGLImageBox->getImageSample(pixX, pixY, 1, green) != 0) ||
00524             (_pGLImageBox->getImageSample(pixX, pixY, 2, blue) != 0) ||
00525             (_pGLImageBox->getImageSample(pixX, pixY, 3, alpha) != 0))
00526             txt = QString::fromAscii("x,y = %1  |  %2 = %3")
00527                   .arg(tr("outside image")).arg(tr("zoom")).arg(zoomFactor,0,'f',1);
00528         else
00529             txt = QString::fromAscii("x,y = %1,%2  |  rgba = %3,%4,%5,%6  |  %7 = %8")
00530                   .arg(icX,0,'f',2).arg(icY,0,'f',2)
00531                   .arg((int)red).arg((int)green).arg((int)blue).arg((int)alpha)
00532                   .arg(tr("zoom")).arg(zoomFactor,0,'f',1);
00533     }
00534     else if ((colorFormat == IB_CF_BGRA32) || 
00535              (colorFormat == IB_CF_BGRA64))
00536     {
00537         double red, green, blue, alpha;
00538         if ((_pGLImageBox->getImageSample(pixX, pixY, 0, blue) != 0) ||
00539             (_pGLImageBox->getImageSample(pixX, pixY, 1, green) != 0) ||
00540             (_pGLImageBox->getImageSample(pixX, pixY, 2, red) != 0) ||
00541             (_pGLImageBox->getImageSample(pixX, pixY, 3, alpha) != 0))
00542             txt = QString::fromAscii("x,y = %1  |  %2 = %3")
00543                   .arg(tr("outside image")).arg(tr("zoom")).arg(zoomFactor,0,'f',1);
00544         else
00545             txt = QString::fromAscii("x,y = %1,%2  |  rgba = %3,%4,%5,%6  |  %7 = %8")
00546                   .arg(icX,0,'f',2).arg(icY,0,'f',2)
00547                   .arg((int)red).arg((int)green).arg((int)blue).arg((int)alpha)
00548                   .arg(tr("zoom")).arg(zoomFactor,0,'f',1);
00549     }
00550 
00551     return txt;
00552 }
00553 
00554 // Starts a mouse drag in the image - stores some initial positions
00555 void ImageView::startDrag()
00556 {
00557     _pGLImageBox->fixBasePosCurr(); // fixes current image position as base position
00558     dragStartWCx = _currX;
00559     dragStartWCy = _currY;
00560 }
00561 
00562 // Zoom the image using vertical mouse movement to define a zoom factor
00563 void ImageView::zoom(int prevX, int prevY, int currX, int currY)
00564 {
00565     // Check we have more of a vertical shift than a hz one
00566     int dx = currX - prevX;
00567     int dy = currY - prevY;
00568     if (abs(dy) > abs(dx))
00569     {
00570         // Get centrally displayed image point
00571         int ICx, ICy;
00572         _pGLImageBox->getCentrePoint(ICx, ICy);
00573 
00574         // Compute zoom factor multiplier
00575         double zoomFactorMultiplier = 1.05;
00576         if (currY > prevY)
00577             zoomFactorMultiplier = 0.95;
00578 
00579         // Zoom around centrally displayed image point
00580         _pGLImageBox->setZoomFactor(_pGLImageBox->getZoomFactor() * zoomFactorMultiplier, true, ICx, ICy);
00581         _pGLImageBox->redraw();
00582     }
00583 }
00584 
00585 // Select at the given position
00586 void ImageView::select(int currX, int currY)
00587 {
00588     // base class implementation does nothing
00589     // override this method and implement selection capability if required
00590 }
00591 
00592 // Add selection at the given position
00593 void ImageView::addSelect(int currX, int currY)
00594 {
00595     // base class implementation does nothing
00596     // override this method and implement selection capability if required
00597 }
00598 
00599 // Draw any 2D graphics necessary
00600 // Use GLImageBox::ICToWC_X and ICToWC_Y methods to transform image coordinates into widget coordinates (which 
00601 // must be used by the OpenGL vertex commands).
00602 void ImageView::drawGraphics()
00603 {
00604     // base class implementation does nothing
00605 
00606     // override this method and implement OpenGL drawing commands to draw any needed graphics on top of the image
00607 
00608     /* Example: draw a red line from image coordinates (100,100) to (120,120)
00609     glColor3ub((GLubyte)255, (GLubyte)0, (GLubyte)0);
00610     glBegin(GL_LINES);
00611     glVertex2d(_pGLImageBox->ICToWC_X(100.0), _pGLImageBox->ICToWC_Y(100.0));
00612     glVertex2d(_pGLImageBox->ICToWC_X(120.0), _pGLImageBox->ICToWC_Y(120.0));
00613     glEnd();
00614     */
00615 }
00616 
00617 #include "moc_ImageView.cpp"
00618 
00619 

Generated on Wed Nov 23 19:00:18 2011 for FreeCAD by  doxygen 1.6.1