ATLAS Offline Software
Loading...
Searching...
No Matches
VP1GraphicsView Class Reference

#include <VP1GraphicsView.h>

Inheritance diagram for VP1GraphicsView:
Collaboration diagram for VP1GraphicsView:

Classes

class  HighLightItem
class  Imp

Public Types

enum  Mode {
  PICK , CHANGEVIEW , SEEK , DRAGZOOM ,
  DRAGZOOMHOLD
}

Public Slots

void addItemCollection (VP1GraphicsItemCollection *)
void removeItemCollection (VP1GraphicsItemCollection *)
void setMode (const Mode &)
void setDisallowInteractions (VP1GraphicsItemCollection *, const bool &disallow=true)
void setDisallowMovable (VP1GraphicsItemCollection *, const bool &disallow=true)
void scaleView (qreal scaleFactor)
void fitViewToContents ()
void viewHome ()
void setHome ()
void initiateAnimatedZoomTo (QRectF)
void setAnimatedZoomSteps (int)
void setAnimatedZoomTime (double)
void setZoomFactorOnSeek (double)
void abortZoomAnimation ()
void seekToPoint (QPointF)
void clearSelections ()
void print ()
void saveImage ()

Public Member Functions

 VP1GraphicsView (QWidget *parent=0)
 VP1GraphicsView (QGraphicsScene *scene, QWidget *parent=0)
Mode mode () const
virtual ~VP1GraphicsView ()

Protected Member Functions

void keyPressEvent (QKeyEvent *)
void wheelEvent (QWheelEvent *)
void mouseDoubleClickEvent (QMouseEvent *event)
void mousePressEvent (QMouseEvent *)
void mouseReleaseEvent (QMouseEvent *)
void mouseMoveEvent (QMouseEvent *)
void drawItems (QPainter *painter, int numItems, QGraphicsItem *items[], const QStyleOptionGraphicsItem options[])
void drawForeground (QPainter *painter, const QRectF &rect)

Private Slots

void updateZoomAnimation ()

Private Member Functions

void emitSelectionChanged (VP1GraphicsItemCollection *)

Private Attributes

Impm_d

Friends

class HighLightItem

Detailed Description

Definition at line 22 of file VP1GraphicsView.h.

Member Enumeration Documentation

◆ Mode

Enumerator
PICK 
CHANGEVIEW 
SEEK 
DRAGZOOM 
DRAGZOOMHOLD 

Definition at line 37 of file VP1GraphicsView.h.

Constructor & Destructor Documentation

◆ VP1GraphicsView() [1/2]

VP1GraphicsView::VP1GraphicsView ( QWidget * parent = 0)

Definition at line 135 of file VP1GraphicsView.cxx.

136 :QGraphicsView(parent), m_d(new Imp)
137{
138 m_d->init(this);
139}

◆ VP1GraphicsView() [2/2]

VP1GraphicsView::VP1GraphicsView ( QGraphicsScene * scene,
QWidget * parent = 0 )

Definition at line 142 of file VP1GraphicsView.cxx.

143 : QGraphicsView(scene,parent), m_d(new Imp)
144{
145 m_d->init(this);
146}

◆ ~VP1GraphicsView()

VP1GraphicsView::~VP1GraphicsView ( )
virtual

Definition at line 203 of file VP1GraphicsView.cxx.

204{
205 delete m_d->transform;
206 delete m_d; m_d=0;
207}

Member Function Documentation

◆ abortZoomAnimation

void VP1GraphicsView::abortZoomAnimation ( )
slot

Definition at line 825 of file VP1GraphicsView.cxx.

826{
827 if (m_d->zoomanim_timer->isActive())
828 m_d->zoomanim_timer->stop();
829 if (!m_d->zoomanim_queue.empty())
830 m_d->zoomanim_queue.clear();
831 if (m_d->savedrenderhints)
832 setRenderHints(m_d->savedrenderhints);
833 m_d->savedrenderhints=QPainter::RenderHints();
834 //Fixme: renderhints changed during an
835 //animation cycle might not be saved... Should
836 //override the renderhints methods to avoid
837 //this.
838}

◆ addItemCollection

void VP1GraphicsView::addItemCollection ( VP1GraphicsItemCollection * ic)
slot

Definition at line 380 of file VP1GraphicsView.cxx.

380 {
381 assert(!m_d->cols_all.contains(ic));
382 assert(!m_d->cols_act.contains(ic));
383 m_d->cols_all << ic;
384 if (ic->interactionMode()!=VP1GraphicsItemCollection::INERT) {
385 m_d->cols_act << ic;
386 ic->setTemporaryIgnoreInteractions( m_d->mode!=PICK || m_d->cols_override_inactive.contains(ic) );
387 ic->setTemporaryIgnoreMovable( m_d->mode!=PICK || m_d->cols_override_unmovable.contains(ic) );
388 }
389 ic->attachToView(this);
390}
int ic
Definition grepfile.py:33

◆ clearSelections

void VP1GraphicsView::clearSelections ( )
slot

Definition at line 673 of file VP1GraphicsView.cxx.

673 {//Fixme: only clear
674 //selections of certain
675 //collections? (so the
676 //permanent items stay
677 //selected?)
678
679 bool haditemsinselection = m_d->ic_multiselection && !m_d->selecteditems.empty();
680
681 //Remove highlight items:
682 QMapIterator<QGraphicsItem*,HighLightItem*> it(m_d->selecteditems);
683 while (it.hasNext()) {
684 it.next();
685 it.value()->sendsignalondelete = false;
686 //assert(!m_d->scene->items().contains(it.key()));
687 if (m_d->scene->items().contains(it.value())) {
688 m_d->scene->removeItem(it.value());
689 // delete it.value();
690 }
691 }
692
693 //Clear lists - possibly emit a signal:
694 m_d->selecteditems.clear();
695 if (m_d->clearselectionsemitsignals&&haditemsinselection) {
696 emitSelectionChanged(m_d->ic_multiselection);
697 m_d->ic_multiselection = 0;//TEST
698 }
699 m_d->clearselectionsemitsignals=true;
700}
void emitSelectionChanged(VP1GraphicsItemCollection *)

◆ drawForeground()

void VP1GraphicsView::drawForeground ( QPainter * painter,
const QRectF & rect )
protected

Definition at line 987 of file VP1GraphicsView.cxx.

987 {
988
989 //Fixme: use rect?
990 if (!m_d->showhelptext)
991 return;
992 QRect imgrect = viewport()->rect();
993 imgrect.setWidth(imgrect.width()*3);
994 imgrect.setHeight(imgrect.height()*3);
995 if (!m_d->helptextimage||m_d->helptextimage->size()!=imgrect.size())
996 m_d->createNewHelptextImage(imgrect);//viewport()->rect());
997 painter->setRenderHint(QPainter::Antialiasing, false);
998 painter->drawImage(mapToScene(viewport()->rect()).boundingRect(),*(m_d->helptextimage),
999 imgrect);
1000}

◆ drawItems()

void VP1GraphicsView::drawItems ( QPainter * painter,
int numItems,
QGraphicsItem * items[],
const QStyleOptionGraphicsItem options[] )
protected

Definition at line 1091 of file VP1GraphicsView.cxx.

1094{
1095
1096 if (!(m_d->transform&&m_d->transformactive)) {
1097 QGraphicsView::drawItems(painter,numItems,items,options);
1098 //Fixme: implement own drawing here also - to make sure inbuilt selection stuff is never shown?
1099 return;
1100 }
1101
1102 for (int i = 0; i < numItems; ++i) {
1103 QGraphicsItem *item = items[i];
1104 painter->save();
1105 painter->setTransform(item->sceneTransform(), true);//??
1106 // std::cout<< item->sceneMatrix().isIdentity()<<std::endl;
1107 // std::cout<< item->sceneMatrix().dx()<<" : "<<item->sceneMatrix().dy()<<std::endl;
1108 m_d->transform->paintItem(painter, item);
1109 painter->restore();
1110 }
1111}

