~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to libs/dimg/filters/levels/histogramwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-21 23:19:11 UTC
  • mfrom: (1.2.33 upstream) (3.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20101221231911-z9jip7s5aht1jqn9
Tags: 2:1.7.0-1ubuntu1
* Merge from Debian Experimental. Remaining Ubuntu changes:
  - Export .pot name and copy to plugins in debian/rules
  - Version build-depends on kipi-plugins-dev to ensure build is against the
    same version on all archs
* Drop debian/patches/kubuntu_01_linker.diff, incoporated upstream
* Remove patches directory and unused patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
    bool    inSelected;
92
92
    bool    selectMode;         // If true, a part of the histogram can be selected !
93
93
    bool    showProgress;       // If true, a message will be displayed during histogram computation,
94
 
                                // else nothing (limit flicker effect in widget especially for small
95
 
                                // image/computation time).
 
94
    // else nothing (limit flicker effect in widget especially for small
 
95
    // image/computation time).
96
96
 
97
97
    int     renderingType;      // Using full image or image selection for histogram rendering.
98
98
    int     range;
100
100
    int     progressCount;      // Position of animation during loading/calculation.
101
101
    ChannelType channelType;    // Channel type to draw
102
102
    HistogramScale scaleType;   // Scale to use for drawing
103
 
    ImageHistogram *imageHistogram;      // Full image
104
 
    ImageHistogram *selectionHistogram;  // Image selection
 
103
    ImageHistogram* imageHistogram;      // Full image
 
104
    ImageHistogram* selectionHistogram;  // Image selection
105
105
 
106
106
    // Current selection information.
107
107
    double  xmin;
108
108
    double  xminOrg;
109
109
    double  xmax;
110
110
 
111
 
    QTimer *progressTimer;
 
111
    QTimer* progressTimer;
112
112
 
113
113
    QPixmap progressPix;
114
114
 
115
115
    DColor  colorGuide;
116
116
 
117
 
    HistogramPainter *histogramPainter;
 
117
    HistogramPainter* histogramPainter;
118
118
 
119
119
};
120
120
 
121
121
// Constructor without image data (needed to use updateData() method after instance created).
122
122
 
123
123
HistogramWidget::HistogramWidget(int w, int h,
124
 
                                 QWidget *parent, bool selectMode,
 
124
                                 QWidget* parent, bool selectMode,
125
125
                                 bool showProgress, bool statisticsVisible)
126
 
               : QWidget(parent), d(new HistogramWidgetPriv)
 
126
    : QWidget(parent), d(new HistogramWidgetPriv)
127
127
{
128
128
    setup(w, h, selectMode, showProgress, statisticsVisible);
129
129
    setAttribute(Qt::WA_DeleteOnClose);
136
136
// Constructor without image selection.
137
137
 
138
138
HistogramWidget::HistogramWidget(int w, int h,
139
 
                                 uchar *i_data, uint i_w, uint i_h,
 
139
                                 uchar* i_data, uint i_w, uint i_h,
140
140
                                 bool i_sixteenBits,
141
 
                                 QWidget *parent, bool selectMode,
 
141
                                 QWidget* parent, bool selectMode,
142
142
                                 bool showProgress, bool statisticsVisible)
143
 
               : QWidget(parent), d(new HistogramWidgetPriv)
 
143
    : QWidget(parent), d(new HistogramWidgetPriv)
144
144
{
145
145
    d->sixteenBits = i_sixteenBits;
146
146
    setup(w, h, selectMode, showProgress, statisticsVisible);
158
158
// Constructor with image selection.
159
159
 
160
160
HistogramWidget::HistogramWidget(int w, int h,
161
 
                                 uchar *i_data, uint i_w, uint i_h,
162
 
                                 uchar *s_data, uint s_w, uint s_h,
 
161
                                 uchar* i_data, uint i_w, uint i_h,
 
162
                                 uchar* s_data, uint s_w, uint s_h,
163
163
                                 bool i_sixteenBits,
164
 
                                 QWidget *parent, bool selectMode,
 
164
                                 QWidget* parent, bool selectMode,
165
165
                                 bool showProgress, bool statisticsVisible)
166
 
               : QWidget(parent), d(new HistogramWidgetPriv)
 
166
    : QWidget(parent), d(new HistogramWidgetPriv)
167
167
{
168
168
    d->sixteenBits = i_sixteenBits;
169
169
    setup(w, h, selectMode, showProgress, statisticsVisible);
184
184
    d->progressTimer->stop();
185
185
 
186
186
    if (d->imageHistogram)
187
 
       delete d->imageHistogram;
 
187
    {
 
188
        delete d->imageHistogram;
 
189
    }
188
190
 
189
191
    if (d->selectionHistogram)
190
 
       delete d->selectionHistogram;
 
192
    {
 
193
        delete d->selectionHistogram;
 
194
    }
191
195
 
192
196
    delete d;
193
197
}
209
213
            this, SLOT(slotProgressTimerDone()));
210
214
}
211
215
 
212
 
void HistogramWidget::connectHistogram(const ImageHistogram *histogram)
 
216
void HistogramWidget::connectHistogram(const ImageHistogram* histogram)
213
217
{
214
 
    connect(histogram, SIGNAL(calculationStarted(const ImageHistogram *)),
215
 
            this, SLOT(slotCalculationStarted(const ImageHistogram *)));
 
218
    connect(histogram, SIGNAL(calculationStarted(const ImageHistogram*)),
 
219
            this, SLOT(slotCalculationStarted(const ImageHistogram*)));
216
220
 
217
 
    connect(histogram, SIGNAL(calculationFinished(const ImageHistogram *, bool)),
218
 
            this, SLOT(slotCalculationFinished(const ImageHistogram *, bool)));
 
221
    connect(histogram, SIGNAL(calculationFinished(const ImageHistogram*, bool)),
 
222
            this, SLOT(slotCalculationFinished(const ImageHistogram*, bool)));
219
223
}
220
224
 
221
225
void HistogramWidget::setHistogramGuideByColor(const DColor& color)
231
235
    {
232
236
        d->renderingType = type;
233
237
 
234
 
        ImageHistogram *nowUsedHistogram;
 
238
        ImageHistogram* nowUsedHistogram;
 
239
 
235
240
        if (d->renderingType == ImageSelectionHistogram && d->selectionHistogram)
 
241
        {
236
242
            nowUsedHistogram = d->selectionHistogram;
 
243
        }
237
244
        else
 
245
        {
238
246
            nowUsedHistogram = d->imageHistogram;
 
247
        }
239
248
 
240
249
        // already calculated?
241
250
        if (!nowUsedHistogram->isValid())
242
251
        {
243
252
            // still computing, or need to start it?
244
253
            if (nowUsedHistogram->isCalculating())
 
254
            {
245
255
                slotCalculationStarted(nowUsedHistogram);
 
256
            }
246
257
            else
 
258
            {
247
259
                nowUsedHistogram->calculateInThread();
 
260
            }
248
261
        }
249
262
        else
 
263
        {
250
264
            update();
 
265
        }
251
266
    }
252
267
}
253
268
 
254
 
ImageHistogram *HistogramWidget::currentHistogram()
 
269
ImageHistogram* HistogramWidget::currentHistogram()
255
270
{
256
271
    if (d->renderingType == ImageSelectionHistogram && d->selectionHistogram)
 
272
    {
257
273
        return d->selectionHistogram;
 
274
    }
258
275
    else
 
276
    {
259
277
        return d->imageHistogram;
 
278
    }
260
279
}
261
280
 
262
281
void HistogramWidget::reset()
265
284
    repaint();
266
285
}
267
286
 
268
 
void HistogramWidget::slotCalculationStarted(const ImageHistogram *histogram)
 
287
void HistogramWidget::slotCalculationStarted(const ImageHistogram* histogram)
269
288
{
270
289
    if (histogram != d->imageHistogram && histogram != d->selectionHistogram)
 
290
    {
271
291
        return;
 
292
    }
272
293
 
273
294
    // only react to the histogram that the user is currently waiting for
274
295
    if (d->renderingType == ImageSelectionHistogram && d->selectionHistogram)
275
296
    {
276
297
        if (histogram == d->imageHistogram)
 
298
        {
277
299
            return;
 
300
        }
278
301
    }
279
302
    else
280
303
    {
281
304
        if (histogram == d->selectionHistogram)
 
305
        {
282
306
            return;
 
307
        }
283
308
    }
284
309
 
285
310
    setCursor( Qt::WaitCursor );
286
311
    d->clearFlag = HistogramWidgetPriv::HistogramStarted;
 
312
 
287
313
    if (!d->inInitialRepaintWait)
288
314
    {
289
315
        if (d->clearFlag != HistogramWidgetPriv::HistogramDataLoading)
303
329
    }
304
330
}
305
331
 
