diff --git a/Code/Seg/BSTools/bsaccumulatoritem.cpp b/Code/Seg/BSTools/bsaccumulatoritem.cpp index 3ecf8c027892b6a754b2b1bf000a7b6e65d5bb70..3d834acddedec339d6d2448dfeabef0ed046ec74 100755 --- a/Code/Seg/BSTools/bsaccumulatoritem.cpp +++ b/Code/Seg/BSTools/bsaccumulatoritem.cpp @@ -53,7 +53,8 @@ void BSAccumulatorItem::paint (QPainter *painter, Q_UNUSED (option); Q_UNUSED (widget); - if (! detector->isFiltering (selaccu)) + if (! (detector->getBlurredSegments(1).empty () + && detector->isFiltering (selaccu))) { painter->fillRect (0, 0, width, height, QBrush (Qt::black)); return; diff --git a/Code/Seg/BSTools/bsdetectionwidget.cpp b/Code/Seg/BSTools/bsdetectionwidget.cpp index 82e379a42d3ec0b12b92b3260ac82d6f992b3ca0..c1af1a64d497a5265eb076fccc673f4674ca37b6 100755 --- a/Code/Seg/BSTools/bsdetectionwidget.cpp +++ b/Code/Seg/BSTools/bsdetectionwidget.cpp @@ -549,7 +549,11 @@ void BSDetectionWidget::extract () drawLine (p1, p2, Qt::red, painter); if (detector.isMultiSelection ()) detector.multidetect (p1, p2); - else detector.detect (p1, p2); + else + { + detector.freeMultiSelection (); + detector.detect (p1, p2); + } // Update auxiliary view if not dragging if (fixed) @@ -560,7 +564,11 @@ void BSDetectionWidget::extract () profileview->scene()->update (); } if (accuview != NULL) accuview->scene()->update (); - if (strucview != NULL) strucview->scene()->update (); + if (strucview != NULL) + { + strucview->setExamined (-1); + strucview->scene()->update (); + } } if (detector.isMultiSelection ()) @@ -609,18 +617,22 @@ void BSDetectionWidget::extractAll () detector.detectAll (); - // Update auxiliary view if not dragging - if (fixed) + // Update auxiliary view + if (profileview != NULL) { - if (profileview != NULL) - { - profileview->buildScans (p1, p2); - profileview->scene()->update (); - } - if (accuview != NULL) accuview->scene()->update (); - if (strucview != NULL) strucview->scene()->update (); + profileview->buildScans (p1, p2); + profileview->scene()->update (); + } + if (accuview != NULL) accuview->scene()->update (); + if (strucview != NULL) + { + strucview->setExamined (-1); + strucview->scene()->update (); } + // Update auxiliary view + if (strucview != NULL) strucview->scene()->update (); + vector<BlurredSegment *> mbs = detector.getBlurredSegments (1); cout << mbs.size () << " blurred segments detected" << endl; vector<BlurredSegment *>::iterator it = mbs.begin (); @@ -660,8 +672,15 @@ void BSDetectionWidget::displayNext (int dir) augmentedImage = loadedImage; QPainter painter (&augmentedImage); - exam = (exam + dir) % ((int) (mbs.size ())); + + // Update auxiliary view + if (strucview != NULL) + { + strucview->setExamined (exam); + strucview->scene()->update (); + } + vector<BlurredSegment *>::iterator it = mbs.begin (); QColor bsCol = Qt::blue; int index = 0; diff --git a/Code/Seg/BSTools/bsstructureitem.cpp b/Code/Seg/BSTools/bsstructureitem.cpp index c4cf2947f1fc77e56b26d6d0d47ae733349b0745..8677a387808565b482610cc21441d4ae72f23ba3 100755 --- a/Code/Seg/BSTools/bsstructureitem.cpp +++ b/Code/Seg/BSTools/bsstructureitem.cpp @@ -109,7 +109,11 @@ void BSStructureItem::paint(QPainter *painter, void BSStructureItem::paintBlurredSegment (QPainter *painter, int step) { - BlurredSegment *bs = det->getBlurredSegment (step); + BlurredSegment *bs = NULL; + vector<BlurredSegment *> mbs = det->getBlurredSegments (step); + if (mbs.empty ()) bs = det->getBlurredSegment (step); + else if (exam != -1) bs = mbs[exam]; + if (bs != NULL) { DigitalStraightSegment *dss = bs->getSegment (); @@ -156,7 +160,11 @@ void BSStructureItem::paintBlurredSegment (QPainter *painter, int step) void BSStructureItem::paintConnectedComponents (QPainter *painter, int step) { - BlurredSegment *bs = det->getBlurredSegment (step); + BlurredSegment *bs = NULL; + vector<BlurredSegment *> mbs = det->getBlurredSegments (step); + if (mbs.empty ()) bs = det->getBlurredSegment (step); + else if (exam != -1) bs = mbs[exam]; + if (bs != NULL) { QColor cols[] = {Qt::blue, Qt::red, Qt::green}; @@ -204,6 +212,8 @@ void BSStructureItem::paintConnectedComponents (QPainter *painter, int step) void BSStructureItem::paintScansAndFilter (QPainter *painter, int step) { + if (! (det->getBlurredSegments(step).empty ())) return; + if (det->scanRecordOn (step)) { if (displayScanLines) diff --git a/Code/Seg/BSTools/bsstructureitem.h b/Code/Seg/BSTools/bsstructureitem.h index d8ea16f85eed6dbab71cc68816e19a3ac14a624b..73d19c04a57e5314e03ae6781654ca9016b93253 100755 --- a/Code/Seg/BSTools/bsstructureitem.h +++ b/Code/Seg/BSTools/bsstructureitem.h @@ -70,6 +70,11 @@ public: */ inline void switchScanDisplay () { displayScanLines = ! displayScanLines; } + /** + * Sets the examined segment from a multi-selection. + */ + inline void setExamined (int index) { exam = index; } + /** * \brief Returns the displayed information title. */ @@ -153,6 +158,8 @@ private: QPen infoPen; /** Information text vertical offset. */ int textOffset; + /** Index of the examined segment in the multi-selection. */ + int exam; /** diff --git a/Code/Seg/BSTools/bsstructureview.cpp b/Code/Seg/BSTools/bsstructureview.cpp index d43e081f99e8f5cab26536c5bca81ff10bccd851..6c5396cdb25b1c986bfb9e2d70c9925478778029 100755 --- a/Code/Seg/BSTools/bsstructureview.cpp +++ b/Code/Seg/BSTools/bsstructureview.cpp @@ -106,64 +106,73 @@ bool BSStructureView::processKeyEvent (QKeyEvent *event) if (event->modifiers () & Qt::ControlModifier) grid->switchScanDisplay (); else grid->toggleDisplay ((event->modifiers () & Qt::ShiftModifier) == 0); setWindowTitle (grid->itemTitle ()); + scene()->update (); update (); - processed = true; + processed = false; break; case Qt::Key_V : // Info display grid->switchInfoDisplay (); + scene()->update (); update (); - processed = true; + processed = false; break; case Qt::Key_B : // Background if (event->modifiers () & Qt::ShiftModifier) toggleGradient (); else toggleBackground (); updateBackground (true); + scene()->update (); update (); - processed = true; + processed = false; break; case Qt::Key_Plus : // Zoom in grid->zoomIn (); updateBackground (true); + scene()->update (); update (); - processed = true; + processed = false; break; case Qt::Key_Minus : // Zoom out grid->zoomOut (); updateBackground (true); + scene()->update (); update (); - processed = true; + processed = false; break; case Qt::Key_Left : // Go leftwards grid->shift (-1, 0); updateBackground (false); + scene()->update (); update (); - processed = true; + processed = false; break; case Qt::Key_Right : // Go rightwards grid->shift (1, 0); updateBackground (false); + scene()->update (); update (); - processed = true; + processed = false; break; case Qt::Key_Up : // Go upwards grid->shift (0, -1); updateBackground (false); + scene()->update (); update (); - processed = true; + processed = false; break; case Qt::Key_Down : // Go downwards grid->shift (0, 1); updateBackground (false); + scene()->update (); update (); - processed = true; + processed = false; break; case Qt::Key_C : // Increments the connected components min size diff --git a/Code/Seg/BSTools/bsstructureview.h b/Code/Seg/BSTools/bsstructureview.h index 6f6dce8cd82ee41ab354ae57e436922a5e9867c6..2c905a0e79690dac4d3ea686726f31c553f693a4 100755 --- a/Code/Seg/BSTools/bsstructureview.h +++ b/Code/Seg/BSTools/bsstructureview.h @@ -26,6 +26,11 @@ public: */ void setGradientImage (VMap *gMap); + /** + * Sets the examined segment from a multi-selection. + */ + inline void setExamined (int index) { grid->setExamined (index); } + /** * Toggles the window background between the current image or plain white. */ diff --git a/Code/Seg/BlurredSegment/bsdetector.cpp b/Code/Seg/BlurredSegment/bsdetector.cpp index ffd2fe27c785263845fbbf3ea2786f4c71ddb1a1..efa1ae6f700667e92f449329dc471706310af7da 100755 --- a/Code/Seg/BlurredSegment/bsdetector.cpp +++ b/Code/Seg/BlurredSegment/bsdetector.cpp @@ -71,6 +71,17 @@ void BSDetector::setGradientMap (VMap *data) } +void BSDetector::freeMultiSelection () +{ + vector<BlurredSegment *>::iterator it = mbsini.begin (); + while (it != mbsini.end ()) delete (*it++); + mbsini.clear (); + it = mbsf.begin (); + while (it != mbsf.end ()) delete (*it++); + mbsf.clear (); +} + + void BSDetector::detectAll () { // Deletes former blurred segments diff --git a/Code/Seg/BlurredSegment/bsdetector.h b/Code/Seg/BlurredSegment/bsdetector.h index f0ec3c818782cd5bd4d3c97f1b8a844f2edbe954..468d5d17aca80228e7676c067d33846f09eec8d2 100755 --- a/Code/Seg/BlurredSegment/bsdetector.h +++ b/Code/Seg/BlurredSegment/bsdetector.h @@ -101,6 +101,11 @@ public: inline vector<BlurredSegment *> getBlurredSegments (int step) { return (step == 0 ? mbsini : mbsf); } + /** + * \brief Resets the multi-selection list. + */ + void freeMultiSelection (); + /** * \brief Avoids the deletion of the last extracted blurred segent. */