本文整理汇总了C++中wxMemoryDC::DrawRectangle方法的典型用法代码示例。如果您正苦于以下问题:C++ wxMemoryDC::DrawRectangle方法的具体用法?C++ wxMemoryDC::DrawRectangle怎么用?C++ wxMemoryDC::DrawRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxMemoryDC
的用法示例。
在下文中一共展示了wxMemoryDC::DrawRectangle方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawHighlightedShapes
void ConnectivityHistCanvas::DrawHighlightedShapes(wxMemoryDC &dc)
{
dc.SetPen(wxPen(highlight_color));
dc.SetBrush(wxBrush(highlight_color, wxBRUSHSTYLE_CROSSDIAG_HATCH));
for (int i=0, iend=selectable_shps.size(); i<iend; i++) {
if (ival_obs_sel_cnt[i] == 0) continue;
double s = (((double) ival_obs_sel_cnt[i]) /
((double) ival_obs_cnt[i]));
GdaRectangle* rec = (GdaRectangle*) selectable_shps[i];
dc.DrawRectangle(rec->lower_left.x, rec->lower_left.y,
rec->upper_right.x - rec->lower_left.x,
(rec->upper_right.y - rec->lower_left.y)*s);
}
}
示例2: DrawEndPoint
void DrawEndPoint(wxMemoryDC &mem,unsigned int endx,unsigned int endy)
{
wxBrush blueback(wxColour(0,0,255),wxSOLID);
wxPen black(wxColour(0,0,0),1,wxSOLID);
wxPen red(wxColour(255,0,0),1,wxSOLID);
if ( (endx!=0) || (endy!=0) )
{
int parent=0;//Get_Object_PathPlanning(endx,endy,1);
mem.SetBrush(blueback);
if ( parent!=0 ) mem.SetPen(red);
else
mem.SetPen(black);
mem.DrawRectangle(endx*map_box_size-map_box_size_half,endy*map_box_size-map_box_size_half,map_box_size,map_box_size);
}
}
示例3: DrawBackground
void FreqWindow::DrawBackground(wxMemoryDC & dc)
{
Layout();
mBitmap.reset();
mPlotRect = mFreqPlot->GetClientRect();
mBitmap = std::make_unique<wxBitmap>(mPlotRect.width, mPlotRect.height);
dc.SelectObject(*mBitmap);
dc.SetBackground(wxBrush(wxColour(254, 254, 254)));// DONT-THEME Mask colour.
dc.Clear();
dc.SetPen(*wxBLACK_PEN);
dc.SetBrush(*wxWHITE_BRUSH);
dc.DrawRectangle(mPlotRect);
dc.SetFont(mFreqFont);
}
示例4: DrawHighlightedShapes
void ConditionalHistogramCanvas::DrawHighlightedShapes(wxMemoryDC &dc)
{
dc.SetPen(wxPen(highlight_color));
dc.SetBrush(wxBrush(highlight_color, wxBRUSHSTYLE_CROSSDIAG_HATCH));
int t = var_info[HIST_VAR].time;
int i=0;
double s;
for (int r=0; r<vert_num_cats; r++) {
for (int c=0; c<horiz_num_cats; c++) {
for (int ival=0; ival<cur_intervals; ival++) {
if (cell_data[t][r][c].ival_obs_sel_cnt[ival] != 0) {
s = (((double) cell_data[t][r][c].ival_obs_sel_cnt[ival]) /
((double) cell_data[t][r][c].ival_obs_cnt[ival]));
GdaRectangle* rec = (GdaRectangle*) selectable_shps[i];
dc.DrawRectangle(rec->lower_left.x, rec->lower_left.y,
rec->upper_right.x - rec->lower_left.x,
(rec->upper_right.y-rec->lower_left.y)*s);
}
i++;
}
}
}
}
示例5: drawTable
// NOTES:(1) store values of width & height at queryTable.
// (2)Need to set a font for the device context before get font metrics with GetTextExtent
void gqbGraphSimple::drawTable(wxMemoryDC& bdc, wxPoint *origin, gqbQueryObject *queryTable)
{
long w=0,h=0,height=0,width=0,margin=5;
// Get Value for row Height
if(!rowHeight)
{
bdc.SetFont(TableTitleFont);
bdc.GetTextExtent(wxT("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxtz"),&w,&h);
rowHeight=h;
}
// Get Title Metrics
bdc.SetFont(TableTitleFont);
height+= rowHeight + rowTopMargin;
// Calculate font metrics for table title with/without alias
if(queryTable->getAlias().length()>0)
bdc.GetTextExtent(queryTable->getName()+wxT(" (")+queryTable->getAlias()+wxT(")"),&w,&h);
else
bdc.GetTextExtent(queryTable->getName(),&w,&h);
width= rowLeftMargin + w + rowRightMargin;
// Get Columns Metrics
bdc.SetFont(normalFont);
// Don't use h value from font metrics to get consistency between columns vertical separation (height)
height+=rowHeight*queryTable->parent->countCols()+rowTopMargin*queryTable->parent->countCols();
gqbIteratorBase *iterator = queryTable->parent->createColumnsIterator();
while(iterator->HasNext())
{
gqbColumn *tmp= (gqbColumn *)iterator->Next();
bdc.GetTextExtent(tmp->getName(),&w,&h);
if((rowLeftMargin + w + rowRightMargin) > width)
width=rowLeftMargin + w + rowRightMargin;
}
//Don't delete iterator because will be use below;
// Set table Size in ObjectModel (Temporary Values for object representation,
// and for this reason the view can modified model without using the controller
// because this values are used by controller when use object's size in internal operations)
if( (height+2) < minTableHeight) // +2 from BackgroundLayers addition
{
queryTable->setHeight(minTableHeight);
height=minTableHeight;
}
else
queryTable->setHeight(height+2);
if( (width+2) < minTableWidth)
{
queryTable->setWidth(minTableWidth);
width=minTableWidth;
}
else
queryTable->setWidth(width+2);
//Decorate Table
bdc.SetPen(*wxTRANSPARENT_PEN);
//draw second Layer
bdc.SetBrush(BackgroundLayer2);
bdc.DrawRectangle(wxRect(wxPoint(origin->x,origin->y), wxSize(width+2,height+2)));
//draw third Layer
bdc.SetBrush(BackgroundLayer1);
bdc.DrawRectangle(wxRect(wxPoint(origin->x,origin->y), wxSize(width+1,height+1)));
//draw real frame layer
bdc.SetBrush(*wxWHITE_BRUSH);
if(queryTable->getSelected())
{
bdc.SetPen(selectedPen);
}
else
{
bdc.SetPen(*wxBLACK_PEN);
}
bdc.DrawRectangle(wxRect(wxPoint(origin->x,origin->y), wxSize(width,height)));
//draw title layer
bdc.SetBrush(BackgroundTitle);
bdc.DrawRectangle(wxRect(wxPoint(origin->x,origin->y), wxSize(width,rowHeight+rowTopMargin)));
bdc.SetFont(TableTitleFont);
if(queryTable->getAlias().length()>0)
bdc.DrawText(queryTable->getName()+wxT(" (")+queryTable->getAlias()+wxT(")"),origin->x+margin,origin->y+rowTopMargin);
else
bdc.DrawText(queryTable->getName(),origin->x+margin,origin->y+rowTopMargin);
bdc.SetFont(normalFont);
// GQB-TODO: in a future reuse a little more the iterator creating it inside the Query or Table Object
// and only delete it when delete the query object.
// Draw Columns
height=rowHeight+rowTopMargin;
iterator->ResetIterator();
while(iterator->HasNext())
//.........这里部分代码省略.........
示例6: drawJoin
void gqbGraphSimple::drawJoin(wxMemoryDC& bdc, wxPoint& origin, wxPoint& dest, wxPoint& anchorUsed, bool selected=false, type_Join joinKind=_equally)
{
wxPoint origin2=origin;
wxPoint dest2=dest;
if(selected)
{
bdc.SetPen(selectedPen);
bdc.SetBrush(selectedBrush);
}
else
{
bdc.SetPen(*wxBLACK_PEN);
bdc.SetBrush(*wxBLACK_BRUSH);
}
// GQB-TODO: optimize this if possible, I know one other can be the same?
// getAnchorsUsed() [-1==left] [1==right] x->origin y->destination
if(anchorUsed.x==1)
{
bdc.DrawRectangle(origin.x,origin.y-4,8,8);
origin2.x+=20;
}
else
{
bdc.DrawRectangle(origin.x-8,origin.y-4,8,8);
origin2.x-=20;
}
if(anchorUsed.y==1)
{
bdc.DrawRectangle(dest.x,dest.y-4,8,8);
dest2.x+=20;
}
else
{
bdc.DrawRectangle(dest.x-8,dest.y-4,8,8);
dest2.x-=20;
}
bdc.DrawLine(origin,origin2);
bdc.DrawLine(dest,dest2);
bdc.DrawLine(origin2,dest2);
// Draw type of join
switch(joinKind)
{
case _equally:
bdc.DrawText(wxT("="),findLineMiddle(origin2, dest2));
break;
case _lesser:
bdc.DrawText(wxT("<"),findLineMiddle(origin2, dest2));
break;
case _greater:
bdc.DrawText(wxT(">"),findLineMiddle(origin2, dest2));
break;
case _equlesser:
bdc.DrawText(wxT("<="),findLineMiddle(origin2, dest2));
break;
case _equgreater:
bdc.DrawText(wxT(">="),findLineMiddle(origin2, dest2));
break;
};
}
示例7: DrawWorld
void DrawWorld(wxMemoryDC &mem,struct Map *floorplancopy)
{
wxBrush blackback(wxColour(0,0,0),wxSOLID);
wxPen white(wxColour(255,255,255),1,wxSOLID);
wxBrush whiteback(wxColour(255,255,255),wxSOLID);
wxBrush grayback(wxColour(123,123,123),wxSOLID);
wxBrush redback(wxColour(255,0,0),wxSOLID);
mem.SetPen(white);
mem.SetBrush(whiteback);
mem.DrawRectangle(0,0,draw_area_width,draw_area_height);
wxPen black(wxColour(0,0,0),1,wxSOLID);
wxPen red(wxColour(255,0,0),1,wxSOLID);
int obj=0;
mem.SetPen(black);
mem.SetBrush(whiteback);
for (unsigned int y =0; y<draw_area_actual_pointsY; y++ )
{
for (unsigned int x =0; x<draw_area_actual_pointsX; x++ )
{
obj = ObstacleExists(GetWorldHandler(),x,y);
if ( obj!=0 )
{
mem.SetPen(red);
mem.SetBrush(blackback);
} else
{
obj = ObstacleRadiousExists(GetWorldHandler(),x,y);
if ( obj!=0 )
{
mem.SetPen(black);
mem.SetBrush(grayback);
}
}
mem.DrawRectangle(x*map_box_size,y*map_box_size,map_box_size,map_box_size);
obj=1;
if ( obj!=0 )
{
mem.SetPen(white); //black for boxes everywhere!
mem.SetBrush(whiteback);
obj = 0;
}
}
}
DrawSolvePath(mem);
unsigned int endx=0,endy=0;
GetAgentTargetLocation(GetWorldHandler(),OURROBOT,&endx,&endy);
DrawEndPoint(mem,endx,endy);
// Draw Start point drawn second in case both points are the same ( we are on target :P )
unsigned int startx=0,starty=0;
GetAgentLocation(GetWorldHandler(),OURROBOT,&startx,&starty);
DrawStartPoint(mem,startx,starty,GetAgentHeading(GetWorldHandler(),OURROBOT));
}
示例8: DrawStartPoint
//.........这里部分代码省略.........
x = r cos q
y = r sin q
x' = r cos ( q + f ) = r cos q cos f - r sin q sin f
y' = r sin ( q + w ) = r sin q cos f + r cos q sin f
hence:
x' = x cos f - y sin f
y' = y cos f + x sin f
We also asume
-,- 0,+ + . -
XL,YL
X4,Y4________________ X1,Y1
| |
XB | * | XF
YB| | YF
|________________|
X3,Y3 X2,Y2
-.+ 0,- + , +
XR,YR
*/
float box_width = robot_length/ (1000*GetMapUnit_In_cm(GetWorldHandler()));
float box_height = robot_width/ (1000*GetMapUnit_In_cm(GetWorldHandler()));
float XA1 = 0.0+box_width/2 ;
float YA1 = 0.0-box_height/2 ;
float XA2 = 0.0+box_width/2 ;
float YA2 = 0.0+box_height/2 ;
float XA3 = 0.0-box_width/2 ;
float YA3 = 0.0+box_height/2 ;
float XA4 = 0.0-box_width/2 ;
float YA4 = 0.0-box_height/2 ;
float XAF = 0.0+box_width/2 ;
float YAF = 0.0;
float XAB= 0.0-box_width/2 ;
float YAB = 0.0;
float XAR = 0.0;
float YAR = 0.0+box_height/2 ;
float XAL = 0.0 ;
float YAL = 0.0-box_height/2 ;
float XB1 , YB1, XB2, YB2, XB3 , YB3, XB4, YB4 , XBF, YBF , XBB, YBB , XBR, YBR , XBL, YBL ;
XB1 = startx + XA1 * cos(heading*PI/180) - YA1 * sin(heading*PI/180);
YB1 = starty + YA1 * cos(heading*PI/180) + XA1 * sin(heading*PI/180);
XB2 = startx + XA2 * cos(heading*PI/180) - YA2 * sin(heading*PI/180);
YB2 = starty + YA2 * cos(heading*PI/180) + XA2 * sin(heading*PI/180);
XB3 = startx + XA3 * cos(heading*PI/180) - YA3 * sin(heading*PI/180);
YB3 = starty + YA3 * cos(heading*PI/180) + XA3 * sin(heading*PI/180);
XB4 = startx + XA4 * cos(heading*PI/180) - YA4 * sin(heading*PI/180);
YB4 = starty + YA4 * cos(heading*PI/180) + XA4 * sin(heading*PI/180);
XBF = startx + XAF * cos(heading*PI/180) - YAF * sin(heading*PI/180);
YBF = starty + YAF * cos(heading*PI/180) + XAF * sin(heading*PI/180);
XBB = startx + XAB * cos(heading*PI/180) - YAB * sin(heading*PI/180);
YBB = starty + YAB * cos(heading*PI/180) + XAB * sin(heading*PI/180);
XBR = startx + XAR * cos(heading*PI/180) - YAR * sin(heading*PI/180);
YBR = starty + YAR * cos(heading*PI/180) + XAR * sin(heading*PI/180);
XBL = startx + XAL * cos(heading*PI/180) - YAL * sin(heading*PI/180);
YBL = starty + YAL * cos(heading*PI/180) + XAL * sin(heading*PI/180);
fprintf(stderr,"We have points %0.2f,%0.2f %0.2f,%0.2f %0.2f,%0.2f %0.2f,%0.2f \n",XB1,YB1,XB2,YB2,XB3,YB3,XB4,YB4);
if ( (startx!=0) || (starty!=0) )
{
mem.SetPen(green);
mem.SetBrush(greenback);
mem.DrawLine((signed int)XB1*map_box_size,(signed int)YB1*map_box_size,(signed int)XB2*map_box_size,(signed int)YB2*map_box_size);
mem.DrawLine((signed int)XB2*map_box_size,(signed int)YB2*map_box_size,(signed int)XB3*map_box_size,(signed int)YB3*map_box_size);
mem.DrawLine((signed int)XB3*map_box_size,(signed int)YB3*map_box_size,(signed int)XB4*map_box_size,(signed int)YB4*map_box_size);
mem.DrawLine((signed int)XB4*map_box_size,(signed int)YB4*map_box_size,(signed int)XB1*map_box_size,(signed int)YB1*map_box_size);
//ARROW
mem.DrawLine((signed int)XBB*map_box_size,(signed int)YBB*map_box_size,(signed int)XBF*map_box_size,(signed int)YBF*map_box_size);
mem.DrawLine((signed int)XBF*map_box_size,(signed int)YBF*map_box_size,(signed int)XBL*map_box_size,(signed int)YBL*map_box_size);
mem.DrawLine((signed int)XBF*map_box_size,(signed int)YBF*map_box_size,(signed int)XBR*map_box_size,(signed int)YBR*map_box_size);
mem.DrawRectangle(startx*map_box_size-1,starty*map_box_size-1,2,2);
}
}
示例9: OnTimer
void SjOscWindow::OnTimer(wxTimerEvent&)
{
SJ_FORCE_IN_HERE_ONLY_ONCE;
if( m_oscModule )
{
// volume stuff
long volume, maxVolume = 1;
bool volumeBeat;
// other objects
long i;
bool titleChanged, forceOscAnim, forceSpectrAnim;
wxString newTitle;
// get data
g_mainFrame->m_player.GetVisData(m_bufferStart, m_sampleCount*SJ_WW_CH*SJ_WW_BYTERES, 0);
// get window client size, correct offscreen DC if needed
wxSize clientSize = m_oscModule->m_oscWindow->GetClientSize();
if( clientSize.x != m_offscreenBitmap.GetWidth() || clientSize.y != m_offscreenBitmap.GetHeight() )
{
m_offscreenBitmap.Create(clientSize.x, clientSize.y);
m_offscreenDc.SelectObject(m_offscreenBitmap);
}
// calculate the points for the lines, collect volume
m_oscilloscope->Calc(clientSize, m_bufferStart, volume);
if( m_oscModule->m_showFlags&SJ_OSC_SHOW_SPECTRUM )
{
m_spectrum->Calc(clientSize, m_bufferStart);
}
// get data that are shared between the threads
{
titleChanged = m_oscModule->m_titleChanged;
m_oscModule->m_titleChanged = FALSE;
if( titleChanged )
{
newTitle = m_oscModule->m_trackName;
if( newTitle.IsEmpty() )
{
newTitle = SJ_PROGRAM_NAME;
}
else if( !m_oscModule->m_leadArtistName.IsEmpty() )
{
newTitle.Prepend(m_oscModule->m_leadArtistName + wxT(" - "));
}
}
forceOscAnim = m_oscModule->m_forceOscAnim;
m_oscModule->m_forceOscAnim = FALSE;
forceSpectrAnim = m_oscModule->m_forceSpectrAnim;
m_oscModule->m_forceSpectrAnim = FALSE;
}
// calculate volume, volume is theoretically max. 255, normally lesser
if( titleChanged ) { maxVolume = 1; }
if( volume > maxVolume ) { maxVolume = volume; }
volumeBeat = (volume > maxVolume/2);
// erase screen
m_offscreenDc.SetPen(*wxTRANSPARENT_PEN);
{
// blue gradient background
#define BG_STEPS 88
int rowH = (clientSize.y/BG_STEPS)+1;
for( i = 0; i < BG_STEPS; i++ )
{
m_bgBrush.SetColour(0, 0, i);
m_offscreenDc.SetBrush(m_bgBrush);
m_offscreenDc.DrawRectangle(0, i*rowH, clientSize.x, rowH);
}
}
// draw text (very background)
{
m_offscreenDc.SetBackgroundMode(wxTRANSPARENT);
m_offscreenDc.SetTextForeground(m_textColour);
m_title->Draw(m_offscreenDc, clientSize, titleChanged, newTitle);
}
// draw figures (they lay in backgroud)
if( m_oscModule->m_showFlags&SJ_OSC_SHOW_FIGURES )
{
long bgLight = 100;
// draw hands (optional)
m_hands->Draw(m_offscreenDc, clientSize, volume, bgLight, titleChanged);
// draw rotor (optional)
m_rotor->Draw(m_offscreenDc, clientSize, m_starfield->IsRunning(), titleChanged, volume, bgLight);
// draw firework (optional)
m_firework->Draw(m_offscreenDc, clientSize, titleChanged, m_starfield->IsRunning(), volumeBeat, bgLight);
}
// draw starfield (optional)
//.........这里部分代码省略.........
示例10: Paint
void wxListSelection::Paint(wxMemoryDC &dc)
{
const StringArray &displayOrder = mParent->GetDisplayOrder();
wxASSERT(false == displayOrder.empty());
wxASSERT(displayOrder.size() == mpImpl->mPoints.size());
wxSize size = GetSize();
wxColour background = mpImpl->mBackground;
// Set background color.
if(mpImpl->mIsHighlight && mpImpl->mIsSelected)
{
background = mpImpl->mHighlightAndSelected;
}
else if(mpImpl->mIsHighlight)
{
background = mpImpl->mHighlight;
}
else if(mpImpl->mIsSelected)
{
background = mpImpl->mSelected;
}
dc.SetPen(wxPen(background));
dc.SetBrush(wxBrush(background));
dc.DrawRectangle(0, 0, size.x, size.y);
// Bitmap (if any)
if(true == mpImpl->mBitmap.Ok())
{
dc.DrawBitmap(mpImpl->mBitmap, sImageBufferX, mpImpl->mImageBufferY, true);
}
// Draw text.
dc.SetFont(mpImpl->mMainFont);
wxColour shadow = mpImpl->mMainTextShadow;
wxColour main = IsEnabled() ? mpImpl->mMainText :
mpImpl->mMainTextDisabled;
for(size_t i = 0; i < displayOrder.size(); ++i)
{
if(1 == i)
{
dc.SetFont(mpImpl->mSubFont);
shadow = mpImpl->mSubTextShadow;
main = mpImpl->mSubText;
}
const wxString &str = mpImpl->mFields[displayOrder[i]];
if(false == str.IsEmpty())
{
const wxPoint &point = mpImpl->mPoints[i];
if(shadow != mpImpl->mTransparent)
{
dc.SetTextForeground(shadow);
dc.DrawText(str, point.x + 1, point.y + 1);
}
dc.SetTextForeground(main);
dc.DrawText(str, point.x, point.y);
}
}
}