◆ emitSelectionChanged()

void VP1GraphicsView::emitSelectionChanged ( VP1GraphicsItemCollection * ic)
private

Definition at line 892 of file VP1GraphicsView.cxx.

892 {
893 QList<QGraphicsItem*> emitlist = m_d->selecteditems.keys();
894 if (emitlist==m_d->lastemittedselecteditems)
895 return;
896 m_d->lastemittedselecteditems=emitlist;
897 ic->selectionChangedPrivate(emitlist);
898}

◆ fitViewToContents

void VP1GraphicsView::fitViewToContents ( )
slot

Definition at line 220 of file VP1GraphicsView.cxx.

221{
222 if (m_d->transform&&m_d->transformactive)
223 fitInView( m_d->transform->transform(scene()->sceneRect()), Qt::KeepAspectRatio );
224 else
225 fitInView( scene()->sceneRect(), Qt::KeepAspectRatio );
226}

◆ initiateAnimatedZoomTo

void VP1GraphicsView::initiateAnimatedZoomTo ( QRectF goal)
slot

Definition at line 780 of file VP1GraphicsView.cxx.

781{
783 if (m_d->zoomanim_nsteps==1) {
784 fitInView(goal);
785 return;
786 }
787
788 QRectF currentview = mapToScene(viewport()->rect()).boundingRect();
789
790 double w1 = currentview.width(), h1 = currentview.height();
791 double x1 = currentview.x(), y1 = currentview.y();
792
793 double w2 = goal.width(), h2 = goal.height();
794 double x2 = goal.x(), y2 = goal.y();
795
796 const double eps = 1.0/m_d->zoomanim_nsteps;
797 for (double f = eps; f < 1.0+0.5*eps; f+=eps ) {
798 //f values are spaced linearly between eps and 1.0. Let us
799 //construct something which has values packed closer near 1.0 (for
800 //that nice smooth slow-down feel):
801 double f2 = sqrt(f);
802 m_d->zoomanim_queue.enqueue(QRectF( x1*(1.0-f2)+x2*f2, y1*(1.0-f2)+y2*f2,
803 w1*(1.0-f2)+w2*f2, h1*(1.0-f2)+h2*f2 ));
804 }
805
806 m_d->savedrenderhints=renderHints();
807 setRenderHints(QPainter::RenderHints());
808 m_d->zoomanim_timer->start();
809}

◆ keyPressEvent()

void VP1GraphicsView::keyPressEvent ( QKeyEvent * event)
protected

Definition at line 244 of file VP1GraphicsView.cxx.

245{
246// VP1Msg::messageDebug("VP1GraphicsView::keyPressEvent");
247
248// std::string keyText = (event->text()).toStdString();
249// VP1Msg::messageDebug(keyText.c_str());
250
251 if (m_d->showhelptext&&!(event->key()==Qt::Key_F1||event->key()==Qt::Key_H)) {
252 m_d->showhelptext=false;
253 viewport()->update();
254 };
255
256 switch (event->key()) {
257 case Qt::Key_Home:
258 if (event->modifiers() & Qt::ControlModifier)
259 setHome();
260 else
261 viewHome();
262 break;
263 case Qt::Key_F1:
264 case Qt::Key_H:
265 m_d->showhelptext=!m_d->showhelptext;
266 viewport()->update();
267 break;
268 case Qt::Key_1:
270 break;
271 case Qt::Key_Escape:
272 if (m_d->mode==SEEK)
273 setMode(m_d->lastmajormode);
274 else if (m_d->mode==PICK)
276 else
277 setMode(PICK);
278 break;
279 case Qt::Key_S:
280 if (m_d->mode!=SEEK)
281 setMode(SEEK);
282 else
283 setMode(m_d->lastmajormode);
284 break;
285 case Qt::Key_Plus:
286 case Qt::Key_Equal:
287 scaleView(1.2);
288 break;
289 case Qt::Key_Minus:
290 scaleView(1 / 1.2);
291 break;
292 case Qt::Key_P:
293 if (event->modifiers() & Qt::ControlModifier)
294 saveImage();
295 else
296 print();
297 break;
298 default:
299 // QGraphicsView::keyPressEvent(event);
300 break;
301 }
302
303// if (m_d->mode==PICK) {
304// for (QGraphicsItem*item : items(event->pos())) {
305// for (VP1GraphicsItemCollection* ic : m_d->cols_act) {
306// if (ic->itemBelongsAndIsPresentlyActive(item)) {
307// event->accept();
308// //EMIT [event] SIGNALS.
309// }
310// }
311// }
312// }
313
314
315 QGraphicsView::keyPressEvent(event);
316}
void setMode(const Mode &)
void scaleView(qreal scaleFactor)

◆ mode()

VP1GraphicsView::Mode VP1GraphicsView::mode ( ) const

Definition at line 374 of file VP1GraphicsView.cxx.

375{
376 return m_d->mode;
377}

◆ mouseDoubleClickEvent()

void VP1GraphicsView::mouseDoubleClickEvent ( QMouseEvent * event)
protected

Definition at line 406 of file VP1GraphicsView.cxx.

406 {
407
408 if (m_d->showhelptext) {
409 m_d->showhelptext=false;
410 viewport()->update();
411 };
412
413 if (m_d->mode!=PICK) {
414 QGraphicsView::mouseDoubleClickEvent(event);
415 return;
416 }
417 //Fixme: transformed pos
418 for (QGraphicsItem*item : items(event->pos())) {
419 for (VP1GraphicsItemCollection* ic : m_d->cols_act) {
420 if (ic->itemBelongsAndIsPresentlyActive(item)) {
421 event->accept();
422 //EMIT SIGNALS. CHANGE SELECTION.
423 }
424 }
425 }
426 QGraphicsView::mouseDoubleClickEvent(event);
427 return;
428}

◆ mouseMoveEvent()

void VP1GraphicsView::mouseMoveEvent ( QMouseEvent * event)
protected

Definition at line 432 of file VP1GraphicsView.cxx.

433{
434
435 //Fixme: transformed pos
436
437 if ((m_d->mode==DRAGZOOM||m_d->mode==DRAGZOOMHOLD) && m_d->dragzoom_startpoint!=QPoint() ) {
438 double delta = event->pos().y()-m_d->dragzoom_startpoint.y();
439 m_d->dragzoom_startpoint=event->pos();
440 ViewportAnchor save = transformationAnchor();
441 setTransformationAnchor(AnchorViewCenter);
442 scaleView(pow((double)2, -delta / (240.0/0.8)));//FIXME!! Dont have this equation more than once!
443 setTransformationAnchor(save);
444 event->accept();
445 return;
446 }
447 if (m_d->mode==PICK) {
448 for (QGraphicsItem*item : items(event->pos())) {
449 for (VP1GraphicsItemCollection* ic : m_d->cols_act) {
450 if (ic->itemBelongsAndIsPresentlyActive(item)) {
451 event->accept();
452 //EMIT [event] SIGNALS.
453 }
454 }
455 }
456 }
457 QGraphicsView::mouseMoveEvent(event);
458 return;
459}
constexpr int pow(int base, int exp) noexcept

◆ mousePressEvent()

void VP1GraphicsView::mousePressEvent ( QMouseEvent * event)
protected

Definition at line 462 of file VP1GraphicsView.cxx.

463{
464 setFocus(Qt::MouseFocusReason);//Fixme: also doubleclick event!
465
466 if (m_d->showhelptext) {
467 m_d->showhelptext=false;
468 viewport()->update();
469 };
470
471 if (m_d->mode==SEEK) {
472 event->accept();
473 setMode(m_d->lastmajormode);
474 seekToPoint(mapToScene(event->pos()));
475 return;
476 }
477
478 if (m_d->mode==CHANGEVIEW&&event->buttons()==(Qt::LeftButton|Qt::MiddleButton)) {
479 event->accept();
480 m_d->dragzoom_startpoint=event->pos();
482 return;
483 }
484
485 if (m_d->mode==DRAGZOOM&&event->buttons()!=(Qt::LeftButton|Qt::MiddleButton)) {
486 if (event->buttons()==(Qt::LeftButton|Qt::MiddleButton|Qt::RightButton)) {
488 } else {
490 }
491 event->accept();
492 return;
493 }
494
495 if (m_d->mode==DRAGZOOMHOLD) {//Fixme: also doubleclick event!
497 event->accept();
498 return;
499 }
500
501
502 if (m_d->mode==PICK) {
503 if (event->buttons()!=Qt::LeftButton) {
504 QGraphicsView::mousePressEvent(event);
505 return;
506 }
507 //If we have previous selections already, and the mult select key
508 //is down, then we will only consider items in the same collection
509 //as active.
510 bool continueselection = m_d->ic_multiselection && (event->modifiers() & Qt::ShiftModifier);
511 QGraphicsItem*item(0);VP1GraphicsItemCollection*ic(0);
512
513// QPoint pickpoint = m_d->transform ?
514// mapFromScene(m_d->transform->inverseTransform( mapToScene(event->pos())))
515// : event->pos();
516 QPoint pickpoint = event->pos();
517 if (continueselection) {
518 assert(m_d->ic_multiselection);
519 m_d->locateActiveItemAtPoint(item,ic,pickpoint,m_d->ic_multiselection);
520 if (!item) {
521 //shift was down, and the user did not hit anything
522 QGraphicsView::mousePressEvent(event);
523 return;
524 }
525 } else {
526 m_d->locateActiveItemAtPoint(item,ic,pickpoint);
527 }
528
529 if (item) {
530 assert(ic);
531 if (ic->interactionMode()==VP1GraphicsItemCollection::SINGLEPICKS) {
533 m_d->setNewSelected(item);
534 ic->itemPickedPrivate(item);
535 } else if (ic->interactionMode()==VP1GraphicsItemCollection::EVENTS) {
537 event->accept();
538 ic->itemGotEventPrivate(item,event);
539 return;
540 } else if (ic->interactionMode()==VP1GraphicsItemCollection::SELECTIONS) {
541 assert(ic);
542 VP1GraphicsItemCollection * tmpic = ic;
543 m_d->ic_multiselection=ic;
544 m_d->setNewSelected(item,continueselection);
546 } else {
547 assert(0);
548 }
549 } else {
551 }
552 }
553
554 QGraphicsView::mousePressEvent(event);
555 return;
556}
void seekToPoint(QPointF)

◆ mouseReleaseEvent()

void VP1GraphicsView::mouseReleaseEvent ( QMouseEvent * event)
protected

Definition at line 559 of file VP1GraphicsView.cxx.

560{
561
562 //Fixme: transformed pos
563 if (m_d->mode==CHANGEVIEW&&event->buttons()==(Qt::LeftButton|Qt::MiddleButton)) {
564 event->accept();
565 m_d->dragzoom_startpoint=event->pos();
567 return;
568 }
569
570 if (m_d->mode==DRAGZOOM&&event->buttons()!=(Qt::LeftButton|Qt::MiddleButton)) {
571 event->accept();
573 return;
574 }
575
576 if (m_d->mode==PICK) {
577// for (QGraphicsItem*item : items(event->pos())) {
578// if (item==static_cast<QGraphicsItem*>(m_d->selectionoutline))//Fixme: Dont do the cast here.
579// continue;
580// for(VP1GraphicsItemCollection* ic : m_d->cols_act) {
581// if (ic->itemBelongsAndIsPresentlyActive(item)) {
582// event->accept();
583// if (ic->interactionMode()==VP1GraphicsItemCollection::EVENTS) {
584// //EMIT EVENT SIGNAL!
585// return;
586// }
587// if (m_d->selecteditem==item) {
588// QGraphicsView::mouseReleaseEvent(event);
589// return;
590// }
591// m_d->setNewSelected(item);
592// //EMIT pick/selection signals.
593// }
594// }
595// }
596 }
597 QGraphicsView::mouseReleaseEvent(event);
598 return;
599
600}

◆ print

void VP1GraphicsView::print ( )
slot

Definition at line 935 of file VP1GraphicsView.cxx.

936{
937 //Fixme: This does not really work well... Check again in QT 4.3?
938 QPrinter printer;
939 QPrintDialog dialog(&printer, this);
940 if (dialog.exec() == QDialog::Accepted) {
941 QPainter painter(&printer);
942 render(&painter);
943 }
944}

◆ removeItemCollection

void VP1GraphicsView::removeItemCollection ( VP1GraphicsItemCollection * ic)
slot

Definition at line 393 of file VP1GraphicsView.cxx.

393 {
394 assert(m_d->cols_all.contains(ic));
395 m_d->cols_all.removeAll(ic);
396 if (m_d->cols_act.contains(ic))
397 m_d->cols_act.removeAll(ic);
398 ic->setTemporaryIgnoreInteractions(false);
399 ic->setTemporaryIgnoreMovable(false);
400 ic->real_detachFromView();
401 //Fixme: When user calls the detach/attach/... methods on the ic, these methods must also be invoked!
402 //Fixme: use groupnode in each ic. This also allows an easy hide/unhide action as well as z values... (ic have external setZValue() method).
403}

◆ saveImage

void VP1GraphicsView::saveImage ( )
slot

Definition at line 947 of file VP1GraphicsView.cxx.

948{
949 QString guess;
950 if (m_d->currentsaveimagefile.isEmpty()) {
951 QString base=VP1Settings::defaultFileSelectDirectory()+QDir::separator()+"vp1_capture";
952 guess=base;
953 int i(2);
954 while (QFile::exists(guess+".png"))
955 guess=base+"_"+QString::number(i++);
956 guess+=".png";
957 } else {
958 guess=m_d->currentsaveimagefile;
959 }
960
961 QString filename = QFileDialog::getSaveFileName(0, "Select target image file", guess,
962 "Image (*.png *.bmp)",
963 0,QFileDialog::DontResolveSymlinks);
964 if(filename.isEmpty())
965 return;
966
967 QPixmap pm = viewport()->grab();
968 if (!(filename.endsWith(".png",Qt::CaseInsensitive)||filename.endsWith(".bmp",Qt::CaseInsensitive)))
969 filename += ".png";
970
971 pm.save(filename);
972 m_d->currentsaveimagefile = std::move(filename);
973}
static QString defaultFileSelectDirectory()
std::string base
Definition hcg.cxx:81

◆ scaleView

void VP1GraphicsView::scaleView ( qreal scaleFactor)
slot

Definition at line 210 of file VP1GraphicsView.cxx.

211{
213 qreal factor = transform().scale(scaleFactor, scaleFactor).mapRect(QRectF(0, 0, 1, 1)).width();
214 if (factor < 1e-5 || factor > 1e5)//Fixme:Set as options!
215 return;
216 scale(scaleFactor, scaleFactor);
217}
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.

◆ seekToPoint

void VP1GraphicsView::seekToPoint ( QPointF targetpoint)
slot

Definition at line 770 of file VP1GraphicsView.cxx.

