@@ -2738,24 +2738,24 @@ void SurfaceManager::saveAllContours(){
27382738 m_allContours.save ( fName );
27392739}
27402740
2741- #include " showallcontoursdlg.h"
2742- void SurfaceManager::showAllContours (){
2743- showAllContoursDlg dlg;
2741+ #include " showallcontoursdlg.h" // TODO move
2742+ void SurfaceManager::showAllContours (){ // TODO move to contourview would make more sense as use only there
2743+ showAllContoursDlg dlg; // TODO not closing on app close
27442744 if (!dlg.exec ()) {
27452745 return ;
27462746 }
27472747 QRect rec = QGuiApplication::primaryScreen ()->geometry ();
27482748 QApplication::setOverrideCursor (Qt::WaitCursor);
2749- ContourPlot *plot =new ContourPlot (0 ,0 );// m_contourPlot;
2750- // plot->m_minimal = true;
2751- int cols = dlg.getColumns ();
2749+ ContourPlot *plot =new ContourPlot (0 ,0 );// m_contourPlot; //TODO leaking ?
2750+ // plot->m_minimal = true;
2751+ int cols = dlg.getColumns (); // TODO parameter number of pixels unused here. update the dlg ui
27522752 int width = rec.width ()/cols;
27532753 int height = width * .82 ;
27542754 surfaceAnalysisTools *saTools = surfaceAnalysisTools::get_Instance ();
27552755 QList<int > list = saTools->SelectedWaveFronts ();
27562756
2757- int rows = ceil ((double )list.size ()/cols);
2758- int columns = std::min ((int )list.size (),int (ceil ((double )list.size ()/rows)));
2757+ int rows = ceil ((float )list.size ()/cols);
2758+ int columns = std::min ((int )list.size (),int (ceil ((float )list.size ()/rows)));
27592759 const QSizeF size (columns * (width + 10 ), rows * (height + 10 ));
27602760 const QRect imageRect = QRect (0 ,0 ,size.width (),size.height ());
27612761 qDebug () << " save all" << imageRect;
@@ -2774,11 +2774,27 @@ void SurfaceManager::showAllContours(){
27742774 {
27752775 wavefront * wf = m_wavefronts[list[i]];
27762776 plot->setSurface (wf);
2777+
2778+ // All these replots and updates are necessary to get the canvas updateAspectRatio to work properly.
2779+
2780+ // Resize the outer plot so its internal canvas area will match
2781+ // the requested image size.
2782+ plot->resize (width, height);
2783+ QCoreApplication::processEvents ();
2784+ // Now ensure the canvas is the target size
2785+ if (plot->canvas ())
2786+ plot->canvas ()->resize (width, height);
2787+ plot->updateAspectRatio ();
2788+ plot->replot ();
2789+ plot->updateAspectRatio ();
27772790 plot->replot ();
2791+
2792+
27782793 int y_offset = height * (i/columns) + 10 ;
27792794 int x_offset = width * (i%columns) + 10 ;
27802795 const QRectF topRect ( x_offset, y_offset, width, height );
27812796 renderer.render ( plot, &painter, topRect );
2797+
27822798 }
27832799 painter.end ();
27842800
0 commit comments