306
 
void HistogramWidget::slotCalculationFinished(const ImageHistogram *histogram, bool success)
 
332
void HistogramWidget::slotCalculationFinished(const ImageHistogram* histogram, bool success)
307
333
{
308
334
    if (histogram != d->imageHistogram && histogram != d->selectionHistogram)
 
335
    {
309
336
        return;
 
337
    }
310
338
 
311
339
    if (d->renderingType == ImageSelectionHistogram && d->selectionHistogram)
312
340
    {
313
341
        if (histogram == d->imageHistogram)
 
342
        {
314
343
            return;
 
344
        }
315
345
    }
316
346
    else
317
347
    {
318
348
        if (histogram == d->selectionHistogram)
 
349
        {
319
350
            return;
 
351
        }
320
352
    }
321
353
 
322
354
    if (success)
345
377
        d->inInitialRepaintWait = false;
346
378
        repaint();
347
379
        setCursor( Qt::ArrowCursor );
348
 
            // Remove old histogram data from memory.
 
380
 
 
381
        // Remove old histogram data from memory.
349
382
        if (d->imageHistogram)
350
383
        {
351
384
            delete d->imageHistogram;
352
385
            d->imageHistogram = 0;
353
386
        }
 
387
 
354
388
        if (d->selectionHistogram)
355
389
        {
356
390
            delete d->selectionHistogram;
357
391
            d->selectionHistogram = 0;
358
392
        }
 
393
 
359
394
        emit signalHistogramComputationFailed();
360
395
    }
361
396
}
387
422
void HistogramWidget::stopHistogramComputation()
388
423
{
389
424
    if (d->imageHistogram)
390
 
       d->imageHistogram->stopCalculation();
 
425
    {
 
426
        d->imageHistogram->stopCalculation();
 
427
    }
391
428
 
392
429
    if (d->selectionHistogram)
393
 
       d->selectionHistogram->stopCalculation();
 
430
    {
 
431
        d->selectionHistogram->stopCalculation();
 
432
    }
394
433
 
395
434
    d->progressTimer->stop();
396
435
    d->progressCount = 0;
397
436
}
398
437
 
399
 
void HistogramWidget::updateData(uchar *i_data, uint i_w, uint i_h,
 
438
void HistogramWidget::updateData(uchar* i_data, uint i_w, uint i_h,
400
439
                                 bool i_sixteenBits,
401
 
                                 uchar *s_data, uint s_w, uint s_h,
 
440
                                 uchar* s_data, uint s_w, uint s_h,
402
441
                                 bool showProgress)
403
442
{
404
443
    d->showProgress = showProgress;
415
454
 
416
455
    // Remove old histogram data from memory.
417
456
    if (d->imageHistogram)
418
 
       delete d->imageHistogram;
 
457
    {
 
458
        delete d->imageHistogram;
 
459
    }
419
460
 
420
461
    if (d->selectionHistogram)
421
 
       delete d->selectionHistogram;
 
462
    {
 
463
        delete d->selectionHistogram;
 
464
    }
422
465
 
423
466
    // Calc new histogram data
424
467
    d->imageHistogram = new ImageHistogram(i_data, i_w, i_h, i_sixteenBits);
430
473
        connectHistogram(d->selectionHistogram);
431
474
    }
432
475
    else
 
476
    {
433
477
        d->selectionHistogram = 0L;
 
478
    }
434
479
 
435
480
    if (d->renderingType == ImageSelectionHistogram && d->selectionHistogram)
 
481
    {
436
482
        d->selectionHistogram->calculateInThread();
 
483
    }
437
484
    else
 
485
    {
438
486
        d->imageHistogram->calculateInThread();
 
487
    }
439
488
}
440
489
 
