guiParticleGraphCtrl.h
Engine/source/gui/editor/guiParticleGraphCtrl.h
Classes:
Public Typedefs
GuiParticleGraphType
Public Functions
Detailed Description
Public Typedefs
typedef GuiParticleGraphCtrl::GraphType GuiParticleGraphType
Public Functions
DefineEnumType(GuiParticleGraphType )
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _GUIPARTICLEGRAPHCTRL_H_ 25#define _GUIPARTICLEGRAPHCTRL_H_ 26 27#ifndef _GUICONTROL_H_ 28#include "gui/core/guiControl.h" 29#endif 30#ifndef _STRINGTABLE_H_ 31#include "core/stringTable.h" 32#endif 33 34 35class GuiParticleGraphCtrl : public GuiControl 36{ 37private: 38 typedef GuiControl Parent; 39 40protected: 41 /// The color of the nuts. 42 ColorI mNutColor; 43 /// The outline color of the nuts. 44 ColorI mOutlineColor; 45 /// The rectangle size to check for clicks on nuts (default 8) which is RectI( pointClick - 4, pointClick - 4, 8, 8 ) 46 S32 mVertexClickSize; 47 48 Point2I findHitNut( Point2I hitPoint ); 49 50public: 51 enum Constants { 52 MaxPlots = 32, 53 MaxDataPoints = 200 54 }; 55 56 enum GraphType { 57 Point, 58 Polyline, 59 Filled, 60 Bar 61 }; 62 63 struct PlotInfo 64 { 65 LinearColorF mGraphColor; 66 Vector<Point2F> mGraphData; 67 Vector<Point2F> mNutList; 68 Point2F mGraphMax; 69 Point2F mGraphMin; 70 GraphType mGraphType; 71 StringTableEntry mGraphName; 72 bool mHidden; 73 F32 mGraphScale; 74 }; 75 76 S32 mSelectedPlot; 77 S32 mSelectedPoint; 78 S32 mOriginalSelectedPoint; 79 S32 mLastSelectedPoint; 80 S32 mTooltipSelectedPlot; 81 S32 mAddedPointIndex; 82 bool mAutoMax; 83 bool mAutoRemove; 84 bool mRenderAllPoints; 85 bool mPointWasAdded; 86 bool mRenderGraphTooltip; 87 bool mRenderNextGraphTooltip; 88 bool mPointXMovementClamped; 89 Point2F mAddedPoint; 90 Point2F mLastMousePos; 91 92 Point2I mCursorPos; 93 94 PlotInfo mPlots[MaxPlots]; 95 96 //creation methods 97 DECLARE_CONOBJECT(GuiParticleGraphCtrl); 98 DECLARE_CATEGORY( "Gui Editor" ); 99 100 GuiParticleGraphCtrl(); 101 virtual ~GuiParticleGraphCtrl() { }; 102 103 void onMouseMove(const GuiEvent &event); 104 void onMouseDown( const GuiEvent &event ); 105 void onMouseUp( const GuiEvent &event ); 106 void onMouseDragged( const GuiEvent &event ); 107 void onRightMouseDown( const GuiEvent &event ); 108 void onRightMouseUp( const GuiEvent &event ); 109 void onRightMouseDragged( const GuiEvent &event ); 110 111 //Parental methods 112 bool onWake(); 113 114 void onRender(Point2I offset, const RectI &updateRect); 115 bool renderGraphTooltip(Point2I cursorPos, StringTableEntry tooltip); 116 117 // Graph interface 118 S32 addPlotPoint(S32 plotID, Point2F v, bool setAdded = true); 119 void insertPlotPoint(S32 plotID, S32 i, Point2F v); 120 S32 changePlotPoint(S32 plotID, S32 i, Point2F v); 121 S32 removePlotPoint(S32 plotID, S32 i); 122 Point2F convertToGraphCoord(S32 plotID, Point2I v); 123 124 // Set Graph specific functions 125 void setGraphType(S32 plotID, const char *graphType); 126 void setSelectedPlot(S32 plotID); 127 void setSelectedPoint(S32 point); 128 void resetSelectedPoint(); 129 void setGraphHidden(S32 plotID, bool isHidden); 130 131 // Set Global Options 132 void setAutoGraphMax(bool autoMax); 133 void setAutoRemove(bool autoRemove); 134 void setRenderAll(bool renderAll); 135 void setRenderGraphTooltip(bool renderGraphTooltip); 136 void setPointXMovementClamped(bool clamped); 137 138 // Get Functions 139 Point2F getGraphExtent(S32 plotID); 140 LinearColorF getGraphColor(S32 plotID); 141 S32 getSelectedPlot(); 142 S32 getSelectedPoint(); 143 Point2F getPlotPoint(S32 plotID, S32 samples); 144 S32 getPlotIndex(S32 plotID, F32 x, F32 y); 145 Point2F getGraphMax(S32 plotID); 146 Point2F getGraphMin(S32 plotID); 147 148 bool isExistingPoint(S32 plotID, S32 point); 149 150 StringTableEntry getGraphName(S32 plotID); 151 152 // Set Graph Min and MaxFunctions 153 void setGraphMin(S32 plotID, Point2F graphMin); 154 void setGraphMinX(S32 plotID, F32 graphMinX); 155 void setGraphMinY(S32 plotID, F32 graphMinY); 156 void setGraphMax(S32 plotID, Point2F graphMax); 157 void setGraphMaxX(S32 plotID, F32 graphMaxX); 158 void setGraphMaxY(S32 plotID, F32 graphMaxY); 159 160 // Other set functions for graphs 161 void setGraphName(S32 plotID, StringTableEntry graphName); 162 163 164 // Clear Functions 165 void clearGraph(S32 plotID); 166 void clearAllGraphs(); 167 168 // Selection nuts. 169 bool inNut( const Point2I &pt, S32 x, S32 y ); 170 void drawNut( const Point2I &nut, S32 size, ColorI &outlineColor, ColorI &nutColor ); 171}; 172 173typedef GuiParticleGraphCtrl::GraphType GuiParticleGraphType; 174DefineEnumType( GuiParticleGraphType ); 175 176#endif 177