コード例 #1
0
ファイル: yaPanel.cpp プロジェクト: Bhagita/virtualagc
/*
 * Here we do the actual rendering. I put it in a separate
 * method so that it can work no matter what type of DC
 * (e.g. wxPaintDC or wxClientDC) is used.
 */
void
wxImagePanel::render(wxDC& dc)
{
  int neww, newh;

  dc.GetSize(&neww, &newh);
  // Adjust aspect ratio.
  if (BackgroundWidth * newh > neww * BackgroundHeight)
    newh = (neww * BackgroundHeight) / BackgroundWidth;
  else
    neww = (newh * BackgroundWidth) / BackgroundHeight;

  if (neww != w || newh != h)
    {
      //static int Count = 0;
      //printf ("Rescale %d: %d %d -> %d %d\n", ++Count, w, h, neww, newh);
      w = neww;
      h = newh;
      resized = wxBitmap(image.Scale(neww, newh, wxIMAGE_QUALITY_HIGH));
      int i;
      for (i = 1; i < NumGraphics; i++) // Skip initial dummy entry.
        Rescale(Graphics[i].UnscaledImage, Graphics[i].ScaledImage);
      for (i = 0; i < MAX_CLOCK_ANGLES; i++)
        {
          Rescale(HandsHours[i].UnscaledImage, HandsHours[i].ScaledImage);
          Rescale(HandsMinutes[i].UnscaledImage, HandsMinutes[i].ScaledImage);
          Rescale(HandsSeconds[i].UnscaledImage, HandsSeconds[i].ScaledImage);
        }
    }
  wxMemoryDC wdc(resized);
  wxBitmap Buffer(resized.GetWidth(), resized.GetHeight());
  wxMemoryDC bdc(Buffer);
  bdc.DrawBitmap(resized, 0, 0, false);
  int i;
  for (i = 0; i < NumFields; i++)
    if (Fields[i].Type == FT_OUT && Fields[i].State != gi_none)
      BufferedComposite(&bdc, Graphics[Fields[i].State].ScaledImage,
          Fields[i].x, Fields[i].y);
  // Do the accutron clock hands.
  time_t t;
  struct tm *tm_struct;
  time(&t);
  tm_struct = gmtime(&t);
  /*
   printf("%d %d %d %d %d %p %p %p\n", Fields[trs_ac_hands].x,
   Fields[trs_ac_hands].y, tm_struct->tm_hour * 5, tm_struct->tm_min * 2,
   tm_struct->tm_sec * 2, HandsHours[tm_struct->tm_hour * 5].ScaledImage,
   HandsMinutes[tm_struct->tm_min * 2].ScaledImage,
   HandsSeconds[tm_struct->tm_sec * 2].ScaledImage);
   */
  BufferedComposite(&bdc, HandsHours[tm_struct->tm_hour * 5].ScaledImage,
      Fields[trs_ac_hands].x, Fields[trs_ac_hands].y);
  BufferedComposite(&bdc, HandsMinutes[tm_struct->tm_min * 2].ScaledImage,
      Fields[trs_ac_hands].x, Fields[trs_ac_hands].y);
  BufferedComposite(&bdc, HandsSeconds[tm_struct->tm_sec * 2].ScaledImage,
      Fields[trs_ac_hands].x, Fields[trs_ac_hands].y);
  // Now actually write the buffer to the screen.
  dc.DrawBitmap(Buffer, 0, 0, false);
}
コード例 #2
0
void SetUpDC(wxDC &dc){

  int w,h;
  dc.SetAxisOrientation(true, true);
  dc.GetSize(&w, &h);
  dc.SetDeviceOrigin(0,h);

}
コード例 #3
0
//---------------------------------------------------------
void CWKSP_Shapes::Edit_Shape_Draw_Move(wxDC &dc, const CSG_Rect &rWorld, const wxPoint &Point, const TSG_Point &ptWorld)
{
	double	ClientToWorld	= rWorld.Get_XRange() / (double)dc.GetSize().x;

	dc.DrawLine(Point.x, Point.y,
		(int)((ptWorld.x - rWorld.Get_XMin()) / ClientToWorld),
		(int)((rWorld.Get_YMax() - ptWorld.y) / ClientToWorld)
	);
}
コード例 #4
0
ファイル: CurvePane.cpp プロジェクト: butcherg/rawproc
void CurvePane::render(wxDC&  dc)
{
	double px = 0.0;
	double py = 0.0;
	double x=0, y=0;
	dc.Clear();
	int w, h;
	dc.GetSize(&w, &h);
	int m=10;
	int radius;
	wxConfigBase::Get()->Read("tool.curve.controlpointradius",&radius,5);
	
	//x axis:
	dc.DrawLine(m,h-m,m,h-m-255);
	//y axis:
	dc.DrawLine(m,h-m,m+255,h-m);

	//center lines:
	dc.SetPen(*wxLIGHT_GREY_PEN);
	dc.DrawLine(m+128,h-m,m+128,h-m-255);
	dc.DrawLine(m,h-m-128,m+255,h-m-128);
	//null curve:
	dc.DrawLine(m,h-m,m+255,h-m-255);
	//quarter lines:
	dc.SetPen(wxPen(wxColour(192,192,192), 1, wxPENSTYLE_DOT_DASH ));
	dc.DrawLine(m+64,h-m,m+64,h-m-255);
	dc.DrawLine(m,h-m-64,m+255,h-m-64);
	dc.DrawLine(m+192,h-m,m+192,h-m-255);
	dc.DrawLine(m,h-m-192,m+255,h-m-192);
	dc.SetPen(*wxBLACK_PEN);

	//double ax = ((double) w/x);
	//double ay = ((double) h/y)*z;


	for (double x=0.0; x<256.0; x++) {
		y=c.getpoint(x);
		if (y>255.0) y = 255.0; if (y<0.0) y=0.0;
		dc.DrawLine(m+px,h-m-py,m+x,h-m-y);
		px = x;
		py = y;
	}

	//if (mousemotion)dc.DrawCircle(pos,5);
	std::vector<cp> controlpts = c.getControlPoints();
	for (unsigned int i=0; i<controlpts.size(); i++) {
		if ((controlpts[i].x == selectedCP.x) & (controlpts[i].y == selectedCP.y)) {
			//dc.DrawText(wxString::Format("%d,%d",selectedCP.x,selectedCP.y),selectedCP.x-20,selectedCP.y-20);
			dc.SetPen(*wxRED_PEN);
		}
		dc.DrawCircle(m+controlpts[i].x,h-m-controlpts[i].y,radius);
		dc.SetPen(*wxBLACK_PEN);
	}
}
コード例 #5
0
void PlayIndicatorOverlayBase::Draw(OverlayPanel &panel, wxDC &dc)
{
   // Set play/record color
   bool rec = gAudioIO->IsCapturing();
   AColor::IndicatorColor(&dc, !rec);

   if (mIsMaster
       && mLastIsCapturing != mNewIsCapturing) {
      // Detect transition to recording during punch and roll; make ruler
      // change its button color too
      const auto ruler = mProject->GetRulerPanel();
      ruler->UpdateButtonStates();
      ruler->Refresh();
   }
   mLastIsCapturing = mNewIsCapturing;

   mLastIndicatorX = mNewIndicatorX;
   if (!between_incexc(0, mLastIndicatorX, dc.GetSize().GetWidth()))
      return;

   if(auto tp = dynamic_cast<TrackPanel*>(&panel)) {
      wxASSERT(mIsMaster);

      // Draw indicator in all visible tracks
      for ( const auto &data : tp->Cells() )
      {
         Track *const pTrack = dynamic_cast<Track*>(data.first.get());
         if (!pTrack)
            continue;

         // Don't draw the indicator in label tracks
         if (pTrack->GetKind() == Track::Label)
         {
            continue;
         }

         // Draw the NEW indicator in its NEW location
         // AColor::Line includes both endpoints so use GetBottom()
         const wxRect &rect = data.second;
         AColor::Line(dc,
                      mLastIndicatorX,
                      rect.GetTop(),
                      mLastIndicatorX,
                      rect.GetBottom());
      }
   }
   else if(auto ruler = dynamic_cast<AdornedRulerPanel*>(&panel)) {
      wxASSERT(!mIsMaster);

      ruler->DoDrawIndicator(&dc, mLastIndicatorX, !rec, IndicatorMediumWidth, false, false);
   }
   else
      wxASSERT(false);
}
コード例 #6
0
/*
 * Here we do the actual rendering. I put it in a separate
 * method so that it can work no matter what type of DC
 * (e.g. wxPaintDC or wxClientDC) is used.
 */