441
 
void HistogramWidget::updateSelectionData(uchar *s_data, uint s_w, uint s_h,
442
 
                                          bool i_sixteenBits,
443
 
                                          bool showProgress)
 
490
void HistogramWidget::updateSelectionData(uchar* s_data, uint s_w, uint s_h,
 
491
        bool i_sixteenBits,
 
492
        bool showProgress)
444
493
{
445
494
    d->showProgress = showProgress;
446
495
 
447
496
    // Remove old histogram data from memory.
448
497
 
449
498
    if (d->selectionHistogram)
450
 
       delete d->selectionHistogram;
 
499
    {
 
500
        delete d->selectionHistogram;
 
501
    }
451
502
 
452
503
    // Calc new histogram data
453
504
    d->selectionHistogram = new ImageHistogram(s_data, s_w, s_h, i_sixteenBits);
454
505
    connectHistogram(d->selectionHistogram);
455
506
 
456
507
    if (d->renderingType == ImageSelectionHistogram)
 
508
    {
457
509
        d->selectionHistogram->calculateInThread();
 
510
    }
458
511
}
459
512
 
460
513
void HistogramWidget::slotProgressTimerDone()
475
528
                               d->clearFlag == HistogramWidgetPriv::HistogramDataLoading))
476
529
       )
477
530
    {
478
 
       QPainter p1(this);
479
 
       p1.fillRect(0, 0, width(), height(), palette().color(QPalette::Disabled, QPalette::Background));
480
 
       p1.setPen(QPen(palette().color(QPalette::Active, QPalette::Foreground), 1, Qt::SolidLine));
481
 
       p1.drawRect(0, 0, width()-1, height()-1);
482
 
       QPen pen(palette().color(QPalette::Disabled, QPalette::Foreground));
483
 
       pen.setStyle(Qt::SolidLine);
484
 
       pen.setWidth(1);
485
 
 
486
 
       p1.setPen(pen);
487
 
       p1.drawRect(0, 0, width(), height());
488
 
       p1.end();
489
 
 
490
 
       return;
 
531
        QPainter p1(this);
 
532
        p1.fillRect(0, 0, width(), height(), palette().color(QPalette::Disabled, QPalette::Background));
 
533
        p1.setPen(QPen(palette().color(QPalette::Active, QPalette::Foreground), 1, Qt::SolidLine));
 
534
        p1.drawRect(0, 0, width()-1, height()-1);
 
535
        QPen pen(palette().color(QPalette::Disabled, QPalette::Foreground));
 
536
        pen.setStyle(Qt::SolidLine);
 
537
        pen.setWidth(1);
 
538
 
 
539
        p1.setPen(pen);
 
540
        p1.drawRect(0, 0, width(), height());
 
541
        p1.end();
 
542
 
 
543
        return;
491
544
    }
492
545
    // Image data is loading or histogram is being computed:
493
546
    // Draw message.
494
547
    else if (  d->showProgress &&
495
 
              (d->clearFlag == HistogramWidgetPriv::HistogramStarted ||
496
 
               d->clearFlag == HistogramWidgetPriv::HistogramDataLoading)
 
548
               (d->clearFlag == HistogramWidgetPriv::HistogramStarted ||
 
549
                d->clearFlag == HistogramWidgetPriv::HistogramDataLoading)
497
550
            )
