ATLAS Offline Software
Loading...
Searching...
No Matches
VP1GraphicsView::Imp Class Reference
Collaboration diagram for VP1GraphicsView::Imp:

Public Member Functions

void init (VP1GraphicsView *)
void setNewSelected (QGraphicsItem *, const bool &multimode=false)
void locateActiveItemAtPoint (QGraphicsItem *&, VP1GraphicsItemCollection *&ic, const QPoint &pos, VP1GraphicsItemCollection *searchic=0)
void select (QGraphicsItem *item)
void deselect (QGraphicsItem *item)
void HighLightItemBeingDeleted (HighLightItem *)
void paintDescription (QPainter *painter)
void createNewHelptextImage (const QRect &imrect)

Public Attributes

QGraphicsScene * scene
VP1GraphicsViewview
Mode mode
Mode lastmajormode
QList< VP1GraphicsItemCollection * > cols_act
QList< VP1GraphicsItemCollection * > cols_all
QSet< VP1GraphicsItemCollection * > cols_override_inactive
QSet< VP1GraphicsItemCollection * > cols_override_unmovable
QRectF home
QTimer * zoomanim_timer
int zoomanim_nsteps
double zoomanim_totaltime
double zoomfactoronseek
QQueue< QRectF > zoomanim_queue
QPainter::RenderHints savedrenderhints
QPoint dragzoom_startpoint
QMap< QGraphicsItem *, HighLightItem * > selecteditems
VP1GraphicsItemCollectionic_multiselection
bool clearselectionsemitsignals
QList< QGraphicsItem * > lastemittedselecteditems
QString currentsaveimagefile
QTextDocument helptext
QImage * helptextimage
bool showhelptext
IVP12DViewTransformationtransform
bool transformactive

Detailed Description

Definition at line 61 of file VP1GraphicsView.cxx.

Member Function Documentation

◆ createNewHelptextImage()

void VP1GraphicsView::Imp::createNewHelptextImage ( const QRect & imrect)

Definition at line 1003 of file VP1GraphicsView.cxx.

1004{
1005 if(helptext.isEmpty()) {
1006 helptext.setHtml ("<html>\n"
1007 "\n"
1008 "<h2>How to navigate a VP1GraphicsView</h2>\n"
1009 "\n"
1010 " <p>\n <b>H/F1</b> Show this help."
1011 " \n <b>S</b> Seek mode.\n"
1012 " \n <b>+/-</b> Zoom.\n"
1013 " \n <b>CTRL+HOME</b> Set home.\n"
1014 " \n <b>HOME</b> View home.\n"
1015 " \n <b>1</b> View all.\n"
1016 " \n <b>ESC</b> Switch between view and pick mode.\n"
1017 " \n <b>P</b> Print view.\n"
1018 " \n <b>CTRL+P</b> Save snapshot to image file.</p>\n"
1019 " <p>\n <b>Mouse wheel</b> zoom. Use <b>CTRL</b> and <b>SHIFT</b> for finegrained control.</p>\n"
1020 " <p>\n To select items (in pick mode), click on them. Selected multiple by holding down <b>SHIFT</b>.</p>\n"
1021 "\n"
1022 "<p>\n"
1023 " Please report any bugs to <i>Thomas.Kittelmann@cern.ch</i>.\n"
1024 "</p>\n"
1025 "\n"
1026 "\n"
1027 "</html>" );
1028 QFont myfont("Helvetica",36);
1029 // myfont.setPointSize(400);
1030 helptext.setDefaultFont ( myfont );
1031 // helptext.defaultFont().setPointSize(400);
1032 }
1033
1034 delete helptextimage;
1035 helptextimage = new QImage(imrect.size(), QImage::Format_ARGB32);//Fixme delete in destructor!!
1036
1037 QPainter painter;
1038 painter.begin(helptextimage);
1039
1040 int pageWidth = qMax(imrect.width() - 100, 100);
1041 int pageHeight = qMax(imrect.height() - 100, 100);
1042 if (pageWidth != helptext.pageSize().width()) {
1043 helptext.setPageSize(QSize(pageWidth, pageHeight));
1044 }
1045
1046 QRect textRect(imrect.width() / 2 - pageWidth / 2,
1047 imrect.height() / 2 - pageHeight / 2,
1048 pageWidth,
1049 pageHeight);
1050 int pad = 10;
1051 QRect clearRect = textRect.adjusted(-pad, -pad, pad, pad);
1052 painter.setPen(Qt::NoPen);
1053 painter.setBrush(QColor(0, 0, 0, 63));
1054 int shade = 10;
1055 painter.drawRect(clearRect.x() + clearRect.width() + 1,
1056 clearRect.y() + shade,
1057 shade,
1058 clearRect.height() + 1);
1059 painter.drawRect(clearRect.x() + shade,
1060 clearRect.y() + clearRect.height() + 1,
1061 clearRect.width() - shade + 1,
1062 shade);
1063
1064 painter.setRenderHint(QPainter::Antialiasing, false);
1065 painter.setBrush(QColor(255, 255, 255, 220));
1066 painter.setPen(Qt::black);
1067 painter.drawRect(clearRect);
1068
1069 painter.setClipRegion(textRect, Qt::IntersectClip);
1070 painter.translate(textRect.topLeft());
1071
1072 QAbstractTextDocumentLayout::PaintContext ctx;
1073
1074 QLinearGradient g(0, 0, 0, textRect.height());
1075 g.setColorAt(0, Qt::black);
1076 g.setColorAt(0.9, Qt::black);
1077 g.setColorAt(1, Qt::transparent);
1078
1079 QPalette pal = view->viewport()->palette();
1080 pal.setBrush(QPalette::Text, g);
1081
1082 ctx.palette = std::move(pal);
1083 ctx.clip = QRect(0, 0, textRect.width(), textRect.height());
1084 helptext.documentLayout()->draw(&painter, ctx);
1085
1086 painter.end();
1087
1088}
VP1GraphicsView * view

◆ deselect()

void VP1GraphicsView::Imp::deselect ( QGraphicsItem * item)

Definition at line 703 of file VP1GraphicsView.cxx.

704{
705 if (selecteditems.count()==1) {
706 view->clearSelections();
707 return;
708 }
709
710 assert(selecteditems.contains(item));
711 QMap<QGraphicsItem*,HighLightItem*>::iterator it = selecteditems.find(item);
712 if (scene->items().contains(it.value())) {
713 assert(scene->items().contains(it.value()));
714 scene->removeItem(it.value());
715 it.value()->sendsignalondelete = false;
716 delete it.value();
717 }
718 assert(selecteditems.contains(item));
719 selecteditems.erase(it);
720 assert(!selecteditems.contains(item));
721}
QGraphicsScene * scene
QMap< QGraphicsItem *, HighLightItem * > selecteditems

◆ HighLightItemBeingDeleted()

void VP1GraphicsView::Imp::HighLightItemBeingDeleted ( HighLightItem * hlitem)

Definition at line 646 of file VP1GraphicsView.cxx.

647{
648
649#ifndef NDEBUG
650 QMapIterator<QGraphicsItem*,HighLightItem*> ittest(selecteditems);
651 assert(ittest.findNext(hlitem));
652#endif
653
654 QMap<QGraphicsItem*,HighLightItem*>::iterator
655 it = selecteditems.begin(), itE = selecteditems.end();
656 for (;it!=itE;++it) {
657 if (it.value()==hlitem) {
658 selecteditems.erase(it);
659 break;
660 }
661 }
662
663 if (ic_multiselection) {
664 view->emitSelectionChanged(ic_multiselection);
665 }
666#ifndef NDEBUG
667 QMapIterator<QGraphicsItem*,HighLightItem*> ittest2(selecteditems);
668 assert(!ittest2.findNext(hlitem));
669#endif
670}
VP1GraphicsItemCollection * ic_multiselection

◆ init()

void VP1GraphicsView::Imp::init ( VP1GraphicsView * v)

Definition at line 149 of file VP1GraphicsView.cxx.

150{
151 view=v;
152 view->setTransformationAnchor(AnchorUnderMouse);
153 view->setResizeAnchor(AnchorViewCenter);
154 if (QGLFormat::hasOpenGL())//It turns out that when doing x-forward (at least from lxplus) GLX, and thus OpenGL support is not present.
155 view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers),view));
156 view->setRenderHint(QPainter::Antialiasing);//QPainter::SmoothPixmapTransform
157 view->setBackgroundBrush(Qt::black);
158 if (!view->scene())
159 view->setScene(new QGraphicsScene());
160 scene=view->scene();
162 view->setMode(PICK);
163
164 view->setFrameStyle(QFrame::NoFrame);
165
166 zoomanim_timer = new QTimer();
167 QObject::connect(zoomanim_timer, SIGNAL(timeout()), view, SLOT(updateZoomAnimation()));
168 zoomfactoronseek = 10.0;
169 //Like this to set the correct timer interval:
170 zoomanim_nsteps = 24;
171 view->setAnimatedZoomTime(1500.0);//ms
172
173 // Due to a bug in Qt 4.3.0 (not present in 4.2.3 and supposedly
174 // fixed in 4.3.1), we have to show the scrollbars if we want to
175 // have proper scrollhanddrag and seek modes. Therefore we uncomment
176 // the next two lines - and we should reenable them for Qt4.3.1 (fixme).
177 // view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
178 // view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
179
180 //Make sure that animation aborts if user moves a scrollbar (in case someone turns them on):
181 QObject::connect(view->horizontalScrollBar(),SIGNAL(sliderMoved(int)),view,SLOT(abortZoomAnimation()));
182 QObject::connect(view->verticalScrollBar(),SIGNAL(sliderMoved(int)),view,SLOT(abortZoomAnimation()));
185// selecteditem=0;
186// selectionoutline=0;
188 showhelptext=false;
189
190 transform = 0;
191 transformactive = false;
192 //fixme:
193 if (false) {
194 transformactive = true;
195 // transform = new VP12DViewRZFishEyeTransformation();
196 transform = new VP12DViewRPhiFishEyeTransformation();
197 view->setInteractive ( false );
198 }
199
200}
IVP12DViewTransformation * transform

◆ locateActiveItemAtPoint()

void VP1GraphicsView::Imp::locateActiveItemAtPoint ( QGraphicsItem *& item,
VP1GraphicsItemCollection *& ic,
const QPoint & pos,
VP1GraphicsItemCollection * searchic = 0 )

Definition at line 603 of file VP1GraphicsView.cxx.

606 {
607
608 //We turn the point into a small circle - to get some chance of picking lines, degenerate rectangles, etc.
609 const double tol = 2.0;
610 QRectF tolrect( pos.x()-tol, pos.y()-tol, 2*tol, 2*tol );
611
612 QPainterPath p;
614 QPainterPath ptmp;
615 ptmp.addEllipse(tolrect);
616 QPainterPath ptmp2;
617 transform->inverseTransformPath(view->mapToScene(ptmp),ptmp2);
618 QPainterPath p = view->mapFromScene(ptmp2);
619 } else {
620 p.addEllipse(tolrect);
621 }
622
623 //Fixme: use faster stl style iterators.
624 for (QGraphicsItem* item2 : view->items(p)) {
625 if (searchic) {
626 if (searchic->itemBelongsAndIsPresentlyActive(item2)) {
627 item=item2;
628 ic=searchic;
629 return;
630 }
631 } else {
632 for (VP1GraphicsItemCollection* ic2 : cols_act) {
633 if (ic2->itemBelongsAndIsPresentlyActive(item2)) {
634 item=item2;
635 ic=ic2;
636 return;
637 }
638 }
639 }
640 }
641 assert(!item&&!ic);
642 return;
643}
bool itemBelongsAndIsPresentlyActive(QGraphicsItem *) const
QList< VP1GraphicsItemCollection * > cols_act
int ic
Definition grepfile.py:33

◆ paintDescription()

void VP1GraphicsView::Imp::paintDescription ( QPainter * painter)

◆ select()

void VP1GraphicsView::Imp::select ( QGraphicsItem * item)

Definition at line 724 of file VP1GraphicsView.cxx.

725{
726 assert(!selecteditems.contains(item));
727
728 QPainterPath path = item->shape();
729
730 HighLightItem* outline = new HighLightItem(path,item,view);
731 outline->setBrush(QColor(250,0,250,100));
732 outline->setPen(QPen(Qt::red,0,Qt::SolidLine,Qt::SquareCap,Qt::RoundJoin));
733 scene->addItem(outline);
734
735 selecteditems.insert(item,outline);
736
737}
friend class HighLightItem
path
python interpreter configuration --------------------------------------—
Definition athena.py:128

◆ setNewSelected()

void VP1GraphicsView::Imp::setNewSelected ( QGraphicsItem * item,
const bool & multimode = false )

Definition at line 740 of file VP1GraphicsView.cxx.

740 {
741
742 assert(item);
743
744 if (continueselection) {
745 if (selecteditems.contains(item))
746 deselect(item);
747 else
748 select(item);
749 return;
750 } else {
751 if (!selecteditems.empty()) {
753 view->clearSelections();
754 }
755 select(item);
756 }
757
758// if (selecteditems.contains(item))
759// view->addselect(item);
760// view->removeselect(item);
761
762// if (!continueselection&&!selecteditems.empty()) {
763// view->clearSelections();
764// }
765
766
767}
void select(QGraphicsItem *item)
void deselect(QGraphicsItem *item)

Member Data Documentation

◆ clearselectionsemitsignals

bool VP1GraphicsView::Imp::clearselectionsemitsignals

Definition at line 102 of file VP1GraphicsView.cxx.

◆ cols_act

QList<VP1GraphicsItemCollection*> VP1GraphicsView::Imp::cols_act

Definition at line 71 of file VP1GraphicsView.cxx.

◆ cols_all

QList<VP1GraphicsItemCollection*> VP1GraphicsView::Imp::cols_all

Definition at line 72 of file VP1GraphicsView.cxx.

◆ cols_override_inactive

QSet<VP1GraphicsItemCollection*> VP1GraphicsView::Imp::cols_override_inactive

Definition at line 76 of file VP1GraphicsView.cxx.

◆ cols_override_unmovable

QSet<VP1GraphicsItemCollection*> VP1GraphicsView::Imp::cols_override_unmovable

Definition at line 77 of file VP1GraphicsView.cxx.

◆ currentsaveimagefile

QString VP1GraphicsView::Imp::currentsaveimagefile

Definition at line 106 of file VP1GraphicsView.cxx.

◆ dragzoom_startpoint

QPoint VP1GraphicsView::Imp::dragzoom_startpoint

Definition at line 88 of file VP1GraphicsView.cxx.

◆ helptext

QTextDocument VP1GraphicsView::Imp::helptext

Definition at line 108 of file VP1GraphicsView.cxx.

◆ helptextimage

QImage* VP1GraphicsView::Imp::helptextimage

Definition at line 109 of file VP1GraphicsView.cxx.

◆ home

QRectF VP1GraphicsView::Imp::home

Definition at line 79 of file VP1GraphicsView.cxx.

◆ ic_multiselection

VP1GraphicsItemCollection* VP1GraphicsView::Imp::ic_multiselection

Definition at line 95 of file VP1GraphicsView.cxx.

◆ lastemittedselecteditems

QList<QGraphicsItem*> VP1GraphicsView::Imp::lastemittedselecteditems

Definition at line 103 of file VP1GraphicsView.cxx.

◆ lastmajormode

Mode VP1GraphicsView::Imp::lastmajormode

Definition at line 69 of file VP1GraphicsView.cxx.

◆ mode

Mode VP1GraphicsView::Imp::mode

Definition at line 68 of file VP1GraphicsView.cxx.

◆ savedrenderhints

QPainter::RenderHints VP1GraphicsView::Imp::savedrenderhints

Definition at line 86 of file VP1GraphicsView.cxx.

◆ scene

QGraphicsScene* VP1GraphicsView::Imp::scene

Definition at line 65 of file VP1GraphicsView.cxx.

◆ selecteditems

QMap<QGraphicsItem*,HighLightItem*> VP1GraphicsView::Imp::selecteditems

Definition at line 91 of file VP1GraphicsView.cxx.

◆ showhelptext

bool VP1GraphicsView::Imp::showhelptext

Definition at line 111 of file VP1GraphicsView.cxx.

◆ transform

IVP12DViewTransformation* VP1GraphicsView::Imp::transform

Definition at line 114 of file VP1GraphicsView.cxx.

◆ transformactive

bool VP1GraphicsView::Imp::transformactive

Definition at line 115 of file VP1GraphicsView.cxx.

◆ view

VP1GraphicsView* VP1GraphicsView::Imp::view

Definition at line 66 of file VP1GraphicsView.cxx.

◆ zoomanim_nsteps

int VP1GraphicsView::Imp::zoomanim_nsteps

Definition at line 82 of file VP1GraphicsView.cxx.

◆ zoomanim_queue

QQueue<QRectF> VP1GraphicsView::Imp::zoomanim_queue

Definition at line 85 of file VP1GraphicsView.cxx.

◆ zoomanim_timer

QTimer* VP1GraphicsView::Imp::zoomanim_timer

Definition at line 81 of file VP1GraphicsView.cxx.

◆ zoomanim_totaltime

double VP1GraphicsView::Imp::zoomanim_totaltime

Definition at line 83 of file VP1GraphicsView.cxx.

◆ zoomfactoronseek

double VP1GraphicsView::Imp::zoomfactoronseek

Definition at line 84 of file VP1GraphicsView.cxx.


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