void 
pcl::visualization::ImageWidgetWX::ImagePanel::render (wxDC&  dc)
{
  //cout << __PRETTY_FUNCTION__<<" called.\n";
  if (image==NULL) return;
  
  int newWidth, newHeight;
  dc.GetSize (&newWidth, &newHeight);
  
  if (newWidth != scaledWidth || newHeight != scaledHeight) 
  {
    resizeImage (newWidth, newHeight);
  }
  dc.DrawBitmap (resized_, 0, 0, false);
  
  int circleSize = 4;
  for (unsigned int i = 0; i < markedPoints.size (); ++i) 
  {
    const ImagePoint& point = markedPoints.at (i);
    dc.SetPen (*point.color);
    dc.SetBrush (*point.background);
    dc.DrawEllipse (pcl_lrint ((point.x+0.5f)*scaledWidth / image->GetWidth ())-0.5f*circleSize,
                    pcl_lrint ((point.y+0.5f)*scaledHeight / image->GetHeight ())-0.5f*circleSize, circleSize, circleSize);
  }
  
  for (unsigned int i = 0; i < lines.size (); ++i) 
  {
    const ImageLine& line = lines.at (i);
    wxPoint points_array[2];
    points_array[0].x = pcl_lrint ((line.x1+0.5f)*scaledWidth / image->GetWidth ());
    points_array[0].y = pcl_lrint ((line.y1+0.5f)*scaledHeight / image->GetHeight ());
    points_array[1].x = pcl_lrint((line.x2+0.5f)*scaledWidth / image->GetWidth ());
    points_array[1].y = pcl_lrint((line.y2+0.5f)*scaledHeight / image->GetHeight ());
    wxPen pen(*line.color);
    pen.SetWidth(3);
    dc.SetPen(pen);
    dc.DrawLines (2, points_array);
  }
  
  if (getParentImageWidget()->visualize_selected_point)
  {
    int selected_x = getParentImageWidget()->last_clicked_point_x,
        selected_y = getParentImageWidget()->last_clicked_point_y;
    if (selected_x >= 0 && selected_y >= 0)
    {
      wxPen pen(*wxGREEN, 2);	 
      dc.SetPen (pen);
      dc.CrossHair (pcl_lrint((selected_x+0.5f)*scaledWidth / image->GetWidth ()),
                    pcl_lrint((selected_y+0.5f)*scaledHeight / image->GetHeight ()));
    }
  }
}
コード例 #7
0
ファイル: printing.cpp プロジェクト: parkovski/tsched
void
Page::print(wxDC &dc) {
    wxString wxs_header = header;
    int top;
    int header_width;
    int width = dc.GetSize().x - mleft - mright;
    dc.GetTextExtent(wxs_header, &header_width, &top);
    top += mtop;
    dc.DrawText(wxs_header, mleft + width / 2 - header_width / 2, mtop);
    
    for (int i = 0; i < trusses.size(); ++i) {
        printTruss(dc, trusses[i], top, width);
    }
}
コード例 #8
0
/*
 * Here we do the actual rendering. I put it in a separate
 * method so that it can work no matter what type of DC
 * (e.g. wxPaintDC or wxClientDC) is used.
 */
void wxImageFrame::render(wxDC&  dc)
{
    int neww, newh;
    dc.GetSize( &neww, &newh );

    if( (neww != w) || (newh != h) )
    {
        resized = wxBitmap( image.Scale( neww, newh ) );
        w = neww;
        h = newh;
        dc.DrawBitmap( resized, 0, 0, false );
    } else {
        dc.DrawBitmap( resized, 0, 0, false );
    }
}
コード例 #9
0
void PlayIndicatorOverlayBase::Draw(OverlayPanel &panel, wxDC &dc)
{
   // Set play/record color
   bool rec = (gAudioIO->GetNumCaptureChannels() > 0);
   AColor::IndicatorColor(&dc, !rec);
   mLastIndicatorX = mNewIndicatorX;
   if (!between_incexc(0, mLastIndicatorX, dc.GetSize().GetWidth()))
      return;

   if(auto tp = dynamic_cast<TrackPanel*>(&panel)) {
      wxASSERT(mIsMaster);

      TrackPanelCellIterator begin(tp, true);
      TrackPanelCellIterator end(tp, false);

      // Draw indicator in all visible tracks
      for (; begin != end; ++begin)
      {
         TrackPanelCellIterator::value_type data(*begin);
         Track *const pTrack = data.first;
         if (!pTrack)
            continue;

         // Don't draw the indicator in label tracks
         if (pTrack->GetKind() == Track::Label)
         {
            continue;
         }

         // Draw the NEW indicator in its NEW location
         // AColor::Line includes both endpoints so use GetBottom()
         const wxRect &rect = data.second;
         AColor::Line(dc,
                      mLastIndicatorX,
                      rect.GetTop(),
                      mLastIndicatorX,
                      rect.GetBottom());
      }
   }
   else if(auto ruler = dynamic_cast<AdornedRulerPanel*>(&panel)) {
      wxASSERT(!mIsMaster);

      ruler->DoDrawIndicator(&dc, mLastIndicatorX, !rec, IndicatorMediumWidth, false);
   }
   else
      wxASSERT(false);
}
コード例 #10
0
/*
 * Here we do the actual rendering. I put it in a separate
 * method so that it can work no matter what type of DC
 * (e.g. wxPaintDC or wxClientDC) is used.
 */
