! initializes all member variables of \c CartesianPlot */
| 133 | initializes all member variables of \c CartesianPlot |
| 134 | */ |
| 135 | void CartesianPlot::init(bool loading) { |
| 136 | // initialize the children objects |
| 137 | m_plotArea = new PlotArea(name() + QStringLiteral(" plot area"), this); |
| 138 | connect(m_plotArea, &WorksheetElement::changed, this, &WorksheetElement::changed); |
| 139 | addChildFast(m_plotArea); |
| 140 | |
| 141 | // title |
| 142 | m_title = new TextLabel(this->name() + QLatin1String(" - ") + i18n("Title"), TextLabel::Type::PlotTitle); |
| 143 | addChild(m_title); |
| 144 | m_title->setHidden(true); |
| 145 | m_title->setParentGraphicsItem(m_plotArea->graphicsItem()); |
| 146 | |
| 147 | Q_D(CartesianPlot); |
| 148 | |
| 149 | // cursor line |
| 150 | d->cursorLine = new Line(QString()); |
| 151 | d->cursorLine->setPrefix(QLatin1String("Cursor")); |
| 152 | d->cursorLine->setHidden(true); |
| 153 | addChild(d->cursorLine); |
| 154 | connect(d->cursorLine, &Line::updatePixmapRequested, [=] { |
| 155 | d->update(); |
| 156 | }); |
| 157 | connect(d->cursorLine, &Line::updateRequested, [=] { |
| 158 | d->update(); |
| 159 | }); |
| 160 | |
| 161 | connect(this, &AbstractAspect::childAspectAdded, this, &CartesianPlot::childAdded); |
| 162 | connect(this, &AbstractAspect::childAspectRemoved, this, &CartesianPlot::childRemoved); |
| 163 | |
| 164 | // if not loading, initialize the default properties (read in load() otherweise) |
| 165 | if (loading) |
| 166 | return; |
| 167 | |
| 168 | m_coordinateSystems << new CartesianCoordinateSystem(this); |
| 169 | |
| 170 | // TODO: load from KConfigGroup |
| 171 | |
| 172 | // offset between the plot area and the area defining the coordinate system, in scene units. |
| 173 | d->horizontalPadding = Worksheet::convertToSceneUnits(1.5, Worksheet::Unit::Centimeter); |
| 174 | d->verticalPadding = Worksheet::convertToSceneUnits(1.5, Worksheet::Unit::Centimeter); |
| 175 | d->rightPadding = Worksheet::convertToSceneUnits(1.5, Worksheet::Unit::Centimeter); |
| 176 | d->bottomPadding = Worksheet::convertToSceneUnits(1.5, Worksheet::Unit::Centimeter); |
| 177 | |
| 178 | d->cursorLine->setStyle(Qt::SolidLine); |
| 179 | d->cursorLine->setColor(Qt::red); // TODO: use theme specific initial settings |
| 180 | d->cursorLine->setWidth(Worksheet::convertToSceneUnits(1.0, Worksheet::Unit::Point)); |
| 181 | |
| 182 | // theme is not set at this point, initialize the color palette with default colors |
| 183 | this->setColorPalette(KConfig()); |
| 184 | } |
| 185 | |
| 186 | /*! |
| 187 | initializes all children of \c CartesianPlot and |
nothing calls this directly
no test coverage detected