770 {
771 abortZoomAnimation();//In case there is already an animation running we abort it.
772 QRectF currentview = mapToScene(viewport()->rect()).boundingRect();
773 double w1= currentview.width(), h1= currentview.height();
774 double w2 = w1/m_d->zoomfactoronseek, h2 = h1/m_d->zoomfactoronseek;
775 double x2 = targetpoint.x()-0.5*w2, y2 = targetpoint.y()-0.5*h2;
776 initiateAnimatedZoomTo( QRectF(x2,y2,w2,h2) );
777}
void initiateAnimatedZoomTo(QRectF)

◆ setAnimatedZoomSteps

void VP1GraphicsView::setAnimatedZoomSteps ( int n)
slot

Definition at line 842 of file VP1GraphicsView.cxx.

843{
844 assert(n>=1);
845 m_d->zoomanim_nsteps = n;
846 m_d->zoomanim_timer->setInterval(std::max(1,static_cast<int>(m_d->zoomanim_totaltime/m_d->zoomanim_nsteps+0.5)));
847 //Same as just below.
848}

◆ setAnimatedZoomTime

void VP1GraphicsView::setAnimatedZoomTime ( double t)
slot

Definition at line 851 of file VP1GraphicsView.cxx.

852{
853 m_d->zoomanim_totaltime = t;
854 m_d->zoomanim_timer->setInterval(std::max(1,static_cast<int>(m_d->zoomanim_totaltime/m_d->zoomanim_nsteps+0.5)));
855 //Same as just above.
856}

◆ setDisallowInteractions

void VP1GraphicsView::setDisallowInteractions ( VP1GraphicsItemCollection * ic,
const bool & disallow = true )
slot

Definition at line 901 of file VP1GraphicsView.cxx.

902{
903 if (m_d->cols_override_inactive.contains(ic)==disallow)
904 return;
905
906 if ( disallow ) {
907 m_d->cols_override_inactive.insert(ic);
908 if ( m_d->cols_all.contains(ic) )
909 ic->setTemporaryIgnoreInteractions(true);
910 } else {
911 m_d->cols_override_inactive.remove(ic);
912 if ( m_d->cols_all.contains(ic) && m_d->mode != PICK )
913 ic->setTemporaryIgnoreInteractions(false);
914 }
915}

◆ setDisallowMovable

void VP1GraphicsView::setDisallowMovable ( VP1GraphicsItemCollection * ic,
const bool & disallow = true )
slot

Definition at line 918 of file VP1GraphicsView.cxx.

919{
920 if (m_d->cols_override_unmovable.contains(ic)==disallow)
921 return;
922
923 if (disallow) {
924 m_d->cols_override_unmovable.insert(ic);
925 if (m_d->cols_all.contains(ic))
926 ic->setTemporaryIgnoreMovable(true);
927 } else {
928 m_d->cols_override_unmovable.remove(ic);
929 if ( m_d->cols_all.contains(ic) && m_d->mode != PICK )
930 ic->setTemporaryIgnoreMovable(false);
931 }
932}

◆ setHome

void VP1GraphicsView::setHome ( )
slot

Definition at line 887 of file VP1GraphicsView.cxx.

887 {
888 m_d->home=mapToScene(viewport()->rect()).boundingRect();
889}

◆ setMode

void VP1GraphicsView::setMode ( const Mode & m)
slot

Definition at line 319 of file VP1GraphicsView.cxx.

