Esempio n. 1
0
void LineChart::DrawMouseoverMarker(wxMemoryDC &dc){

	dc.SetPen(*wxThePenList->FindOrCreatePen(*wxWHITE, 1, wxSOLID));
	dc.DrawLine(m_mouseX, 0, m_mouseX, _currentHeight);

	size_t dataIndex = (size_t)(((double)GetMaxSeriesBufferSize()) * m_viewOffsetFactor) + m_mouseX - m_leftEdge;
	DrawCurrentValues(dc, dataIndex, m_mouseX, m_mouseY);
}
Esempio n. 2
0
void
TstLayer_t::_updateDC(void)
{
    if (mDC) delete mDC;
    mDC = new wxMemoryDC(*mSurface);
    mDC->SetBackground(*wxBLACK_BRUSH);
    mDC->SetPen(*_pen);
}
Esempio n. 3
0
void
TstLayer_t::paint_cursor(wxCoord cx, wxCoord cy)
{
    wxSize sz;

    _drawbegin();
    sz = mDC->GetSize();
    mDC->Clear();
    mDC->DrawLine(cx, 0, cx, sz.GetHeight());
    mDC->DrawLine(0, cy, sz.GetWidth(), cy);
    _drawend();
}
Esempio n. 4
0
void
TstLayer_t::paint_grid(void)
{
    wxCoord px, py;
    wxSize sz;

    _drawbegin();
    sz = mDC->GetSize();
    for (px = 32; px < sz.GetWidth(); px += 32)
        mDC->DrawLine(px, 0, px, sz.GetHeight());
    for (py = 32; py < sz.GetHeight(); py += 32)
        mDC->DrawLine(0, py, sz.GetWidth(), py);
    _drawend();
}
Esempio n. 5
0
void StripChart::DrawCurrentValues(wxMemoryDC &dc){
	
	//see if data was logged for the mouse location
	int dataBufferSize = _dataBuffer.size();
	float zoomFactor = (float)_zoomPercentage / 100.0;
	int dataBufferIndex = dataBufferSize - (int)(((float)(_currentWidth - _mouseX)) / zoomFactor) - 1;
	//adjust for uboundoffset
	dataBufferIndex-=((dataBufferSize - 1) -_currentDataBufferUBound);
	if (dataBufferIndex < 0 || dataBufferIndex >= dataBufferSize) return;
	
	
	dc.SetPen(*wxThePenList->FindOrCreatePen(*wxWHITE, 1, wxSOLID));
	dc.DrawLine(_mouseX, 0, _mouseX, _currentHeight);

	int currentOffset = 0;
	StripChartLogItem logItem = _dataBuffer[dataBufferIndex];
	
	wxDateTime timestamp = logItem.GetTimestamp();
	
	wxDateTime fromTime;
	switch(_timespanMode){
		case TIMESPAN_FROM_LAST_LOG_ENTRY:
		{
			StripChartLogItem lastLogItem = _dataBuffer[dataBufferSize - 1];
			fromTime = lastLogItem.GetTimestamp();
			break;
		}
		case TIMESPAN_FROM_NOW:
			fromTime = wxDateTime::UNow();
			break;
	}
	wxTimeSpan span =  (fromTime - timestamp);
	wxString timeString = wxString::Format("%d seconds back",(int)span.GetSeconds().ToLong());
	
	
	wxFont labelFont = GetFont();
	int labelWidth,labelHeight,descent,externalLeading;
	dc.GetTextExtent(timeString, &labelHeight, &labelWidth, &descent, &externalLeading, &labelFont);
	dc.SetTextForeground(*wxWHITE);
	
	dc.DrawRotatedText(timeString, _mouseX - labelWidth, _mouseY,90);
	
	for (LogItemTypes::iterator it = _logItemTypes.begin(); it != _logItemTypes.end(); ++it){

		wxString key = it->first;		
		LogItemType *logItemType = it->second;
		ChartScale *scale = &_chartScales[logItemType->scaleId];
		
		dc.SetTextForeground(logItemType->lineColor);

		int value = logItem[logItemType->typeKey];
		wxString valueString = logItemType->typeLabel + ": " + wxString::Format("%d",value) + " " +scale->scaleLabel;

		dc.GetTextExtent(valueString, &labelHeight, &labelWidth, &descent, &externalLeading, &labelFont);
		
		currentOffset += labelWidth;
		dc.DrawRotatedText(valueString,_mouseX - labelHeight - 15, _mouseY - currentOffset,0);
	}
}
Esempio n. 6
0
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);
    }
}
Esempio n. 7
0
wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ) :
   wxDCImpl( owner )
{
#if defined(__WXMSW__) && wxUSE_WXDIB
    // It seems that GDI+ sets invalid values for alpha channel when used with
    // a compatible bitmap (DDB). So we need to convert the currently selected
    // bitmap to a DIB before using it with any GDI+ functions to ensure that
    // we get the correct alpha channel values in it at the end.

    wxBitmap bmp = dc.GetSelectedBitmap();
    wxASSERT_MSG( bmp.IsOk(), "Should select a bitmap before creating wxGCDC" );

    // We don't need to convert it if it can't have alpha at all (any depth but
    // 32) or is already a DIB with alpha.
    if ( bmp.GetDepth() == 32 && (!bmp.IsDIB() || !bmp.HasAlpha()) )
    {
        // We need to temporarily deselect this bitmap from the memory DC
        // before modifying it.
        const_cast<wxMemoryDC&>(dc).SelectObject(wxNullBitmap);

        bmp.ConvertToDIB(); // Does nothing if already a DIB.

        if( !bmp.HasAlpha() )
        {
            // Initialize alpha channel, even if we don't have any alpha yet,
            // we should have correct (opaque) alpha values in it for GDI+
            // functions to work correctly.
            {
                wxAlphaPixelData data(bmp);
                if ( data )
                {
                    wxAlphaPixelData::Iterator p(data);
                    for ( int y = 0; y < data.GetHeight(); y++ )
                    {
                        wxAlphaPixelData::Iterator rowStart = p;

                        for ( int x = 0; x < data.GetWidth(); x++ )
                        {
                            p.Alpha() = wxALPHA_OPAQUE;
                            ++p;
                        }

                        p = rowStart;
                        p.OffsetY(data, 1);
                    }
                }
            } // End of block modifying the bitmap.

            // Using wxAlphaPixelData sets the internal "has alpha" flag but we
            // don't really have any alpha yet, so reset it back for now.
            bmp.ResetAlpha();
        }

        // Undo SelectObject() at the beginning of this block.
        const_cast<wxMemoryDC&>(dc).SelectObjectAsSource(bmp);
    }
#endif // wxUSE_WXDIB

    Init(wxGraphicsContext::Create(dc));
}
Esempio n. 8
0
void
TstLayer_t::paint_1(void)
{
    wxCoord px, py;
    wxSize sz;

    _drawbegin();
    sz = mDC->GetSize();
    for (px = 32; px < sz.GetWidth(); px += 64)
        for (py = 32; py < sz.GetHeight(); py += 64) {
            mDC->DrawLine(px - cross_size, py - cross_size,
                          px + cross_size, py + cross_size);
            mDC->DrawLine(px - cross_size, py + cross_size,
                          px + cross_size, py - cross_size);
        }
    _drawend();
}
Esempio n. 9
0
void
TstLayer_t::setSize(const wxSize &sz)
{
    if (sz == mDC->GetSize()) return;
    mSurface->SetWidth(sz.GetWidth());
    mSurface->SetHeight(sz.GetHeight());
    _updateDC();
}
Esempio n. 10
0
void DrawSolvePath(wxMemoryDC &mem)
{
  unsigned int route_count=0;
  unsigned int x=0,y=0;

  wxBrush yellowback(wxColour(255,255,0),wxSOLID);
  wxPen yellow(wxColour(255,255,0),1,wxSOLID);


  while ( GetRouteWaypoint(GetWorldHandler(),0,route_count,&x,&y) == 1 )
    {
      mem.SetPen(yellow);
      mem.SetBrush(yellowback);

      mem.DrawRectangle(x*map_box_size,y*map_box_size,map_box_size,map_box_size);
      ++route_count;
    }

  //printf("Drawing Level 1 Lines \n");
  wxPen redfat(wxColour(255,0,0),3,wxSOLID);
  unsigned int oldx=0,oldy=0;
  if ( GetStraightRouteWaypoint(GetWorldHandler(),OURROBOT,0,&oldx,&oldy)==1 ) { mem.DrawCircle(oldx*10+5,oldy*10+5,3); }
  route_count=1;
  while ( GetStraightRouteWaypoint(GetWorldHandler(),OURROBOT,route_count,&x,&y)==1 )
    {
      mem.SetPen(redfat);
      mem.DrawCircle(x*map_box_size+map_box_size_half,y*map_box_size+map_box_size_half,3);
      mem.DrawLine(oldx*map_box_size+map_box_size_half,oldy*map_box_size+map_box_size_half,x*map_box_size+map_box_size_half,y*map_box_size+map_box_size_half);
      ++route_count;
      oldx = x , oldy = y ;
    }
  return;
}
Esempio n. 11
0
void FreqWindow::DrawBackground(wxMemoryDC & dc)
{
   Layout();

   if (mBitmap)
   {
      delete mBitmap;
      mBitmap = NULL;
   }

   mPlotRect = mFreqPlot->GetClientRect();

   mBitmap = new 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);
}
Esempio n. 12
0
void BoxNewPlotCanvas::DrawSelectableShapes(wxMemoryDC &dc)
{
	LOG_MSG("In BoxNewPlotCanvas::DrawSelectableShapes");
	int radius = TemplateCanvas::markers_size;
	for (int t=cur_first_ind; t<=cur_last_ind; t++) {
		int min_IQR = hinge_stats[t].min_IQR_ind;
		int max_IQR = hinge_stats[t].max_IQR_ind;
		int ind_base = (t-cur_first_ind)*num_obs;
		dc.SetPen(GdaConst::boxplot_point_color);
		dc.SetBrush(*wxWHITE_BRUSH);
		for (int i=0; i<min_IQR; i++) {
			int ind = ind_base + data_sorted[t][i].second;
			dc.DrawCircle(selectable_shps[ind]->center, radius);
		}
		for (int i=max_IQR+1; i<num_obs; i++) {
			int ind = ind_base + data_sorted[t][i].second;
			dc.DrawCircle(selectable_shps[ind]->center, radius);
		}
		int iqr_s = GenUtils::max<double>(min_IQR, 0);
		int iqr_t = GenUtils::min<double>(max_IQR, num_obs-1);
		dc.SetPen(GdaConst::boxplot_q1q2q3_color);
		dc.SetBrush(GdaConst::boxplot_q1q2q3_color);
		for (int i=iqr_s; i<=iqr_t; i++) {
			int ind = ind_base + data_sorted[t][i].second;
			GdaRectangle* rec = (GdaRectangle*) selectable_shps[ind];
			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);
		}
	}	
}
Esempio n. 13
0
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);
    }
}
Esempio n. 14
0
void LineChart::DrawCurrentValues(wxMemoryDC &dc, size_t dataIndex, int x, int y){
	int currentOffset = 0;
	wxFont labelFont = GetFont();
	int labelWidth,labelHeight,descent,externalLeading;

	for (SeriesMap::iterator it = m_seriesMap.begin(); it != m_seriesMap.end(); ++it){

		Series *series = it->second;
		double dataValue = series->GetValueAtOrNear(dataIndex);
		wxString numberFormat = "% 2." + wxString::Format("%df", series->GetPrecision());
		wxString valueString = (DatalogValue::NULL_VALUE == dataValue ? "---" : wxString::Format(numberFormat.ToAscii(), dataValue)) + " " + series->GetLabel();
		dc.SetTextForeground(series->GetColor());
		dc.GetTextExtent(valueString, &labelHeight, &labelWidth, &descent, &externalLeading, &labelFont);

		dc.DrawRotatedText(valueString, x + CURRENT_VALUES_RIGHT_OFFSET, y + currentOffset,0);
		currentOffset += labelWidth;
	}
}
Esempio n. 15
0
//set the font on memDC such that text can fit in specified width and height
void ExportMixerPanel::SetFont( wxMemoryDC &memDC, wxString text, int width,
                                int height )
{
    int l = 0, u = 13, m, w, h;
    wxFont font = memDC.GetFont();
    while( l < u - 1 )
    {
        m = ( l + u ) / 2;
        font.SetPointSize( m );
        memDC.SetFont( font );
        memDC.GetTextExtent( text, &w, &h );

        if( w < width && h < height )
            l = m;
        else
            u = m;
    }
    font.SetPointSize( l );
    memDC.SetFont( font );
}
Esempio n. 16
0
// On some platforms, notably Mac OS X with Core Graphics, we can't blit from
// a window, so we need to draw the background explicitly.
bool MyDragImage::UpdateBackingFromWindow(wxDC& WXUNUSED(windowDC), wxMemoryDC& destDC, const wxRect& WXUNUSED(sourceRect),
                    const wxRect& destRect) const
{
    destDC.SetClippingRegion(destRect);

    if (wxGetApp().GetBackgroundBitmap().IsOk())
        wxGetApp().TileBitmap(destRect, destDC, wxGetApp().GetBackgroundBitmap());

    m_canvas->DrawShapes(destDC);
    return true;
}
Esempio n. 17
0
bool ChartPlugInWrapper::RenderRegionViewOnDC(wxMemoryDC& dc, const ViewPort& VPoint,
                                              const wxRegion &Region)
{
      if(m_ppicb)
      {
            PlugIn_ViewPort pivp = CreatePlugInViewport( VPoint);
            dc.SelectObject(m_ppicb->RenderRegionView( pivp, Region));
            return true;
      }
      else
            return false;
}
Esempio n. 18
0
void BoxNewPlotCanvas::DrawHighlightedShapes(wxMemoryDC &dc)
{
	int radius = 3;
	std::vector<bool>& hs = highlight_state->GetHighlight();
	
	dc.SetBrush(highlight_color);
	for (int t=cur_first_ind; t<=cur_last_ind; t++) {
		int min_IQR = hinge_stats[t].min_IQR_ind;
		int max_IQR = hinge_stats[t].max_IQR_ind;
		int ind_base = (t-cur_first_ind)*num_obs;
		dc.SetPen(*wxRED_PEN);
		for (int i=0; i<min_IQR; i++) {
			if (!hs[data_sorted[t][i].second]) continue;
			int ind = ind_base + data_sorted[t][i].second;
			dc.DrawCircle(selectable_shps[ind]->center, radius);
		}
		for (int i=max_IQR+1; i<num_obs; i++) {
			if (!hs[data_sorted[t][i].second]) continue;
			int ind = ind_base + data_sorted[t][i].second;
			dc.DrawCircle(selectable_shps[ind]->center, radius);
		}
		int iqr_s = GenUtils::max<double>(min_IQR, 0);
		int iqr_t = GenUtils::min<double>(max_IQR, num_obs-1);
		dc.SetPen(highlight_color);
		for (int i=iqr_s; i<=iqr_t; i++) {
			if (!hs[data_sorted[t][i].second]) continue;
			int ind = ind_base + data_sorted[t][i].second;
			GdaRectangle* rec = (GdaRectangle*) selectable_shps[ind];
			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);
		}
	}
}
Esempio n. 19
0
void LineChart::DrawGrid(wxMemoryDC &dc){

	dc.SetPen(*wxThePenList->FindOrCreatePen(wxColor(40,40,40), 1, wxSOLID));

	int width = _currentWidth;
	int height = _currentHeight;

	float zoomFactor = (float)_zoomPercentage / 100;

	int gridIncrement = (int)(GRID_SIZE * zoomFactor);

	for (int x = width; x >=0 ; x -= gridIncrement){
		dc.DrawLine(x, 0, x, height);
	}

	float i = 0;
	while (i < 1){
		int y = (int)(((float)height) * i);
		dc.DrawLine(0, y, width, y);
		i = i + 0.1;
	}
}
Esempio n. 20
0
void
TstLayer_t::paint_right(wxCoord cx, wxCoord cy)
{
    wxPoint points[4];

    _drawbegin();
    points[0] = wxPoint(cx, cy - diamond_size1);
    points[1] = wxPoint(cx + diamond_size0, cy);
    points[2] = wxPoint(cx, cy + diamond_size1);
    points[3] = wxPoint(cx - diamond_size0, cy);
    mDC->DrawPolygon(4, points);
    _drawend();
}
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++;
			}
		}
	}
}
Esempio n. 22
0
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);
}
Esempio n. 23
0
void wxBuildUI::Paint(wxMemoryDC &dc)
{
	wxSize size = GetSize();

	dc.SetBrush(wxBrush(sBackgroundBuild, wxSOLID));
	dc.SetPen(wxPen(mClickable ? sClickable : sOutline, 1, wxSOLID));
	
	dc.DrawRectangle(0, 0, size.x, size.y);

	// If we're not clickable, draw hatch lines over the bitmap to show it.
	if(false == mClickable)
	{
		wxBrush brush(sOutline);
		brush.SetStyle(wxBDIAGONAL_HATCH);

		dc.SetBrush(brush);
		dc.DrawRectangle(0, 0, size.x, size.y);

		dc.DrawBitmap(mDisabledBitmap, 1, 1, true);
	}
}
// 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())
    {
        gqbColumn *tmp= (gqbColumn *)iterator->Next();
        if(queryTable->existsColumn(tmp))
        {
            bdc.SetTextForeground(* wxRED);
            bdc.SetFont(normalFont);
            bdc.DrawBitmap(imgSelBoxSelected,origin->x+3,origin->y+height,true);
        }
        else
        {
            bdc.SetFont(normalFont);
            bdc.DrawBitmap(imgSelBoxEmpty,origin->x+3,origin->y+height,true);
        }
        bdc.DrawText(tmp->getName(),origin->x+rowLeftMargin,origin->y+height);
        bdc.SetTextForeground( *wxBLACK);
        height+=rowHeight+rowTopMargin;
    }
    delete iterator;                              //now if delete because it's not needed anymore

}
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;
    };
}
Esempio n. 26
0
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));


}
Esempio n. 27
0
void gqbView::drawAll(wxMemoryDC &bdc, bool adjustScrolling)
{
	bdc.Clear();
	if(!iterator)
		// Get an iterator for the objects (tables/views) in the model.
		iterator = this->model->createQueryIterator();
	else
		iterator->ResetIterator();

	// First Draw Tables
	while(iterator->HasNext())
	{
		gqbQueryObject *tmp = (gqbQueryObject *)iterator->Next();
		wxPoint pt = wxPoint(tmp->position);      // Use a copy because I don't want to store the modified
		// version of point after CalcScrolledPosition was called

		if (adjustScrolling)
		{
			// adjust coordinates
			this->CalcScrolledPosition(pt.x, pt.y, &pt.x, &pt.y);
		}
		graphBehavior->drawTable(bdc, &pt, tmp);  // graph table
	}

	// Later Draw Joins over Tables
	iterator->ResetIterator();
	while(iterator->HasNext())
	{
		gqbQueryObject *tmp = (gqbQueryObject *)iterator->Next();

		if(tmp->getHaveJoins())
		{
			gqbIteratorBase *joinsIterator = tmp->createJoinsIterator();
			while(joinsIterator->HasNext())
			{
				gqbQueryJoin *join = (gqbQueryJoin *) joinsIterator->Next();
				wxPoint o = join->getSourceAnchor();
				wxPoint d = join->getDestAnchor();

				if (adjustScrolling)
				{
					// adjust coordinates origin
					this->CalcScrolledPosition(o.x, o.y, &o.x, &o.y);

					// adjust coordinates destination
					this->CalcScrolledPosition(d.x, d.y, &d.x, &d.y);
				}
				graphBehavior->drawJoin(bdc, o, d, join->getAnchorsUsed(), join->getSelected(), join->getKindofJoin());
			}
			delete joinsIterator;
		}

	}

	// This iterator is delete at destroyer for reuse purposes
	if(joinSource)
	{
		// Draw temporary line while creating a join
		wxPoint source = jpos;
		wxPoint destination = pos;
		if(adjustScrolling)
		{
			this->CalcScrolledPosition(source.x, source.y, &source.x, &source.y);
			this->CalcScrolledPosition(destination.x, destination.y, &destination.x, &destination.y);
		}
		graphBehavior->drawTempJoinLine(bdc, source, destination);
	}
}
Esempio n. 28
0
void DrawStartPoint(wxMemoryDC &mem,unsigned int startx,unsigned int starty,float heading)
{
  wxBrush greenback(wxColour(0,255,0),wxSOLID);
  wxPen green(wxColour(0,255,0),1,wxSOLID);

  fprintf(stderr,"Drawing Start point @ %u,%u heading %0.2f\n",startx,starty,heading);

  // We have a box sized 6x12
  // and want to rotate it accordign to heading
  /*

   |
   |       * X',Y'
   |      -         * X,Y
   |  r  -       -
   |    -     -
   |   -   -  r
   |  - -
   |_-_________________

  (old coordinates are (x, y) and the new coordinates are (x', y'))

   q = initial angle, f = angle of rotation.

   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);
    }
}
Esempio n. 29
0
bool wxGenericDragImage::UpdateBackingFromWindow(wxDC& windowDC, wxMemoryDC& destDC,
    const wxRect& sourceRect, const wxRect& destRect) const
{
    return destDC.Blit(destRect.x, destRect.y, destRect.width, destRect.height, & windowDC,
        sourceRect.x, sourceRect.y);
}
Esempio n. 30
0
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)
		m_starfield->Draw(m_offscreenDc, clientSize, false, titleChanged, (m_oscModule->m_showFlags&SJ_OSC_SHOW_STARFIELD)!=0);

		// draw spectrum and/or oscilloscope (for both, the spectrum lays over the oscillosope)
		m_offscreenDc.SetPen(m_fgPen);

		if( m_oscModule->m_showFlags&SJ_OSC_SHOW_OSC )
		{
			m_oscilloscope->Draw(m_offscreenDc, forceOscAnim);
		}

		if( m_oscModule->m_showFlags&SJ_OSC_SHOW_SPECTRUM )
		{
			m_spectrum->Draw(m_offscreenDc, volumeBeat,
						  (m_oscModule->m_showFlags&SJ_OSC_SHOW_FIGURES)? true : false,
						  forceSpectrAnim);
		}

		// draw offscreen bitmap to screen
		wxClientDC dc(this);
		dc.Blit(0, 0, m_offscreenBitmap.GetWidth(), m_offscreenBitmap.GetHeight(), &m_offscreenDc, 0, 0);
	}
}