void wxStateButton::render(wxDC& dc) {
	int w;
	int h;
	dc.GetSize(&w,&h);
    if (m_bChecked) {
        dc.SetBrush(*wxGREY_BRUSH);
		dc.SetTextForeground(wxColor(255, 255, 255));
	} else {
        dc.SetBrush(wxBrush(wxColor(64, 64, 64))); 
		dc.SetTextForeground(*wxLIGHT_GREY);
	}
	dc.SetPen(*wxGREY_PEN);

	wxRect r = GetClientRect();
    dc.DrawRectangle(0, 0, w, h);
	dc.SetFont(wxSystemSettings::GetFont(wxSystemFont::wxSYS_DEFAULT_GUI_FONT));
	dc.DrawLabel(GetLabel(), r, wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_HORIZONTAL);
}
コード例 #11
0
ファイル: vis_bg.cpp プロジェクト: boh1996/silverjuke
void SjVisGrBg::DrawBackground(wxDC& dc)
{
	// blue gradient background
	wxSize size = dc.GetSize();
	int rowH = (m_height/BG_STEPS)+1, y, yCol;
	dc.SetPen(*wxTRANSPARENT_PEN);
	for( y = 0; y < BG_STEPS; y++ )
	{
		if( m_imgOpFlags & SJ_IMGOP_GRAYSCALE )
		{
			yCol = int(float(y)*BG_GRAYSCALE);
			m_brush.SetColour(yCol, yCol, yCol);
		}
		else
		{
			m_brush.SetColour(0, 0, y);
		}

		dc.SetBrush(m_brush);
		dc.DrawRectangle(0, y*rowH, size.x, rowH);
	}
}
コード例 #12
0
ファイル: KeyControl.cpp プロジェクト: pthiben/Helium
///////////////////////////////////////////////////////////////////////////////
// Draws the background of this control.
// 
void KeyControl::DrawGradient( wxDC& dc ) const
{
  const wxSize size = dc.GetSize();

  const u32 numKeys = m_KeyArray->GetCount();
  if ( numKeys > 1 )
  {
    // Draw gradients
    u32 keyIndex = 0;
    while ( keyIndex < numKeys )
    {
      const Key* keyA = m_KeyArray->GetKey( keyIndex++ );

      if ( keyIndex >= numKeys )
      {
        break;
      }

      const Key* keyB = m_KeyArray->GetKey( keyIndex );

      const Math::Color3& colorA = keyA->GetColor();
      const Math::Color3& colorB = keyB->GetColor();

      i32 posA = GetPos( keyA->GetLocation() );
      i32 width = ::abs( GetPos( keyB->GetLocation() ) - posA );

      dc.GradientFillLinear( wxRect( posA, 0, width, size.y ), wxColor( colorA.r, colorA.g, colorA.b ), wxColor( colorB.r, colorB.g, colorB.b ) );
    }
  }
  else if ( numKeys == 1 )
  {
    // No gradient, solid fill
    const Key* key = m_KeyArray->GetKey( 0 );
    dc.SetBrush( wxBrush( wxColor( key->GetColor().r, key->GetColor().g, key->GetColor().b ) ) );
    dc.DrawRectangle( 0, 0, size.x, size.y );
  }
}
コード例 #13
0
ファイル: vis_bg.cpp プロジェクト: boh1996/silverjuke
void SjVisImgBg::DrawBackground(wxDC& dc)
{
	wxASSERT( wxThread::IsMain() );

	if( m_scaledImage.IsOk() )
	{
		if( m_scaledBitmap == NULL )
		{
			m_scaledBitmap = new wxBitmap(m_scaledImage);
		}

		if( m_scaledBitmap->IsOk() )
		{
			dc.DrawBitmap(*m_scaledBitmap, 0, 0);
			return;
		}
	}

	// error
	wxSize size = dc.GetSize();
	dc.SetBrush(*wxBLACK_BRUSH);
	dc.SetPen(*wxTRANSPARENT_PEN);
	dc.DrawRectangle(0, 0, size.x, size.y);
}
コード例 #14
0
ファイル: draw.cpp プロジェクト: colindr/calchart
void DrawForPrintingHelper(wxDC& dc, const CalChartConfiguration& config, const CalChartDoc& show, const CC_sheet& sheet, unsigned ref, bool landscape)
{
    // set up everything to be restored after we print
    SaveAndRestore_DeviceOrigin orig_dev(dc);
    SaveAndRestore_UserScale orig_scale(dc);
    SaveAndRestore_Font orig_font(dc);

    // get the page dimensions
    int pageW, pageH;
    dc.GetSize(&pageW, &pageH);

    dc.Clear();
    dc.SetLogicalFunction(wxCOPY);

    // Print the field:
    // create a field for drawing:
    const auto pts = sheet.GetPoints();
    auto boundingBox = GetMarcherBoundingBox(pts);
    auto mode = CreateFieldForPrinting(Coord2Int(boundingBox.first.x), Coord2Int(boundingBox.second.x), landscape);

    // set the origin and scaling for drawing the field
    dc.SetDeviceOrigin(kFieldBorderOffset*pageW, kFieldTop*pageH);
    auto scale = (pageW-2*kFieldBorderOffset*pageW)/(double)mode->Size().x;
    dc.SetUserScale(scale, scale);

    // draw the field.
    DrawMode(dc, config, *mode, ShowMode_kPrinting);
    wxFont *pointLabelFont = wxTheFontList->FindOrCreateFont((int)Float2Coord(config.Get_DotRatio() * config.Get_NumRatio()), wxSWISS, wxNORMAL, wxNORMAL);
    dc.SetFont(*pointLabelFont);
    for (auto i = 0u; i < pts.size(); i++)
    {
        const auto point = pts.at(i);
        const auto pos = point.GetPos(ref) + mode->Offset();
        dc.SetBrush(*wxBLACK_BRUSH);
        DrawPointHelper(dc, config, pos, point, show.GetPointLabel(i));
    }

    // now reset everything to draw the rest of the text
    dc.SetDeviceOrigin(Int2Coord(0), Int2Coord(0));
    dc.SetBrush(*wxTRANSPARENT_BRUSH);

    // set the page for drawing:
    dc.GetSize(&pageW, &pageH);
    if (landscape)
    {
        dc.SetUserScale(pageW/kSizeXLandscape, pageH/kSizeYLandscape);
        pageW = kSizeXLandscape;
        pageH = kSizeYLandscape;
    }
    else
    {
        dc.SetUserScale(pageW/kSizeX, pageH/kSizeY);
        pageW = kSizeX;
        pageH = kSizeY;
    }

    // draw the header
    dc.SetFont(*wxTheFontList->FindOrCreateFont(16, wxROMAN, wxNORMAL, wxBOLD));
    dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, 1, wxSOLID));

    DrawCenteredText(dc, kHeader, wxPoint(pageW*kHeaderLocation[landscape][0], pageH*kHeaderLocation[landscape][1]));

    DrawCenteredText(dc, sheet.GetNumber(), wxPoint(pageW*kUpperNumberPosition[landscape][0], pageH*kUpperNumberPosition[landscape][1]));
    DrawCenteredText(dc, sheet.GetNumber(), wxPoint(pageW*kLowerNumberPosition[landscape][0], pageH*kLowerNumberPosition[landscape][1]));
    dc.DrawRectangle(pageW*kLowerNumberBox[landscape][0], pageH*kLowerNumberBox[landscape][1], pageW*kLowerNumberBox[landscape][2], pageH*kLowerNumberBox[landscape][3]);

    dc.SetFont(*wxTheFontList->FindOrCreateFont(8, wxSWISS, wxNORMAL, wxNORMAL));

    DrawLineOverText(dc, kMusicLabel, wxPoint(pageW*kMusicLabelPosition[landscape][0], pageH*kMusicLabelPosition[landscape][1]), pageW*kMusicLabelPosition[landscape][2]);
    DrawLineOverText(dc, kFormationLabel, wxPoint(pageW*kFormationLabelPosition[landscape][0], pageH*kFormationLabelPosition[landscape][1]), pageW*kFormationLabelPosition[landscape][2]);
    DrawLineOverText(dc, kGameLabel, wxPoint(pageW*kGameLabelPosition[landscape][0], pageH*kGameLabelPosition[landscape][1]), pageW*kGameLabelPosition[landscape][2]);
    DrawLineOverText(dc, kPageLabel, wxPoint(pageW*kPageLabelPosition[landscape][0], pageH*kPageLabelPosition[landscape][1]), pageW*kPageLabelPosition[landscape][2]);
    DrawCenteredText(dc, kSideLabel, wxPoint(pageW*kSideLabelPosition[landscape][0], pageH*kSideLabelPosition[landscape][1]));

    // draw arrows
    DrawCenteredText(dc, kUpperSouthLabel, wxPoint(pageW*kUpperSouthPosition[landscape][0], pageH*kUpperSouthPosition[landscape][1]));
    DrawArrow(dc, wxPoint(pageW*kUpperSouthArrow[landscape][0], pageH*kUpperSouthArrow[landscape][1]), pageW*kUpperSouthArrow[landscape][2], false);
    DrawCenteredText(dc, kUpperNorthLabel, wxPoint(pageW*kUpperNorthPosition[landscape][0], pageH*kUpperNorthPosition[landscape][1]));
    DrawArrow(dc, wxPoint(pageW*kUpperNorthArrow[landscape][0], pageH*kUpperNorthArrow[landscape][1]), pageW*kUpperNorthArrow[landscape][2], true);
    DrawCenteredText(dc, kLowerSouthLabel, wxPoint(pageW*kLowerSouthPosition[landscape][0], pageH*kLowerSouthPosition[landscape][1]));
    DrawArrow(dc, wxPoint(pageW*kLowerSouthArrow[landscape][0], pageH*kLowerSouthArrow[landscape][1]), pageW*kLowerSouthArrow[landscape][2], false);
    DrawCenteredText(dc, kLowerNorthLabel, wxPoint(pageW*kLowerNorthPosition[landscape][0], pageH*kLowerNorthPosition[landscape][1]));
    DrawArrow(dc, wxPoint(pageW*kLowerNorthArrow[landscape][0], pageH*kLowerNorthArrow[landscape][1]), pageW*kLowerNorthArrow[landscape][2], true);

    DrawCont(dc, sheet.GetPrintableContinuity(), wxRect(wxPoint(10, pageH*kContinuityStart[landscape]), wxSize(pageW-20, pageH-pageH*kContinuityStart[landscape])), landscape);
}
コード例 #15
0
void MyDayInfoPlot::DrawPricePlot(wxDC&dc){
    TotalDayInfoStru MyDays[TOTAY_DAYS_MYDAYINFO];
    double MaxSz,MinSz,MaxSh,MinSh,MaxTotal,MinTotal,MaxDelta,MinDelta;
	MaxSz=MinSz=MaxSh=MinSh=MaxTotal=MinTotal=MaxDelta=MinDelta=0;

	for (int tidx=0;tidx<TOTAY_DAYS_MYDAYINFO;tidx++){
		MyDays[tidx].Valid=false;
	}

    wxString keyPath=WStockConfig::GetMyDayInfoPath();
    wxFileName keyf(keyPath);
    keyf.MakeAbsolute();
    xmlDocPtr doc=NULL;
    if (keyf.FileExists()){
        //Load Stocks Name From file
		doc = xmlParseFile((const char*)keyf.GetFullPath().mb_str());
    }

    //If Load Fail, Create the Xml Memory
    if (doc==NULL){
        dc.DrawText(_("No Info File Found!"),10,10);
        return;
    }

    for (xmlNodePtr node=doc->children->children;node;node=node->next){
            if (xmlStrcmp(node->name,(const xmlChar*)"DayInfo")==0){
				wxString Date(wxConvUTF8.cMB2WC(
					(char*)xmlGetProp(node, (const xmlChar*)"Date")),*wxConvCurrent);
				wxString Sz(wxConvUTF8.cMB2WC(
					(char*)xmlGetProp(node, (const xmlChar*)"ShenZhen")),*wxConvCurrent);
				wxString Sh(wxConvUTF8.cMB2WC(
					(char*)xmlGetProp(node, (const xmlChar*)"ShangHai")),*wxConvCurrent);
				wxString Total(wxConvUTF8.cMB2WC(
					(char*)xmlGetProp(node, (const xmlChar*)"Total")),*wxConvCurrent);
				wxString Delta(wxConvUTF8.cMB2WC(
					(char*)xmlGetProp(node, (const xmlChar*)"TodayEarning")),*wxConvCurrent);

                wxDateTime date;
                date.ParseDate(Date);
                int idx=(wxDateTime::Today()-date).GetDays();
                if  (idx<TOTAY_DAYS_MYDAYINFO){
                    Sz.ToDouble(&MyDays[idx].sz);
                    Sh.ToDouble(&MyDays[idx].sh);
                    Total.ToDouble(&MyDays[idx].total);
                    Delta.ToDouble(&MyDays[idx].delta);
					MyDays[idx].Valid = true;
					MyDays[idx].date = date;
                }
            }
    }

	int i;
	for (i=0;i<TOTAY_DAYS_MYDAYINFO;i++){
		if (MyDays[i].Valid){
			if (MyDays[i].sz>MaxSz) MaxSz = MyDays[i].sz;
			if (MyDays[i].sz<MinSz) MinSz = MyDays[i].sz;

			if (MyDays[i].sh>MaxSh) MaxSh = MyDays[i].sh;
			if (MyDays[i].sh<MinSh) MinSh = MyDays[i].sh;

			if (MyDays[i].total>MaxTotal) MaxTotal = MyDays[i].total;
			if (MyDays[i].total<MinTotal) MinTotal = MyDays[i].total;

			if (MyDays[i].delta>MaxDelta) MaxDelta = MyDays[i].delta;
			if (MyDays[i].delta<MinDelta) MinDelta = MyDays[i].delta;

		}
	}

	dc.SetPen(wxPen(*wxBLACK,3));
	int XStart=100,YStart=10,YFree=60;
	int TotalY=dc.GetSize().y-30-YFree;
	int XTotal = dc.GetSize().x-110;
	float TotalDelta=0;
	if (MinDelta<0)	TotalDelta = MaxTotal - MinDelta+YFree;
	else TotalDelta = MaxTotal+YFree;
	if (TotalDelta<0.0003) TotalDelta = 1;
	int ZeroY = (int)(double)(TotalY/TotalDelta * MaxTotal + YStart);
	dc.DrawLine(XStart,YStart,XStart,YStart + TotalY + YFree);
	dc.DrawLine(XStart-10,ZeroY,XStart+XTotal,ZeroY);

	for (i=0;i<TOTAY_DAYS_MYDAYINFO;i++){
		if (MyDays[i].Valid){
			int MyTotalY=(int)(double)(ZeroY - TotalY/TotalDelta * MyDays[i].total);
			int MyDeltaY=(int)(double)(ZeroY - TotalY/TotalDelta * MyDays[i].delta);
			dc.SetBrush(*wxBLACK_BRUSH);
			dc.DrawRectangle(XStart+(i+1)*(XTotal / (TOTAY_DAYS_MYDAYINFO + 1)) - 5,MyTotalY,10,Abs(ZeroY-MyTotalY));
			dc.SetBrush(*wxGREEN_BRUSH);
			dc.DrawRectangle(XStart+(i+1)*(XTotal / (TOTAY_DAYS_MYDAYINFO + 1)) - 5,MyDeltaY,10,Abs(ZeroY-MyDeltaY));
			//wxLogMessage(wxT("Draw Rect at:%d %d %d %d"),(int)(XStart+(i+1)*(XTotal / (TOTAY_DAYS_MYDAYINFO + 1)) - 5),
			//MyDeltaY,10,Abs(ZeroY-MyDeltaY));
			dc.DrawText(MyDays[i].date.FormatISODate(),XStart+(i+1)*(XTotal / (TOTAY_DAYS_MYDAYINFO + 1))-30,YStart+TotalY);
		}
	}

}
コード例 #16
0
void RawDataVisualizeFrame::DrawRawBoxplot(wxDC &dc){

  int i,j;

  int w,h;
  dc.GetSize(&w, &h);

  int min_x = min((int)(pltarea_min_x*(double)w),(int)(160*(double)(dc.GetPPI().x)/(double)72));
  int min_y = min((int)(pltarea_min_y*(double)h),(int)(165*(double)(dc.GetPPI().x)/(double)72));
  int max_x = max((int)((pltarea_max_x-pltarea_min_x)*(double)w),(int)(w - 100*(double)(dc.GetPPI().x)/(double)72 - min_x));
  int max_y = max((int)((pltarea_max_y-pltarea_min_y)*(double)h),(int)(h-160*(double)(dc.GetPPI().x)/(double)72 - min_y));
   



  labeledplotAxes myAxes(dc,wxPoint(min_x,min_y),
			 wxPoint(max_x,max_y),
			 wxRealPoint(0.5,3.5),
			 wxRealPoint((double)MyRawData->count_arrays()+ 0.5 ,15.5),
			 true,
			 wxPoint(0,0),true,10);
  //dc.SetClippingRegion(80,30*5-80 ,w-30*5,h-30*5);  
  //dc.SetBackground(*wxGREY_BRUSH);
  //dc.Clear();

  //SetUpDC(dc); 




  
  //dc.Clear();
  myAxes.setupDCforPlot(dc);


  wxArrayDouble xtickpoints;
  wxArrayDouble ytickpoints;
  wxArrayString x_tick_labels;
  wxArrayString y_tick_labels;

  wxString temp;

  

  for (i =1; i <= MyRawData->count_arrays();i++){
    xtickpoints.Add((double)i);
    wxString mynewstring = wxString::Format(_T("%d"), i);
    x_tick_labels.Add(mynewstring); 
  }

  x_tick_labels = MyRawData->GetArrayNames();

  // Strip the ".CEL" from the labels 
  for (i =0; i < MyRawData->count_arrays();i++){
    temp = wxString(x_tick_labels[i]);
    x_tick_labels[i] = temp.Remove(temp.Len() - 4);

  }

  for (i=2; i <= 15; i++){
    ytickpoints.Add((double)i); 
    y_tick_labels.Add(wxString::Format(_T("%d"), i));
  }
  
  myAxes.setTickLocationX(xtickpoints);
  myAxes.setTickLocationY(ytickpoints);

  myAxes.setTickLabelsX(x_tick_labels);
  myAxes.setTickLabelsY(y_tick_labels);

  myAxes.setTickLabelsPerpendicular(true);


  wxString x_label = wxT("");
  wxString y_label = wxT("log2 PM");

  myAxes.setAxisLabelX(x_label);
  myAxes.setAxisLabelY(y_label);


  
  myAxes.setTitle(wxT("log2 PM by array for raw data"));
 




  wxColor tempColor = wxColor(100,100,255);

  for (j =0; j < MyRawData->count_arrays();j++){


    Draw_Single_Boxplot(dc,
			myAxes.FindPoint(wxRealPoint(1.0,max(log((*BoxplotStatistics)[j*5 + 0])/log(2.0),3.5))).y,
			myAxes.FindPoint(wxRealPoint(1.0,log((*BoxplotStatistics)[j*5 + 1])/log(2.0))).y,
			myAxes.FindPoint(wxRealPoint(1.0,log((*BoxplotStatistics)[j*5 + 2])/log(2.0))).y,
			myAxes.FindPoint(wxRealPoint(1.0,log((*BoxplotStatistics)[j*5 + 3])/log(2.0))).y,
			myAxes.FindPoint(wxRealPoint(1.0,min(log((*BoxplotStatistics)[j*5 + 4])/log(2.0),15.5))).y,
			myAxes.FindPoint(wxRealPoint((double)(j+1),0)).x,
			myAxes.FindPoint(wxRealPoint(3.4,0)).x - myAxes.FindPoint(wxRealPoint(2.6,0)).x,&tempColor);
  }


  


  dc.DestroyClippingRegion();
  myAxes.Draw(dc);
	
  

}
コード例 #17
0
void RawDataVisualizeFrame::DrawIndividualRawDensityPlot(wxDC& dc){

  //PrepareDC(dc);
  
  //SetUpDC(dc);
 
  int w,h;
  dc.GetSize(&w, &h);

    
  /* labeledplotAxes myAxes(wxPoint(80,80),
     wxPoint(w-30*5,h-30*5),
     wxRealPoint(0.0,1000.0),
     wxRealPoint(50.0,4000.0),
     true);
  */
  
  int min_x = min((int)(pltarea_min_x*(double)w),(int)(160*(double)(dc.GetPPI().x)/(double)72));
  int min_y = min((int)(pltarea_min_y*(double)h),(int)(165*(double)(dc.GetPPI().x)/(double)72));
  int max_x = max((int)((pltarea_max_x-pltarea_min_x)*(double)w),(int)(w - 100*(double)(dc.GetPPI().x)/(double)72 - min_x));
  int max_y = max((int)((pltarea_max_y-pltarea_min_y)*(double)h),(int)(h-160*(double)(dc.GetPPI().x)/(double)72 - min_y));


  labeledplotAxes myAxes(dc, wxPoint(min_x,min_y),
			 wxPoint(max_x,max_y),
			 wxRealPoint(3.0,0.0),
			 wxRealPoint(15.5,1.0),
			 true);
  
  dc.Clear(); 
  myAxes.setBackgroundColor(*wxWHITE_BRUSH);
  myAxes.setupDCforPlot(dc);
  

  // myAxes.addGrid(2, 0.2);

  wxArrayDouble xtickpoints;
  wxArrayDouble ytickpoints;

  int i,j;

  wxArrayString x_tick_labels;
  wxArrayString y_tick_labels;

  for (i=3; i <= 15; i++){
    xtickpoints.Add((double)i); 
    x_tick_labels.Add(wxString::Format(_T("%d"), i));
  }
  
  for (i =0; i <= 10; i++){
    ytickpoints.Add((double)i/10.0); 
    y_tick_labels.Add(wxString::Format(_T("%.2f"), i/10.0));
  }

  myAxes.setTickLocationX(xtickpoints);
  myAxes.setTickLocationY(ytickpoints);

  myAxes.setTickLabelsX(x_tick_labels);
  myAxes.setTickLabelsY(y_tick_labels);


  wxString x_label = wxT("log2 PM");
  wxString y_label = wxT("Density");

  myAxes.setAxisLabelX(x_label);
  myAxes.setAxisLabelY(y_label);
  
  myAxes.setTitle(MyRawData->GetArrayNames()[whichdensity]);

  wxPoint xsq[512];
  
  j = whichdensity;
  for (i =0; i < 512; i++){
    xsq[i] = myAxes.FindPoint(wxRealPoint((*DensityPlotStatistics_x)[j*512 + i], (*DensityPlotStatistics_y)[j*512 + i]));
  }
  dc.DrawSpline(WXSIZEOF(xsq),xsq);
  
  

  dc.DestroyClippingRegion();
  myAxes.Draw(dc);

  


}
コード例 #18
0
wxColour wxJigsawShape::DrawBackground(wxDC & dc, 
		const wxPoint & pos, const wxSize & headerSize, 
		const wxSize & size, double scale)
{	
	wxColour color(m_Colour);
		
	if(wxJigsawEditorMainFrame::Get()->GetCanvas()->GetSelectedShape() == this)
	{
		//Shape selected. Give a feedback to the user!
		double bright =  1.15 + .08*GetLevelColor();

		color.Set(__min(bright*color.Red(), 255), __min(bright*color.Green(), 255), __min(bright*color.Blue(), 255));		
	}
	else if(m_Parent && m_Colour == m_Parent->GetColour())
	{
		//Change the shape bright to contrast with the parent shape
		double bright =  1 + .08*GetLevelColor();

		color.Set(__min(bright*color.Red(), 255), __min(bright*color.Green(), 255), __min(bright*color.Blue(), 255));
	}
	
	dc.SetBrush(wxBrush(color));
	dc.SetPen(*wxTRANSPARENT_PEN);
	
	wxPoint connector[5] = 
	{
		wxPoint(0,0), 
		wxPoint(wxJigsawShape::ConnectorSize.GetHeight(),
			wxJigsawShape::ConnectorSize.GetHeight()), 
		wxPoint(wxJigsawShape::ConnectorSize.GetWidth()-wxJigsawShape::ConnectorSize.GetHeight(),
			wxJigsawShape::ConnectorSize.GetHeight()), 
		wxPoint(wxJigsawShape::ConnectorSize.GetWidth(),0), 
		wxPoint(0,0)
	};
	for(size_t i = 0; i < 5; i++)
	{
		connector[i].x *= scale;
		connector[i].y *= scale;
	}
	wxSize childrenSize = GetChildrenSize(dc, scale);
	int cShapeHeight = wxMax(childrenSize.GetHeight(), 10*scale);
	wxRegion clippingRegion(0, 0, dc.GetSize().GetWidth(), dc.GetSize().GetHeight());
	if(m_HasNotch)
	{
		wxRegion connectorRegion(5, connector);
		connectorRegion.Offset(pos.x + wxJigsawShape::ConnectorSize.GetWidth()*scale, pos.y);
		clippingRegion.Xor(connectorRegion);
	}
	if(m_HasCShape)
	{
		wxRegion connectorRegion(5, connector);
		connectorRegion.Offset(
			pos.x + (wxJigsawShape::CShapeThickness+wxJigsawShape::ConnectorSize.GetWidth())*scale, 
			pos.y + headerSize.GetHeight()+cShapeHeight);
		clippingRegion.Xor(connectorRegion);
	}

	dc.SetClippingRegion(clippingRegion);
	//dc.DrawRoundedRectangle(m_Position.x, m_Position.y, headerSize.GetWidth(), headerSize.GetHeight(), 4);
	DrawShapeHeader(dc, pos, headerSize, IntToJigsawShapeStyle(m_Style));
	
	if(m_HasCShape)
	{
		dc.DrawRectangle(pos.x, 
			pos.y + headerSize.GetHeight() / 2, 
			(wxJigsawShape::CShapeThickness+4)*scale, 
			headerSize.GetHeight() / 2 + cShapeHeight + (wxJigsawShape::CShapeThickness*scale)/2);
		dc.DrawRoundedRectangle(pos.x, 
			pos.y + headerSize.GetHeight()+cShapeHeight, 
			headerSize.GetWidth(), 
			wxJigsawShape::CShapeThickness*scale, 4);
		// Upper inner notch
		dc.DrawPolygon(5, connector, 
			pos.x + (wxJigsawShape::CShapeThickness+wxJigsawShape::ConnectorSize.GetWidth())*scale, 
			pos.y + headerSize.GetHeight());
	}
	if(m_HasBump)
	{
		dc.DrawPolygon(5, connector, 
			pos.x + wxJigsawShape::ConnectorSize.GetWidth()*scale, 
			pos.y + size.GetHeight());
	}
	dc.DestroyClippingRegion();

	return color;
}
コード例 #19
0
bool SjSjScreen::Render(wxDC& dc, SjVisBg& bg, bool pleaseUpdateAll)
{
	// basic screen calculations
	wxSize      dcSize = dc.GetSize(); if( dcSize.y <= 0 ) return false;
	float       dcAspect = (float)dcSize.x / (float)dcSize.y;

	float       areaAspect = 300.0F / 216.0F; // for a good compatibility to CDG, use the same area and aspect

	long areaX, areaY, areaW, areaH;
	if( dcAspect > areaAspect )
	{
		// scale by height
		areaH = long( (float)dcSize.y * KARAOKE_RENDER_SHRINK );
		areaW = long( (float)areaH * areaAspect );
	}
	else
	{
		// scale by width
		areaW = long( (float)dcSize.x * KARAOKE_RENDER_SHRINK );
		areaH = long( (float)areaW / areaAspect );
	}

	// find center
	areaX = (dcSize.x - areaW) / 2;
	areaY = (dcSize.y - areaH) / 2;

	// done?
	unsigned long stayMs = SjTools::GetMsTicks()-m_startMs;
	if( m_done )
	{
		return false;
	}
	else if( m_stayMs!=0 && stayMs > m_stayMs)
	{
		dc.SetClippingRegion(areaX, areaY, areaW, areaH);
		bg.DrawBackground(dc);
		dc.DestroyClippingRegion();
		m_done = true;
		return false;
	}

	// update font?
	{
		wxCoord fontPixelH = areaH/9;
		if( fontPixelH != m_fontPixelH )
		{
			SjVisBg::SetFontPixelH(dc, m_font, fontPixelH);
			m_fontPixelH = fontPixelH;
			pleaseUpdateAll = true;
		}

		dc.SetFont(m_font);
	}

	// draw!
	dc.SetBackgroundMode(wxTRANSPARENT);

	for( int i = 0; i <= 1; i++ )
	{
		int offset = 0;
		if( i == 0 )
		{
			// draw black shadow
			if( !pleaseUpdateAll )
				continue;

			dc.SetTextForeground(*wxBLACK);
			offset = m_fontPixelH / 16;
			if( m_fontPixelH < 2 ) m_fontPixelH = 2;
		}
		else
		{
			// draw white fade
			long g = stayMs/4;
			if( g > 245 ) g = 245;
			m_colour.Set(g, g, g);
			dc.SetTextForeground(m_colour);
		}

		long x = areaX+areaW/2;
		long y = areaY+areaH/2-m_fontPixelH; if( m_line2.IsEmpty() ) y += m_fontPixelH/2;
		DrawCentered(dc, x+offset, y+offset, m_line1);
		y += m_fontPixelH;
		DrawCentered(dc, x+offset, y+offset, m_line2);
	}

	return true;
}