-
Notifications
You must be signed in to change notification settings - Fork 122
/
ProjectionSurface.cpp
773 lines (689 loc) · 21 KB
/
ProjectionSurface.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
#include "ProjectionSurface.h"
#include "GLColor.h"
#include "MantidGLWidget.h"
#include "OpenGLError.h"
#include "InputController.h"
#include "MantidGeometry/IDetector.h"
#include "MantidGeometry/Objects/Object.h"
#include "MantidAPI/IPeaksWorkspace.h"
#include <QRgb>
#include <QSet>
#include <QMenu>
#include <QMouseEvent>
#include <QPainter>
#include <QMessageBox>
#include <cfloat>
#include <limits>
#include <cmath>
#include <algorithm>
#include "MantidKernel/V3D.h"
using Mantid::Kernel::V3D;
/**
* The constructor.
* @param rootActor :: The instrument actor containning all info about the instrument
*/
ProjectionSurface::ProjectionSurface(const InstrumentActor* rootActor):
m_instrActor(rootActor),
m_viewImage(NULL),
m_pickImage(NULL),
m_viewRect(),
m_selectRect(),
m_interactionMode(MoveMode),
m_isLightingOn(false),
m_peakLabelPrecision(2),
m_peakShapesStyle(0),
m_viewChanged(true),
m_redrawPicking(true)
{
connect(rootActor,SIGNAL(colorMapChanged()),this,SLOT(colorMapChanged()));
connect(&m_maskShapes,SIGNAL(shapeCreated()),this,SIGNAL(shapeCreated()));
connect(&m_maskShapes,SIGNAL(shapeSelected()),this,SIGNAL(shapeSelected()));
connect(&m_maskShapes,SIGNAL(shapesDeselected()),this,SIGNAL(shapesDeselected()));
connect(&m_maskShapes,SIGNAL(shapesRemoved()),this,SIGNAL(shapesRemoved()));
connect(&m_maskShapes,SIGNAL(shapeChanged()),this,SIGNAL(shapeChanged()));
connect(&m_maskShapes,SIGNAL(cleared()),this,SIGNAL(shapesCleared()));
// create and connect the pick input controller
InputControllerPick* pickController = new InputControllerPick(this);
setInputController(PickSingleMode, pickController);
setInputController(PickTubeMode, pickController);
setInputController(AddPeakMode, pickController);
connect(pickController,SIGNAL(pickPointAt(int,int)),this,SLOT(pickDetectorAt(int,int)));
connect(pickController,SIGNAL(touchPointAt(int,int)),this,SLOT(touchDetectorAt(int,int)));
// create and connect the mask drawing input controller
InputControllerDrawShape* drawController = new InputControllerDrawShape(this);
setInputController(DrawMode, drawController);
connect(drawController,SIGNAL(addShape(QString,int,int,QColor,QColor)),&m_maskShapes,SLOT(addShape(QString,int,int,QColor,QColor)));
connect(this,SIGNAL(signalToStartCreatingShape2D(QString,QColor,QColor)),drawController,SLOT(startCreatingShape2D(QString,QColor,QColor)));
connect(drawController,SIGNAL(moveRightBottomTo(int,int)),&m_maskShapes,SLOT(moveRightBottomTo(int,int)));
connect(drawController,SIGNAL(selectAt(int,int)),&m_maskShapes,SLOT(selectShapeOrControlPointAt(int,int)));
connect(drawController,SIGNAL(selectCtrlAt(int,int)),&m_maskShapes,SLOT(addToSelectionShapeAt(int,int)));
connect(drawController,SIGNAL(moveBy(int,int)),&m_maskShapes,SLOT(moveShapeOrControlPointBy(int,int)));
connect(drawController,SIGNAL(touchPointAt(int,int)),&m_maskShapes,SLOT(touchShapeOrControlPointAt(int,int)));
connect(drawController,SIGNAL(disabled()),&m_maskShapes,SLOT(deselectAll()));
connect(drawController,SIGNAL(removeSelectedShapes()),&m_maskShapes,SLOT(removeSelectedShapes()));
connect(drawController,SIGNAL(deselectAll()),&m_maskShapes,SLOT(deselectAll()));
connect(drawController,SIGNAL(restoreOverrideCursor()),&m_maskShapes,SLOT(restoreOverrideCursor()));
connect(drawController,SIGNAL(setSelection(QRect)),this,SLOT(setSelectionRect(QRect)));
connect(drawController,SIGNAL(finishSelection(QRect)),this,SLOT(selectMultipleMasks(QRect)));
connect(drawController,SIGNAL(finishSelection(QRect)),this,SIGNAL(shapeChangeFinished()));
// create and connect the peak eraser controller
InputControllerErase* eraseController = new InputControllerErase(this);
setInputController(EraseMode, eraseController);
connect(eraseController,SIGNAL(erase(QRect)),this,SLOT(erasePeaks(QRect)));
}
ProjectionSurface::~ProjectionSurface()
{
if (m_viewImage)
{
delete m_viewImage;
}
if (m_pickImage)
{
delete m_pickImage;
}
for(int i=0;i < m_peakShapes.size(); ++i)
{
if (m_peakShapes[i]) delete m_peakShapes[i];
}
m_peakShapes.clear();
}
/**
* Resets the instrument actor. The caller must ensure that the instrument
* stays the same and workspace dimensions also don't change.
*/
void ProjectionSurface::resetInstrumentActor(const InstrumentActor* rootActor)
{
m_instrActor = rootActor;
connect(rootActor,SIGNAL(colorMapChanged()),this,SLOT(colorMapChanged()));
}
void ProjectionSurface::clear()
{
if (m_viewImage)
{
delete m_viewImage;
m_viewImage = NULL;
}
if (m_pickImage)
{
delete m_pickImage;
m_pickImage = NULL;
}
m_viewChanged = true;
m_redrawPicking = true;
m_viewRect = RectF();
m_selectRect = QRect();
}
/**
* Draw the surface on an OpenGL widget
* @param widget :: A widget to draw on.
*/
void ProjectionSurface::draw(MantidGLWidget *widget)const
{
if ( m_viewChanged && ( m_redrawPicking
|| m_interactionMode == PickSingleMode
|| m_interactionMode == PickTubeMode
|| m_interactionMode == DrawMode ) )
{
draw(widget,true);
m_redrawPicking = false;
}
draw(widget,false);
if ( m_viewChanged )
{
m_viewChanged = false;
}
}
/**
* Draw the surface on an OpenGL widget.
* @param widget :: A widget to draw on.
* @param picking :: Picking / normal drawing switch.
*/
void ProjectionSurface::draw(MantidGLWidget *widget,bool picking)const
{
QImage **image = picking ? &m_pickImage : &m_viewImage;
if (!*image || (*image)->width() != widget->width() || (*image)->height() != widget->height())
{
m_viewChanged = true;
}
if (m_viewChanged)
{
this->drawSurface(widget,picking);
if (*image)
{
delete (*image);
}
(*image) = new QImage(widget->grabFrameBuffer());
if (!picking)
{
QPainter painter(widget);
RectF windowRect = getSurfaceBounds();
m_maskShapes.setWindow(windowRect,painter.viewport());
m_maskShapes.draw(painter);
for(int i=0;i < m_peakShapes.size(); ++i)
{
m_peakShapes[i]->setWindow(windowRect,painter.viewport());
m_peakShapes[i]->draw(painter);
}
painter.end();
}
}
else if (!picking)
{
QPainter painter(widget);
painter.drawImage(0,0,**image);
RectF windowRect = getSurfaceBounds();
m_maskShapes.setWindow(windowRect,painter.viewport());
m_maskShapes.draw(painter);
for(int i=0;i < m_peakShapes.size(); ++i)
{
m_peakShapes[i]->setWindow(windowRect,painter.viewport());
m_peakShapes[i]->draw(painter);
}
// draw the selection rectangle
if (!m_selectRect.isNull())
{
painter.setPen(Qt::blue);
//painter.setCompositionMode(QPainter::CompositionMode_Xor);
painter.drawRect(m_selectRect);
}
getController()->onPaint( painter );
painter.end();
// Discard any error generated here
glGetError();
}
}
/**
* Draw the surface onto a normal widget without OpenGL
* @param widget :: A widget to draw on.
*/
void ProjectionSurface::drawSimple(QWidget* widget)const
{
if (m_viewChanged)
{
if ( !m_viewImage || m_viewImage->width() != widget->width() || m_viewImage->height() != widget->height())
{
if ( m_viewImage ) delete m_viewImage;
m_viewImage = new QImage(widget->width(), widget->height(),QImage::Format_RGB32);
if (m_pickImage) delete m_pickImage;
m_pickImage = new QImage(widget->width(), widget->height(),QImage::Format_RGB32);
}
if ( m_redrawPicking || m_interactionMode == PickSingleMode || m_interactionMode == PickTubeMode )
{
drawSimpleToImage(m_pickImage,true);
m_redrawPicking = false;
}
drawSimpleToImage(m_viewImage,false);
m_viewChanged = false;
}
QPainter painter(widget);
painter.drawImage(0,0,*m_viewImage);
RectF windowRect = getSurfaceBounds();
m_maskShapes.setWindow(windowRect,painter.viewport());
m_maskShapes.draw(painter);
for(int i=0;i < m_peakShapes.size(); ++i)
{
m_peakShapes[i]->setWindow(windowRect,painter.viewport());
m_peakShapes[i]->draw(painter);
}
// draw the selection rectangle
if (!m_selectRect.isNull())
{
painter.setPen(Qt::blue);
//painter.setCompositionMode(QPainter::CompositionMode_Xor);
painter.drawRect(m_selectRect);
}
getController()->onPaint( painter );
painter.end();
}
void ProjectionSurface::resize(int, int)
{
updateView();
}
/**
* Draw the surface onto an image without OpenGL
* @param image :: Image to draw on.
* @param picking :: If true draw a picking image.
*/
void ProjectionSurface::drawSimpleToImage(QImage*,bool)const
{
}
void ProjectionSurface::mousePressEvent(QMouseEvent* e)
{
getController()->mousePressEvent( e );
}
void ProjectionSurface::mouseMoveEvent(QMouseEvent* e)
{
getController()->mouseMoveEvent( e );
}
void ProjectionSurface::mouseReleaseEvent(QMouseEvent* e)
{
getController()->mouseReleaseEvent( e );
}
void ProjectionSurface::wheelEvent(QWheelEvent* e)
{
getController()->wheelEvent( e );
}
void ProjectionSurface::keyPressEvent(QKeyEvent* e)
{
getController()->keyPressEvent( e );
}
void ProjectionSurface::enterEvent(QEvent *e)
{
getController()->enterEvent( e );
}
void ProjectionSurface::leaveEvent(QEvent *e)
{
getController()->leaveEvent( e );
}
/**
* Update the view of the surface at the next redraw.
* @param picking :: Set to true to update the picking image regardless the interaction
* mode of the surface.
*/
void ProjectionSurface::updateView(bool picking)
{
m_viewChanged = true;
if (picking)
{
// don't change to false if it's already true
m_redrawPicking = true;
}
}
void ProjectionSurface::updateDetectors()
{
clear();
this->init();
// if integration range in the instrument actor has changed
// update visiblity of peak markers
setPeakVisibility();
}
/// Send a redraw request to the surface owner
void ProjectionSurface::requestRedraw(bool resetPeakVisibility)
{
if ( resetPeakVisibility )
{
setPeakVisibility();
}
emit redrawRequired();
}
QRect ProjectionSurface::selectionRect()const
{
if (m_selectRect.width() <= 1 || m_selectRect.height() <= 1) return QRect();
int x_min = m_selectRect.left();
int x_size = m_selectRect.width();
int y_min = m_selectRect.top();
int y_size = m_selectRect.height();
if (x_size < 0)
{
x_min += x_size;
x_size = abs(x_size);
}
if (y_size < 0)
{
y_min += y_size;
y_size = abs(y_size);
}
return QRect(x_min,y_min,x_size,y_size);
}
RectF ProjectionSurface::selectionRectUV()const
{
double left = static_cast<double>(m_selectRect.left());
double right = static_cast<double>(m_selectRect.right());
double top = static_cast<double>(m_selectRect.top());
double bottom = static_cast<double>(m_selectRect.bottom());
if ( left > right )
{
std::swap( left, right );
}
if ( top > bottom )
{
std::swap( top, bottom );
}
if ( abs(m_selectRect.width()) <= 1 || abs(m_selectRect.height()) <= 1) return RectF();
double sx = m_viewRect.xSpan() / m_viewImage->width();
double sy = m_viewRect.ySpan() / m_viewImage->height();
double x_min = left * sx + m_viewRect.x0();
double x_max = right * sx + m_viewRect.x0();
double y_min = (m_viewImage->height() - bottom) * sy + m_viewRect.y0();
double y_max = (m_viewImage->height() - top) * sy + m_viewRect.y0();
return RectF( QPointF(x_min, y_min), QPointF(x_max, y_max) );
}
bool ProjectionSurface::hasSelection()const
{
return ! m_selectRect.isNull() && m_selectRect.width() > 0;
}
void ProjectionSurface::colorMapChanged()
{
this->changeColorMap();
updateView(false);
}
/**
* Set an interaction mode for the surface.
* @param mode :: A new mode.
*/
void ProjectionSurface::setInteractionMode(int mode)
{
if ( mode < 0 || mode >= m_inputControllers.size() )
{
throw std::logic_error("Invalid interaction mode requested.");
}
if ( mode == m_interactionMode ) return;
InputController *controller = m_inputControllers[m_interactionMode];
if ( !controller ) throw std::logic_error("Input controller doesn't exist.");
controller->onDisabled();
m_interactionMode = mode;
controller = m_inputControllers[m_interactionMode];
if ( !controller ) throw std::logic_error("Input controller doesn't exist.");
controller->onEnabled();
if ( mode != DrawMode )
{
m_maskShapes.deselectAll();
foreach(PeakOverlay* po, m_peakShapes)
{
po->deselectAll();
}
}
}
/**
* Return detector id at image coordinats x,y if in pick mode. -1 otherwise
*/
int ProjectionSurface::getDetectorID(int x, int y)const
{
if (!m_pickImage) return -7;
if (!m_pickImage->valid(x,y)) return -1;
QRgb pixel = m_pickImage->pixel(x,y);
return getDetectorID((unsigned char)qRed(pixel),(unsigned char)qGreen(pixel),(unsigned char)qBlue(pixel));
}
//------------------------------------------------------------------------------
boost::shared_ptr<const Mantid::Geometry::IDetector> ProjectionSurface::getDetector(int x, int y)const
{
if (!m_pickImage || !m_pickImage->valid(x,y)) return boost::shared_ptr<const Mantid::Geometry::IDetector>();
QRgb pixel = m_pickImage->pixel(x,y);
int index = getDetectorIndex((unsigned char)qRed(pixel),(unsigned char)qGreen(pixel),(unsigned char)qBlue(pixel));
if ( index >= 0 ) return m_instrActor->getDetector(index);
return boost::shared_ptr<const Mantid::Geometry::IDetector>();
}
/**
* Return info text for interactions common to all surfaces.
*/
QString ProjectionSurface::getInfoText() const
{
switch ( m_interactionMode )
{
case PickSingleMode:
case PickTubeMode:
return "Move cursor over instrument to see detector information. ";
case AddPeakMode:
return "Click on a detector then click on the mini-plot to add a peak.";
case DrawMode:
return "Select a tool button to draw a new shape. "
"Click on shapes to select. Click and move to edit.";
case EraseMode:
return "Click and move the mouse to erase peaks. "
"Rotate the wheel to resize the cursor.";
}
return "";
}
//------------------------------------------------------------------------------
/** Return the detector position (in real-space) at the pixel coordinates.
*
* @param x :: x pixel coordinate
* @param y :: y pixel coordinate
* @return V3D of the detector position
*/
Mantid::Kernel::V3D ProjectionSurface::getDetectorPos(int x, int y) const
{
if (!m_pickImage || !m_pickImage->valid(x,y)) return V3D();
QRgb pixel = m_pickImage->pixel(x,y);
int index = getDetectorIndex((unsigned char)qRed(pixel),(unsigned char)qGreen(pixel),(unsigned char)qBlue(pixel));
if ( index >= 0 )
return m_instrActor->getDetPos(index);
else
return V3D();
}
/**
* Is context menu allowed?
*/
bool ProjectionSurface::canShowContextMenu() const
{
InputController *controller = m_inputControllers[m_interactionMode];
if ( controller )
{
return controller->canShowContextMenu();
}
return false;
}
//------------------------------------------------------------------------------
int ProjectionSurface::getDetectorIndex(unsigned char r,unsigned char g,unsigned char b)const
{
size_t index = GLActor::decodePickColor(r,g,b);
if (index > m_instrActor->ndetectors())
{
return -1;
}
else
{
return int(index);
}
}
int ProjectionSurface::getDetectorID(unsigned char r,unsigned char g,unsigned char b)const
{
int index = getDetectorIndex(r,g,b);
if (index < 0) return index;
return m_instrActor->getDetID(index);
}
/**
* Adds an input controller to the controller list.
* @param mode :: The interaction mode which is the index of the controller in the list.
* @param controller :: A pointer to the controller to be set.
*/
void ProjectionSurface::setInputController(int mode, InputController *controller)
{
m_inputControllers[mode] = controller;
}
/**
* Set visibility of the peak markers according to the integration range
* in the instrument actor.
*/
void ProjectionSurface::setPeakVisibility() const
{
if ( hasPeakOverlays() )
{
Mantid::Kernel::Unit_sptr unit = m_instrActor->getWorkspace()->getAxis(0)->unit();
QString unitID = QString::fromStdString(unit->unitID());
double xmin = m_instrActor->minBinValue();
double xmax = m_instrActor->maxBinValue();
foreach(PeakOverlay* po, m_peakShapes)
{
po->setPeakVisibility(xmin,xmax,unitID);
}
}
}
/**
* Returns the current controller. If the controller doesn't exist throws a logic_error exceotion.
*/
InputController *ProjectionSurface::getController() const
{
InputController* controller = m_inputControllers[m_interactionMode];
if ( !controller )
{
throw std::logic_error("Input controller doesn't exist for current interaction mode.");
}
return controller;
}
// --- Shape2D manipulation --- //
void ProjectionSurface::startCreatingShape2D(const QString& type,const QColor& borderColor,const QColor& fillColor)
{
emit signalToStartCreatingShape2D(type,borderColor,fillColor);
}
/**
* Return a combined list of peak parkers from all overlays
* @param detID :: The detector ID of interest
*/
QList<PeakMarker2D*> ProjectionSurface::getMarkersWithID(int detID)const
{
QList<PeakMarker2D*> out;
for(int i=0;i < m_peakShapes.size(); ++i)
{
out += m_peakShapes[i]->getMarkersWithID(detID);
}
return out;
}
/**
* Get peaks workspace for manually editing.
*/
boost::shared_ptr<Mantid::API::IPeaksWorkspace> ProjectionSurface::getEditPeaksWorkspace() const
{
if ( !m_peakShapes.isEmpty() )
{
return m_peakShapes.last()->getPeaksWorkspace();
}
return boost::shared_ptr<Mantid::API::IPeaksWorkspace>();
}
/**
* Remove an overlay if its peaks workspace is deleted.
* @param ws :: Shared pointer to the deleted peaks workspace.
*/
void ProjectionSurface::deletePeaksWorkspace(boost::shared_ptr<Mantid::API::IPeaksWorkspace> ws)
{
const int npeaks = m_peakShapes.size();
for(int i=0;i < npeaks; ++i)
{
if (m_peakShapes[i]->getPeaksWorkspace() == ws)
{
delete m_peakShapes[i];
m_peakShapes.removeAt(i);
break;
}
}
if ( m_peakShapes.size() < npeaks )
{
emit peaksWorkspaceDeleted();
}
}
/**
* Remove all peak overlays.
*/
void ProjectionSurface::clearPeakOverlays()
{
if ( !m_peakShapes.isEmpty() )
{
for(int i=0;i < m_peakShapes.size(); ++i)
{
delete m_peakShapes[i];
}
m_peakShapes.clear();
m_peakShapesStyle = 0;
emit peaksWorkspaceDeleted();
}
}
/**
* Set the precision (significant digits) with which the HKL peak labels are displayed.
* @param n :: Precision, > 0
*/
void ProjectionSurface::setPeakLabelPrecision(int n)
{
if (n < 1)
{
QMessageBox::critical(NULL,"MantidPlot - Error","Precision must be a positive number");
return;
}
m_peakLabelPrecision = n;
for(int i=0;i < m_peakShapes.size(); ++i)
{
m_peakShapes[i]->setPrecision(n);
}
}
/**
* Enable or disable the show peak row flag
*/
void ProjectionSurface::setShowPeakRowsFlag(bool on)
{
m_showPeakRows = on;
for(int i=0;i < m_peakShapes.size(); ++i)
{
m_peakShapes[i]->setShowRowsFlag(on);
}
}
/**
* Enable or disable the show peak label flag
*/
void ProjectionSurface::setShowPeakLabelsFlag(bool on)
{
m_showPeakLabels = on;
for(int i=0;i < m_peakShapes.size(); ++i)
{
m_peakShapes[i]->setShowLabelsFlag(on);
}
}
/**
* Set the selection rect in screen corrds.
* @param rect :: New selection rectangle.
*/
void ProjectionSurface::setSelectionRect(const QRect &rect)
{
if ( m_interactionMode != DrawMode || !m_maskShapes.hasSelection() )
{
m_selectRect = rect;
}
}
/**
* Delete selection rectanle.
*/
void ProjectionSurface::emptySelectionRect()
{
m_selectRect = QRect();
}
/**
* Select multiple mask shapes as a result of a rubber-band selection
* @param rect :: The rubber band rect.
*/
void ProjectionSurface::selectMultipleMasks(const QRect &rect)
{
if ( !m_maskShapes.hasSelection() )
{
m_maskShapes.selectIn( rect );
}
emptySelectionRect();
}
/**
* Pick a detector at a pointe on the screen.
*/
void ProjectionSurface::pickDetectorAt(int x, int y)
{
int id = getDetectorID( x, y );
emit singleDetectorPicked(id);
}
void ProjectionSurface::touchDetectorAt(int x, int y)
{
int id = getDetectorID( x, y );
emit singleDetectorTouched(id);
}
void ProjectionSurface::erasePeaks(const QRect &rect)
{
foreach(PeakOverlay* po, m_peakShapes)
{
po->selectIn( rect );
po->removeSelectedShapes();
}
}
/**
* Enable or disable lighting in non-picking mode
* @param on :: True for enabling, false for disabling.
*/
void ProjectionSurface::enableLighting(bool on)
{
m_isLightingOn = on;
}
/**
* Return names of attached peaks workspaces.
*/
QStringList ProjectionSurface::getPeaksWorkspaceNames() const
{
QStringList names;
foreach(PeakOverlay* po, m_peakShapes)
{
names << QString::fromStdString(po->getPeaksWorkspace()->name());
}
return names;
}