Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring to move profiles out of SkyModelPlot #149

Open
wants to merge 28 commits into
base: beta_162
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a8f6b65
Refactor profiles to clean up SkyModelPlot
bennahugo Jul 26, 2022
2e34241
add new split out files
bennahugo Jul 26, 2022
4d50c74
Fix naming plottableProfiles
bennahugo Jul 26, 2022
f514898
Make active and inactive selected profile marker colour user selectable
bennahugo Jul 26, 2022
518a94a
Add space before global profile marker settings
bennahugo Jul 26, 2022
c228e7f
Organised imports
razman786 Aug 4, 2022
e8a37e7
Refactored setting plot axis title
razman786 Aug 4, 2022
0e6ff44
Fixed formatting
razman786 Aug 4, 2022
ff82bd8
Fixed unbound variable
razman786 Aug 4, 2022
103b562
Organised imports
razman786 Aug 4, 2022
b72a6d2
Fixed formatting
razman786 Aug 4, 2022
5042cb0
Organised imports
razman786 Aug 4, 2022
86372d3
Fixed formatting
razman786 Aug 4, 2022
ced7f70
Added copyright notice
razman786 Aug 4, 2022
ad885d3
Organised imports
razman786 Aug 4, 2022
0001e05
Fixed formatting
razman786 Aug 4, 2022
31973f9
Fixed formatting
razman786 Aug 4, 2022
309e320
Organised imports
razman786 Aug 4, 2022
9f99e4c
Fix exception for not implemented
razman786 Aug 4, 2022
b60c767
Explicitly raise from previous error
razman786 Aug 4, 2022
9707e05
Removed bare except clause
razman786 Aug 4, 2022
6dcfa4f
Fixed formatting
razman786 Aug 4, 2022
6fa6531
Fixed saving and loading of JSON profiles from file
razman786 Aug 4, 2022
addce94
Changed dashed lines for solid lines for clearer display
razman786 Aug 15, 2022
ed4fa4a
Fixed formatting
razman786 Aug 15, 2022
cef4a37
Simplify logical expression using De-Morgan identities
razman786 Aug 15, 2022
5f4e210
Fixed formatting
razman786 Aug 15, 2022
d655b4e
Fixed loading of profile file coordinates and plot marker
razman786 Aug 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
# Copyright (C) 2002-2022
# The MeqTree Foundation &
# ASTRON (Netherlands Foundation for Research in Astronomy)
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>,
# or write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

from PyQt5.Qt import QColor, QPen
from PyQt5.QtCore import Qt
from PyQt5.Qwt import QwtPlotCurve, QwtPlotItem

from TigGUI.kitties.profiles import MutableTiggerProfile
from TigGUI.Widgets import TiggerPlotCurve

from TigGUI.kitties.profiles import MutableTiggerProfile


class PlottableTiggerProfile(MutableTiggerProfile):
def __init__(self, profilename, axisname, axisunit, xdata, ydata,
qwtplot=None,
def __init__(self, profilename, axisname, axisunit, xdata, ydata,
qwtplot=None,
profilecoord=None):
"""
"""
Plottable (Mutable) Tigger Profile
profilename: A name for this profile
axisname: Name for the axis
Expand All @@ -20,10 +43,10 @@ def __init__(self, profilename, axisname, axisunit, xdata, ydata,
profilecoord: coordinate (world) coord tuple to from which this profile is drawn, optional
use None to leave unset
"""
MutableTiggerProfile.__init__(self, profilename, axisname, axisunit, xdata, ydata)
MutableTiggerProfile.__init__(self, profilename, axisname, axisunit, xdata, ydata, profilecoord)
self._curve_color = QColor("white")
self._curve_pen = self.createPen()
self._curve_pen.setStyle(Qt.DashDotLine)
self._curve_pen = self.createPen()
self._curve_pen.setStyle(Qt.SolidLine)
self._profcurve = TiggerPlotCurve(profilename)
self._profcurve.setRenderHint(QwtPlotItem.RenderAntialiased)
self._ycs = TiggerPlotCurve()
Expand All @@ -32,7 +55,7 @@ def __init__(self, profilename, axisname, axisunit, xdata, ydata,
self._profcurve.setStyle(QwtPlotCurve.Lines)
self._profcurve.setOrientation(Qt.Horizontal)
self._parentPlot = qwtplot
self._profilecoord = None
self._profilecoord = profilecoord
self.profileAssociatedCoord = profilecoord

self._profcurve.setData(xdata, ydata)
Expand All @@ -46,27 +69,30 @@ def createPen(self):
@property
def hasAssociatedCoord(self):
return self._profilecoord is not None

@property
def profileAssociatedCoord(self):
return (self._profilecoord[0],
return (self._profilecoord[0],
self._profilecoord[1])

@profileAssociatedCoord.setter
def profileAssociatedCoord(self, profilecoord):
# JSON does not handle tuples,
# instead they are converted to lists
if profilecoord is not None:
if not (isinstance(profilecoord, tuple) and
len(profilecoord) == 2 and
all(map(lambda x: isinstance(x, float), profilecoord))):
raise TypeError("profilecoord should be 2-element world coord tuple")
if not (isinstance(profilecoord, tuple) or isinstance(
profilecoord, list)) and len(profilecoord) == 2 and all(
map(lambda x: isinstance(x, float), profilecoord)):
raise TypeError(
"profilecoord should be 2-element world coord tuple or list")
self._profilecoord = profilecoord

def setCurveColor(self, color):
if not isinstance(color, QColor):
raise TypeError("Color must be QColor object")
self._curve_color = color
self._curve_pen = QPen(self._curve_color)
self._curve_pen.setStyle(Qt.DashDotLine)
self._curve_pen.setStyle(Qt.SolidLine)
self._profcurve.setPen(self._curve_pen)
if self._parentPlot is not None:
if self._attached:
Expand All @@ -78,7 +104,7 @@ def attach(self):
self._profcurve.attach(self._parentPlot)
self._parentPlot.replot()
self._attached = True

def detach(self):
if self._attached:
self._attached = False
Expand All @@ -91,4 +117,4 @@ def setAxesData(self, xdata, ydata, shouldSetVisible=True):
if shouldSetVisible:
self._profcurve.setData(xdata, ydata)
self._profcurve.setVisible(shouldSetVisible)
self.attach()
self.attach()
Loading