00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 #ifndef VIEW_H 00011 #define VIEW_H 00012 00013 #include "ColorType.h" 00014 #include "ConfigurationSettings.h" 00015 #include "LocationType.h" 00016 #include "SessionItem.h" 00017 #include "Subject.h" 00018 #include "TypesFile.h" 00019 00020 #include <string> 00021 #include <vector> 00022 00023 class AnimationController; 00024 class Classification; 00025 class MouseMode; 00026 class QImage; 00027 class QSize; 00028 class QWidget; 00029 class UndoAction; 00030 00031 /** 00032 * A means to display data. 00033 * 00034 * This class is a base class containing common functionality to display data to 00035 * the user. A view is actually a widget has a name and a type, and classification. 00036 * Zooming and panning functionality is provided, along with capability to link 00037 * other views to this view and to set other display features. 00038 * 00039 * When the user right-clicks in the view, a \ref contextmenus "context menu" 00040 * is invoked allowing the user to change the display characteristics of the 00041 * view. 00042 * 00043 * This subclass of Subject will notify upon the following conditions: 00044 * - The following methods are called: setMouseMode(), setName(), setClassificationPosition(), 00045 * setClassification(), setBackgroundColor(), setDataOrigin(). 00046 * - The user right-clicks in the view to invoke a context menu. 00047 * - Everything else documented in Subject. 00048 * 00049 * @see Window 00050 */ 00051 class View : public SessionItem, public Subject 00052 { 00053 public: 00054 SETTING(BackgroundColor, View, ColorType, ColorType()); 00055 SETTING(DataOrigin, View, DataOrigin, UPPER_LEFT); 00056 SETTING(InsetShowCoordinates, View, bool, false); 00057 SETTING(InsetSize, View, unsigned int, 300); 00058 SETTING(InsetZoom, View, unsigned int, 5); 00059 SETTING(InsetZoomMode, View, InsetZoomMode, ABSOLUTE_MODE); 00060 SETTING(MousePanSensitivity, View, int, 100); 00061 SETTING(PixelValueMinimumFontSize, View, unsigned int, 5); 00062 SETTING(PixelValueMaximumFontSize, View, unsigned int, 20); 00063 SETTING(DisplayCrosshair, View, bool, false); 00064 SETTING(CrosshairColor, View, ColorType, ColorType(255, 175, 127)); 00065 SETTING(CrosshairBlend, View, bool, true); 00066 SETTING(CrosshairSize, View, int, 20); 00067 SETTING(CrosshairWidth, View, unsigned int, 1); 00068 SETTING(UseViewResolution, View, bool, false); 00069 SETTING(AspectRatioLock, View, bool, false); 00070 SETTING(OutputWidth, View, unsigned int, 0); 00071 SETTING(OutputHeight, View, unsigned int, 0); 00072 SETTING(LinkType, View, LinkType, AUTOMATIC_LINK); 00073 00074 /** 00075 * This class accesses portions of a view image. 00076 * 00077 * If you need to grab a "screen shot" of an image which is 00078 * larger than the physical display dimensions, this class can 00079 * be used to access tiled sub-images. 00080 */ 00081 class SubImageIterator 00082 { 00083 public: 00084 /** 00085 * Destructor. 00086 * 00087 * It is safe to delete a SubImageIterator. 00088 * Ownership semantics are described in functions which 00089 * return a SubImageIterator. Typically, the caller owns 00090 * the SubImageIterator and must delete it when finished. 00091 * 00092 * @see View::getSubImageIterator() 00093 */ 00094 virtual ~SubImageIterator() {} 00095 00096 /** 00097 * Is there another sub-image? 00098 * This should be checked before calling next(). 00099 * 00100 * @return True if there is another sub-image, false otherwise. 00101 */ 00102 virtual bool hasNext() const = 0; 00103 00104 /** 00105 * Get the next sub-image. 00106 * This will initialize the image to the size and encoding 00107 * specified when the SubImageIterator was created. 00108 * 00109 * @param image 00110 * This will hold the resultant image. If this is 00111 * an invalid QImage, it will be initialized by 00112 * this method. Alternately, a QImage which was 00113 * initialized by a previous call to next() may 00114 * be passed. This prevents re-initialization of 00115 * the QImage which is more efficient. 00116 * 00117 * @return True if the image was successfully returned. 00118 * False if an error occurred. If there are no 00119 * tiles left (the iterator is at the end), false 00120 * will be returned. If false is returned 00121 * the state of image is undefined. 00122 */ 00123 virtual bool next(QImage &image) = 0; 00124 00125 /** 00126 * Access the location of the current sub-image. 00127 * This should be called after next(). It will return 00128 * the sub-image location of the image returned by next(). 00129 * 00130 * @param x 00131 * The zero indexed x-access index of the sub-image. 00132 * 00133 * @param y 00134 * The zero indexed y-access index of the sub-image. 00135 */ 00136 virtual void location(int &x, int &y) const = 0; 00137 00138 /** 00139 * Access the total number of sub-images. 00140 * 00141 * @param x 00142 * The number of horizontal sub-images. 00143 * @param y 00144 * The number of vertical sub-images. 00145 */ 00146 virtual void count(int &x, int &y) const = 0; 00147 }; 00148 00149 /** 00150 * Emitted with any<vector<LocationType> > when the selection box is changed. 00151 */ 00152 SIGNAL_METHOD(View, SelectionBoxChanged) 00153 00154 /** 00155 * Emitted when the view name changes with boost::any<std::string> 00156 * containing the new name. 00157 */ 00158 SIGNAL_METHOD(View, Renamed) 00159 00160 /** 00161 * Emitted with boost::any<const \link Classification\endlink*> when the 00162 * classification changes. 00163 * 00164 * @see signalClassificationTextChanged(), setClassification() 00165 */ 00166 SIGNAL_METHOD(View, ClassificationChanged) 00167 00168 /** 00169 * Emitted when the displayed classification text changes as a result of a 00170 * classification change with boost::any<std::string> containing the new 00171 * classification text. 00172 * 00173 * This signal will not always be emitted when the 00174 * signalClassificationChanged() signal is emitted as a result of a 00175 * classification change, if the modified classification parameters do not 00176 * appear in the displayed text. 00177 * 00178 * @see signalClassificationChanged(), setClassification() 00179 */ 00180 SIGNAL_METHOD(View, ClassificationTextChanged) 00181 00182 /** 00183 * Emitted with any<QFont> when the classification font is changed. 00184 */ 00185 SIGNAL_METHOD(View, ClassificationFontChanged) 00186 00187 /** 00188 * Emitted with any<ColorType> when the classification color is changed. 00189 */ 00190 SIGNAL_METHOD(View, ClassificationColorChanged) 00191 00192 /** 00193 * Emitted with any<ColorType> when the background color is changed. 00194 */ 00195 SIGNAL_METHOD(View, BackgroundColorChanged) 00196 00197 /** 00198 * Emitted with any<DataOrigin> when the origin is changed. 00199 */ 00200 SIGNAL_METHOD(View, OriginChanged) 00201 00202 /** 00203 * Emitted with any<const MouseMode*> when the mouse mode is changed. 00204 */ 00205 SIGNAL_METHOD(View, MouseModeChanged) 00206 00207 /** 00208 * Emitted with boost::any<bool> when mouse pan is enabled or 00209 * disabled by the user. 00210 */ 00211 SIGNAL_METHOD(View, MousePanEnabled) 00212 00213 /** 00214 * Emitted with any<boost::tuple<double,double,double,double> > when the 00215 * view extents are changed. The values in the tuple are minX, minY, 00216 * maxX and maxY respectively. 00217 */ 00218 SIGNAL_METHOD(View, ExtentsChanged) 00219 00220 /** 00221 * Emitted with boost::any<ContextMenu*> when the user right-clicks to 00222 * invoke a context menu. 00223 * 00224 * This signal provides a means by which an object can be notified when a 00225 * context menu is invoked by the user clicking inside a view. To receive 00226 * notification for when a context menu is invoked when the user clicks on 00227 * any session item, attach to the 00228 * DesktopServices::signalAboutToShowContextMenu() signal instead. 00229 * 00230 * This signal is emitted after getContextMenuActions() is called and 00231 * after the DesktopServices::signalAboutToShowContextMenu() signal is 00232 * emitted, but before the context menu is shown to give attached objects a 00233 * chance to add or modify the context menu that will be displayed to the 00234 * user. 00235 * 00236 * The ContextMenu pointer value is guaranteed to be non-\c NULL. The 00237 * session items vector in the context menu contains the view. 00238 * 00239 * @see \ref callingsequence "Context menu calling sequence" 00240 */ 00241 SIGNAL_METHOD(View, AboutToShowContextMenu) 00242 00243 /** 00244 * Sets the view name. 00245 * 00246 * @param viewName 00247 * The new name for the view. Cannot be empty. 00248 * 00249 * @notify This method will notify signalRenamed() with any<std::string>. 00250 */ 00251 virtual void setName(const std::string& viewName) = 0; 00252 00253 /** 00254 * Returns the view type. 00255 * 00256 * @return The view type. 00257 * 00258 * @see ViewType 00259 */ 00260 virtual ViewType getViewType() const = 0; 00261 00262 /** 00263 * Returns the widget that displays the view. 00264 * 00265 * This method returns the Qt widget that displays the view. This can be used 00266 * to add the view to a custom dialog or widget if it is not already contained 00267 * in a ViewWindow. 00268 * 00269 * @return A pointer to the widget that displays the view. \c NULL is 00270 * returned if the widget cannot be accessed. 00271 */ 00272 virtual QWidget* getWidget() const = 0; 00273 00274 /** 00275 * Sets the background color of the view. 00276 * 00277 * This method does not call refresh() so that multiple calls to modify view 00278 * settings can be made without refreshing the view after each modification. 00279 * 00280 * @param backgroundColor 00281 * The new background color. Must be a valid color. 00282 * 00283 * @see ColorType 00284 * 00285 * @notify This method will notify signalBackgroundColorChanged() with 00286 * any<ColorType>. 00287 */ 00288 virtual void setBackgroundColor(const ColorType& backgroundColor) = 0; 00289 00290 /** 00291 * Returns the background color of the view. 00292 * 00293 * @return The current background color. 00294 */ 00295 virtual ColorType getBackgroundColor() const = 0; 00296 00297 /** 00298 * Sets the classification of the view. 00299 * 00300 * This method does not call refresh() so that multiple calls to modify view 00301 * settings can be made without refreshing the view after each modification. 00302 * 00303 * @param pClassification 00304 * The classification for the view. A deep copy is performed so it 00305 * is the responsibility of the calling object to delete the given 00306 * Classification object when necessary. This method does nothing 00307 * if \c NULL is passed in. 00308 * 00309 * @notify This method will notify signalClassificationChanged() with 00310 * boost::any<const \link Classification\endlink*> if the 00311 * classification changes. This method will also notify 00312 * signalClassificationTextChanged() with boost::any<std::string> 00313 * containing the new classification that that will be displayed 00314 * only if the text generated by the given classification has 00315 * changed from the previously displayed classification text. 00316 */ 00317 virtual void setClassification(const Classification* pClassification) = 0; 00318 00319 /** 00320 * Returns a pointer to the view's classification object. 00321 * 00322 * The classification object documents how the data in the view is to be 00323 * handled and/or restricted. 00324 * 00325 * @return A pointer to the view's classification object. 00326 * 00327 * @see Classification 00328 */ 00329 virtual Classification* getClassification() = 0; 00330 00331 /** 00332 * Returns read-only access to the view's classification object. 00333 * 00334 * The classification object documents how the data in the view is to be 00335 * handled and/or restricted. 00336 * 00337 * @return A const pointer to the view's classification object. The 00338 * classification represented by the returned pointer should not 00339 * be modified. To modify the values, call the non-const version 00340 * of getClassification() instead. 00341 * 00342 * @see Classification 00343 */ 00344 virtual const Classification* getClassification() const = 0; 00345 00346 /** 00347 * Returns the position for the classification markings. 00348 * 00349 * @return An enum that designates the positions for the top and bottom classification markings. 00350 * 00351 * @see \link PositionType\endlink 00352 */ 00353 virtual PositionType getClassificationPosition() const = 0; 00354 00355 /** 00356 * Sets the position of the classification markings in the view. 00357 * 00358 * @param position 00359 * An enum that designates the positions for the top and bottom classification markings. 00360 * 00361 * @see \link PositionType\endlink 00362 * 00363 * @notify This method will notify Subject::signalModified() with 00364 * boost::any<\link ::PositionType PositionType\endlink>. 00365 */ 00366 virtual void setClassificationPosition(PositionType position) = 0; 00367 00368 /** 00369 * Retrieves a text string containing the classification markings. 00370 * 00371 * @return A string containing the complete classification text. 00372 */ 00373 virtual std::string getClassificationText() const = 0; 00374 00375 /** 00376 * Enables/disables display of classification markings. 00377 * 00378 * @param enable 00379 * If \c true (the default), classification markings are displayed 00380 * on the view. If \c false, classification markings are not 00381 * displayed. 00382 */ 00383 virtual void enableClassification(bool enable) = 0; 00384 00385 /** 00386 * Sets the data origin location in the view. 00387 * 00388 * This method does not call refresh() so that multiple calls to modify view 00389 * settings can be made without refreshing the view after each modification. 00390 * 00391 * @param dataOrigin 00392 * The new origin location of the world coordinate system. 00393 * 00394 * @notify This method will notify signalOriginChanged() with 00395 * any<DataOrigin>. 00396 */ 00397 virtual void setDataOrigin(const DataOrigin& dataOrigin) = 0; 00398 00399 /** 00400 * Returns the data origin location. 00401 * 00402 * @return The current origin of the world coordinate system. 00403 */ 00404 virtual DataOrigin getDataOrigin() const = 0; 00405 00406 /** 00407 * Registers a new mouse mode. 00408 * 00409 * @param pMouseMode 00410 * The mouse mode to register with the view. Cannot be \c NULL. 00411 * The mouse mode name must be unique for all mouse modes 00412 * registered with the view. 00413 * 00414 * @return TRUE if the mouse mode was successfully registered the view, 00415 * otherwise FALSE. FALSE is returned if the mouse mode cannot be 00416 * registered, i.e. it has the same name as an existing mouse mode. 00417 */ 00418 virtual bool addMouseMode(MouseMode* pMouseMode) = 0; 00419 00420 /** 00421 * Sets the current mouse mode. 00422 * 00423 * @param pMouseMode 00424 * The new mouse mode. 00425 * 00426 * @return TRUE if the mouse mode was successfully set for the view, 00427 * otherwise FALSE. FALSE is returned if the view does not support 00428 * the mouse mode. 00429 * 00430 * @notify This method will notify signalMouseModeChanged() with 00431 * any<const MouseMode*>. 00432 * 00433 * @see MouseMode 00434 */ 00435 virtual bool setMouseMode(MouseMode* pMouseMode) = 0; 00436 00437 /** 00438 * Sets the current mouse mode. 00439 * 00440 * This method serves as a convenience function to set the mouse mode. It 00441 * sets the mouse mode based on the mode name. 00442 * 00443 * @param modeName 00444 * The name for the mouse mode to set for the view. Cannot be 00445 * empty. 00446 * 00447 * @return TRUE if the mouse mode was successfully set for the view, 00448 * otherwise FALSE. FALSE is returned if the view does not contain 00449 * a mouse mode with the given name. 00450 * 00451 * @notify This method will notify signalMouseModeChanged() with 00452 * any<const MouseMode*>. 00453 */ 00454 virtual bool setMouseMode(const std::string& modeName) = 0; 00455 00456 /** 00457 * Queries whether a given mouse mode is registered with the view. 00458 * 00459 * @param pMouseMode 00460 * The mouse mode to query. 00461 * 00462 * @return TRUE if the mouse mode is registered for the view, otherwise 00463 * FALSE. FALSE is returned if the view does not support the 00464 * mouse mode. 00465 * 00466 * @see MouseMode 00467 */ 00468 virtual bool containsMouseMode(MouseMode* pMouseMode) const = 0; 00469 00470 /** 00471 * Returns the mouse mode with a given name. 00472 * 00473 * @param modeName 00474 * The name for the mouse mode to get. Cannot be empty. 00475 * 00476 * @return A pointer to the mouse mode with the given name. \c NULL is 00477 * returned if the view does not contain a mouse mode with the 00478 * given name. 00479 */ 00480 virtual MouseMode* getMouseMode(const std::string& modeName) const = 0; 00481 00482 /** 00483 * Returns the current mouse mode. 00484 * 00485 * @return A pointer to the current mouse mode. \c NULL is returned if 00486 * the view does not contain any mouse modes, or if no mode is 00487 * considered current. 00488 */ 00489 virtual MouseMode* getCurrentMouseMode() const = 0; 00490 00491 /** 00492 * Retrieves all mouse modes registered with the view. 00493 * 00494 * @param modes 00495 * Populated with pointers to the registered mouse modes. 00496 */ 00497 virtual void getMouseModes(std::vector<MouseMode*>& modes) const = 0; 00498 00499 /** 00500 * Retrieves the animation controller associated with the view. 00501 * 00502 * @return A pointer to the associated AnimationController or \c NULL 00503 * if there is no associated AnimationController 00504 * 00505 * @see setAnimationController() 00506 */ 00507 virtual AnimationController *getAnimationController() const = 0; 00508 00509 /** 00510 * Associates an animation controller with the view. 00511 * 00512 * @param pPlayer 00513 * The AnimationController to associate with the view. 00514 * 00515 * @see getAnimationController() 00516 */ 00517 virtual void setAnimationController(AnimationController *pPlayer) = 0; 00518 00519 /** 00520 * Returns the number of registered mouse mode. 00521 * 00522 * @return The number of mouse modes currently available in the view. 00523 */ 00524 virtual unsigned int getNumMouseModes() const = 0; 00525 00526 /** 00527 * Retrieves the data extents in world coordinates. 00528 * 00529 * @param dMinX 00530 * The minimum data value in the X dimension. 00531 * @param dMinY 00532 * The minimum data value in the Y dimension. 00533 * @param dMaxX 00534 * The maximum data value in the X dimension. 00535 * @param dMaxY 00536 * The maximum data value in the Y dimension. 00537 */ 00538 virtual void getExtents(double& dMinX, double& dMinY, double& dMaxX, double& dMaxY) const = 0; 00539 00540 /** 00541 * Retrieves the corner coordinates of the visible view area. 00542 * 00543 * @param lowerLeft 00544 * A LocationType that is populated with the lower left coordinate. 00545 * @param upperLeft 00546 * A LocationType that is populated with the upper left coordinate. 00547 * @param upperRight 00548 * A LocationType that is populated with the upper right coordinate. 00549 * @param lowerRight 00550 * A LocationType that is populated with the lower right coordinate. 00551 * 00552 * @see getVisibleCenter() 00553 */ 00554 virtual void getVisibleCorners(LocationType& lowerLeft, LocationType& upperLeft, LocationType& upperRight, 00555 LocationType& lowerRight) const = 0; 00556 00557 /** 00558 * Returns the coordinate at the current visible center of the view. 00559 * 00560 * @return The current center coordinate. 00561 */ 00562 virtual LocationType getVisibleCenter() const = 0; 00563 00564 /** 00565 * Zooms the image to the data extents. 00566 * 00567 * This method zooms the view out so that the entire extents of the data are 00568 * displayed. 00569 * 00570 * This method does not call refresh() so that multiple calls to modify view 00571 * settings can be made without refreshing the view after each modification. 00572 * 00573 * @see zoomToBox() 00574 */ 00575 virtual void zoomExtents() = 0; 00576 00577 /** 00578 * Zooms the image to a defined rectangular area. 00579 * 00580 * This method does not call refresh() so that multiple calls to modify view 00581 * settings can be made without refreshing the view after each modification. 00582 * 00583 * @param lowerLeft 00584 * The lower left location of the view in world coordinates. 00585 * @param upperRight 00586 * The upper right location of the view in world coordinates. 00587 * 00588 * @see zoomExtents() 00589 */ 00590 virtual void zoomToBox(const LocationType& lowerLeft, const LocationType& upperRight) = 0; 00591 00592 /** 00593 * Centers the image on a given point. 00594 * 00595 * This method does not call refresh() so that multiple calls to modify view 00596 * settings can be made without refreshing the view after each modification. 00597 * 00598 * @param worldCoord 00599 * The point to pan to the center of the view in world coordinates. 00600 * 00601 * @see panToCenter(), panBy() 00602 */ 00603 virtual void panTo(const LocationType& worldCoord) = 0; 00604 00605 /** 00606 * Centers the image in the view. 00607 * 00608 * This method does not call refresh() so that multiple calls to modify view 00609 * settings can be made without refreshing the view after each modification. 00610 * 00611 * @see panTo(), panBy() 00612 */ 00613 virtual void panToCenter() = 0; 00614 00615 /** 00616 * Moves the image by a given distance. 00617 * 00618 * This method does not call refresh() so that multiple calls to modify view 00619 * settings can be made without refreshing the view after each modification. 00620 * 00621 * @param dDeltaX 00622 * The X distance from which to pan the view from its current location 00623 * in world coordinates. 00624 * @param dDeltaY 00625 * The Y distance from which to pan the view from its current location 00626 * in world coordinates. 00627 * 00628 * @see panTo() 00629 */ 00630 virtual void panBy(double dDeltaX, double dDeltaY) = 0; 00631 00632 /** 00633 * Toggles the display of a dynamic inset window. 00634 * 00635 * This methods toggles the display of a dynamic inset window, which appears 00636 * on top of the view. The window displays a portion of the view at a 00637 * different zoom and level than the view. The default size and zoom level 00638 * of the inset window are specified in the Options. 00639 * 00640 * @param bEnable 00641 * Set this value to TRUE to display the inset window or to FALSE 00642 * to hide the inset window. 00643 * 00644 * @return TRUE if the inset window was successfully enabled or disabled, or 00645 * FALSE if the inset window is not supported by the view. 00646 * 00647 * @see setInsetPoint() 00648 */ 00649 virtual bool enableInset(bool bEnable) = 0; 00650 00651 /** 00652 * Queries whether the dynamic inset window is enabled. 00653 * 00654 * @return TRUE if the inset window is enabled, whereby it is drawn on top 00655 * of the view, or FALSE if the inset window is disabled. 00656 */ 00657 virtual bool isInsetEnabled() const = 0; 00658 00659 /** 00660 * Sets the center of the dynamic inset window. 00661 * 00662 * @param worldCoord 00663 * The new inset center point in world coordinates. 00664 */ 00665 virtual void setInsetPoint(const LocationType& worldCoord) = 0; 00666 00667 /** 00668 * Toggles the display of the view crosshair. 00669 * 00670 * This methods toggles the display of a crosshair marker in the center of 00671 * the view. 00672 * 00673 * @param bEnable 00674 * Set this value to \c true to display the crosshair in the view 00675 * or to \c false to hide the crosshair. 00676 * 00677 * @return Returns \c true if the crosshair was successfully enabled or 00678 * disabled, or \c false if the crosshair is not supported by the 00679 * view. 00680 */ 00681 virtual bool enableCrossHair(bool bEnable) = 0; 00682 00683 /** 00684 * Queries whether the view crosshair is enabled. 00685 * 00686 * @return Returns \c true if the crosshair is currently enabled, whereby 00687 * it is drawn in the center of the view, or \c false if the 00688 * crosshair is currently disabled. 00689 */ 00690 virtual bool isCrossHairEnabled() const = 0; 00691 00692 /** 00693 * Sets the crosshair color in the view. 00694 * 00695 * This method does not call refresh() so that multiple calls to modify view 00696 * settings can be made without refreshing the view after each modification. 00697 * 00698 * Calling this method still sets the crosshair color, even if 00699 * isCrossHairEnabled() returns \c false. 00700 * 00701 * @param color 00702 * The new crosshair color. This method does nothing if an invalid 00703 * color is passed in. 00704 * 00705 * @see ColorType::isValid() 00706 */ 00707 virtual void setCrossHairColor(const ColorType& color) = 0; 00708 00709 /** 00710 * Returns the crosshair color. 00711 * 00712 * @return The current crosshair color. 00713 */ 00714 virtual ColorType getCrossHairColor() const = 0; 00715 00716 /** 00717 * Sets the crosshair color to be blended with the view color. 00718 * 00719 * Enabling the blended state combines the crosshair color with the color in 00720 * the view just behind the crosshair to provide enough contrast for the 00721 * crosshair to always be visible. 00722 * 00723 * This method does not call refresh() so that multiple calls to modify view 00724 * settings can be made without refreshing the view after each modification. 00725 * 00726 * Calling this method still sets the crosshair blended state, even if 00727 * isCrossHairEnabled() returns \c false. 00728 * 00729 * @param blended 00730 * Set this value to \c true to enable blending the crosshair color 00731 * with the color in the view just behind the crosshair. Set this 00732 * value to \c false to display the crosshair as a solid color, 00733 * regardless of the view color. 00734 * 00735 * @see setCrossHairColor() 00736 */ 00737 virtual void setCrossHairBlended(bool blended) = 0; 00738 00739 /** 00740 * Returns the blended state when drawing the crosshair. 00741 * 00742 * @return Returns \c true if the crosshair color will be blended with the 00743 * view color when drawn. Returns \c false if the crosshair is 00744 * drawn as a solid color regardless of the view color. 00745 * 00746 * @see setCrossHairBlended() 00747 */ 00748 virtual bool isCrossHairBlended() const = 0; 00749 00750 /** 00751 * Sets the overall width and height of the crosshair in the view in screen 00752 * pixels. 00753 * 00754 * This method does not call refresh() so that multiple calls to modify view 00755 * settings can be made without refreshing the view after each modification. 00756 * 00757 * Calling this method still sets the crosshair size, even if 00758 * isCrossHairEnabled() returns \c false. 00759 * 00760 * @param size 00761 * The crosshair width and height in screen pixels. This method 00762 * does nothing if a value less than one is passed in. 00763 */ 00764 virtual void setCrossHairSize(int size) = 0; 00765 00766 /** 00767 * Returns the crosshair size. 00768 * 00769 * @return The current crosshair size. 00770 */ 00771 virtual int getCrossHairSize() const = 0; 00772 00773 /** 00774 * Sets the line width of the crosshair in the view. 00775 * 00776 * This method does not call refresh() so that multiple calls to modify view 00777 * settings can be made without refreshing the view after each modification. 00778 * 00779 * Calling this method still sets the crosshair line width, even if 00780 * isCrossHairEnabled() returns \c false. 00781 * 00782 * @param width 00783 * The crosshair line width in screen pixels. This method does 00784 * nothing if a value of zero is passed in. 00785 */ 00786 virtual void setCrossHairWidth(unsigned int width) = 0; 00787 00788 /** 00789 * Returns the crosshair line width. 00790 * 00791 * @return The current crosshair line width in screen pixels. 00792 */ 00793 virtual unsigned int getCrossHairWidth() const = 0; 00794 00795 /** 00796 * Redraws the current contents of the view. 00797 */ 00798 virtual void refresh() = 0; 00799 00800 /** 00801 * Retrieves an image of the current view state. 00802 * 00803 * This method retrieves the data for the current image as displayed in the view. 00804 * This is similar to taking a screen snapshot of the view. 00805 * 00806 * @param image 00807 * A Qt image reference that is populated with the current view 00808 * image. If a null image is passed in, the size of the image 00809 * will be equal to the size of the view in screen pixels. 00810 * Otherwise, the view will be scaled to the image size when 00811 * generating the image data. If a size is specified, the QImage 00812 * should use QImage::Format_ARGB32. If the format is different, 00813 * the QImage will be converted to QImage::Format_ARGB32. 00814 * 00815 * @return Returns \c true if a valid image was successfully retrieved, 00816 * otherwise returns \c false. 00817 */ 00818 virtual bool getCurrentImage(QImage &image) = 0; 00819 00820 /** 00821 * Retrieves an iterator over sub-images of the current view state. 00822 * 00823 * This method is similar to getCurrentImage(QImage&) except it obtains 00824 * an iterator which accesses sub-sections of the view. This is used for "pan and scan" 00825 * image generation. The caller takes ownership of the SubImageIterator and MUST delete 00826 * the SubImageIterator when it is no longer needed. When a SubImageIterator exists for a 00827 * view, another can not be created and no other view operations should be performed. 00828 * 00829 * @param totalSize 00830 * This is the size of the entire image. If all the generated sub-images are 00831 * stitched together, they will make an image this size. 00832 * 00833 * @param subImageSize 00834 * This is the size of each sub-image. 00835 * 00836 * @return A SubImageIterator over the view. The iterator will immediatly return false 00837 * to SubImageIterator::hasNext() calls if an error occurs. If a SubImageIterator 00838 * already exists for this View, that iterator will be returned. 00839 */ 00840 virtual SubImageIterator *getSubImageIterator(const QSize &totalSize, const QSize &subImageSize) = 0; 00841 00842 /** 00843 * Links a view with this view. 00844 * 00845 * This method establishes a link between this view and another view. Linked views 00846 * are linked depending on the link type specified. 00847 * 00848 * @param pView 00849 * The view to link with this view. Cannot be \c NULL. 00850 * @param type 00851 * The type of link to create. Specifying NO_LINK 00852 * is equivilent to calling unlinkView(). 00853 * @return TRUE if the view was successfully linked with this view, otherwise 00854 * FALSE. 00855 */ 00856 virtual bool linkView(View* pView, LinkType type) = 0; 00857 00858 /** 00859 * Retrieves views linked with this view. 00860 * 00861 * @param linkedViews 00862 * A reference to a vector that is populated with pointers to views linked 00863 * with this view and the associated link type. If no views are linked, 00864 * the vector is emptied. 00865 */ 00866 virtual void getLinkedViews(std::vector<std::pair<View*, LinkType> > &linkedViews) const = 0; 00867 00868 /** 00869 * Queries what kind of link a view has with this view. 00870 * 00871 * @param pView 00872 * The view to query for linkage with this view. 00873 * 00874 * @return The type of link that exists. NO_LINK indicated 00875 * that there is no linking relationship. 00876 */ 00877 virtual LinkType getViewLinkType(View* pView) const = 0; 00878 00879 /** 00880 * Breaks the link between this view and a given view. 00881 * 00882 * @param pView 00883 * The view to unlink with this view. Cannot be \c NULL. 00884 * 00885 * @return TRUE if the view was successfully unlinked with this view, otherwise 00886 * FALSE. 00887 */ 00888 virtual bool unlinkView(View* pView) = 0; 00889 00890 /** 00891 * Creates a new view with the same settings and properties as this view. 00892 * 00893 * This is designed to copy an existing view into a product view object. 00894 * This method will not create a new window. 00895 * 00896 * @return A pointer to the new view. \c NULL is returned if an error 00897 * occurs. 00898 */ 00899 virtual View* copy() const = 0; 00900 00901 /** 00902 * Copies view settings and properties to an existing view. 00903 * 00904 * This performs a shallow copy into an existing view. The common use case 00905 * is to create a new window/view and copy the settings of an existing view. 00906 * This creates a duplicate but independent view into the same data. 00907 * 00908 * @param pView 00909 * The target view. 00910 * @return True if successful, false if there was an error. 00911 */ 00912 virtual bool copy(View *pView) const = 0; 00913 00914 /** 00915 * Removes an existing mouse mode. 00916 * 00917 * This method removes the given mouse mode from the view regardless of whether 00918 * the mode is enabled or disabled. The mouse mode is not deleted. 00919 * 00920 * @param pMouseMode 00921 * The mouse mode to remove from the view. 00922 * 00923 * @return True if the mouse mode was successfully removed from the view. False 00924 * is returned if the mouse mode is not contained in this view. 00925 * 00926 * @see isMouseModeEnabled() 00927 */ 00928 virtual bool removeMouseMode(const MouseMode* pMouseMode) = 0; 00929 00930 /** 00931 * Enables or disables a mouse mode. 00932 * 00933 * This method enables or disabled the given mouse mode from the view. A disabled 00934 * mouse mode cannot be made current with the setMouseMode() method. 00935 * 00936 * @param pMouseMode 00937 * The mouse mode to enable or disable. This method does nothing if the 00938 * view does not contain the given mouse mode. 00939 * @param bEnable 00940 * Set this parameter to true to enable the mouse mode or to false to 00941 * disable the mouse mode. 00942 * 00943 * @see setMouseMode(), isMouseModeEnabled() 00944 */ 00945 virtual void enableMouseMode(const MouseMode* pMouseMode, bool bEnable) = 0; 00946 00947 /** 00948 * Queries whether a mouse mode is currently enabled or disabled. 00949 * 00950 * This method removes the given mouse mode from the view regardless of whether 00951 * the mode is enabled or disabled. The mouse mode is not deleted. 00952 * 00953 * @param pMouseMode 00954 * The mouse mode to query whether it is enabled or disabled. 00955 * 00956 * @return True if the mouse mode is currently enabled or false if the mode is 00957 * disabled. False is also returned if the mouse mode is not contained 00958 * in this view. 00959 * 00960 * @see enableMouseMode() 00961 */ 00962 virtual bool isMouseModeEnabled(const MouseMode* pMouseMode) const = 0; 00963 00964 /** 00965 * Retrieves a screen coordinate for a given world coordinate. 00966 * 00967 * This method converts a world coordinate into a screen coordinate. The world 00968 * coordinate is the linear coordinate system used internally to draw the data, 00969 * which is typically the same coodinate system as the data itself. The screen 00970 * coordinate is the location relative to the view widget with the origin being 00971 * in the lower left corner. 00972 * 00973 * @param dWorldX 00974 * The x-position of the world coordinate. The value does not need to 00975 * be within the view extents. 00976 * @param dWorldY 00977 * The y-position of the world coordinate. The value does not need to 00978 * be within the view extents. 00979 * @param dScreenX 00980 * Populated with the screen x-coordinate of the given world coordinate. 00981 * A negative value indicates that the world coordinate is not currently 00982 * displayed in the view widget. 00983 * @param dScreenY 00984 * Populated with the screen y-coordinate of the given world coordinate. 00985 * A negative value indicates that the world coordinate is not currently 00986 * displayed in the view widget. 00987 * @param pVisible 00988 * If this value is non-\c NULL, the pointer is populated with a value 00989 * indicating whether the given world coordinate is visible with the 00990 * current view widget. 00991 * 00992 * @see translateScreenToWorld(), getPixelSize() 00993 */ 00994 virtual void translateWorldToScreen(double dWorldX, double dWorldY, double& dScreenX, double& dScreenY, 00995 bool* pVisible = NULL) const = 0; 00996 00997 /** 00998 * Retrieves a world coordinate for a given screen coordinate. 00999 * 01000 * This method converts an OpenGL screen coordinate into a world coordinate. 01001 * The OpenGL screen coordinate is the location relative to the view widget 01002 * with the origin being in the lower left corner. To determine the correct 01003 * dScreenY value, the mouse event y-coordinate must be subtracted from the 01004 * view height,e.g., dScreenY = pViewWidget.height() - pMouseEvent.pos().y(). 01005 * 01006 * The world coordinate is the linear coordinate system used 01007 * internally to draw the data, which is typically the same coodinate system 01008 * as the data itself. 01009 * 01010 * @param dScreenX 01011 * The x-position of the screen coordinate. The value does not need to be 01012 * within the view extents. 01013 * @param dScreenY 01014 * The y-position of the screen coordinate. The value does not need to be 01015 * within the view extents. 01016 * @param dWorldX 01017 * Populated with the world x-coordinate of the given screen coordinate. 01018 * @param dWorldY 01019 * Populated with the world y-coordinate of the given screen coordinate. 01020 * 01021 * @see translateWorldToScreen(), getPixelSize() 01022 */ 01023 virtual void translateScreenToWorld(double dScreenX, double dScreenY, double& dWorldX, double& dWorldY) const = 0; 01024 01025 /** 01026 * Returns the number of screen pixels that cover a given range of world pixels. 01027 * 01028 * @warning This method assumes that the scene pixel aspect ratio is one, 01029 * and therefore should not be called on an orthographic view. 01030 * For orthographic views, call OrthographicView::getPixelSize() 01031 * instead. When calling this method on a perspective view, if 01032 * PerspectiveView::getPixelAspect() returns a value other than 01033 * one, the return value should be multiplied by the pixel aspect 01034 * to get the correct pixel size for the x-dimension, as shown in 01035 * the code sample below: 01036 * @code 01037 * double pixelSize = pPerspectiveView->getPixelSize(llCorner, urCorner); 01038 * double pixelSizeX = pixelSize * pPerspectiveView->getPixelAspect(); 01039 * double pixelSizeY = pixelSize; 01040 * @endcode 01041 * 01042 * @param lowerLeft 01043 * The world coordinate closest to the origin. 01044 * @param upperRight 01045 * The world coordinate furthest from the origin. 01046 * 01047 * @return The number of screen pixels covering the given range of world coordinates. 01048 * 01049 * @see translateWorldToScreen(), translateScreenToWorld() 01050 */ 01051 virtual double getPixelSize(const LocationType& lowerLeft, const LocationType& upperRight) const = 0; 01052 01053 /** 01054 * Queries whether undo actions are able to be added to the view's undo 01055 * stack. 01056 * 01057 * @return Returns \c true if undo actions cannot be added to the undo 01058 * stack, or \c false if undo actions are added to the stack. 01059 * 01060 * @see UndoLock, addUndoAction() 01061 */ 01062 virtual bool isUndoBlocked() const = 0; 01063 01064 /** 01065 * Queries whether undo actions are currently added to an undo group. 01066 * 01067 * @return Returns \c true if undo actions are added to an undo group, or 01068 * \c false if undo actions are added directly to the stack. 01069 * 01070 * @see UndoGroup, addUndoAction() 01071 */ 01072 virtual bool inUndoGroup() const = 0; 01073 01074 /** 01075 * Adds an action to the undo stack. 01076 * 01077 * This method add the given action to the undo stack. If startUndoGroup() 01078 * has been called without a corresponding call to endUndoGroup() the 01079 * action is added to the group. 01080 * 01081 * This method only needs to be called from a plug-in if adding custom undo 01082 * actions defined in the plug-in. 01083 * 01084 * @warning If a plug-in defines its own UndoAction subclass, the plug-in 01085 * must remain loaded until the view is deleted to ensure the 01086 * action can be properly deleted. 01087 * 01088 * @param pAction 01089 * The action to add to the undo stack. The view assumes 01090 * ownership of the action and will delete it when necessary. If 01091 * isUndoBlocked() returns \c true, this method deletes the given 01092 * action immediately. 01093 */ 01094 virtual void addUndoAction(UndoAction* pAction) = 0; 01095 01096 /** 01097 * Clears the undo stack. 01098 * 01099 * This method removes all undo actions from the undo stack regardless of 01100 * whether adding undo actions is blocked. If inUndoGroup() returns 01101 * \c true, any actions existing in the group are destroyed. 01102 */ 01103 virtual void clearUndo() = 0; 01104 01105 protected: 01106 /** 01107 * This should be destroyed by calling DesktopServices::deleteView. 01108 */ 01109 virtual ~View() {} 01110 01111 friend class UndoLock; 01112 friend class UndoGroup; 01113 01114 /** 01115 * Prevents undo actions from being added to the view's undo stack. 01116 * 01117 * @warning This method exists for implementation purposes and cannot be 01118 * used directly. Instead, use the UndoLock object to prevent 01119 * undo actions from being added to the view. 01120 * 01121 * @see UndoLock, isUndoBlocked() 01122 */ 01123 virtual void blockUndo() = 0; 01124 01125 /** 01126 * Allows undo actions to be added to the view's undo stack. 01127 * 01128 * @warning This method exists for implementation purposes and cannot be 01129 * used directly. Instead, use the UndoLock object to prevent 01130 * undo actions from being added to the view. 01131 * 01132 * @see UndoLock, isUndoBlocked() 01133 */ 01134 virtual void unblockUndo() = 0; 01135 01136 /** 01137 * Instructs the undo stack to add all future undo actions to a group. 01138 * 01139 * @warning This method exists for implementation purposes and cannot be 01140 * used directly. Instead, use the UndoGroup object to group 01141 * future undo actions into a single undoable operation. 01142 * 01143 * @param text 01144 * The name for the undo action group that will appear to the 01145 * user. 01146 * 01147 * @see UndoGroup, inUndoGroup(), addUndoAction() 01148 */ 01149 virtual void startUndoGroup(const std::string& text) = 0; 01150 01151 /** 01152 * Returns the undo stack to normal operations when adding undo actions. 01153 * 01154 * @warning This method exists for implementation purposes and cannot be 01155 * used directly. Instead, use the UndoGroup object to group 01156 * future undo actions into a single undoable operation. 01157 * 01158 * @see UndoGroup, inUndoGroup(), addUndoAction() 01159 */ 01160 virtual void endUndoGroup() = 0; 01161 }; 01162 01163 #endif