void RecSkinPushButton::paintEvent(QPaintEvent */*e*/) { QPainter painter(this); if(isEnter) { if(isSkin) { painter.drawPixmap(0, 0, drawPixmap); //QRect blueRect(0, 0,width()-,this->height() - 2); QPen bluePen(QPen(QColor(0, 0, 255, 200))); bluePen.setWidth(3); painter.setPen(bluePen); painter.drawRect(rect()); QRect whiteRect(0, 0, width()-4, height()-4); whiteRect.moveCenter(rect().center()); painter.setPen(QPen(QColor(255, 255, 255, 150))); painter.drawRect(whiteRect); painter.fillRect(whiteRect, QBrush(QColor(0, 0, 0, 100))); } else { painter.drawPixmap(0,0,drawPixmap); } } else { painter.drawPixmap(0,0,drawPixmap); } }
WMNMap::WMNMap(QWidget *parent) : QWidget(parent) { qsrand(QTime::currentTime().hour() * 3600 + QTime::currentTime().minute() * 60 + QTime::currentTime().second()); _Self = this; TrafficMap << 35 << 10 << 45 << 100 << 70 << 85 << 60 << 50; bzero(&inputParams, 0); haveInputParams = false; QPen redPen(Qt::red); redPen.setWidth(4); QPen bluePen(Qt::blue); bluePen.setWidth(4); QPen greenPen(Qt::green); greenPen.setWidth(4); QPen grayPen(Qt::gray); grayPen.setWidth(4); WMNArea = new QwtPlot(QwtText("Wireless Mesh Network Implementation")); // WMNArea->setAxisScale(0, 0, inputParams.squareArea); // WMNArea->setAxisScale(2, 0, inputParams.squareArea); curveMAP = new QwtPlotCurve("MAPs"); curveMAP->setRenderHint(QwtPlotItem::RenderAntialiased); curveMAP->setPen(redPen); curveMAP->setStyle(QwtPlotCurve::Dots); curveMAP->attach(WMNArea); curveMR = new QwtPlotCurve("MRs"); curveMR->setRenderHint(QwtPlotItem::RenderAntialiased); curveMR->setPen(bluePen); curveMR->setStyle(QwtPlotCurve::Dots); curveMR->attach(WMNArea); curveTP = new QwtPlotCurve("TPs"); curveTP->setRenderHint(QwtPlotItem::RenderAntialiased); curveTP->setPen(greenPen); curveTP->setStyle(QwtPlotCurve::Dots); curveTP->attach(WMNArea); curveDA = new QwtPlotCurve("MAPs"); curveDA->setRenderHint(QwtPlotItem::RenderAntialiased); curveDA->setPen(grayPen); curveDA->setStyle(QwtPlotCurve::Dots); curveDA->attach(WMNArea); QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(WMNArea); this->setLayout(layout); this->setWindowTitle(QTextCodec::codecForName("UTF8")->toUnicode("Сгенерированная WMN")); }
void DesignerWindow::HighlightSelection( wxDC& dc ) { wxSize size; PObjectBase object = m_selObj.lock(); if ( m_selSizer ) { wxPoint point = m_selSizer->GetPosition(); size = m_selSizer->GetSize(); wxPen bluePen( *wxBLUE, 1, wxSOLID ); dc.SetPen( bluePen ); dc.SetBrush( *wxTRANSPARENT_BRUSH ); PObjectBase sizerParent = object->FindNearAncestorByBaseClass( wxT("sizer") ); if ( sizerParent && sizerParent->GetParent() ) { DrawRectangle( dc, point, size, sizerParent ); } } if ( m_selItem ) { wxPoint point; bool shown; wxWindow* windowItem = wxDynamicCast( m_selItem, wxWindow ); wxSizer* sizerItem = wxDynamicCast( m_selItem, wxSizer ); if ( NULL != windowItem ) { point = windowItem->GetPosition(); size = windowItem->GetSize(); shown = windowItem->IsShown(); } else if ( NULL != sizerItem ) { point = sizerItem->GetPosition(); size = sizerItem->GetSize(); shown = true; } else { return; } if ( shown ) { wxPen redPen( *wxRED, 1, wxSOLID ); dc.SetPen( redPen ); dc.SetBrush( *wxTRANSPARENT_BRUSH ); DrawRectangle( dc, point, size, object ); } } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); scene =new QGraphicsScene(this); ui->graphicsView->setScene(scene); QBrush redBrush(Qt::red); QBrush greenBrush(Qt::green); QPen bluePen(Qt::blue); bluePen.setWidth(6); ellipse=scene->addEllipse(10,10,100,100,bluePen,redBrush); rectangle=scene->addRect(-100,-100,50,50,bluePen,greenBrush); rectangle->setFlag(QGraphicsItem::ItemIsMovable); }
void CMapDetail::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: 在此处添加消息处理程序代码 // 不为绘图消息调用 CStatic::OnPaint() CRect rect; GetClientRect( &rect ); dc.FillRect( &rect, &m_bgBrush ); CPen bluePen( PS_SOLID, 2, RGB( 0, 0, 255 ) ); //定义画笔 CPen* pOldPen = dc.SelectObject( &bluePen ); int nHalfInterval = nInterval / 2; std::map<std::string,ImageInfo>::iterator iter = m_mapImages.begin(); std::map<std::string,ImageInfo>::iterator iter_end = m_mapImages.end(); for( ; iter != iter_end; ++iter ) { iter->second.pImage->Draw( dc, iter->second.nOffsetX, iter->second.nOffsetY ); if( m_strCurrentName.compare( iter->first ) != 0 ) { dc.MoveTo( iter->second.nOffsetX - nHalfInterval, iter->second.nOffsetY - nHalfInterval ); dc.LineTo( iter->second.nOffsetX - nHalfInterval, iter->second.nOffsetY + iter->second.nHeight + nHalfInterval ); dc.LineTo( iter->second.nOffsetX + iter->second.nWidth + nHalfInterval, iter->second.nOffsetY + iter->second.nHeight + nHalfInterval ); dc.LineTo( iter->second.nOffsetX + iter->second.nWidth + nHalfInterval, iter->second.nOffsetY - nHalfInterval ); dc.LineTo( iter->second.nOffsetX - nHalfInterval, iter->second.nOffsetY - nHalfInterval ); } } iter = m_mapImages.find( m_strCurrentName ); if( iter != iter_end ) { CPen redPen( PS_SOLID, 2, RGB( 255, 0, 0 ) ); //定义画笔 dc.SelectObject( &redPen ); dc.MoveTo( iter->second.nOffsetX - nHalfInterval, iter->second.nOffsetY - nHalfInterval ); dc.LineTo( iter->second.nOffsetX - nHalfInterval, iter->second.nOffsetY + iter->second.nHeight + nHalfInterval ); dc.LineTo( iter->second.nOffsetX + iter->second.nWidth + nHalfInterval, iter->second.nOffsetY + iter->second.nHeight + nHalfInterval ); dc.LineTo( iter->second.nOffsetX + iter->second.nWidth + nHalfInterval, iter->second.nOffsetY - nHalfInterval ); dc.LineTo( iter->second.nOffsetX - nHalfInterval, iter->second.nOffsetY - nHalfInterval ); } dc.SelectObject( pOldPen ); }
void CPage_Node_Lane::DrawMovements(CPaintDC *pDC,CRect PlotRect) { CPen NormalPen(PS_SOLID,2,RGB(0,0,0)); CPen TimePen(PS_DOT,1,RGB(0,0,0)); CPen DataPen(PS_SOLID,0,RGB(0,0,0)); CPen SelectedPen(PS_SOLID,4,RGB(255,0,0)); CPen SelectedPhasePen(PS_SOLID,4,RGB(0,0,255)); CPen redPen(PS_SOLID,3,RGB(255,0,0)); CPen bluePen(PS_SOLID,3,RGB(0,0,255)); CBrush WhiteBrush(RGB(255,255,255)); pDC->SetBkMode(TRANSPARENT); CPen *pOldPen = pDC->SelectObject(&DataPen); CBrush *pOldBrush = pDC->SelectObject(&WhiteBrush); pDC->Rectangle (PlotRect); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
wxBitmap BacklashGraph::CreateGraph(int bmpWidth, int bmpHeight) { wxMemoryDC dc; wxBitmap bmp(bmpWidth, bmpHeight, -1); wxPen axisPen("BLACK", 3, wxCROSS_HATCH); wxPen redPen("RED", 3, wxSOLID); wxPen bluePen("BLUE", 3, wxSOLID); wxBrush redBrush("RED", wxSOLID); wxBrush blueBrush("BLUE", wxSOLID); //double fakeNorthPoints[] = //{152.04, 164.77, 176.34, 188.5, 200.25, 212.36, 224.21, 236.89, 248.62, 260.25, 271.34, 283.54, 294.79, 307.56, 319.22, 330.87, 343.37, 355.75, 367.52, 379.7, 391.22, 403.89, 415.34, 427.09, 439.41, 450.36, 462.6}; //double fakeSouthPoints[] = //{474.84, 474.9, 464.01, 451.83, 438.08, 426, 414.68, 401.15, 390.39, 377.22, 366.17, 353.45, 340.75, 328.31, 316.93, 304.55, 292.42, 280.45, 269.03, 255.02, 243.76, 231.53, 219.43, 207.35, 195.22, 183.06, 169.47}; //std::vector <double> northSteps(fakeNorthPoints, fakeNorthPoints + 27); //std::vector <double> southSteps(fakeSouthPoints, fakeSouthPoints + 27); std::vector <double> northSteps = m_BLT->GetNorthSteps(); std::vector <double> southSteps = m_BLT->GetSouthSteps(); double xScaleFactor; double yScaleFactor; int xOrigin; int yOrigin; int ptRadius; int graphWindowWidth; int graphWindowHeight; int numNorth; double northInc; int numSouth; // Find the max excursion from the origin in order to scale the points to fit the bitmap double maxDec = -9999.0; double minDec = 9999.0; for (std::vector<double>::const_iterator it = northSteps.begin(); it != northSteps.end(); ++it) { maxDec = wxMax(maxDec, *it); minDec = wxMin(minDec, *it); } for (std::vector<double>::const_iterator it = southSteps.begin(); it != southSteps.end(); ++it) { maxDec = wxMax(maxDec, *it); minDec = wxMin(minDec, *it); } graphWindowWidth = bmpWidth; graphWindowHeight = 0.7 * bmpHeight; yScaleFactor = (graphWindowHeight) / (maxDec - minDec + 1); xScaleFactor = (graphWindowWidth) / (northSteps.size() + southSteps.size()); // Since we get mount coordinates, north steps will always be in ascending order numNorth = northSteps.size(); northInc = (northSteps.at(numNorth - 1) - northSteps.at(0)) / numNorth; numSouth = southSteps.size(); // Should be same as numNorth but be careful dc.SelectObject(bmp); dc.SetBackground(*wxLIGHT_GREY_BRUSH); dc.SetFont(wxFont(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); dc.Clear(); // Bottom and top labels dc.SetTextForeground("BLUE"); dc.DrawText(_("Ideal"), 0.7 * graphWindowWidth, bmpHeight - 25); dc.SetTextForeground("RED"); dc.DrawText(_("Measured"), 0.2 * graphWindowWidth, bmpHeight - 25); dc.DrawText(_("North"), 0.1 * graphWindowWidth, 10); dc.DrawText(_("South"), 0.8 * graphWindowWidth, 10); // Draw the axes dc.SetPen(axisPen); xOrigin = graphWindowWidth / 2; yOrigin = graphWindowHeight + 40; // Leave room at the top for labels and such dc.DrawLine(0, yOrigin, graphWindowWidth, yOrigin); // x dc.DrawLine(xOrigin, yOrigin, xOrigin, 0); // y // Draw the north steps dc.SetPen(redPen); dc.SetBrush(redBrush); ptRadius = 2; for (int i = 0; i < numNorth; i++) { wxPoint where = wxPoint(i * xScaleFactor, round(yOrigin - (northSteps.at(i) - minDec) * yScaleFactor)); dc.DrawCircle(wxPoint(i * xScaleFactor, round(yOrigin - (northSteps.at(i) - minDec) * yScaleFactor)), ptRadius); } // Draw the south steps for (int i = 0; i < numSouth; i++) { dc.DrawCircle(wxPoint((i + numNorth) * xScaleFactor, round(yOrigin - (southSteps.at(i) - minDec) * yScaleFactor)), ptRadius); } // Now show an ideal south recovery line dc.SetPen(bluePen); dc.SetBrush(blueBrush); double peakSouth = southSteps.at(0); for (int i = 1; i <= numNorth; i++) { wxPoint where = wxPoint((i + numNorth)* xScaleFactor, round(yOrigin - (peakSouth - i * northInc - minDec) * yScaleFactor)); dc.DrawCircle(where, ptRadius); } dc.SelectObject(wxNullBitmap); return bmp; }
void DlgHisto::OnPaint() { CPaintDC dc(this); // device context for painting CDemoDoc* pDoc = (CDemoDoc*) ((CMainFrame*)AfxGetMainWnd())->GetActiveFrame()->GetActiveDocument(); RECT r; GetClientRect(&r); CPen gridPen(PS_DOT,1,::GetSysColor(COLOR_APPWORKSPACE)); CPen* pOldPen = dc.SelectObject(&gridPen); for (int gx=9+32;gx<265;gx+=32){ dc.MoveTo(gx,40); dc.LineTo(gx,r.bottom - 6); } for (int gy=0;gy<(r.bottom - 40);gy+=((r.bottom - 40)/10)){ dc.MoveTo(8,r.bottom - 9 - gy); dc.LineTo(268,r.bottom - 9 - gy); } dc.SelectObject(pOldPen); CPen axisPen(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW)); pOldPen = dc.SelectObject(&axisPen); dc.MoveTo(9, 38); dc.LineTo(9, r.bottom - 9); dc.LineTo(266, r.bottom - 9); dc.LineTo(266, 38); dc.SelectObject(pOldPen); if (pDoc && pDoc->image) { if (pDoc->m_hmax){ int ybase = r.bottom-10; if (m_logen){ float yratio = (r.bottom - r.top - 50)/(float)log10((float)(pDoc->m_hmax+1)); if (m_ren){ CPen redPen(PS_SOLID, 1, RGB(222, 0, 0)); pOldPen = dc.SelectObject(&redPen); dc.MoveTo(10, (int)(ybase-log10((float)(1+pDoc->m_hr[0]))*yratio)); for (int x=1; x<256; x++) dc.LineTo(x+10, (int)(ybase-log10((float)(1+pDoc->m_hr[x]))*yratio)); } if (m_gen){ CPen greenPen(PS_SOLID, 1, RGB(0, 222, 0)); pOldPen = dc.SelectObject(&greenPen); dc.MoveTo(10, (int)(ybase-log10((float)(1+pDoc->m_hg[0]))*yratio)); for (int x=1; x<256; x++) dc.LineTo(x+10, (int)(ybase-log10((float)(1+pDoc->m_hg[x]))*yratio)); } if (m_ben){ CPen bluePen(PS_SOLID, 1, RGB(0, 0, 222)); pOldPen = dc.SelectObject(&bluePen); dc.MoveTo(10, (int)(ybase-log10((float)(1+pDoc->m_hb[0]))*yratio)); for (int x=1; x<256; x++) dc.LineTo(x+10, (int)(ybase-log10((float)(1+pDoc->m_hb[x]))*yratio)); } if (m_grayen){ CPen grayPen(PS_SOLID, 1, RGB(64, 64, 64)); pOldPen = dc.SelectObject(&grayPen); dc.MoveTo(10, (int)(ybase-log10((float)(1+pDoc->m_hgray[0]))*yratio)); for (int x=1; x<256; x++) dc.LineTo(x+10, (int)(ybase-log10((float)(1+pDoc->m_hgray[x]))*yratio)); } dc.SelectObject(pOldPen); } else { float yratio = (r.bottom - r.top - 50)/(float)pDoc->m_hmax; if (m_ren){ CPen redPen(PS_SOLID, 1, RGB(222, 0, 0)); pOldPen = dc.SelectObject(&redPen); dc.MoveTo(10, (int)(ybase-pDoc->m_hr[0]*yratio)); for (int x=1; x<256; x++) dc.LineTo(x+10, (int)(ybase-pDoc->m_hr[x]*yratio)); } if (m_gen){ CPen greenPen(PS_SOLID, 1, RGB(0, 222, 0)); pOldPen = dc.SelectObject(&greenPen); dc.MoveTo(10, (int)(ybase-pDoc->m_hg[0]*yratio)); for (int x=1; x<256; x++) dc.LineTo(x+10, (int)(ybase-pDoc->m_hg[x]*yratio)); } if (m_ben){ CPen bluePen(PS_SOLID, 1, RGB(0, 0, 222)); pOldPen = dc.SelectObject(&bluePen); dc.MoveTo(10, (int)(ybase-pDoc->m_hb[0]*yratio)); for (int x=1; x<256; x++) dc.LineTo(x+10, (int)(ybase-pDoc->m_hb[x]*yratio)); } if (m_grayen){ CPen grayPen(PS_SOLID, 1, RGB(64, 64, 64)); pOldPen = dc.SelectObject(&grayPen); dc.MoveTo(10, (int)(ybase-pDoc->m_hgray[0]*yratio)); for (int x=1; x<256; x++) dc.LineTo(x+10, (int)(ybase-pDoc->m_hgray[x]*yratio)); } dc.SelectObject(pOldPen); } } else { pDoc->m_hmax=pDoc->GetImage()->Histogram(pDoc->m_hr,pDoc->m_hg,pDoc->m_hb,pDoc->m_hgray); if (pDoc->m_hmax) Invalidate(); } } }
void BifurcationPlot::drawPlot() { /** * Main drawing function for the plot classes. * * The bifurcation plot is stored in a wxBitmap object so that we don't * have to recalculate and draw every point every time we refresh the * screen. Since all of the ChaosPlots are buffered, this means that * the Bifurcation drawing functions actually go through two buffers. * This is not the most efficient way to do this, but it does allow us * to use the functionality of the ChaosPlot subclass. * * Steps for drawing: * * Calculate X & Y axis values and size. * * Store our current size. * * Calls startDraw() to initalize the drawing DC. (Updates size) * * Compare old size with current size to determine if it needs to redraw everything. * * If so, draw axis on BufferedDC and copy them over to the MemoryDC, * then redraw all points. * * If not, collect points for up to 2 MDAC values and only draw * the new points on the MemoryDC. * * Draw the MDAC reference line on the graph. * * Finally, copy the MemoryDC over to the BufferedDC and draw it to the DC. * */ float x_min, x_max; float y_min, y_max; wxString xaxis_title; wxMemoryDC bifMemDC; // Get information for the X axis if(ChaosSettings::BifXAxis == ChaosSettings::MDAC_VALUES) { xaxis_title = wxString(wxT("Mdac values")); } else { xaxis_title = wxString(wxT("Resistance (Ohms)")); } // Get scaling/label information for the Y axis if(ChaosSettings::YAxisLabels == ChaosSettings::Y_AXIS_VGND) { graph_subtitle = wxString::Format(wxT("Peaks (V) vs. %s"), xaxis_title.c_str()); y_min = smallest_y_value*3.3/1024; y_max = largest_y_value*3.3/1024; x_min = smallest_x_value*3.3/1024; x_max = largest_x_value*3.3/1024; } else if(ChaosSettings::YAxisLabels == ChaosSettings::Y_AXIS_VBIAS) { graph_subtitle = wxString::Format(wxT("Peaks (V) vs. %s"), xaxis_title.c_str()); y_min = smallest_y_value*3.3/1024 - 1.2; y_max = largest_y_value*3.3/1024 - 1.2; x_min = smallest_x_value*3.3/1024 - 1.2; x_max = largest_x_value*3.3/1024 - 1.2; } else { graph_subtitle = wxString::Format(wxT("Peaks (ADC) vs. %s"), xaxis_title.c_str()); y_min = smallest_y_value; y_max = largest_y_value; x_min = smallest_x_value; x_max = largest_x_value; } // Store old size information for future comparison int old_width = width; int old_height = height; // Update size and draw background & titles startDraw(); // Check and see if the size of the graph has changed // If it has, we need to redraw our cached image if(old_width != width || old_height != height) { ChaosSettings::BifRedraw = true; } // Do we need to redraw everything that we have cached? if(ChaosSettings::BifRedraw == true) { // Draw the Y axis on the buffered DC drawYAxis(y_min, y_max, (y_max-y_min)/4.0); // Draw the X axis on the buffered DC if(ChaosSettings::BifXAxis == ChaosSettings::MDAC_VALUES) { drawXAxis(float(largest_x_value), float(smallest_x_value), -1*((largest_x_value-smallest_x_value)/4)); } else { float min = libchaos_mdacToResistance(largest_x_value); float max = libchaos_mdacToResistance(smallest_x_value); drawXAxis(min, max, ((max-min)/4)); } // If we aren't connected, then we're done if(device_connected == false) { endDraw(); return; } // if we already have a cached image, delete it if(bifBmp) delete bifBmp; // Create a bitmap to cache our bifurcation drawing to bifBmp = new wxBitmap(width, height); // Select the bitmap to a memory DC so we can draw on it and initialize it with a background bifMemDC.SelectObject(*bifBmp); bifMemDC.SetBrush(dc->GetBackground()); bifMemDC.SetPen(*wxTRANSPARENT_PEN); bifMemDC.DrawRectangle(0,0,width,height); // Copy what we have on the buffer so far (title, axis, labels) to the cache bifMemDC.Blit(0, 0, width, height, buffer, 0, 0); } else { // No need to redraw everything, just select the cache so we can draw more onto it bifMemDC.SelectObject(*bifBmp); } //Use blue pen wxPen bluePen(*wxBLUE, 1); // blue pen of width 1 wxBrush blueBrush(*wxBLUE_BRUSH); bifMemDC.SetPen(bluePen); bifMemDC.SetBrush(blueBrush); int* peaks; int new_points; int step = (int)(float(graph_width) / float(ChaosSettings::BifStepsPerWindow)); if(step == 0) step = 1; // If we are paused, don't collect new data points if(paused || ChaosSettings::Paused) { new_points = 0; } else { new_points = 2; libchaos_disableFFT(); } // Draw points, collecting new data if necessary. int miss_mdac = -1; for(int i = 1; i < graph_width; i+=step) { int mdac_value = xToMdac(i); /* Since the user can technically zoom into areas slightly beyond our mdac limits, we have to ensure we have a correct value. */ if (mdac_value > 4095) { mdac_value = 4095; } else if (mdac_value < 0) { mdac_value = 0; } bool cacheHit = libchaos_peaksCacheHit(mdac_value); if(!cacheHit) new_points--; if((ChaosSettings::BifRedraw && cacheHit) || (!cacheHit && new_points > 0)) { peaks = libchaos_getPeaks(mdac_value); if(cacheHit == false) { miss_mdac = mdac_value; } bifMemDC.SetPen(bluePen); for(int j = 0; j < ChaosSettings::PeaksPerMdac; j++) { int y = valueToY(peaks[j]); if(y < graph_height + top_gutter_size && y > top_gutter_size) { drawPoint(&bifMemDC, valueToX(mdac_value), y); } } } } if( new_points > 0 ) libchaos_enableFFT(); if(miss_mdac != -1) { device_mdac_value = miss_mdac; } // We're finished redrawing everything, so don't do it again unless we need to if(ChaosSettings::BifRedraw == true) { ChaosSettings::BifRedraw = false; } // Copy our cache onto the buffered DC // (It is redundant to use a MemoryDC and a BufferedDC, it may be more efficient // to not use the BufferedDC for the bifurcation) buffer->Blit(0,0, width, height, &bifMemDC, 0, 0); // Draw the line for the MDAC drawMdacLine(buffer); // Flush the buffer and output to the screen. endDraw(); }
void DesignerWindow::HighlightSelection( wxDC& dc ) { // do not highlight if AUI is used in floating mode VisualEditor *editor = wxDynamicCast( GetParent(), VisualEditor ); if( editor && editor->m_auimgr ) { wxWindow *windowItem = wxDynamicCast( m_selItem, wxWindow ); while( windowItem ) { wxAuiPaneInfo info = editor->m_auimgr->GetPane( windowItem ); if( info.IsOk() ) { if( info.IsFloating() ) return; else break; } windowItem = windowItem->GetParent(); } } wxSize size; PObjectBase object = m_selObj.lock(); if ( m_selSizer ) { wxPoint point = m_selSizer->GetPosition(); size = m_selSizer->GetSize(); wxPen bluePen( *wxBLUE, 1, wxSOLID ); dc.SetPen( bluePen ); dc.SetBrush( *wxTRANSPARENT_BRUSH ); PObjectBase sizerParent = object->FindNearAncestorByBaseClass( wxT("sizer") ); if( !sizerParent ) sizerParent = object->FindNearAncestorByBaseClass( wxT("gbsizer") ); if ( sizerParent && sizerParent->GetParent() ) { DrawRectangle( dc, point, size, sizerParent ); } } if ( m_selItem ) { wxPoint point; bool shown; wxWindow* windowItem = wxDynamicCast( m_selItem, wxWindow ); wxSizer* sizerItem = wxDynamicCast( m_selItem, wxSizer ); if ( NULL != windowItem ) { point = windowItem->GetPosition(); size = windowItem->GetSize(); shown = windowItem->IsShown(); } else if ( NULL != sizerItem ) { point = sizerItem->GetPosition(); size = sizerItem->GetSize(); shown = true; } else { return; } if ( shown ) { wxPen redPen( *wxRED, 1, wxSOLID ); dc.SetPen( redPen ); dc.SetBrush( *wxTRANSPARENT_BRUSH ); DrawRectangle( dc, point, size, object ); } } }
void QCompass::paintEvent(QPaintEvent *) { QPainter painter(this); QBrush bgGround(QColor(48,172,220)); QPen whitePen(Qt::white); QPen blackPen(Qt::black); QPen redPen(Qt::red); QPen bluePen(Qt::blue); QPen greenPen(Qt::green); whitePen.setWidth(1); blackPen.setWidth(2); redPen.setWidth(2); bluePen.setWidth(2); greenPen.setWidth(2); painter.setRenderHint(QPainter::Antialiasing); painter.translate(width() / 2, height() / 2); // draw background { painter.setPen(blackPen); painter.setBrush(bgGround); painter.drawEllipse(-m_size/2, -m_size/2, m_size, m_size); } // draw yaw lines { int nyawLines = 36; float rotAng = 360.0 / nyawLines; int yawLineLeng = m_size/25; double fx1, fy1, fx2, fy2; int fontSize = 8; QString s; blackPen.setWidth(1); painter.setPen(blackPen); for(int i=0; i<nyawLines; i++) { if( i == 0 ) { s = "N"; painter.setPen(bluePen); painter.setFont(QFont("", fontSize*1.3)); } else if ( i == 9 ) { s = "W"; painter.setPen(blackPen); painter.setFont(QFont("", fontSize*1.3)); } else if ( i == 18 ) { s = "S"; painter.setPen(redPen); painter.setFont(QFont("", fontSize*1.3)); } else if ( i == 27 ) { s = "E"; painter.setPen(blackPen); painter.setFont(QFont("", fontSize*1.3)); } else { s = QString("%1").arg(i*rotAng); painter.setPen(blackPen); painter.setFont(QFont("", fontSize)); } fx1 = 0; fy1 = -m_size/2 + m_offset; fx2 = 0; if( i % 3 == 0 ) { fy2 = fy1 + yawLineLeng; painter.drawLine(QPointF(fx1, fy1), QPointF(fx2, fy2)); fy2 = fy1 + yawLineLeng+4; painter.drawText(QRectF(-50, fy2, 100, fontSize+2), Qt::AlignCenter, s); } else { fy2 = fy1 + yawLineLeng/2; painter.drawLine(QPointF(fx1, fy1), QPointF(fx2, fy2)); } painter.rotate(-rotAng); } } // draw S/N arrow { int arrowWidth = m_size/5; double fx1, fy1, fx2, fy2, fx3, fy3; fx1 = 0; fy1 = -m_size/2 + m_offset + m_size/25 + 15; fx2 = -arrowWidth/2; fy2 = 0; fx3 = arrowWidth/2; fy3 = 0; painter.setPen(Qt::NoPen); painter.setBrush(QBrush(Qt::blue)); QPointF pointsN[3] = { QPointF(fx1, fy1), QPointF(fx2, fy2), QPointF(fx3, fy3) }; painter.drawPolygon(pointsN, 3); fx1 = 0; fy1 = m_size/2 - m_offset - m_size/25 - 15; fx2 = -arrowWidth/2; fy2 = 0; fx3 = arrowWidth/2; fy3 = 0; painter.setBrush(QBrush(Qt::red)); QPointF pointsS[3] = { QPointF(fx1, fy1), QPointF(fx2, fy2), QPointF(fx3, fy3) }; painter.drawPolygon(pointsS, 3); } // draw yaw marker { int yawMarkerSize = m_size/12; double fx1, fy1, fx2, fy2, fx3, fy3; painter.rotate(-m_yaw); painter.setBrush(QBrush(QColor(0xFF, 0x00, 0x00, 0xE0))); fx1 = 0; fy1 = -m_size/2 + m_offset; fx2 = fx1 - yawMarkerSize/2; fy2 = fy1 + yawMarkerSize; fx3 = fx1 + yawMarkerSize/2; fy3 = fy1 + yawMarkerSize; QPointF points[3] = { QPointF(fx1, fy1), QPointF(fx2, fy2), QPointF(fx3, fy3) }; painter.drawPolygon(points, 3); painter.rotate(m_yaw); } // draw altitude { int altFontSize = 13; int fx, fy, w, h; QString s; char buf[200]; w = 130; h = 2*(altFontSize + 8); fx = -w/2; fy = -h/2; blackPen.setWidth(2); painter.setPen(blackPen); painter.setBrush(QBrush(Qt::white)); painter.setFont(QFont("", altFontSize)); painter.drawRoundedRect(fx, fy, w, h, 6, 6); painter.setPen(bluePen); sprintf(buf, "ALT: %6.1f m", m_alt); s = buf; painter.drawText(QRectF(fx, fy+2, w, h/2), Qt::AlignCenter, s); sprintf(buf, "H: %6.1f m", m_h); s = buf; painter.drawText(QRectF(fx, fy+h/2, w, h/2), Qt::AlignCenter, s); } }
// Build the calibration "step" graph which will appear on the lefthand side of the panels wxBitmap CalReviewDialog::CreateGraph(bool AO) { wxMemoryDC memDC; wxBitmap bmp(CALREVIEW_BITMAP_SIZE, CALREVIEW_BITMAP_SIZE, -1); wxPen axisPen("BLACK", 3, wxCROSS_HATCH); wxPen redPen("RED", 3, wxSOLID); wxPen bluePen("BLUE", 3, wxSOLID); wxBrush redBrush("RED", wxSOLID); wxBrush blueBrush("BLUE", wxSOLID); CalibrationDetails calDetails; double scaleFactor; int ptRadius; if (!pSecondaryMount) { pMount->GetCalibrationDetails(&calDetails); // Normal case, no AO } else { if (AO) { pMount->GetCalibrationDetails(&calDetails); // AO tab, use AO details } else { pSecondaryMount->GetCalibrationDetails(&calDetails); // Mount tab, use mount details } } // Find the max excursion from the origin in order to scale the points to fit the bitmap double biggestVal = -100.0; for (std::vector<wxRealPoint>::const_iterator it = calDetails.raSteps.begin(); it != calDetails.raSteps.end(); ++it) { biggestVal = wxMax(biggestVal, fabs(it->x)); biggestVal = wxMax(biggestVal, fabs(it->y)); } for (std::vector<wxRealPoint>::const_iterator it = calDetails.decSteps.begin(); it != calDetails.decSteps.end(); ++it) { biggestVal = wxMax(biggestVal, fabs(it->x)); biggestVal = wxMax(biggestVal, fabs(it->y)); } if (biggestVal > 0.0) scaleFactor = ((CALREVIEW_BITMAP_SIZE - 5) / 2) / biggestVal; // Leave room for circular point else scaleFactor = 1.0; memDC.SelectObject(bmp); memDC.SetBackground(*wxLIGHT_GREY_BRUSH); memDC.Clear(); memDC.SetPen(axisPen); // Draw the axes memDC.SetDeviceOrigin(wxCoord(CALREVIEW_BITMAP_SIZE / 2), wxCoord(CALREVIEW_BITMAP_SIZE / 2)); memDC.DrawLine(-CALREVIEW_BITMAP_SIZE / 2, 0, CALREVIEW_BITMAP_SIZE / 2, 0); // x memDC.DrawLine(0, -CALREVIEW_BITMAP_SIZE / 2, 0, CALREVIEW_BITMAP_SIZE / 2); // y if (calDetails.raStepCount > 0) { // Draw the RA data memDC.SetPen(redPen); memDC.SetBrush(redBrush); ptRadius = 2; // Scale the points, then plot them individually for (int i = 0; i < (int) calDetails.raSteps.size(); i++) { if (i == calDetails.raStepCount + 2) // Valid even for "single-step" calibration { memDC.SetPen(wxPen("Red", 1)); // 1-pixel-thick red outline memDC.SetBrush(wxNullBrush); // Outline only for "return" data points ptRadius = 3; } memDC.DrawCircle(IntPoint(calDetails.raSteps.at(i), scaleFactor), ptRadius); } // Show the line PHD2 will use for the rate memDC.SetPen(redPen); if ((int)calDetails.raSteps.size() > calDetails.raStepCount) // New calib, includes return values memDC.DrawLine(IntPoint(calDetails.raSteps.at(0), scaleFactor), IntPoint(calDetails.raSteps.at(calDetails.raStepCount), scaleFactor)); else memDC.DrawLine(IntPoint(calDetails.raSteps.at(0), scaleFactor), IntPoint(calDetails.raSteps.at(calDetails.raStepCount - 1), scaleFactor)); } // Handle the Dec data memDC.SetPen(bluePen); memDC.SetBrush(blueBrush); ptRadius = 2; if (calDetails.decStepCount > 0) { for (int i = 0; i < (int) calDetails.decSteps.size(); i++) { if (i == calDetails.decStepCount + 2) { memDC.SetPen(wxPen("Blue", 1)); // 1-pixel-thick red outline memDC.SetBrush(wxNullBrush); // Outline only for "return" data points ptRadius = 3; } memDC.DrawCircle(IntPoint(calDetails.decSteps.at(i), scaleFactor), ptRadius); } // Show the line PHD2 will use for the rate memDC.SetPen(bluePen); if ((int)calDetails.decSteps.size() > calDetails.decStepCount) // New calib, includes return values memDC.DrawLine(IntPoint(calDetails.decSteps.at(0), scaleFactor), IntPoint(calDetails.decSteps.at(calDetails.decStepCount), scaleFactor)); else memDC.DrawLine(IntPoint(calDetails.decSteps.at(0), scaleFactor), IntPoint(calDetails.decSteps.at(calDetails.decStepCount - 1), scaleFactor)); } memDC.SelectObject(wxNullBitmap); return bmp; }
void BpDocument::composeFireCharacteristicsDiagram( void ) { // Surface Module must be active and using fuel model inputs PropertyDict *prop = m_eqTree->m_propDict; if ( ! prop->boolean( "surfaceModuleActive" ) || ! prop->boolean( "surfaceCalcFireCharacteristicsDiagram" ) ) { return; } // Graph fonts. QFont textFont( property()->string( "graphTextFontFamily" ), property()->integer( "graphTextFontSize" ) ); QColor textColor( property()->color( "graphTextFontColor" ) ); QPen textPen( textColor ); QFont subTitleFont( property()->string( "graphSubtitleFontFamily" ), property()->integer( "graphSubtitleFontSize" ) ); QColor subTitleColor( property()->color( "graphSubtitleFontColor" ) ); // Open the result file QString resultFile = m_eqTree->m_resultFile; FILE *fptr = 0; if ( ! ( fptr = fopen( resultFile.latin1(), "r" ) ) ) // This code block should never be executed! { QString text(""); translate( text, "BpDocument:FireCharacteristicsDiagram:NoLogOpen", resultFile ); error( text ); return; } // Allocate ros and hpua data arrays int rows = tableRows(); int cols = tableCols(); int cells = rows * cols; double *hpua = new double[ cells ]; checkmem( __FILE__, __LINE__, hpua, "double hpua", cells ); double *ros = new double[ cells ]; checkmem( __FILE__, __LINE__, ros, "double ros", cells ); // Set the variable names we're looking for const char* hpuaName = "vSurfaceFireHeatPerUnitArea"; const char* rosName = "vSurfaceFireSpreadAtHead"; if ( prop->boolean( "surfaceConfSpreadDirInput" ) ) { rosName = "vSurfaceFireSpreadAtVector"; } // Read and store the ros and hpua values char buffer[1024], varName[128], varUnits[128]; int row, col, cell; double value; double rosMax = 0.0; double hpuaMax = 0.0; while ( fgets( buffer, sizeof(buffer), fptr ) ) { if ( strncmp( buffer, "CELL", 4 ) == 0 ) { if ( strstr( buffer, hpuaName ) ) { sscanf( buffer, "CELL %d %d %s cont %lf %s", &row, &col, varName, &value, varUnits ); cell = ( col - 1 ) + ( cols * ( row - 1) ); if ( ( hpua[ cell ] = value ) > hpuaMax ) { hpuaMax = value; } } else if ( strstr( buffer, rosName ) ) { sscanf( buffer, "CELL %d %d %s cont %lf %s", &row, &col, varName, &value, varUnits ); cell = ( col - 1 ) + ( cols * ( row - 1) ); if ( ( ros[ cell ] = value ) > rosMax ) { rosMax = value; } } } } fclose( fptr ); // Get variable pointers EqVar *hpuaVar = m_eqTree->m_varDict->find( "vSurfaceFireHeatPerUnitArea" ); EqVar *rosVar = m_eqTree->m_varDict->find( "vSurfaceFireSpreadAtHead" ); EqVar *fliVar = m_eqTree->m_varDict->find( "vSurfaceFireLineIntAtHead" ); EqVar *flVar = m_eqTree->m_varDict->find( "vSurfaceFireFlameLengAtHead" ); // Conversion factor double flFactor, fliFactor, rosFactor, hpuaFactor, offset; appSiUnits()->conversionFactorOffset( flVar->m_nativeUnits, flVar->m_displayUnits, &flFactor, &offset ); appSiUnits()->conversionFactorOffset( fliVar->m_nativeUnits, fliVar->m_displayUnits, &fliFactor, &offset ); appSiUnits()->conversionFactorOffset( hpuaVar->m_nativeUnits, hpuaVar->m_displayUnits, &hpuaFactor, &offset ); appSiUnits()->conversionFactorOffset( rosVar->m_nativeUnits, rosVar->m_displayUnits, &rosFactor, &offset ); // Determine which of four different chart scales to use static const int Scales = 4; static double RosScale[Scales] = { 100., 200., 400., 800. }; // ft/min static double HpuaScale[Scales] = { 2000., 4000., 8000., 16000. }; // Btu/ft2 double rosScale = 0.; // Max y-axis ros double hpuaScale = 0.; // Max x-axis hpua int scale; for ( scale=0; scale<Scales; scale++ ) { if ( rosMax < ( rosScale = RosScale[ scale ] ) ) { break; } } for ( scale=0; scale<Scales; scale++ ) { if ( hpuaMax < ( hpuaScale = HpuaScale[scale] ) ) { break; } } // Set axis maximums to appropriate predefined scale in display units rosMax = rosFactor * rosScale; hpuaMax = hpuaFactor * hpuaScale; double ratio = rosMax / hpuaMax; // Create the graph Graph graph; GraphLine *graphLine; GraphMarker *graphMarker; static const int Points = 100; double l_x[Points]; double l_y[Points]; // Draw the four standard hauling chart fli-fl levels static const int Lines = 4; static const double Fli[Lines] = { 100., 500., 1000., 2000. }; // Btu/ft/s static const double Fl[Lines] = { 4., 8., 11., 15. }; // ft // Create the hauling chart lines // Put Fireline Int label 65% of the way along the HPUA axis (display units) double xPosFli = 0.65 * hpuaMax; // Put Flame Length label 85% of the way along the HPUA axis (display units) double xPosFl = 0.85 * hpuaMax; // Fireline Int and Flame Length label Y positions (display units) double yPosFl[Lines], yPosFli[Lines]; // Icon locations (in display units) double xIcon[Lines+1], yIcon[Lines+1]; double diff, minDiff; QString label; QPen redPen( "red", 1 ); QColor blackColor( "black" ); int alignCenter = Qt::AlignHCenter | Qt::AlignVCenter; // Fireline intensity - flame length curves int line, point; for ( line = 0; line < Lines; line++ ) { minDiff = 999999999.; for ( point = 0; point < Points; point++ ) { // Hpua value in native units (Btu/ft2) l_x[point] = ( (point+1) * hpuaScale ) / (double) Points; // Ros value in native units (ft/min) l_y[point] = 60. * Fli[line] / l_x[point]; // Convert to display units l_x[point] *= hpuaFactor; l_y[point] *= rosFactor; // Check for curve inflection point (for icon placement) if ( ( diff = fabs( l_y[point]/l_x[point] - ratio ) ) < minDiff ) { minDiff = diff; xIcon[line+1] = l_x[point]; yIcon[line+1] = l_y[point]; } } // Create a graph line (with its own copy of the data). graphLine = graph.addGraphLine( Points, l_x, l_y, redPen ); // Fireline intensity label label = QString( "%1" ).arg( ( Fli[line] * fliFactor ), 0, 'f', 0 ); yPosFli[line] = rosFactor * ( 60. * Fli[line] / ( xPosFli / hpuaFactor ) ); graph.addGraphMarker( xPosFli, yPosFli[line], label, textFont, blackColor, alignCenter ); // Flame length label label = QString( "%1" ).arg( ( Fl[line] * flFactor ), 0, 'f', 0 ); yPosFl[line] = rosFactor * ( 60. * Fli[line] / ( xPosFl / hpuaFactor ) ); graph.addGraphMarker( xPosFl, yPosFl[line], label, textFont, blackColor, alignCenter ); } // Next line // Fireline intensity label and units translate( label, "BpDocument:FireCharacteristicsDiagram:FLI" ); graph.addGraphMarker( xPosFli, ( yPosFli[Lines-1] + 0.10 * rosMax ), label, textFont, blackColor, alignCenter ); graph.addGraphMarker( xPosFli, ( yPosFli[Lines-1] + 0.05 * rosMax ), fliVar->m_displayUnits, textFont, blackColor, alignCenter ); // Flame length label and units translate( label, "BpDocument:FireCharacteristicsDiagram:FL" ); graph.addGraphMarker( xPosFl, ( yPosFl[Lines-1] + 0.10 * rosMax ), label, textFont, blackColor, alignCenter ); graph.addGraphMarker( xPosFl, ( yPosFl[Lines-1] + 0.05 * rosMax ), flVar->m_displayUnits, textFont, blackColor, alignCenter ); // Add icons QPixmap pixmap[Lines]; pixmap[0] = QPixmap( fireman_xpm ); pixmap[1] = QPixmap( dozer_xpm ); pixmap[2] = QPixmap( torchtree_xpm ); pixmap[3] = QPixmap( mtnfire_xpm ); xIcon[0] = yIcon[0] = 0.0; for ( line=0; line<Lines; line++ ) { graphMarker = graph.addGraphMarker( xIcon[line] + ( 0.5 * ( xIcon[line+1] - xIcon[line] ) ), yIcon[line] + ( 0.5 * ( yIcon[line+1] - yIcon[line] ) ), "", textFont, blackColor, alignCenter ); graphMarker->setGraphMarkerPixmap( pixmap[line] ); } // Finally, add a marker for each output result QColor bluePen( "blue" ); for ( cell=0; cell<cells; cell++ ) { //fprintf( stderr, "%02d: %3.2f %3.2f\n", i, hpua[i], ros[i] ); graph.addGraphMarker( hpua[cell], ros[cell], QString( "%1" ).arg( cell + 1 ), textFont, bluePen, alignCenter ); } // Compose the graph EqVar *zVar = 0; GraphAxleParms xParms( 0.0, hpuaMax, 11 ); GraphAxleParms yParms( 0.0, rosMax, 11 ); composeGraphBasics( &graph, true, hpuaVar, rosVar, zVar, Lines, &xParms, &yParms ); // Create a separate page for this graph. translate( label, "BpDocument:FireCharacteristicsDiagram:Caption" ); graph.setSubTitle( label, subTitleFont, subTitleColor ); startNewPage( label, TocHaulChart ); // This is how we save the graph and its composer. m_composer->graph( graph, m_pageSize->m_marginLeft + m_pageSize->m_bodyWd * property()->real( "graphXOffset" ), m_pageSize->m_marginTop + m_pageSize->m_bodyHt * property()->real( "graphYOffset" ), m_pageSize->m_bodyWd * property()->real( "graphScaleWidth" ), m_pageSize->m_bodyHt * property()->real( "graphScaleHeight" ) ); // Be polite and stop the composer. m_composer->end(); delete[] ros; ros = 0; delete[] hpua; hpua = 0; return; }
void MainWindow::on_pushButton_clicked() { this->scene->clear(); out="自配置\n"; this->ui->textEdit->setText(out); QBrush redBrush(Qt::red); QBrush blueBrush(Qt::blue); QBrush yellowBrush(Qt::yellow); QPen blackPen(Qt::black); blackPen.setWidth(0.5); QPen bluePen(Qt::blue); bluePen.setWidth(0.5); self_window = new self_set; qDebug()<<"hello"<<endl; self_window->exec(); QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间 QString _time = time.toString("yyyy-MM-dd hh:mm:ss ddd"); //设置显示格式 out=out+_time+"\n"; this->ui->textEdit->setText(out); qDebug()<<this->self_window->_yes; setAlgo = new Set_algorithm; if(this->self_window->_yes==true){ this->ui->textEdit->setText(out); QString ch = (self_window->choice==1)? "平均SINR最高":"能效比最高"; out=out+"\n自配置参数预制如下:\n-----------------------\n"; out=out+"RESP0:"+QString::number(self_window->RESP0)+"\n"+ "优化标准:"+ch+"\n"+ "路损模型参数:\n"+"a="+QString::number(self_window->a)+" b="+QString::number(self_window->b)+"\n" +"覆盖率:"+QString::number(self_window->coverRate)+"%\n"+ "额定功率:"+QString::number(self_window->power)+"\n" +"临界信噪比:"+QString::number(self_window->SINR)+"\n"+ "-----------------------\n自配置开始......\n"; this->ui->textEdit->setText(out); setAlgo->RESP0=self_window->RESP0; setAlgo->choice=self_window->choice; setAlgo->coverRate=self_window->coverRate; setAlgo->power=self_window->power; setAlgo->SINR = self_window->SINR; setAlgo->a=self_window->a; setAlgo->b=self_window->b; qDebug()<<out; QString resultPower=QString::number(setAlgo->getResultPower())+"\n"; out=out+resultPower; this->ui->textEdit->setText(out); for(int i=0;i<setAlgo->apList.size();i++){ AP *temp = setAlgo->apList.at(i); qDebug()<<"x,y:"<<temp->x()<<" "<<temp->y()<<endl; if(temp->frequency==1) this->scene->addEllipse(temp->x(),temp->y(),(setAlgo->ratio)*EXR,(setAlgo->ratio)*EXR,blackPen,blueBrush); else if(temp->frequency==6) this->scene->addEllipse(temp->x(),temp->y(),(setAlgo->ratio)*EXR,(setAlgo->ratio)*EXR,blackPen,redBrush); else if(temp->frequency==11) this->scene->addEllipse(temp->x(),temp->y(),(setAlgo->ratio)*EXR,(setAlgo->ratio)*EXR,blackPen,yellowBrush); } } _addLineGraph(); }
void MainWindow::setupMainGraph(int M,int N) { this->_cleanTheList(); QBrush redBrush(Qt::red); QBrush blueBrush(Qt::blue); QBrush yellowBrush(Qt::yellow); QPen blackPen(Qt::black); blackPen.setWidth(0.5); QPen bluePen(Qt::blue); bluePen.setWidth(0.5); srand((int)time(NULL)); /* for(int i=0;i<5;i++){ elipse[i] = scene->addEllipse(-200+i*100+rand()%30,-110+rand()%30,-100,100,blackPen,redBrush); elipse[i]->setFlag(QGraphicsItem::ItemIsMovable); } for(int i=6;i<11;i++){ elipse[i] = scene->addEllipse(-200+(i-5)*100+rand()%30,100+rand()%30,-100,100,blackPen,yelloBrush); elipse[i]->setFlag(QGraphicsItem::ItemIsMovable); } for(int i=12;i<19;i++){ elipse[i] = scene->addEllipse(-200+(i-12)*100+rand()%30,300+rand()%30,-100,100,blackPen,blueBrush); elipse[i]->setFlag(QGraphicsItem::ItemIsMovable); } */ srand((int)time(NULL)); for(int j=-N;j<=N;j++){ for(int i=-M;i<=M;i++){ blue = new QGraphicsEllipseItem; blue = scene->addEllipse(2*sqrt(3)*R*i+RD,6*R*j+RD,2*R+EXTRA,2*R+EXTRA,blackPen,blueBrush); blue->setX(2*sqrt(3)*R*i+RD); blue ->setY(6*R*j+RD); blueElipse.append(blue); } } for(int j=-N;j<=N;j++){ for(int i=-M;i<=M;i++){ blue = new QGraphicsEllipseItem; blue = scene->addEllipse(-sqrt(3)*R+2*sqrt(3)*R*i+RD,-3*R+6*R*j+RD,2*R+EXTRA,2*R+EXTRA,blackPen,blueBrush); blue->setX(-sqrt(3)*R+2*sqrt(3)*R*i+RD); blue->setY(-3*R+6*R*j+RD); blueElipse.append(blue); } } for(int j=-N;j<=N;j++){ for(int i=-M;i<=M;i++){ red = new QGraphicsEllipseItem; red = scene->addEllipse(2*sqrt(3)*R*i+RD,2*R+6*R*j+RD,2*R+EXTRA,2*R+EXTRA,blackPen,redBrush); red->setX(2*sqrt(3)*R*i+RD); red->setY(2*R+6*R*j+RD); redElipse.append(red); } } for(int j=-N;j<=N;j++){ for(int i=-M;i<=M;i++){ red = new QGraphicsEllipseItem; red = scene->addEllipse(-sqrt(3)*R+2*sqrt(3)*R*i+RD,-R+6*R*j+RD,2*R+EXTRA,2*R+EXTRA,blackPen,redBrush); red->setX(-sqrt(3)*R+2*sqrt(3)*R*i+RD); red->setY(-R+6*R*j+RD); redElipse.append(red); } } for(int j=-N;j<=N;j++){ for(int i=-M;i<=M;i++){ yellow = new QGraphicsEllipseItem; yellow = scene->addEllipse(-sqrt(3)*R+2*sqrt(3)*R*i+RD,R+6*R*j+RD,2*R+EXTRA,2*R+EXTRA,blackPen,yellowBrush); yellow->setX(-sqrt(3)*R+2*sqrt(3)*R*i+RD); yellow->setY(R+6*R*j+RD); yellowElipse.append(yellow); } } for(int j=-N;j<=N;j++){ for(int i=-M;i<=M;i++){ yellow = new QGraphicsEllipseItem; yellow = scene->addEllipse(2*sqrt(3)*R*i+RD,-2*R+6*R*j+RD,2*R+EXTRA,2*R+EXTRA,blackPen,yellowBrush); yellow ->setX(2*sqrt(3)*R*i+RD); yellow ->setY(-2*R+6*R*j+RD); yellowElipse.append(yellow); } } qDebug()<<redElipse.size(); foreach(QGraphicsEllipseItem *red,redElipse){ red->setFlag(QGraphicsItem::ItemIsMovable); qDebug()<<red->x()<<" "<<red->y()<<endl; }