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

Method onRender

Engine/source/gui/editor/guiGraphCtrl.cpp:132–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

getGlobalBoundsFunction · 0.85
getFloatVariableFunction · 0.85
beginFunction · 0.85
vertex2fFunction · 0.85
endFunction · 0.85
getWidthFunction · 0.85
setBlendMethod · 0.80
createStateBlockMethod · 0.80
drawRectFillMethod · 0.80
getDrawUtilMethod · 0.80
drawRectMethod · 0.80
getCurrentTimeFunction · 0.50

Tested by

no test coverage detected