MCPcopy Create free account
hub / github.com/CieNTi/serial_port_plotter / addLayer

Method addLayer

qcustomplot/qcustomplot.cpp:14069–14089  ·  view source on GitHub ↗

! Adds a new layer to this QCustomPlot instance. The new layer will have the name \a name, which must be unique. Depending on \a insertMode, it is positioned either below or above \a otherLayer. Returns true on success, i.e. if there is no other layer named \a name and \a otherLayer is a valid layer inside this QCustomPlot. If \a otherLayer is 0, the highest layer in the QCustomPlo

Source from the content-addressed store, hash-verified

14067 \see layer, moveLayer, removeLayer
14068*/
14069bool QCustomPlot::addLayer(const QString &name, QCPLayer *otherLayer, QCustomPlot::LayerInsertMode insertMode)
14070{
14071 if (!otherLayer)
14072 otherLayer = mLayers.last();
14073 if (!mLayers.contains(otherLayer))
14074 {
14075 qDebug() << Q_FUNC_INFO << "otherLayer not a layer of this QCustomPlot:" << reinterpret_cast<quintptr>(otherLayer);
14076 return false;
14077 }
14078 if (layer(name))
14079 {
14080 qDebug() << Q_FUNC_INFO << "A layer exists already with the name" << name;
14081 return false;
14082 }
14083
14084 QCPLayer *newLayer = new QCPLayer(this, name);
14085 mLayers.insert(otherLayer->index() + (insertMode==limAbove ? 1:0), newLayer);
14086 updateLayerIndices();
14087 setupPaintBuffers(); // associates new layer with the appropriate paint buffer
14088 return true;
14089}
14090
14091/*!
14092 Removes the specified \a layer and returns true on success.

Callers

nothing calls this directly

Calls 3

layerFunction · 0.85
containsMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected