# User options
# ============
OPTION(SALOME_CURVEPLOT_STANDALONE "Standalone installation of CURVEPLOT" OFF)
-OPTION(SALOME_BUILD_DOC "Generate SALOME CURVEPLOT documentation" ON)
+OPTION(SALOME_BUILD_DOC "Generate SALOME CURVEPLOT documentation" OFF)
OPTION(SALOME_BUILD_TESTS "Generate SALOME CURVEPLOT tests" ON)
# Common CMake macros
from .PlotManager import PlotManager
from .CurveTabsView import CurveTabsView
from .CurveModel import CurveModel
+from .BarModel import BarModel
from .TableModel import TableModel
from .utils import Logger
import numpy as np
if curve_label != "":
bm.setTitle(curve_label)
else:
- ti = table.getColumnTitle(y_col_index)
+ ti = table.getColumnTitle(height_col_index)
if ti != "":
bm.setTitle(ti)
"""
Debug Info.
"""
- LOG_LEVEL = 1 # 0 means all, 1 means all but DEBUG, 2 means all but INFO and DEBUG, 3 only FATAL
+ LOG_LEVEL = 0 # 0 means all, 1 means all but DEBUG, 2 means all but INFO and DEBUG, 3 only FATAL
@classmethod
def Debug(cls, msg):
SET(_all_lib_SCRIPTS
Model.py
CurveModel.py
+ BarModel.py
TableModel.py
PlotManager.py
XYPlotSetModel.py
class CurveModel(Model):
def __init__(self, controller, table=None, index=-1):
Model.__init__(self, controller)
+
+ # self._name = "CurveModel"
self._title = "Curve %d" % self.getID()
self._table = table
self._yaxisIndex = index # column index in the table
SET(_all_SCRIPTS
PlotCurve_Standalone.py
+ PlotCurve_Standalone_test.py
plot_test.py
TestDesktop.py
+ TestDesktop_test.py
)
SET(_test_SCRIPTS
self.addTabAction.triggered.connect(self.addTab)
self.memAction.triggered.connect(self.memPrint)
self.perfTestAction.triggered.connect(self.perfTest)
+ self.addBarPlotAction.triggered.connect(self.addBarplot)
def generateID(self):
self._currID += 1
self.addTabActionID = self.generateID()
self.memActionID = self.generateID()
self.perfActionID = self.generateID()
+ self.addBarPlotActionID = self.generateID()
# Menus
self.etudeMenuID = self.generateID()
self._sgPyQt.createMenu(self.addPSAction, curveMenu)
self._sgPyQt.createMenu(self.memAction, curveMenu)
self._sgPyQt.createMenu(self.perfTestAction, curveMenu)
+ self._sgPyQt.createMenu(self.addBarPlotAction, curveMenu)
dummyMenu = self._sgPyQt.createMenu( "Dummy", -1, self.dummyMenuID, self._sgPyQt.defaultMenuGroup() )
self._sgPyQt.createMenu(self.addTabAction, dummyMenu)
curveplot.UnlockRepaint()
print("Elapsed: %.2f" % ( time() - t0))
+ @pyqtSlot()
+ def addBarplot(self):
+ x, height = self.__generateRandomData()
+ width = np.full(x.size, 0.05)
+ isDirac = True
+ _, ps_id = curveplot.AddBarPlot(x, height, width, isDirac,
+ x_label="the x axis", y_label="the y axis", append=True)
+ curveplot.SetLegendVisible(ps_id, True)
+ if self.cnt >= 0:
+ QTimer.singleShot(self.timeLap, self, SLOT("itemDel()"))
+
def clearPlotSet(self):
curveplot.ClearPlotSet()
class CurveView(View):
_PICKER_PRECISION = 20 #pts
+ _PICKER_PRECISION_BAR = 5 #pts
def __init__(self, controller, parentXYView):
View.__init__(self, controller)
self._isHighlighted = False
self._initialLineWidth = None
+ self._initialEdgeColorBar = None
self._parentXYView = parentXYView
self._marker = None
m = self._model
# Check si BarModel ou CurveModel
if (m._name == "BarModel"):
- self._mplAxes.container.BarContainer.remove(self._mplBars[0])
+ self._mplBars.remove()
self._mplBars = None
else:
self._mplAxes.lines.remove(self._mplLines[0])
x_idx, height_idx, width_idx = m.getXAxisIndex(), m.getHeightIndex(), m.getWidthIndex()
x_align = "center" if m.getIsDirac() else "edge"
d = self._model.getTable().getData()
- self._mplBars = self._mplAxes.bar(d[:, x_idx], d[:, height_idx], width=d[:, height_idx],
- align=x_align, label=m._title, picker=self._PICKER_PRECISION)
+ self._mplBars = self._mplAxes.bar(d[:, x_idx], d[:, height_idx], width=d[:, width_idx],
+ align=x_align, label=m._title, picker=self._PICKER_PRECISION_BAR)
+ self._initialLineWidth = self._mplBars[0].get_linewidth()
+ print("Bar initial lw : ", self._initialLineWidth)
+ self._initialEdgeColorBar = self._mplBars[0].get_edgecolor()
+ print("Bar initial ec : ", self._initialEdgeColorBar)
else:
x_idx, y_idx = m.getXAxisIndex(), m.getYAxisIndex()
d = self._model.getTable().getData()
if (m._name == "BarModel"):
if self._mplBars is None:
return
- self._mplBars[0].set_label(self._model._title)
+ self._mplBars.set_label(self._model._title)
else:
if self._mplLines is None:
return
self.erase()
self.draw()
self.setColor(color)
- # self.toggleHighlight(self._isHighlighted, force=True)
+ self.toggleHighlight(self._isHighlighted, force=True)
else:
if self._mplLines is None:
return
return self._mplLines[0].get_marker()
def toggleHighlight(self, highlight, force=False):
- lin = self._mplLines[0]
- if highlight and (force or not self._isHighlighted):
- lin.set_linewidth(2*self._initialLineWidth)
- self._isHighlighted = True
- elif not highlight and (force or self._isHighlighted):
- lin.set_linewidth(self._initialLineWidth)
- self._isHighlighted = False
+ if (self._model._name == "BarModel"):
+ bar = self._mplBars.patches
+ if highlight and (force or not self._isHighlighted):
+ for rect in bar :
+ rect.set_linewidth(2*self._initialLineWidth)
+ rect.set_edgecolor("red")
+ self._isHighlighted = True
+ elif not highlight and (force or self._isHighlighted):
+ for rect in bar :
+ rect.set_linewidth(self._initialLineWidth)
+ rect.set_edgecolor(self._initialEdgeColorBar)
+ self._isHighlighted = False
+ else:
+ # Nothing to do, already the correct state
+ return
else:
- # Nothing to do, already the correct state
- return
+ lin = self._mplLines[0]
+ if highlight and (force or not self._isHighlighted):
+ lin.set_linewidth(2*self._initialLineWidth)
+ self._isHighlighted = True
+ elif not highlight and (force or self._isHighlighted):
+ lin.set_linewidth(self._initialLineWidth)
+ self._isHighlighted = False
+ else:
+ # Nothing to do, already the correct state
+ return
def isHighlighted(self):
return self._isHighlighted
m = self._model
# Check si BarModel ou CurveModel
if (m._name == "BarModel"):
- bar = self._mplBars[0]
+ bar = self._mplBars
bar.set_color(rgb_color)
else:
lin = self._mplLines[0]
import matplotlib.pyplot as plt
import matplotlib.colors as colors
+from matplotlib.patches import Rectangle
from pyqtside import QtWidgets, QtCore
from pyqtside.QtCore import QObject
from matplotlib.figure import Figure
newC.setModel(self._model._curves[curveID])
newC.setMPLAxes(self._mplAxes)
newC.draw()
- newC.setMarker(self.getMarker(go_next=True))
+ if (self._model._curves[curveID]._name == "BarModel"):
+ print("Appending un bar model !")
+ else:
+ newC.setMarker(self.getMarker(go_next=True))
self._curveViews[curveID] = newC
def removeCurve(self, curveID):
def onClearAll(self):
""" Just does an update with a reset of the marker cycle. """
if self.__repaintOK():
- self._lastMarkerID = -1
+ if (self._model._name != "BarModel") : self._lastMarkerID = -1
self.update()
def onPick(self, event):
if event.mouseevent.button == 1:
selected_id = -1
a = event.artist
+
for crv_id, cv in list(self._curveViews.items()):
- if cv._mplLines[0] is a:
- selected_id = crv_id
+ if (cv._model._name == "BarModel") :
+ # Checks if the picked artist is in the list of Rectangles
+ if a in cv._mplBars:
+ selected_id = crv_id
+ print(selected_id, " barplot selected")
+ else:
+ if cv._mplLines[0] is a:
+ selected_id = crv_id
+ print(selected_id, " curve selected")
# Use the plotmanager so that other plot sets get their current reset:
self._controller._plotManager.setCurrentCurve(selected_id)
action = self._curveActionGroup.checkedAction()
if action is self._pointsAction :
for crv_view in list(self._curveViews.values()):
- crv_view.setLineStyle("None")
+ if (crv_view._model._name != "BarModel") :
+ crv_view.setLineStyle("None")
elif action is self._linesAction :
for crv_view in list(self._curveViews.values()):
- crv_view.setLineStyle("-")
+ if (crv_view._model._name != "BarModel") :
+ crv_view.setLineStyle("-")
else :
raise NotImplementedError
if repaint: