Beispiel #1
0
/**
 * @brief WidgetCompLineChart::drawChart draw the chart
 */
void WidgetCompLineChart::drawChart()
{

    ui->widgetCompLineChart_2->clearPlottables();
    srand(time(NULL));
    int j = 0;
    QList<QListWidgetItem*> tempMuniList = ui->listLineChartMunicipality_4->selectedItems();
    for(QList<QListWidgetItem*>::Iterator it = tempMuniList.begin(); it != tempMuniList.end(); ++it) {
        ui->widgetCompLineChart_2->addGraph();
        QPen tempPen(QColor(rand()%255,rand()%255,rand()%255,255));
        tempPen.setWidth(PEN_WIDTH);
        ui->widgetCompLineChart_2->graph(j)->setPen(tempPen);
        ++j;
    }
    int k = 0;
    for(QList<QListWidgetItem*>::Iterator it = tempMuniList.begin(); it != tempMuniList.end(); ++it) {
        ui->widgetCompLineChart_2->addGraph(ui->widgetCompLineChart_2->xAxis2,ui->widgetCompLineChart_2->yAxis2);
        QPen tempPen(QColor(rand()%255,rand()%255,rand()%255,255));
        tempPen.setWidth(PEN_WIDTH);
        ui->widgetCompLineChart_2->graph(k+j)->setPen(tempPen);
        ++k;
    }
    ui->widgetCompLineChart_2->xAxis->setAutoTickStep(false);
    ui->widgetCompLineChart_2->xAxis->setTickStep(1.0);
    ui->widgetCompLineChart_2->xAxis->setTickLabelRotation(-60);
    ui->widgetCompLineChart_2->xAxis2->setAutoTickStep(false);
    ui->widgetCompLineChart_2->xAxis2->setTickStep(1.0);
    ui->widgetCompLineChart_2->xAxis2->setTickLabelRotation(-60);
    if(_ylist->size() > 0) {
        ui->widgetCompLineChart_2->xAxis->setRange(_ylist->at(0).toInt(),_ylist->at(_ylist->size()-1).toInt());
        ui->widgetCompLineChart_2->xAxis2->setRange(_ylist->at(0).toInt(),_ylist->at(_ylist->size()-1).toInt());
    }
    ui->widgetCompLineChart_2->yAxis->setLabel(_meas->id()+":"+_meas->name());
    ui->widgetCompLineChart_2->yAxis2->setLabel(_meas2->id()+":"+_meas2->name());
    ui->widgetCompLineChart_2->yAxis->setRange(_meas->maxmin().first*GRAPH_LOW_RATIO,_meas->maxmin().second*GRAPH_HIGH_RATIO);
    ui->widgetCompLineChart_2->yAxis2->setRange(_meas2->maxmin().first*GRAPH_LOW_RATIO,_meas2->maxmin().second*GRAPH_HIGH_RATIO);
    ui->widgetCompLineChart_2->yAxis2->setVisible(true);

    for(int i = 0; i < _meas->yearRange().size(); ++i) {
        if(ui->listLineChartYears_4->item(i)->isSelected()) {
            drawYear(i);
            drawYear2(i,k);
        }

    }

    ui->widgetCompLineChart_2->legend->setVisible(true);
    ui->widgetCompLineChart_2->replot();
}
void AbstractFigure::draw() {
    QPen tempPen(borderColor);
    tempPen.setWidth(borderWidth);
    if (isSelected()) {
        tempPen.setWidth(3);
        tempPen.setStyle(Qt::DotLine);
    }
    painter->setPen(tempPen);
    painter->drawPath(painterPath);
}
Beispiel #3
0
/**
 * Draw a line graph using the selected years and Municipalities and plots everything back to default.
 * @param lowrange the low range of the data
 * @param highrange the high range of the data
 */
void WidgetLineChart::drawChartDefault()
{
    ui->widgetLineChart_2->clearPlottables();

    //put back default title
    ui->widgetLineChart_2->plotLayout()->removeAt(0);
    QString title = _meas->name() + " Over the Years";
    ui->widgetLineChart_2->plotLayout()->addElement(0, 0, new QCPPlotTitle(ui->widgetLineChart_2,title));

    //Random Number stuff
    srand(time(NULL));

    QList<QListWidgetItem*> tempMuniList = ui->listLineChartMunicipality->selectedItems();
    int j = 0;
    for(QList<QListWidgetItem*>::Iterator it = tempMuniList.begin(); it != tempMuniList.end(); ++it) {

        ui->widgetLineChart_2->addGraph();
        QPen tempPen(QColor(rand()%255,rand()%255,rand()%255,255));
        tempPen.setWidth(PEN_WIDTH);
        ui->widgetLineChart_2->graph(j)->setPen(tempPen);
        ++j;
    }

    ui->widgetLineChart_2->xAxis->setAutoTickStep(false);
    ui->widgetLineChart_2->xAxis->setTickStep(1.0);
    ui->widgetLineChart_2->xAxis->setTickLabelRotation(-60);
    ui->widgetLineChart_2->xAxis->setLabel("Years");
    if(_meas->yearRange().size() > 0 )ui->widgetLineChart_2->xAxis->setRange(_meas->yearRange().at(0).toInt(),_meas->yearRange().at(_meas->yearRange().size()-1).toInt());
    ui->widgetLineChart_2->yAxis->setLabel(_meas->name());
    ui->widgetLineChart_2->yAxis->setRange(_range.first*GRAPH_LOW_RATIO,_range.second*GRAPH_HIGH_RATIO);

    for(int j = 0; j < _meas->yearRange().size(); ++j)
        if(ui->listLineChartYears->item(j)->isSelected()) drawYear(j);

    if(ui->radioButtonMeanAllDataBar->isChecked()) {
        drawAverage();
    }

    ui->widgetLineChart_2->setBackground(QBrush(Qt::white));
    ui->widgetLineChart_2->axisRect()->setBackground(QBrush(Qt::white));

    ui->widgetLineChart_2->legend->setVisible(true);
    ui->widgetLineChart_2->replot();
}
Beispiel #4
0
void wxDCBase::DoDrawEllipticArcRot( wxCoord x, wxCoord y,
                                     wxCoord w, wxCoord h,
                                     double sa, double ea, double angle )
{
    wxList list;

    CalculateEllipticPoints( &list, x, y, w, h, sa, ea );
    Rotate( &list, angle, wxPoint( x+w/2, y+h/2 ) );

    // Add center (for polygon/pie)
    list.Append( (wxObject*) new wxPoint( x+w/2, y+h/2 ) );

    // copy list into array and delete list elements
    int n = list.Number();
    wxPoint *points = new wxPoint[n];
    int i = 0;
    wxNode* node = 0;
    for ( node = list.First(); node; node = node->Next(), i++ )
    {
        wxPoint *point = (wxPoint *)node->Data();
        points[i].x = point->x;
        points[i].y = point->y;
        delete point;
    }

    // first draw the pie without pen, if necessary
    if( GetBrush() != *wxTRANSPARENT_BRUSH )
    {
        wxPen tempPen( GetPen() );
        SetPen( *wxTRANSPARENT_PEN );
        DoDrawPolygon( n, points, 0, 0 );
        SetPen( tempPen );
    }

    // then draw the arc without brush, if necessary
    if( GetPen() != *wxTRANSPARENT_PEN )
    {
        // without center
        DoDrawLines( n-1, points, 0, 0 );
    }

    delete [] points;

} // DrawEllipticArcRot
Beispiel #5
0
void  CProfileGraphDlg::fillGraphLine( HTREEITEM hTreeSel )
{
	// get client rect
	CRect  rectTemp;

	m_GraphLine.GetClientRect(&rectTemp);


	// create graph line
	CClientDC tempDC( &m_GraphLine );
	CBitmap*  tempBitmap = NULL;

	m_CompatibleDC.DeleteDC();
	m_CompatibleBitmap.DeleteObject();

	m_CompatibleDC.CreateCompatibleDC( &tempDC );
	m_CompatibleBitmap.CreateCompatibleBitmap( &tempDC, rectTemp.Width(), rectTemp.Height() );

	tempBitmap = m_CompatibleDC.SelectObject( &m_CompatibleBitmap );

	m_CompatibleDC.SetBkColor( RGB( 255, 255, 255 ) );
	m_CompatibleDC.SelectStockObject( WHITE_BRUSH );
	m_CompatibleDC.Rectangle( &rectTemp );
	
	m_CompatibleDC.SelectStockObject( BLACK_BRUSH );
	m_CompatibleDC.MoveTo( 0, 0 );
	m_CompatibleDC.LineTo( rectTemp.Width(), 0 );
	m_CompatibleDC.LineTo( rectTemp.Width(), rectTemp.Height() );
	m_CompatibleDC.LineTo( 0, rectTemp.Height() );
	m_CompatibleDC.LineTo( 0, 0 );



	// draw graph line
	DWORD_PTR itemData = m_treeGraphCall.GetItemData( hTreeSel );
	CProfileGraphNode* pNode = m_GraphDoc.GetNodeByIndex( static_cast< UINT >( itemData ) );

	if ( NULL != pNode )
	{
		// insert seg
		static COLORREF colorTable[] = {
			0x0000CC00, 0x00FF0000, 0x00CCCC00, 0x000000FF,
			0x000000CC, 0x0000FF00,	0x00FF00FF, 0x00CC00CC,
            0x00CC0000,	0x0000FFFF, 0x0000CCCC, 0x00FFFF00
		};



		float frameFreq = 1;//rectStatic.Width() / m_GraphDoc.GetFrameNumber();
		float timeFreq = 2;//rectStatic.Height() / 1000;
		int   offLeft = 5;
		int   offTop = -5;

		for ( int frame = 0; frame < m_GraphDoc.GetFrameNumber(); ++ frame )
		{
			// push back
			typedef std::vector< GraphSort_t >	SortVector_t;
			SortVector_t	sortVector;
			int   i = 0;

			for ( CProfileGraphNode* pChild = pNode->GetChildPtr(); 
				NULL != pChild; 
				pChild = pChild->GetSiblingPtr(), ++ i
				)
			{
				float firstTime = m_GraphDoc.GetFrameNodeTime( frame == 0 ? 0 : frame - 1, pChild->GetCounter() );
				float curTime = m_GraphDoc.GetFrameNodeTime( frame, pChild->GetCounter() );

				sortVector.push_back( GraphSort_t( i, curTime - firstTime ) );
			}


			// sort graph
			std::sort( sortVector.begin(), sortVector.end(), SortCompare_Graph );
			for ( SortVector_t::iterator iter  = sortVector.begin();
										 iter != sortVector.end();
										 ++ iter 
										 )
			{
				int x = frame * frameFreq + offLeft;
				int y = rectTemp.Height() - iter->time * timeFreq + offTop;

				//m_CompatibleDC.SetPixel( x, y, colorTable[i] );
				CPen  tempPen( PS_SOLID, 1, colorTable[iter->color] );
				CPen* pOldPen = NULL;

				pOldPen = m_CompatibleDC.SelectObject( &tempPen );
				m_CompatibleDC.MoveTo( x, rectTemp.Height() );
				m_CompatibleDC.LineTo( x, y );
				m_CompatibleDC.SelectObject( pOldPen );
			}

		}

	}


	tempDC.BitBlt( 0, 0, rectTemp.Width(), rectTemp.Height(), &m_CompatibleDC, 0, 0, SRCCOPY );
	m_CompatibleDC.SelectObject( tempBitmap );

}