Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
plot/src/mouse.cpp at develop · disorderedmaterials/plot · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Uh oh!
There was an error while loading.
Please reload this page
.
disorderedmaterials
/
plot
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
17
Pull requests
3
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
develop
Breadcrumbs
plot
/
src
/
mouse.cpp
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
147 lines (128 loc) · 5.92 KB
develop
Breadcrumbs
plot
/
src
/
mouse.cpp
Copy path
Top
File metadata and controls
Code
Blame
147 lines (128 loc) · 5.92 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
"
widget.h
"
using
namespace
Mildred
;
//
! React to mouse movement
/*
!
* React to mouse move events signalled by a Qt3DMouseHandler attached to the Qt3D surface, potentially affecting changes to the
* axes ranges or view volume, depending on the current view type and options.
*
* Active mouse buttons modify the effect of the event, and which also depends on the current view mode and depressed modifier
* keys.
*
* | Button | View Type | Modifier | Action |
* | :----: | :-------: | :------: | ------ |
* | Left | Flat / 2D | None | Update current coordinate under the mouse. |
* | ^ | ^ | Ctrl | |
* | ^ | ^ | Shift | |
* | ^ | 3D | None | None |
* | ^ | ^ | Ctrl | |
* | ^ | ^ | Shift | |
* | Middle | Flat / 2D | None | Translate view in the XY plane, modifying the corresponding ranges of the x and y axes |
* | ^ | ^ | Ctrl | |
* | ^ | ^ | Shift | |
* | ^ | 3D | None | |
* | ^ | ^ | Ctrl | |
* | ^ | ^ | Shift | |
* | Right | Flat / 2D | None | None |
* | ^ | ^ | Ctrl | |
* | ^ | ^ | Shift | |
* | ^ | 3D | None | Rotate view volume around its centroid. |
* | ^ | ^ | Ctrl | |
* | ^ | ^ | Shift | |
*/
void
MildredWidget::mousePositionChanged
(Qt3DInput::QMouseEvent *event)
{
//
Mouse is over the widget, so grab focus (for keyboard events)
setFocus
();
//
Check previous position
if
(lastMousePosition_.
isNull
())
{
lastMousePosition_ =
QPoint
(event->
x
(), event->
y
());
return
;
}
//
Right button - Rotate scene volume (3D)
if
(event->
buttons
() & Qt3DInput::QMouseEvent::RightButton)
{
//
Rotations only allowed for 3D view
if
(!flatView_)
{
viewRotationMatrix_ *=
QQuaternion::fromEulerAngles
(event->
y
() - lastMousePosition_.
y
(), event->
x
() - lastMousePosition_.
x
(),
0.0
);
sceneRootTransform_->
setRotation
(viewRotationMatrix_);
}
}
//
Middle button - translate axis ranges (2D)
if
(event->
buttons
() & Qt3DInput::QMouseEvent::MiddleButton)
{
if
(flatView_)
{
xAxis_->
shiftLimitsByPixels
(lastMousePosition_.
x
() - event->
x
());
yAxis_->
shiftLimitsByPixels
(event->
y
() - lastMousePosition_.
y
());
updateTransforms
();
}
}
lastMousePosition_ =
QPoint
(event->
x
(), event->
y
());
if
(flatView_)
{
//
Ensure that mouse is within plot area.
if
((event->
x
() >= metrics_.
displayVolumeOrigin
().
x
()) &&
(event->
x
() <= (metrics_.
displayVolumeExtent
().
x
() + metrics_.
displayVolumeOrigin
().
x
())) &&
(
height
() - event->
y
() >= metrics_.
displayVolumeOrigin
().
y
()) &&
(
height
() - event->
y
() <= (metrics_.
displayVolumeExtent
().
y
() + metrics_.
displayVolumeOrigin
().
y
())))
{
//
Convert mouse position to 2D axes value.
auto
coords =
toAxes2D
(
QPoint
(event->
x
(),
height
() - event->
y
()));
//
Emit signal indicating that mouse coordinates have been changed.
emit
mouseCoordChanged
(coords);
//
Update the mouse coordinates in the text entity.
mouseCoordEntity_->
setText
(
QString
(
"
%1 %2
"
).
arg
(coords.
x
(),
0
,
'
g
'
,
4
).
arg
(coords.
y
(),
0
,
'
g
'
,
4
));
//
Enable the text entity, to ensure that it is visible.
mouseCoordEntity_->
setEnabled
(
true
);
if
(mouseCoordStyle_ == CoordinateDisplayStyle::FixedAnchor)
{
//
Anchor the text entity at the bottom left of the widget.
mouseCoordEntity_->
setAnchorPosition
(
{-metrics_.
displayVolumeOrigin
().
x
(), -metrics_.
displayVolumeOrigin
().
y
(),
0.1
});
}
else
if
(mouseCoordStyle_ == CoordinateDisplayStyle::MouseAnchor)
{
//
Anchor the text entity at the mouse cursor.
mouseCoordEntity_->
setAnchorPosition
({
float
(event->
x
()) - metrics_.
displayVolumeOrigin
().
x
(),
height
() -
float
(event->
y
()) - metrics_.
displayVolumeOrigin
().
y
(),
0
});
}
else
if
(mouseCoordStyle_ == CoordinateDisplayStyle::None)
{
//
Hide the text entity.
mouseCoordEntity_->
setEnabled
(
false
);
}
}
else
{
//
Hide the text entity.
mouseCoordEntity_->
setEnabled
(
false
);
}
}
updateShaderParameters
();
}
void
MildredWidget::mouseButtonPressed
(Qt3DInput::QMouseEvent *event) {}
void
MildredWidget::mouseButtonReleased
(Qt3DInput::QMouseEvent *event) {}
void
MildredWidget::mouseWheeled
(Qt3DInput::QWheelEvent *event)
{
if
(flatView_)
{
const
auto
sensitivity =
3
;
//
Determine factor based on wheel amount, and axis deltas based on that
auto
sign = event->
angleDelta
().
y
() >
0
?
1
: -
1
;
const
auto
factor =
0.05
;
auto
xDelta = xAxis_->
range
() * factor * sign;
auto
yDelta = yAxis_->
range
() * factor * sign;
xAxis_->
setLimits
(xAxis_->
minimum
() + xDelta, xAxis_->
maximum
() - xDelta);
yAxis_->
setLimits
(yAxis_->
minimum
() + yDelta, yAxis_->
maximum
() - yDelta);
//
Shift view centre towards current mouse position
//
-- Get the data-space delta between the centre coordinates of the 2D axes and the current mouse position
auto
centreDelta =
QPoint
(event->
x
(),
height
() - event->
y
()) -
screen2DCentre
();
xAxis_->
shiftLimitsByPixels
(centreDelta.
x
() / (sign * sensitivity));
yAxis_->
shiftLimitsByPixels
(centreDelta.
y
() / (sign * sensitivity));
updateTransforms
();
}
}
void
MildredWidget::setMouseCoordStyle
(CoordinateDisplayStyle style) { mouseCoordStyle_ = style; }
You can’t perform that action at this time.