Version: 9.16.0
Scene.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#include "Scene.hxx"
21#include "SceneItem.hxx"
22#include "SceneTextItem.hxx"
23#include "QtGuiContext.hxx"
24
25#include <QGraphicsSceneMouseEvent>
26#include <QToolTip>
27
28#include <cassert>
29#include <cmath>
30
31//#define _DEVDEBUG_
32#include "YacsTrace.hxx"
33
34using namespace std;
35using namespace YACS::HMI;
36
37bool Scene::_straightLinks = false;
38bool Scene::_autoComputeLinks = true;
39bool Scene::_simplifyLinks = true;
40bool Scene::_force2NodesLink = true;
41bool Scene::_addRowCols = true;
42
43Scene::Scene(QObject *parent): QGraphicsScene(parent)
44{
45 _zooming = false;
46}
47
49{
50}
51
56void Scene::setZoom(bool zooming)
57{
58 _zooming = zooming;
59}
60
65{
66 return _zooming;
67}
68
69void Scene::helpEvent(QGraphicsSceneHelpEvent *event)
70{
71 DEBTRACE("Scene::helpEvent");
72 QGraphicsItem *qit = itemAt(event->scenePos(), QTransform());
73 SceneItem * item = dynamic_cast<SceneItem*>(qit);
74 if (item)
75 {
76 QToolTip::showText(event->screenPos(), item->getToolTip());
77 return;
78 }
79 SceneTextItem * itemt = dynamic_cast<SceneTextItem*>(qit);
80 if (itemt)
81 {
82 QToolTip::showText(event->screenPos(), itemt->getToolTip());
83 return;
84 }
85 QToolTip::hideText();
86}
87
88void Scene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
89{
90 //DEBTRACE("Scene::mousePressEvent");
91 QGraphicsScene::mousePressEvent(mouseEvent);
92 QGraphicsItem *qit = mouseGrabberItem();
93 if (qit)
94 {
95 //DEBTRACE(qit);
96 SceneItem *item = dynamic_cast<SceneItem*>(qit);
97 if (item)
98 DEBTRACE("mouseGrabberItem " <<item->handlesChildEvents()
99 << " " << item->getLabel().toStdString());
100 }
101// QList<QGraphicsItem*> selItems = items(mouseEvent->scenePos());
102}
103
104void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent* mouseEvent)
105{
106 _zooming = false;
107 QGraphicsScene::mouseReleaseEvent(mouseEvent);
108}
109
110void Scene::mouseMoveEvent(QGraphicsSceneMouseEvent* mouseEvent)
111{
112 //QGraphicsScene::mouseMoveEvent(mouseEvent);
113 QGraphicsScene::mouseMoveEvent(mouseEvent);
114
115}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
virtual QString getLabel()
Definition: SceneItem.cxx:135
virtual QString getToolTip()
Definition: SceneItem.cxx:336
virtual QString getToolTip()
bool isZooming()
Definition: Scene.cxx:64
virtual ~Scene()
Definition: Scene.cxx:48
virtual void helpEvent(QGraphicsSceneHelpEvent *event)
Definition: Scene.cxx:69
void setZoom(bool zooming)
Definition: Scene.cxx:56
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: Scene.cxx:104
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: Scene.cxx:110
virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
Definition: Scene.cxx:88