void PlotWidget::saveMarkers (DataBase &db) { // save plot markers QHashIterator<QString, Plot *> pit(_plots); while (pit.hasNext()) { pit.next(); Plot *p = pit.value(); QHash<QString, Marker *> markers = p->markers(); QHashIterator<QString, Marker *> mit(markers); while (mit.hasNext()) { mit.next(); Marker *m = mit.value(); if (m->readOnly()) continue; if (! m->modified()) continue; Entity *e = m->settings(); e->setName(mit.key()); db.transaction(); db.set(e); db.commit(); m->setModified(FALSE); } } }
GrLayerAtlas::GrLayerAtlas(GrTextureProvider* texProvider, GrPixelConfig config, GrSurfaceFlags flags, const SkISize& backingTextureSize, int numPlotsX, int numPlotsY) { fTexProvider = texProvider; fPixelConfig = config; fFlags = flags; fBackingTextureSize = backingTextureSize; int textureWidth = fBackingTextureSize.width(); int textureHeight = fBackingTextureSize.height(); int plotWidth = textureWidth / numPlotsX; int plotHeight = textureHeight / numPlotsY; SkASSERT(plotWidth * numPlotsX == textureWidth); SkASSERT(plotHeight * numPlotsY == textureHeight); // We currently do not support compressed atlases... SkASSERT(!GrPixelConfigIsCompressed(config)); // set up allocated plots fPlotArray = new Plot[numPlotsX * numPlotsY]; Plot* currPlot = fPlotArray; for (int y = numPlotsY-1; y >= 0; --y) { for (int x = numPlotsX-1; x >= 0; --x) { currPlot->init(y*numPlotsX+x, x, y, plotWidth, plotHeight); // build LRU list fPlotList.addToHead(currPlot); ++currPlot; } } }
void PlotWidget::setScrollBarSize () { bool flag = FALSE; int page = 0; int max = 0; QHashIterator<QString, Plot *> it(_plots); while (it.hasNext()) { it.next(); Plot *plot = it.value(); int tpage, tmax; plot->scrollBarSize(tpage, tmax); if (! flag) { page = tpage; max = tmax; flag = TRUE; } else { if (tpage > page) page = tpage; if (tmax > max) max = tmax; } } _cw->setScrollBar(0, max, page); }
void PlotCurve::computeWaterfallOffsets() { Plot *plot = static_cast<Plot *>(this->plot()); Graph *g = static_cast<Graph *>(plot->parent()); // reset the offsets d_x_offset = 0.0; d_y_offset = 0.0; if (g->isWaterfallPlot()) { int index = g->curveIndex(this); int curves = g->curves(); auto firstCurve = g->curve(0); // Get the minimum value of the first curve in this plot double ymin = firstCurve ? firstCurve->minYValue() : 0.0; PlotCurve *c = dynamic_cast<PlotCurve *>(g->curve(0)); if (index > 0 && c) { // Compute offsets based on the maximum value for the curve d_x_offset = index * g->waterfallXOffset() * 0.01 * g->curve(0)->maxXValue() / (double)(curves - 1); d_y_offset = index * g->waterfallYOffset() * 0.01 * g->curve(0)->maxYValue() / (double)(curves - 1); setZ(-index); setBaseline(ymin - d_y_offset); // Fill down to minimum value of first curve } else { setZ(0); setBaseline(ymin); // This is for when 'fill under curve' is turn on } if (g->grid()) g->grid()->setZ(-g->curves() /*Count()*/ - 1); } }
void PlotWidget::removePlot (QString name) { Plot *plot = _plots.value(name); if (! plot) return; Entity *e = _settings.value(name); if (! e) return; // remove markers DataBase db(g_session); db.transaction(); QHash<QString, Marker *> markers = plot->markers(); QList<QString> ml = markers.keys(); db.remove(ml); // remove indicator settings db.remove(QStringList() << name); db.commit(); delete plot; delete e; _plots.remove(name); _settings.remove(name); }
void plotsDialog::print() { QPrinter printer( QPrinter::HighResolution ); Plot* currentPlot = dynamic_cast<Plot*>(tabs->currentWidget()); QString docName = currentPlot->title().text(); if ( !docName.isEmpty() ) { docName.replace ( QRegExp ( QString::fromLatin1 ( "\n" ) ), tr ( " -- " ) ); printer.setDocName ( docName ); } printer.setCreator( currentPlot->title().text()); printer.setOrientation( QPrinter::Landscape ); QPrintDialog dialog( &printer ); if ( dialog.exec() ) { QwtPlotRenderer renderer; if ( printer.colorMode() == QPrinter::GrayScale ) { renderer.setDiscardFlag( QwtPlotRenderer::DiscardBackground ); renderer.setDiscardFlag( QwtPlotRenderer::DiscardCanvasBackground ); renderer.setDiscardFlag( QwtPlotRenderer::DiscardCanvasFrame ); renderer.setLayoutFlag( QwtPlotRenderer::FrameWithScales ); } renderer.renderTo( currentPlot, printer ); } }
void Plotter::handlePlotData(const plot_msgs::PlotConstPtr& data) { if(m_blocked || m_ui->pauseButton->isChecked()) return; for(std::size_t i = 0; i < data->points.size(); ++i) { const plot_msgs::PlotPoint& point = data->points[i]; QString name = QString::fromStdString(point.name); if(name.isEmpty()) continue; Plot* plot = m_plotModel->rootPlot()->findOrCreatePlotByPath(name); plot->put(data->header.stamp, point.value, NULL, true, false); } for(std::size_t i = 0; i < data->events.size(); ++i) { const std::string& event = data->events[i]; QString name = QString::fromStdString(event); if(name.isEmpty()) continue; Plot* plot = m_plotModel->rootPlot()->findOrCreatePlotByPath(name); plot->setIsEventChannel(true); plot->put(data->header.stamp, NAN, &m_labelY, true, false); } }
void plotsDialog::resetZoomer(int i) { Plot* currentPlot = dynamic_cast<Plot*>(tabs->currentWidget()); d_zoomer[0] = new Zoomer( QwtPlot::xBottom, QwtPlot::yLeft, currentPlot->canvas() ); d_zoomer[0]->setRubberBand( QwtPicker::RectRubberBand ); d_zoomer[0]->setRubberBandPen( QColor( Qt::green ) ); d_zoomer[0]->setTrackerMode( QwtPicker::ActiveOnly ); d_zoomer[0]->setTrackerPen( QColor( Qt::white ) ); d_zoomer[1] = new Zoomer( QwtPlot::xTop, QwtPlot::yRight, currentPlot->canvas() ); d_panner = new QwtPlotPanner( currentPlot->canvas() ); d_panner->setMouseButton( Qt::MidButton ); d_picker = new QwtPlotPicker( QwtPlot::xBottom, QwtPlot::yLeft, QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, currentPlot->canvas() ); d_picker->setStateMachine( new QwtPickerDragPointMachine() ); d_picker->setRubberBandPen( QColor( Qt::green ) ); d_picker->setRubberBand( QwtPicker::CrossRubberBand ); d_picker->setTrackerPen( QColor( Qt::white ) ); connect(d_picker,SIGNAL(moved(QPoint)),SLOT(moved(QPoint))); ui->overlayButton->setHidden(currentPlot->isParametric); ui->dataSelectButton->setHidden(!currentPlot->isParametric); enableZoomMode(false); }
int main ( int argc, char **argv ) { #if USE_OPENGL #if QT_VERSION >= 0x040600 && QT_VERSION < 0x050000 // on my box QPaintEngine::OpenGL2 has serious problems, f.e: // the lines of a simple drawRect are wrong. QGL::setPreferredPaintEngine( QPaintEngine::OpenGL ); #endif #endif QApplication a( argc, argv ); Plot plot; #if USE_OPENGL QwtPlotGLCanvas *canvas = new QwtPlotGLCanvas(); canvas->setFrameStyle( QwtPlotGLCanvas::NoFrame ); #else QwtPlotCanvas *canvas = new QwtPlotCanvas(); canvas->setFrameStyle( QFrame::NoFrame ); canvas->setPaintAttribute( QwtPlotCanvas::BackingStore, false ); #endif plot.setCanvas( canvas ); plot.setCanvasBackground( QColor( 30, 30, 50 ) ); plot.resize( 400, 400 ); plot.show(); return a.exec(); }
bool TestPlotWithArea::DoTest() { Plot *plot; plot = new Plot(); Area *area = new Area2D(); Box *box1, *box2; box1 = new Box(plot); box2 = new Box(plot); Series *series; series = new Series2D("Series"); DataTyped<int> *xdata; xdata = new DataTyped<int>(); series->SetData(xdata, AXIS_X); area->AddSeries(series); plot->AddArea(area); delete box1; delete plot; return true; }
int main(int argc, char **argv) { QApplication a(argc, argv); Plot plot; plot.resize(800,600); plot.show(); return a.exec(); }
void plotsDialog::edit() { Plot* currentPlot = dynamic_cast<Plot*>(tabs->currentWidget()); curvesetting * dialog = new curvesetting(¤tPlot->curvelist,currentPlot,this); dialog->setModal(true); if (dialog->exec()== QDialog::Accepted) currentPlot->replot(); }
QString PlotCurve::saveCurveLayout() { Plot *plot = static_cast<Plot *>(this->plot()); Graph *g = static_cast<Graph *>(plot->parent()); int index = g->curveIndex(static_cast<QwtPlotCurve *>(this)); int style = g->curveType(index); QString s = "<Style>" + QString::number(style) + "</Style>\n"; if (style == Graph::Spline) s += "<LineStyle>5</LineStyle>\n"; else if (style == Graph::VerticalSteps) s += "<LineStyle>6</LineStyle>\n"; else s += "<LineStyle>" + QString::number(this->style()) + "</LineStyle>\n"; QPen pen = this->pen(); if (pen.style() != Qt::NoPen){ s += "<Pen>\n"; s += "\t<Color>" + pen.color().name() + "</Color>\n"; s += "\t<Style>" + QString::number(pen.style()-1) + "</Style>\n"; s += "\t<Width>" + QString::number(pen.widthF()) + "</Width>\n"; s += "</Pen>\n"; } QBrush brush = this->brush(); if (brush.style() != Qt::NoBrush){ s += "<Brush>\n"; s += "\t<Color>" + brush.color().name() + "</Color>\n"; s += "\t<Style>" + QString::number(PatternBox::patternIndex(brush.style())) + "</Style>\n"; s += "</Brush>\n"; } const QwtSymbol symbol = this->symbol(); if (symbol.style() != QwtSymbol::NoSymbol){ s += "<Symbol>\n"; s += "\t<Style>" + QString::number(SymbolBox::symbolIndex(symbol.style())) + "</Style>\n"; s += "\t<Size>" + QString::number(symbol.size().width()) + "</Size>\n"; s += "\t<SymbolPen>\n"; s += "\t\t<Color>" + symbol.pen().color().name() + "</Color>\n"; s += "\t\t<Width>" + QString::number(symbol.pen().widthF()) + "</Width>\n"; s += "\t</SymbolPen>\n"; brush = this->brush(); if (brush.style() != Qt::NoBrush){ s += "\t<SymbolBrush>\n"; s += "\t\t<Color>" + symbol.brush().color().name() + "</Color>\n"; s += "\t\t<Style>" + QString::number(PatternBox::patternIndex(symbol.brush().style())) + "</Style>\n"; s += "\t</SymbolBrush>\n"; } s += "</Symbol>\n"; } s += "<xAxis>" + QString::number(xAxis()) + "</xAxis>\n"; s += "<yAxis>" + QString::number(yAxis()) + "</yAxis>\n"; s += "<Visible>" + QString::number(isVisible()) + "</Visible>\n"; return s; }
void plotsDialog::moved(const QPoint &pos) { Plot* currentPlot = dynamic_cast<Plot*>(tabs->currentWidget()); QString info; info.sprintf( "X=%g, Y=%g",currentPlot->invTransform(QwtPlot::xBottom,pos.x()) ,currentPlot->invTransform(QwtPlot::yLeft,pos.y())); showInfo( info ); }
PlotTab( bool parametric, QWidget *parent ): QMainWindow( parent ) { Plot *plot = new Plot( parametric, this ); setCentralWidget( plot ); QToolBar *toolBar = new QToolBar( this ); #ifndef QT_NO_PRINTER ToolButton *btnPrint = new ToolButton( "Print", toolBar ); toolBar->addWidget( btnPrint ); QObject::connect( btnPrint, SIGNAL( clicked() ), plot, SLOT( printPlot() ) ); #endif ToolButton *btnOverlay = new ToolButton( "Overlay", toolBar ); btnOverlay->setCheckable( true ); toolBar->addWidget( btnOverlay ); QObject::connect( btnOverlay, SIGNAL( toggled( bool ) ), plot, SLOT( setOverlaying( bool ) ) ); if ( parametric ) { QComboBox *parameterBox = new QComboBox( toolBar ); parameterBox->addItem( "Uniform" ); parameterBox->addItem( "Centripetral" ); parameterBox->addItem( "Chordal" ); parameterBox->addItem( "Manhattan" ); toolBar->addWidget( parameterBox ); connect( parameterBox, SIGNAL( activated( const QString & ) ), plot, SLOT( setParametric( const QString & ) ) ); parameterBox->setCurrentIndex( 2 ); // chordal plot->setParametric( parameterBox->currentText() ); ToolButton *btnClosed = new ToolButton( "Closed", toolBar ); btnClosed->setCheckable( true ); toolBar->addWidget( btnClosed ); QObject::connect( btnClosed, SIGNAL( toggled( bool ) ), plot, SLOT( setClosed( bool ) ) ); } QComboBox *boundaryBox = new QComboBox( toolBar ); boundaryBox->addItem( "Natural" ); boundaryBox->addItem( "Linear Runout" ); boundaryBox->addItem( "Parabolic Runout" ); boundaryBox->addItem( "Cubic Runout" ); boundaryBox->addItem( "Not a Knot" ); toolBar->addWidget( boundaryBox ); connect( boundaryBox, SIGNAL( activated( const QString & ) ), plot, SLOT( setBoundaryCondition( const QString & ) ) ); addToolBar( toolBar ); }
void pieDialog::setMultiLayerPlot(MultiLayer *m) { mPlot = m; Graph* g = (Graph*)mPlot->activeGraph(); Plot *p = g->plotWidget(); boxMargin->setValue (p->margin()); boxBorderWidth->setValue(p->lineWidth()); boxBorderColor->setColor(p->frameColor()); boxBackgroundColor->setColor(p->paletteBackgroundColor()); }
int main(int argc, char **argv) { QApplication a(argc, argv); Plot plot; #if QT_VERSION < 0x040000 a.setMainWidget(&plot); #endif plot.resize(800,600); plot.show(); return a.exec(); }
Plot* buildAndCacheP(int x, int y) { int linear_index = y * width + x; Plot* cachedPtr(cache[linear_index]); if (cachedPtr != nullptr) { //std::cout << "from cache: " << cachedPtr << std::endl; return cachedPtr; } Plot *p = Plot::create(x, y, width); cache[p->Id()] = p; //std::cout << "buildAndCache: " << cache[p->Id()] << " => " << x << ", " << y << std::endl; return p; }
void Garrison::CancelBuildingConstruction(uint32 garrPlotInstanceId) { WorldPackets::Garrison::GarrisonBuildingRemoved buildingRemoved; buildingRemoved.GarrTypeID = GARRISON_TYPE_GARRISON; buildingRemoved.Result = CheckBuildingRemoval(garrPlotInstanceId); if (buildingRemoved.Result == GARRISON_SUCCESS) { Plot* plot = GetPlot(garrPlotInstanceId); buildingRemoved.GarrPlotInstanceID = garrPlotInstanceId; buildingRemoved.GarrBuildingID = plot->BuildingInfo.PacketInfo->GarrBuildingID; Map* map = FindMap(); if (map) plot->DeleteGameObject(map); plot->ClearBuildingInfo(_owner); _owner->SendDirectMessage(buildingRemoved.Write()); GarrBuildingEntry const* constructing = sGarrBuildingStore.AssertEntry(buildingRemoved.GarrBuildingID); // Refund construction/upgrade cost _owner->ModifyCurrency(constructing->CostCurrencyID, constructing->CostCurrencyAmount, false, true); _owner->ModifyMoney(constructing->CostMoney * GOLD, false); if (constructing->Level > 1) { // Restore previous level building uint32 restored = sGarrisonMgr.GetPreviousLevelBuildingId(constructing->Type, constructing->Level); ASSERT(restored); WorldPackets::Garrison::GarrisonPlaceBuildingResult placeBuildingResult; placeBuildingResult.GarrTypeID = GARRISON_TYPE_GARRISON; placeBuildingResult.Result = GARRISON_SUCCESS; placeBuildingResult.BuildingInfo.GarrPlotInstanceID = garrPlotInstanceId; placeBuildingResult.BuildingInfo.GarrBuildingID = restored; placeBuildingResult.BuildingInfo.TimeBuilt = time(nullptr); placeBuildingResult.BuildingInfo.Active = true; plot->SetBuildingInfo(placeBuildingResult.BuildingInfo, _owner); _owner->SendDirectMessage(placeBuildingResult.Write()); } if (map) if (GameObject* go = plot->CreateGameObject(map, GetFaction())) map->AddToMap(go); } else _owner->SendDirectMessage(buildingRemoved.Write()); }
void Garrison::PlaceBuilding(uint32 garrPlotInstanceId, uint32 garrBuildingId) { WorldPackets::Garrison::GarrisonPlaceBuildingResult placeBuildingResult; placeBuildingResult.GarrTypeID = GARRISON_TYPE_GARRISON; placeBuildingResult.Result = CheckBuildingPlacement(garrPlotInstanceId, garrBuildingId); if (placeBuildingResult.Result == GARRISON_SUCCESS) { placeBuildingResult.BuildingInfo.GarrPlotInstanceID = garrPlotInstanceId; placeBuildingResult.BuildingInfo.GarrBuildingID = garrBuildingId; placeBuildingResult.BuildingInfo.TimeBuilt = time(nullptr); Plot* plot = GetPlot(garrPlotInstanceId); uint32 oldBuildingId = 0; Map* map = FindMap(); GarrBuildingEntry const* building = sGarrBuildingStore.AssertEntry(garrBuildingId); if (map) plot->DeleteGameObject(map); if (plot->BuildingInfo.PacketInfo) { oldBuildingId = plot->BuildingInfo.PacketInfo->GarrBuildingID; if (sGarrBuildingStore.AssertEntry(oldBuildingId)->Type != building->Type) plot->ClearBuildingInfo(_owner); } plot->SetBuildingInfo(placeBuildingResult.BuildingInfo, _owner); if (map) if (GameObject* go = plot->CreateGameObject(map, GetFaction())) map->AddToMap(go); _owner->ModifyCurrency(building->CostCurrencyID, -building->CostCurrencyAmount, false, true); _owner->ModifyMoney(-building->CostMoney * GOLD, false); if (oldBuildingId) { WorldPackets::Garrison::GarrisonBuildingRemoved buildingRemoved; buildingRemoved.GarrTypeID = GARRISON_TYPE_GARRISON; buildingRemoved.Result = GARRISON_SUCCESS; buildingRemoved.GarrPlotInstanceID = garrPlotInstanceId; buildingRemoved.GarrBuildingID = oldBuildingId; _owner->SendDirectMessage(buildingRemoved.Write()); } _owner->UpdateCriteria(CRITERIA_TYPE_PLACE_GARRISON_BUILDING, garrBuildingId); } _owner->SendDirectMessage(placeBuildingResult.Write()); }
MyPanner(Plot* plot) : QObject(plot) { mEnabled = false; mMouseButton = Qt::LeftButton; mKeyboardButton = Qt::NoButton; mPlot = plot; mPlot->canvas()->installEventFilter(this); }
// Normally, a value < 1.0 zooms in, a value > 1.0 zooms out. // This function is overloaded to invert the magnification direction. virtual void rescale( double factor ) { factor = qAbs( factor ); factor = (1-factor) + 1; mPlot->flagAxisSyncRequired(); this->QwtPlotMagnifier::rescale(factor); }
void PlotWidget::saveSettings () { DataBase db(g_session); db.transaction(); // save controlWidget settings _cw->saveSettings(&db); // save this settings Entity *e = settings(); db.set(e); delete e; QHashIterator<QString, Entity *> it(_settings); while (it.hasNext()) { it.next(); Entity *e = it.value(); Plot *p = _plots.value(it.key()); if (! p) continue; QVariant *tset = e->get(QString("date")); if (tset) tset->setValue(p->date()); tset = e->get(QString("grid")); if (tset) tset->setValue(p->grid()); tset = e->get(QString("info")); if (tset) tset->setValue(p->info()); // save indicator settings db.set(e); } // save markers saveMarkers(db); db.commit(); }
void MantidMatrixCurve::loadData() { // This should only be called for waterfall plots // Calculate the offsets... double xDataOffset = 0.0; double yDataOffset = 0.0; computeWaterfallOffsets(xDataOffset, yDataOffset); Plot *plot = static_cast<Plot *>(this->plot()); Graph *g = static_cast<Graph *>(plot->parent()); MantidQwtWorkspaceData &data = dynamic_cast<MantidQwtWorkspaceData &>(this->data()); data.setWaterfallPlot(g->isWaterfallPlot()); data.setXOffset(xDataOffset); data.setYOffset(yDataOffset); invalidateBoundingRect(); }
void PlotWidget::loadMarkers (DataBase &db) { // load marker names QStringList names; db.getTypes(QString("marker"), names); for (int pos = 0; pos < names.size(); pos++) { Entity te; te.setName(names.at(pos)); te.set(QString("plugin"), new QVariant(QString())); te.set(QString("plot"), new QVariant(QString())); te.set(QString("symbol"), new QVariant(QString())); if (! db.get(&te)) continue; QVariant *tset = te.get(QString("symbol")); if (tset->toString() != g_symbol->symbol()) continue; tset = te.get(QString("plot")); Plot *p = _plots.value(tset->toString()); if (! p) { qDebug() << "PlotWidget::loadMarkers: plot not found" << tset->toString(); continue; } tset = te.get(QString("plugin")); Marker *m = new Marker(tset->toString()); m->setID(names.at(pos)); Entity *e = m->settings(); e->setName(names.at(pos)); db.get(e); p->setMarker(m); } }
bool Crops::is_used_plot(const Plot& plot) const { for (auto it = _vcrops.cbegin(); it != _vcrops.cend(); ++it) { if ((*it)->get_shape().overlaps(plot.get_shape())) { return true; } } return false; }
void PlotWidget::addPlot (QString plugin, int row, QString name) { PluginFactory fac; Plugin *plug = fac.load(plugin); if (! plug) return; PluginData pd; pd.command = QString("settings"); if (! plug->command(&pd)) return; Entity *settings = pd.settings; settings->setName(name); _settings.insert(name, settings); addPlotSettings(settings); QVariant *tset = settings->get(QString("row")); if (tset) tset->setValue(row); Plot *plot = new Plot(name, 0); plot->setMinimumHeight(30); _plots.insert(name, plot); _csplitter->insertWidget(row, plot); plot->setStartIndex(_cw->scrollBarValue()); // connect all we need here connect(plot, SIGNAL(signalResizeScrollBar(Plot *)), _cw, SLOT(resizeScrollBar(Plot *))); connect(this, SIGNAL(signalClear()), plot, SLOT(clear())); connect(this, SIGNAL(signalDraw()), plot, SLOT(updatePlot())); connect(this, SIGNAL(signalSetDates()), plot, SLOT(setDates())); connect(this, SIGNAL(signalBarLength(int)), plot, SLOT(setBarLength(int))); connect(this, SIGNAL(signalIndex(int)), plot, SLOT(setStartIndex(int))); connect(plot, SIGNAL(signalMessage(QString)), this, SIGNAL(signalMessage(QString))); connect(plot, SIGNAL(signalDeleteMarkers(QStringList)), this, SLOT(deleteMarkers(QStringList))); }
void PlotWidget::setPanScrollBarSize () { int range = _controlWidget->getRange(); bool flag = false; int page = 0; int max = 0; int min = 0; int end, start; QHashIterator<QString, Plot *> it(_plots); while (it.hasNext()) { it.next(); Plot *plot = it.value(); PlotSettings pPlotSettings = plot->getPlotSettings(); start = pPlotSettings.startPos; end = pPlotSettings.endPos; int tpage, tmax; plot->panScrollBarSize(tpage, tmax); if (! flag) { page = tpage; max = tmax; flag = true; } else { if (tpage > page) page = tpage; if (tmax > max) max = tmax; } // max = end; // min = start; } // qDebug() << "range : " << range; // qDebug() << "(page + max) : " << (page + max); qDebug() << "start " << start << "end "<< end; max = (max + page) - range; _controlWidget->setPan(end-start, max, page); }
void pieDialog::setMultiLayerPlot(MultiLayer *m) { mPlot = m; Graph* g = (Graph*)mPlot->activeGraph(); QwtPieCurve *pie = (QwtPieCurve *)g->curve(0); if (!pie) return; Plot *p = g->plotWidget(); boxMargin->setValue (p->margin()); boxBorderWidth->setValue(p->lineWidth()); boxBorderColor->setColor(p->frameColor()); boxBackgroundColor->setColor(p->paletteBackgroundColor()); boxCanvasColor->setColor(p->canvasBackground()); curvesList->insertItem(pie->title().text()); curvesList->setCurrentItem (0); boxRay->setValue(pie->ray()); boxPattern->setPattern(pie->pattern()); boxLineWidth->setValue(pie->pen().width()); boxLineColor->setColor(pie->pen().color()); setBorderStyle(pie->pen().style()); boxFirstColor->setCurrentItem(pie->first()); }
GrLayerAtlas::Plot* GrLayerAtlas::addToAtlas(ClientPlotUsage* usage, int width, int height, SkIPoint16* loc) { // Iterate through the plots currently being used by this client and see if we can find a hole. // The last one was most recently added and probably most empty. // We want to consolidate the uses from individual clients to the same plot(s) so that // when a specific client goes away they are more likely to completely empty a plot. for (int i = usage->numPlots()-1; i >= 0; --i) { Plot* plot = usage->plot(i); if (plot->allocateRect(width, height, loc)) { this->makeMRU(plot); return plot; } } // before we get a new plot, make sure we have a backing texture if (nullptr == fTexture) { this->createBackingTexture(); if (nullptr == fTexture) { return nullptr; } } // Now look through all allocated plots for one we can share, in MRU order // TODO: its seems like traversing from emptiest to fullest would make more sense PlotList::Iter plotIter; plotIter.init(fPlotList, PlotList::Iter::kHead_IterStart); Plot* plot; while ((plot = plotIter.get())) { if (plot->allocateRect(width, height, loc)) { this->makeMRU(plot); // new plot for atlas, put at end of array usage->appendPlot(plot); return plot; } plotIter.next(); } // If the above fails, then the current plot list has no room return nullptr; }