From 9e49012cd8afd1df01fa6db0729115b0a7f1cf71 Mon Sep 17 00:00:00 2001 From: even <philippe.even@loria.fr> Date: Wed, 5 Dec 2018 23:32:29 +0100 Subject: [PATCH] Aux view capture --- Code/Seg/BSTools/bsaccumulatoritem.cpp | 2 +- Code/Seg/BSTools/bsaccumulatoritem.h | 10 ++++++++++ Code/Seg/BSTools/bsaccumulatorview.cpp | 10 +++++++++- Code/Seg/BSTools/bsdetectionwidget.cpp | 3 ++- Code/Seg/BSTools/bsidetitem.cpp | 8 +++++++- Code/Seg/BSTools/bsidetitem.h | 20 ++++++++++++++------ Code/Seg/BSTools/bsidetview.cpp | 25 ++++++++++++++++++++----- Code/Seg/BSTools/bsidetview.h | 5 +++++ Code/Seg/BSTools/bsprofileitem.h | 10 ++++++++++ Code/Seg/BSTools/bsprofileview.cpp | 8 ++++++++ Code/Seg/BSTools/bsstructureitem.h | 10 ++++++++++ Code/Seg/BSTools/bsstructureview.cpp | 8 ++++++++ Methode/ctrl.tex | 6 ++++-- 13 files changed, 108 insertions(+), 17 deletions(-) diff --git a/Code/Seg/BSTools/bsaccumulatoritem.cpp b/Code/Seg/BSTools/bsaccumulatoritem.cpp index 31aba67..30d1306 100755 --- a/Code/Seg/BSTools/bsaccumulatoritem.cpp +++ b/Code/Seg/BSTools/bsaccumulatoritem.cpp @@ -108,7 +108,7 @@ void BSAccumulatorItem::paint (QPainter *painter, addText (painter, QString ("R resolution : ") + QString::number (resol[0]) + QString (" pixels x ") + QString::number (resol[1]) + QString (" degrees")); - addText (painter, QString ("P sub-pixellisation level : ") + addText (painter, QString ("W sub-pixellisation level : ") + QString::number (hugues->getSubpix ())); addText (painter, QString ("F selectivity : ") + QString::number (hugues->getSelectionThreshold ()) diff --git a/Code/Seg/BSTools/bsaccumulatoritem.h b/Code/Seg/BSTools/bsaccumulatoritem.h index 80c923e..6095f22 100755 --- a/Code/Seg/BSTools/bsaccumulatoritem.h +++ b/Code/Seg/BSTools/bsaccumulatoritem.h @@ -47,6 +47,16 @@ public: void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + /** + * \brief Returns the accumulator width. + */ + inline int getWidth () const { return width; } + + /** + * \brief Returns the accumulator height. + */ + inline int getHeight () const { return height; } + /** * \brief Switches on or off the information text display modality. */ diff --git a/Code/Seg/BSTools/bsaccumulatorview.cpp b/Code/Seg/BSTools/bsaccumulatorview.cpp index 4610b54..5618ea4 100755 --- a/Code/Seg/BSTools/bsaccumulatorview.cpp +++ b/Code/Seg/BSTools/bsaccumulatorview.cpp @@ -65,7 +65,7 @@ bool BSAccumulatorView::processKeyEvent (QKeyEvent *event) (event->modifiers () & Qt::ShiftModifier) == 0); break; - case Qt::Key_P : + case Qt::Key_W : processed = grid->subpixellise ( (event->modifiers () & Qt::ShiftModifier) != 0); break; @@ -74,6 +74,14 @@ bool BSAccumulatorView::processKeyEvent (QKeyEvent *event) processed = grid->setFilterSelectivity ( (event->modifiers () & Qt::ShiftModifier) == 0); break; + + case Qt::Key_P : // Capture + viewport()->grab ( + QRect (QPoint (0, 0), + QSize (grid->getWidth(), grid->getHeight())) + ).toImage().save ("accu.png"); + cout << "Accumulator shot in capture.png" << endl; + break; } return processed; } diff --git a/Code/Seg/BSTools/bsdetectionwidget.cpp b/Code/Seg/BSTools/bsdetectionwidget.cpp index 700674c..8f0e344 100755 --- a/Code/Seg/BSTools/bsdetectionwidget.cpp +++ b/Code/Seg/BSTools/bsdetectionwidget.cpp @@ -285,6 +285,7 @@ void BSDetectionWidget::switchIdetAnalyzer () { idetview = new BSIdetView (&detector); idetview->setImage (&loadedImage, gMap); + idetview->update (); idetview->show (); } } @@ -877,7 +878,7 @@ void BSDetectionWidget::displayDetectionResult () // Update auxiliary view if not dragging if (nodrag) { - if (idetview != NULL) idetview->scene()->update (); + if (idetview != NULL) idetview->update (); if (profileview != NULL) { profileview->buildScans (p1, p2); diff --git a/Code/Seg/BSTools/bsidetitem.cpp b/Code/Seg/BSTools/bsidetitem.cpp index 77f7ba5..c4ee2c4 100755 --- a/Code/Seg/BSTools/bsidetitem.cpp +++ b/Code/Seg/BSTools/bsidetitem.cpp @@ -31,6 +31,9 @@ BSIdetItem::BSIdetItem (BSDetector *detector) displayItem = DISPLAY_INTENSITY; det = detector; ds = NULL; + + offx = 0; + offy = 0; } @@ -49,7 +52,7 @@ void BSIdetItem::paint (QPainter *painter, if (det->getBlurredSegments().empty () || det->getMaxTrials () > 0) { - buildScans (); +// buildScans (); paintStripes (painter); } } @@ -67,6 +70,9 @@ void BSIdetItem::setImage (QImage *image, VMap *idata) void BSIdetItem::buildScans () { + if ((! det->getBlurredSegments().empty ()) && det->getMaxTrials () <= 0) + return; + if (ds != NULL) { delete ds; diff --git a/Code/Seg/BSTools/bsidetitem.h b/Code/Seg/BSTools/bsidetitem.h index bc594ac..dd3485b 100755 --- a/Code/Seg/BSTools/bsidetitem.h +++ b/Code/Seg/BSTools/bsidetitem.h @@ -52,6 +52,16 @@ public: else return ("No info"); } + /** + * \brief Returns the detection view width. + */ + inline int getWidth () const { return width; } + + /** + * \brief Returns the detection view height. + */ + inline int getHeight () const { return height; } + /** * \brief Increments the current stripe index. * @param inc Direction (1 for rightwards, -1 for leftwards) @@ -70,8 +80,11 @@ public: */ void toggleDisplay (bool next); + /** + * \brief Sets the image scan area from the detection initial scan. + */ + void buildScans (); -protected: private: @@ -137,11 +150,6 @@ private: */ void paintStripes (QPainter *painter); - /** - * \brief Sets the image scan area from the detection initial scan. - */ - void buildScans (); - }; #endif diff --git a/Code/Seg/BSTools/bsidetview.cpp b/Code/Seg/BSTools/bsidetview.cpp index dc6cfcc..6b3beea 100755 --- a/Code/Seg/BSTools/bsidetview.cpp +++ b/Code/Seg/BSTools/bsidetview.cpp @@ -49,28 +49,43 @@ bool BSIdetView::processKeyEvent (QKeyEvent *event) case Qt::Key_I : idet->toggleDisplay ((event->modifiers () & Qt::ShiftModifier) == 0); setWindowTitle (idet->itemTitle ()); - idet->update (); + scene()->update (); + break; + + case Qt::Key_P : // Capture + viewport()->grab ( + QRect (QPoint (0, 0), + QSize (idet->getWidth(), idet->getHeight())) + ).toImage().save ("firstDetection.png"); + cout << "First detection window shot in capture.png" << endl; break; case Qt::Key_Left : idet->incX (-1); - idet->update (); + scene()->update (); break; case Qt::Key_Right : idet->incX (1); - idet->update (); + scene()->update (); break; case Qt::Key_Up : idet->incY (1); - idet->update (); + scene()->update (); break; case Qt::Key_Down : idet->incY (-1); - idet->update (); + scene()->update (); break; } return false; } + + +void BSIdetView::update () +{ + idet->buildScans (); + scene()->update (); +} diff --git a/Code/Seg/BSTools/bsidetview.h b/Code/Seg/BSTools/bsidetview.h index 18182af..efa3014 100755 --- a/Code/Seg/BSTools/bsidetview.h +++ b/Code/Seg/BSTools/bsidetview.h @@ -47,6 +47,11 @@ public: */ bool processKeyEvent (QKeyEvent *event); + /** + * \brief Update the initial detection widget. + */ + void update (); + private: diff --git a/Code/Seg/BSTools/bsprofileitem.h b/Code/Seg/BSTools/bsprofileitem.h index 3ca04bc..51078bd 100755 --- a/Code/Seg/BSTools/bsprofileitem.h +++ b/Code/Seg/BSTools/bsprofileitem.h @@ -65,6 +65,16 @@ public: else return ("No profile"); } + /** + * \brief Returns the widget display width. + */ + inline int getWidth () const { return widWidth; } + + /** + * \brief Returns the widget display height. + */ + inline int getHeight () const { return widHeight; } + /** * \brief Increments the current stripe index. * @param inc Direction (1 for leftwards, -1 for rightwards) diff --git a/Code/Seg/BSTools/bsprofileview.cpp b/Code/Seg/BSTools/bsprofileview.cpp index e20f8b7..31208ff 100755 --- a/Code/Seg/BSTools/bsprofileview.cpp +++ b/Code/Seg/BSTools/bsprofileview.cpp @@ -73,6 +73,14 @@ bool BSProfileView::processKeyEvent (QKeyEvent *event) prof->update (); break; + case Qt::Key_P : // Capture + viewport()->grab ( + QRect (QPoint (0, 0), + QSize (prof->getWidth(), prof->getHeight())) + ).toImage().save ("profiles.png"); + cout << "Profiles shot in capture.png" << endl; + break; + case Qt::Key_Up : prof->incStripe (1); prof->update (); diff --git a/Code/Seg/BSTools/bsstructureitem.h b/Code/Seg/BSTools/bsstructureitem.h index f2095de..4b2d660 100755 --- a/Code/Seg/BSTools/bsstructureitem.h +++ b/Code/Seg/BSTools/bsstructureitem.h @@ -21,6 +21,16 @@ public: */ ~BSStructureItem (); + /** + * \brief Return the width. + */ + inline int getWidth () const { return w; } + + /** + * \brief Return the height. + */ + inline int getHeight () const { return h; } + /** * \brief Return the zoom factor. */ diff --git a/Code/Seg/BSTools/bsstructureview.cpp b/Code/Seg/BSTools/bsstructureview.cpp index 044d1b0..aec15cd 100755 --- a/Code/Seg/BSTools/bsstructureview.cpp +++ b/Code/Seg/BSTools/bsstructureview.cpp @@ -115,6 +115,14 @@ bool BSStructureView::processKeyEvent (QKeyEvent *event) } break; + case Qt::Key_P : // Capture + viewport()->grab ( + QRect (QPoint (0, 0), + QSize (grid->getWidth(), grid->getHeight())) + ).toImage().save ("structure.png"); + cout << "Structure shot in capture.png" << endl; + break; + case Qt::Key_Plus : // Zoom in grid->zoomIn (); updateBackground (); diff --git a/Methode/ctrl.tex b/Methode/ctrl.tex index 481f53f..eff09ff 100755 --- a/Methode/ctrl.tex +++ b/Methode/ctrl.tex @@ -71,9 +71,11 @@ Ctrl-y && Commute l'affichage des pixels des segments flous. \\ \newpage \begin{tabular}{|rcl|} \hline -\multicolumn{3}{|l|}{Contr\^ole de l'extraction : \hspace{9.0cm} .} \\ +\multicolumn{3}{|l|}{Contr\^ole des fen\^etres auxiliaires : +\hspace{9.0cm} .} \\ i && Changement d'info \\ v && Commute l'affichage du texte \\ +p && Capture la fen\^etre dans un fichier .png \\ \hline \hline \multicolumn{3}{|l|}{Analyse des segments flous extraits :} \\ Ctrl-i && Commute le type d'affichage des scans \\ @@ -84,7 +86,7 @@ $< \wedge > \vee$ && D\'ecalage de l'observation \\ \multicolumn{3}{|l|}{Analyse des accumulateurs :} \\ s && Taille de l'accumulateur (nombre de cellules) \\ r && R\'esolution (espace couvert par une cellule) \\ -p && Sub-pixelisation (pour le vote) \\ +w && Sub-pixelisation (pour le vote) \\ f && S\'electivit\'e du filtre \\ \hline \hline \multicolumn{3}{|l|}{Analyse des profils :} \\ -- GitLab