498
551
    {
499
 
       // In first, we draw an animation.
500
 
 
501
 
       QPixmap anim(d->progressPix.copy(0, d->progressCount*22, 22, 22));
502
 
       d->progressCount++;
503
 
       if (d->progressCount == 8) d->progressCount = 0;
504
 
 
505
 
       // ... and we render busy text.
506
 
 
507
 
       QPainter p1(this);
508
 
       p1.fillRect(0, 0, width(), height(), palette().color(QPalette::Active, QPalette::Background));
509
 
       p1.setPen(QPen(palette().color(QPalette::Active, QPalette::Foreground), 1, Qt::SolidLine));
510
 
       p1.drawRect(0, 0, width()-1, height()-1);
511
 
       p1.drawPixmap(width()/2 - anim.width() /2, anim.height(), anim);
512
 
       p1.setPen(palette().color(QPalette::Active, QPalette::Text));
513
 
 
514
 
       if (d->clearFlag == HistogramWidgetPriv::HistogramDataLoading)
515
 
           p1.drawText(0, 0, width(), height(), Qt::AlignCenter,
516
 
                       i18n("Loading image..."));
517
 
       else
518
 
           p1.drawText(0, 0, width(), height(), Qt::AlignCenter,
519
 
                       i18n("Histogram calculation..."));
520
 
       p1.end();
521
 
 
522
 
       return;
 
552
        // In first, we draw an animation.
 
553
 
 
554
        QPixmap anim(d->progressPix.copy(0, d->progressCount*22, 22, 22));
 
555
        d->progressCount++;
 
556
 
 
557
        if (d->progressCount == 8)
 
558
        {
 
559
            d->progressCount = 0;
 
560
        }
 
561
 
 
562
        // ... and we render busy text.
 
563
 
 
564
        QPainter p1(this);
 
565
        p1.fillRect(0, 0, width(), height(), palette().color(QPalette::Active, QPalette::Background));
 
566
        p1.setPen(QPen(palette().color(QPalette::Active, QPalette::Foreground), 1, Qt::SolidLine));
 
567
        p1.drawRect(0, 0, width()-1, height()-1);
 
568
        p1.drawPixmap(width()/2 - anim.width() /2, anim.height(), anim);
 
569
        p1.setPen(palette().color(QPalette::Active, QPalette::Text));
 
570
 
 
571
        if (d->clearFlag == HistogramWidgetPriv::HistogramDataLoading)
 
572
            p1.drawText(0, 0, width(), height(), Qt::AlignCenter,
 
573
                        i18n("Loading image..."));
 
574
        else
 
575
            p1.drawText(0, 0, width(), height(), Qt::AlignCenter,
 
576
                        i18n("Histogram calculation..."));
 
577
 
 
578
        p1.end();
 
579
 
 
580
        return;
523
581
    }
524
582
    // Histogram computation failed:
525
583
    // Draw message.
526
584
    else if (d->clearFlag == HistogramWidgetPriv::HistogramFailed)
527
585
    {
528
 
       QPainter p1(this);
529
 
       p1.fillRect(0, 0, width(), height(), palette().color(QPalette::Active, QPalette::Background));
530
 
       p1.setPen(QPen(palette().color(QPalette::Active, QPalette::Foreground), 1, Qt::SolidLine));
531
 
       p1.drawRect(0, 0, width()-1, height()-1);
532
 
       p1.setPen(palette().color(QPalette::Active, QPalette::Text));
533
 
       p1.drawText(0, 0, width(), height(), Qt::AlignCenter,
534
 
                   i18n("Histogram\ncalculation\nfailed."));
535
 
       p1.end();
 
586
        QPainter p1(this);
 
587
        p1.fillRect(0, 0, width(), height(), palette().color(QPalette::Active, QPalette::Background));
 
588
        p1.setPen(QPen(palette().color(QPalette::Active, QPalette::Foreground), 1, Qt::SolidLine));
 
589
        p1.drawRect(0, 0, width()-1, height()-1);
 
590
        p1.setPen(palette().color(QPalette::Active, QPalette::Text));
 
591
        p1.drawText(0, 0, width(), height(), Qt::AlignCenter,
 
592
                    i18n("Histogram\ncalculation\nfailed."));
 
593
        p1.end();
536
594
 
537
 
       return;
 
595
        return;
538
596
    }
539
597
 
540
598
    // render histogram in normal case
541
599
    ImageHistogram* histogram = 0;
 
600
 
542
601
    if (d->renderingType == ImageSelectionHistogram && d->selectionHistogram)
543
602
    {
544
 
       histogram = d->selectionHistogram;
 
603
        histogram = d->selectionHistogram;
545
604
    }
546
605
    else
547
606
    {
548
 
       histogram = d->imageHistogram;
 
607
        histogram = d->imageHistogram;
549
608
    }
550
609
 
551
610
    if (!histogram)
559
618
    d->histogramPainter->setScale(d->scaleType);
560
619
    d->histogramPainter->setSelection(d->xmin, d->xmax);
561
620
    d->histogramPainter->setHighlightSelection(d->selectMode);
 
621
 
562
622
    if (d->guideVisible == true)
563
623
    {
564
624
        d->histogramPainter->enableHistogramGuideByColor(d->colorGuide);
582
642
    // render statistics if needed
583
643
    if (d->statisticsVisible)
584
644
    {
585
 
       DToolTipStyleSheet cnt;
586
 
       QString            tipText, value;
587
 
       tipText = "<qt><table cellspacing=0 cellpadding=0>";
588
 
 
589
 
       tipText += cnt.cellBeg + i18n("Mean:") + cnt.cellMid;
590
 
       double mean = histogram->getMean(d->channelType, 0, histogram->getHistogramSegments()-1);
591
 
       tipText += value.setNum(mean, 'f', 1) + cnt.cellEnd;
592
 
 
593
 
       tipText += cnt.cellBeg + i18n("Pixels:") + cnt.cellMid;
594
 
       double pixels = histogram->getPixels();
595
 
       tipText += value.setNum((float)pixels, 'f', 0) + cnt.cellEnd;
596
 
 
597
 
       tipText += cnt.cellBeg + i18n("Std dev.:") + cnt.cellMid;
598
 
       double stddev = histogram->getStdDev(d->channelType, 0, histogram->getHistogramSegments()-1);
599
 
       tipText += value.setNum(stddev, 'f', 1) + cnt.cellEnd;
600
 
 
601
 
       tipText += cnt.cellBeg + i18n("Count:") + cnt.cellMid;
602
 
       double counts = histogram->getCount(d->channelType, 0, histogram->getHistogramSegments()-1);
603
 
       tipText += value.setNum((float)counts, 'f', 0) + cnt.cellEnd;
604
 
 
605
 
       tipText += cnt.cellBeg + i18n("Median:") + cnt.cellMid;
606
 
       double median = histogram->getMedian(d->channelType, 0, histogram->getHistogramSegments()-1);
607
 
       tipText += value.setNum(median, 'f', 1) + cnt.cellEnd;
608
 
 
609
 
       tipText += cnt.cellBeg + i18n("Percent:") + cnt.cellMid;
610
 
       double percentile = (pixels > 0 ? (100.0 * counts / pixels) : 0.0);
611
 
       tipText += value.setNum(percentile, 'f', 1) + cnt.cellEnd;
612
 
 
613
 
       tipText += "</table></qt>";
614
 
 
615
 
       this->setToolTip(tipText);
 
645
        DToolTipStyleSheet cnt;
 
646
        QString            tipText, value;
 
647
        tipText = "<qt><table cellspacing=0 cellpadding=0>";
 
648
 
 
649
        tipText += cnt.cellBeg + i18n("Mean:") + cnt.cellMid;
 
650
        double mean = histogram->getMean(d->channelType, 0, histogram->getHistogramSegments()-1);
 
651
        tipText += value.setNum(mean, 'f', 1) + cnt.cellEnd;
 
652
 
 
653
        tipText += cnt.cellBeg + i18n("Pixels:") + cnt.cellMid;
 
654
        double pixels = histogram->getPixels();
 
655
        tipText += value.setNum((float)pixels, 'f', 0) + cnt.cellEnd;
 
656
 
 
657
        tipText += cnt.cellBeg + i18n("Std dev.:") + cnt.cellMid;
 
658
        double stddev = histogram->getStdDev(d->channelType, 0, histogram->getHistogramSegments()-1);
 
659
        tipText += value.setNum(stddev, 'f', 1) + cnt.cellEnd;
 
660
 
 
661
        tipText += cnt.cellBeg + i18n("Count:") + cnt.cellMid;
 
662
        double counts = histogram->getCount(d->channelType, 0, histogram->getHistogramSegments()-1);
 
663
        tipText += value.setNum((float)counts, 'f', 0) + cnt.cellEnd;
 
664
 
 
665
        tipText += cnt.cellBeg + i18n("Median:") + cnt.cellMid;
 
666
        double median = histogram->getMedian(d->channelType, 0, histogram->getHistogramSegments()-1);
 
667
        tipText += value.setNum(median, 'f', 1) + cnt.cellEnd;
 
668
 
 
669
        tipText += cnt.cellBeg + i18n("Percent:") + cnt.cellMid;
 
670
        double percentile = (pixels > 0 ? (100.0 * counts / pixels) : 0.0);
 
671
        tipText += value.setNum(percentile, 'f', 1) + cnt.cellEnd;
 
672
 
 
673
        tipText += "</table></qt>";
 
674
 
 
675
        this->setToolTip(tipText);
616
676
    }
617
677
 
618
678
}
619
679
 
620
 
void HistogramWidget::mousePressEvent ( QMouseEvent * e )
 
680
void HistogramWidget::mousePressEvent ( QMouseEvent* e )
621
681
{
622
682
    if ( d->selectMode == true && d->clearFlag == HistogramWidgetPriv::HistogramCompleted )
623
683
    {
635
695
    }
636
696
}
637
697
 
638
 
void HistogramWidget::mouseReleaseEvent ( QMouseEvent * )
 
698
void HistogramWidget::mouseReleaseEvent ( QMouseEvent* )
639
699
{
640
700
    if ( d->selectMode == true  && d->clearFlag == HistogramWidgetPriv::HistogramCompleted )
641
701
    {
642
702
        d->inSelected = false;
 
703
 
643
704
        // Only single click without mouse move? Remove selection.
644
705
        if (d->xmax == 0.0)
645
706
        {
652
713
    }
653
714
}
654
715
 
655
 
void HistogramWidget::mouseMoveEvent ( QMouseEvent * e )
 
716
void HistogramWidget::mouseMoveEvent ( QMouseEvent* e )
656
717
{
657
718
    if ( d->selectMode == true && d->clearFlag == HistogramWidgetPriv::HistogramCompleted )
658
719
    {
659
 
       setCursor( Qt::CrossCursor );
660
 
 
661
 
       if (d->inSelected)
662
 
       {
663
 
          double max = ((double)e->pos().x()) / ((double)width());
664
 
          //int max = (int)(e->pos().x()*((float)m_imageHistogram->getHistogramSegments()/(float)width()));
665
 
 
666
 
          if (max < d->xminOrg)
667
 
          {
668
 
             d->xmax = d->xminOrg;
669
 
             d->xmin = max;
670
 
             //emit signalMinValueChanged( (int)(d->xmin * d->range) );
671
 
          }
672
 
          else
673
 
          {
674
 
             d->xmin = d->xminOrg;
675
 
             d->xmax = max;
676
 
          }
677
 
 
678
 
          notifyValuesChanged();
679
 
          //emit signalMaxValueChanged( d->xmax == 0.0 ? d->range : (int)(d->xmax * d->range) );
680
 
 
681
 
          repaint();
682
 
       }
 
720
        setCursor( Qt::CrossCursor );
 
721
 
 
722
        if (d->inSelected)
 
723
        {
 
724
            double max = ((double)e->pos().x()) / ((double)width());
 
725
            //int max = (int)(e->pos().x()*((float)m_imageHistogram->getHistogramSegments()/(float)width()));
 
726
 
 
727
            if (max < d->xminOrg)
 
728
            {
 
729
                d->xmax = d->xminOrg;
 
730
                d->xmin = max;
 
731
                //emit signalMinValueChanged( (int)(d->xmin * d->range) );
 
732
            }
 
733
            else
 
734
            {
 
735
                d->xmin = d->xminOrg;
 
736
                d->xmax = max;
 
737
            }
 
738
 
 
739
            notifyValuesChanged();
 
740
            //emit signalMaxValueChanged( d->xmax == 0.0 ? d->range : (int)(d->xmax * d->range) );
 
741
 
 
742
            repaint();
 
743
        }
683
744
    }
684
745
}
685
746
 
698
759
            d->xmin = 0.0;
699
760
            d->xmax = 0.0;
700
761
        }
 
762
 
701
763
        if (min >= 0 && min < d->range)
702
764
        {
703
 
           d->xmin = ((double)min)/d->range;
 
765
            d->xmin = ((double)min)/d->range;
704
766
        }
 
767
 
705
768
        repaint();
706
769
    }
707
770
}
720
783
        {
721
784
            d->xmax = ((double)max)/d->range;
722
785
        }
 
786
 
723
787
        repaint();
724
788
    }
725
789
}