320{
321 if (m_d->mode==m)
322 return;
323 m_d->mode=m;
324 if (m==PICK||m==CHANGEVIEW)
325 m_d->lastmajormode=m;
326
327 if (m!=DRAGZOOM&&m!=DRAGZOOMHOLD)
328 m_d->dragzoom_startpoint=QPoint();
329
330 //Dragmode:
331 if (m==CHANGEVIEW) {
332 setDragMode(QGraphicsView::ScrollHandDrag);
333 } else {
334 setDragMode(QGraphicsView::NoDrag);
335 }
336
337 //Cursor:
338 switch (m) {
339 case PICK:
340 setCursor(Qt::ArrowCursor);
341 break;
342 case CHANGEVIEW:
343 setCursor(Qt::OpenHandCursor);
344 break;
345 case DRAGZOOM:
346 case DRAGZOOMHOLD:
347 setCursor(Qt::SizeVerCursor);
348 break;
349 case SEEK:
350 setCursor(Qt::CrossCursor);
351 break;
352 default:
353 assert(0);
354 break;
355 }
356
357 //Interactions/movable:
358 if (m==PICK) {
359 for (VP1GraphicsItemCollection*ic : m_d->cols_act)
360 if (!m_d->cols_override_inactive.contains(ic))
361 ic->setTemporaryIgnoreInteractions(false);
362 for (VP1GraphicsItemCollection*ic : m_d->cols_all)
363 if (!m_d->cols_override_unmovable.contains(ic))
364 ic->setTemporaryIgnoreMovable(false);
365 } else {
366 for (VP1GraphicsItemCollection*ic : m_d->cols_all)
367 ic->setTemporaryIgnoreMovable(true);
368 for (VP1GraphicsItemCollection*ic : m_d->cols_act)
369 ic->setTemporaryIgnoreInteractions(true);
370 }
371}

◆ setZoomFactorOnSeek

void VP1GraphicsView::setZoomFactorOnSeek ( double zf)
slot

Definition at line 859 of file VP1GraphicsView.cxx.

860{
861 m_d->zoomfactoronseek = zf;
862}

◆ updateZoomAnimation

void VP1GraphicsView::updateZoomAnimation ( )
privateslot

Definition at line 812 of file VP1GraphicsView.cxx.

813{
814 assert(!m_d->zoomanim_queue.empty());
815 //For testing:
816 // QGraphicsRectItem * item = new QGraphicsRectItem(m_d->zoomanim_queue.dequeue());
817 // item->setPen(QPen(Qt::blue,0,Qt::SolidLine,Qt::SquareCap,Qt::RoundJoin));
818 // scene()->addItem(item);
819 fitInView( m_d->zoomanim_queue.dequeue(), Qt::KeepAspectRatio );
820 if (m_d->zoomanim_queue.empty())
821 m_d->zoomanim_timer->stop();
822}

◆ viewHome

void VP1GraphicsView::viewHome ( )
slot

Definition at line 865 of file VP1GraphicsView.cxx.

865 {
866
867 const bool animatedhome = true;//Fixme: option?
868 if (m_d->home == QRect()) {
869 if (animatedhome) {
870 if (m_d->transform&&m_d->transformactive)
871 initiateAnimatedZoomTo(m_d->transform->transform(scene()->sceneRect()));
872 else
873 initiateAnimatedZoomTo(scene()->sceneRect());
874 } else {
876 }
877 } else {
878 if (animatedhome) {
880 } else {
881 fitInView( m_d->home, Qt::KeepAspectRatio );
882 }
883 }
884}

◆ wheelEvent()

void VP1GraphicsView::wheelEvent ( QWheelEvent * event)
protected

Definition at line 229 of file VP1GraphicsView.cxx.

230{
231 if (m_d->showhelptext) {
232 m_d->showhelptext=false;
233 viewport()->update();
234 };
235 double ratefact = 0.8;
236 if (event->modifiers() & Qt::ControlModifier)
237 ratefact = 0.1;
238 if (event->modifiers() & Qt::ShiftModifier)
239 ratefact = 0.01;
240 scaleView(pow((double)2, -event->angleDelta().y() / (240.0/ratefact)));
241}

◆ HighLightItem

friend class HighLightItem
friend

Definition at line 98 of file VP1GraphicsView.h.

Member Data Documentation

◆ m_d

Imp* VP1GraphicsView::m_d
private

Definition at line 96 of file VP1GraphicsView.h.


The documentation for this class was generated from the following files: