void MultiLayer::confirmRemoveLayer() { if (graphs>1) { switch(QMessageBox::information(this, tr("QtiPlot - Guess best origin for the new layer?"), tr("Do you want QtiPlot to rearrange the remaining layers?"), tr("&Yes"), tr("&No"), tr("&Cancel"), 0, 2) ) { case 0: removeLayer(); arrangeLayers(0, 0, 5, 5, true); break; case 1: removeLayer(); break; case 2: return; break; } } else removeLayer(); }
void MultiLayer::confirmRemoveLayer() { if (graphs > 1) { switch (QMessageBox::information( this, tr("Guess best layout?"), tr("Do you want AlphaPlot to rearrange the remaining layers?"), tr("&Yes"), tr("&No"), tr("&Cancel"), 0, 2)) { case 0: removeLayer(); arrangeLayers(true, false); break; case 1: removeLayer(); break; case 2: return; break; } } else { removeLayer(); if(!active_graph) removeLayoutButton->setEnabled(false); } }
void MultiLayer::arrangeLayers(bool fit, bool userSize) { if (!graphs) return; QApplication::setOverrideCursor(Qt::waitCursor); if (d_layers_selector) delete d_layers_selector; if (fit) findBestLayout(rows, cols); // the canvas sizes of all layers become equal only after several // resize iterations, due to the way Qwt handles the plot layout int iterations = 0; QSize size = arrangeLayers(userSize); QSize canvas_size = QSize(1, 1); while (canvas_size != size && iterations < 10) { iterations++; canvas_size = size; size = arrangeLayers(userSize); } if (userSize) { // resize window bool ignoreResize = active_graph->ignoresResizeEvents(); for (int i = 0; i < (int)graphsList.count(); i++) { Graph *gr = (Graph *)graphsList.at(i); gr->setIgnoreResizeEvents(true); } this->showNormal(); QSize size = canvas->childrenRect().size(); this->resize(QSize(size.width() + right_margin, size.height() + bottom_margin + LayerButton::btnSize())); for (int i = 0; i < (int)graphsList.count(); i++) { Graph *gr = (Graph *)graphsList.at(i); gr->setIgnoreResizeEvents(ignoreResize); } } emit modifiedPlot(); QApplication::restoreOverrideCursor(); }
void MultiLayer::arrangeLayers(int c, int r, int colsGap, int rowsGap, bool fit) { if (fit) { int rows, cols; findBestLayout(rows, cols); double canvas_width=double(canvas->width()-(cols-1)*colsSpace - 10)/(double)cols; double canvas_height=double(canvas->height()-(rows-1)*rowsSpace - 10)/(double)rows;; QSize layer_size = QSize((int)canvas_width, (int)canvas_height); for (int i=0; i<graphs; i++) { Graph *gr=(Graph *)graphsList->at(i); gr->resize(layer_size); } arrangeLayers(cols, rows, colsGap, rowsGap); } else arrangeLayers(c, r, colsGap, rowsGap); }