00001 //# PlotMSAnnotator.h: Annotator tool for PlotMS. 00002 //# Copyright (C) 2009 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: $ 00027 #ifndef PLOTMSANNOTATOR_H_ 00028 #define PLOTMSANNOTATOR_H_ 00029 00030 #include <graphics/GenericPlotter/PlotTool.h> 00031 #include <plotms/Actions/PlotMSAction.h> 00032 #include <plotms/Plots/PlotMSPlotManager.h> 00033 00034 #include <QAction> 00035 00036 namespace casa { 00037 00038 //# Forward Declarations. 00039 //class PlotMSApp; 00040 class PlotMSPlotter; 00041 00042 // Subclass of PlotMouseTool for drawing/managing annotations on the plot 00043 // canvases of PlotMSApp. 00044 class PlotMSAnnotator : public PlotMouseTool, public PlotMSPlotManagerWatcher { 00045 00046 //# Friend class declarations. 00047 friend class PlotMSPlotter; 00048 00049 public: 00050 // Static // 00051 00052 // Drawing mode for the annotator. 00053 enum Mode { 00054 TEXT = 0, 00055 RECTANGLE = 1 00056 }; 00057 00058 00059 // Non-Static // 00060 00061 // Constructor which takes the PlotMS parent and optional starting mode. 00062 PlotMSAnnotator(/*PlotMSApp**/PlotMSPlotter* parent, Mode startingMode = TEXT); 00063 00064 // Destructor. 00065 ~PlotMSAnnotator(); 00066 00067 00068 // Gets/Sets the current drawing mode. 00069 // <group> 00070 Mode drawingMode() const; 00071 void setDrawingMode(Mode mode); 00072 // </group> 00073 00074 // Gets/Sets the current text properties (null means default for 00075 // PlotAnnotation object). Only applies to future text annotations. 00076 // <group> 00077 PlotFontPtr textFont() const; 00078 void setTextFont(const PlotFontPtr font); 00079 PlotLinePtr textOutline() const; 00080 void setTextOutline(const PlotLinePtr outline); 00081 PlotAreaFillPtr textBackground() const; 00082 void setTextBackground(const PlotAreaFillPtr background); 00083 // </group> 00084 00085 // Gets/Sets the current rectangle properties (null means default for 00086 // PlotShapeRectangle object). Only applies to future rectangle 00087 // annotations. 00088 // <group> 00089 PlotLinePtr rectangleLine() const; 00090 void setRectangleLine(const PlotLinePtr line); 00091 PlotAreaFillPtr rectangleAreaFill() const; 00092 void setRectangleAreaFill(const PlotAreaFillPtr fill); 00093 // </group> 00094 00095 // Clears all text/rectangle annotations off the given canvas. If the 00096 // given canvas is NULL, then it clears them from all canvases. 00097 // <group> 00098 void clearText(PlotCanvas* canvas = NULL); 00099 void clearRectangles(PlotCanvas* canvas = NULL); 00100 void clearAll(PlotCanvas* canvas = NULL); 00101 // </group> 00102 00103 00104 // Overrides PlotTool::setActive(). 00105 void setActive(bool isActive = true); 00106 00107 // Implements PlotMouseTool::handleMouseEvent(). 00108 void handleMouseEvent(const PlotEvent& event); 00109 00110 // Implements PlotMSPlotManagerWatcher::plotChanged(). Removes annotations 00111 // that are attached to canvases that no longer exist. 00112 void plotsChanged(const PlotMSPlotManager& manager); 00113 00114 protected: 00115 // Sets the annotate and mode actions and the factory to the given. MUST 00116 // be called before the annotator is used. 00117 void setActions(QAction* annotateAction, 00118 const QMap<PlotMSAction::Type, QAction*>& actionMap, 00119 PlotFactoryPtr factory); 00120 00121 // Overrides PlotTool::attach(). 00122 void attach(PlotCanvas* canvas); 00123 00124 // Overrides PlotTool::detach(). 00125 void detach(); 00126 00127 private: 00128 // Parent. 00129 //PlotMSApp* itsParent_; 00130 00131 // Factory for generating plot objects. 00132 PlotFactoryPtr itsFactory_; 00133 00134 // Current drawing mode. 00135 Mode itsMode_; 00136 00137 // Actions to keep updated. 00138 // <group> 00139 QAction* itsAnnotateAction_; 00140 QMap<Mode, QAction*> itsModeActions_; 00141 // </group> 00142 00143 // Text annotations. 00144 QMultiMap<PlotCanvas*, PlotAnnotationPtr> itsAText_; 00145 00146 // Current text properties. 00147 // <group> 00148 PlotFontPtr itsTextFont_; 00149 PlotLinePtr itsTextOutline_; 00150 PlotAreaFillPtr itsTextFill_; 00151 // </group> 00152 00153 // Rectangle annotations. 00154 QMultiMap<PlotCanvas*, PlotShapeRectanglePtr> itsARect_; 00155 00156 // Current rectangle properties. 00157 // <group> 00158 PlotLinePtr itsRectLine_; 00159 PlotAreaFillPtr itsRectFill_; 00160 // </group> 00161 00162 00163 // Sets properties to their defaults. 00164 void setDefaults(); 00165 00166 PlotMSPlotter* guiParent; 00167 }; 00168 00169 } 00170 00171 #endif /* PLOTMSANNOTATOR_QO_H_ */