MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / onRender

Method onRender

Engine/source/gui/editor/guiGraphCtrl.cpp:131–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129//-----------------------------------------------------------------------------
130
131void GuiGraphCtrl::onRender(Point2I offset, const RectI &updateRect)
132{
133 if (mBlendSB.isNull())
134 {
135 GFXStateBlockDesc desc;
136
137 desc.setBlend(true, GFXBlendSrcColor, GFXBlendInvSrcColor);
138 mBlendSB = GFX->createStateBlock(desc);
139
140 desc.setBlend(false, GFXBlendOne, GFXBlendZero);
141 mSolidSB = GFX->createStateBlock(desc);
142
143 }
144
145 GFX->setStateBlock( mBlendSB );
146
147 GFX->getDrawUtil()->drawRectFill( updateRect, mProfile->mFillColor );
148
149 GFX->setStateBlock( mSolidSB );
150
151 const Point2I globalPos = getGlobalBounds().point;
152 const F32 midPointY = F32( globalPos.y ) + F32( getExtent().y ) * mCenterY;
153
154 for( S32 k = 0; k < MaxPlots; ++ k )
155 {
156 // Check if there is an autoplot and the proper amount of time has passed, if so add datum.
157 if( mAutoPlot[ k ] && mAutoPlotDelay[ k ] < (Sim::getCurrentTime() - mAutoPlotLastDisplay[ k ] ) )
158 {
159 mAutoPlotLastDisplay[ k ] = Sim::getCurrentTime();
160 addDatum( k, Con::getFloatVariable( mAutoPlot[ k ] ) );
161 }
162
163 // Nothing to graph
164 if( mGraphData[ k ].size() == 0 )
165 continue;
166
167 // Adjust scale to max value + 5% so we can see high values
168 F32 Scale = F32( getExtent().y ) / F32( mGraphMax[ k ] * 1.05 );
169
170 const S32 numSamples = mGraphData[ k ].size();
171
172 switch( mGraphType[ k ] )
173 {
174 case Bar:
175 {
176 F32 prevOffset = 0;
177
178 for( S32 sample = 0; sample < numSamples; ++ sample )
179 {
180 PrimBuild::begin( GFXTriangleStrip, 4 );
181 PrimBuild::color( mGraphColor[ k ] );
182
183 F32 offset = F32( getExtent().x ) / F32( MaxDataPoints ) * F32( sample + 1 );
184
185 PrimBuild::vertex2f( globalPos.x + prevOffset,
186 midPointY - ( getDatum( k, sample ) * Scale ) );
187
188 PrimBuild::vertex2f( globalPos.x + offset,

Callers

nothing calls this directly

Calls 15

getGlobalBoundsFunction · 0.85
getFloatVariableFunction · 0.85
beginFunction · 0.85
colorFunction · 0.85
vertex2fFunction · 0.85
endFunction · 0.85
getWidthFunction · 0.85
setBlendMethod · 0.80
createStateBlockMethod · 0.80
setStateBlockMethod · 0.80
drawRectFillMethod · 0.80
getDrawUtilMethod · 0.80

Tested by

no test coverage detected