9#include "CubePlotCurve.h" 
   14#include <QApplication> 
   28#include <qwt_legend.h> 
   32#include "CubeViewport.h" 
   34#include "IException.h" 
   36#include "CubePlotCurveConfigureDialog.h" 
   70    QString expectedHeader(
"PLOT_TOOL_CURVE_V1");
 
   71    int headerKeySize = expectedHeader.toUtf8().size();
 
   73    if (classData.size() > headerKeySize) {
 
   75      const char *rawClassData = classData.data();
 
   77      QString givenKey = QString::fromUtf8(classData.data() + dataPos,
 
   79      dataPos += headerKeySize;
 
   80      if (givenKey != expectedHeader) {
 
   81        IString msg = 
"The given byte array does not contain the required " 
   86      int numSourceCubes = *(((
int *)(rawClassData + dataPos)));
 
   87      dataPos += 
sizeof(int);
 
   89      for (
int i = 0; i < numSourceCubes; i++) {
 
   90        int sourceCubeSize = *(((
int *)(rawClassData + dataPos)));
 
   91        dataPos += 
sizeof(int);
 
   92        QString data = QString::fromUtf8(classData.data() + dataPos,
 
   95        dataPos += sourceCubeSize;
 
   98      int pointListSize = *(((
int *)(rawClassData + dataPos)));
 
   99      dataPos += 
sizeof(int);
 
  101      for (
int i = 0; i < pointListSize; i ++) {
 
  102        int npts = *(((
int *)(rawClassData + dataPos)));
 
  103        dataPos += 
sizeof(int);
 
  105        QList<QPointF> points;
 
  106        for (
int pt = 0; pt < npts; pt++) {
 
  107          double x = *((
double *)(rawClassData + dataPos));
 
  108          dataPos += 
sizeof(double);
 
  110          double y = *((
double *)(rawClassData + dataPos));
 
  111          dataPos += 
sizeof(double);
 
  113          points.append(QPointF(x, y));
 
  120      IString msg = 
"The given byte array is not large enough to contain the " 
 
  138    bool blockWidgetFromEvent = 
false;
 
  141      case QEvent::MouseButtonPress: {
 
  143        blockWidgetFromEvent = 
true;
 
  147      case QEvent::MouseButtonDblClick:
 
  148      case QEvent::MouseButtonRelease:
 
  149        blockWidgetFromEvent = 
true;
 
  157    return blockWidgetFromEvent;
 
 
  173      customPen.setColor(pen().
color());
 
  174      customPen.setWidth(pen().width());
 
  176      if (pen().style() != Qt::NoPen)
 
  177        customPen.setStyle(pen().style());
 
  179      painter->setPen(customPen);
 
  181      QList<QPointF> points = allPoints.at(i);
 
  183      for (
int p = 1; p <= points.size(); p++) {
 
  189        if (p != points.size()) {
 
  190          vp->cubeToViewport(points[p - 1].x(), points[p - 1].y(), sample1, line1);
 
  191          vp->cubeToViewport(points[p].x(), points[p].y(), sample2, line2);
 
  194          vp->cubeToViewport(points[p - 1].x(), points[p - 1].y(),
 
  196          vp->cubeToViewport(points[0].x(), points[0].y(), sample2, line2);
 
  199        painter->drawLine(QPoint(sample1, line1), QPoint(sample2,  line2));
 
 
  263  void CubePlotCurve::clearSource() {
 
  278  void CubePlotCurve::addSource(CubeViewport *cvp, QList<QPoint> screenPoints,
 
  285        setTitle(title().text() + 
" - " +
 
  289          setTitle(title().text() + 
"+" + IString(band).ToQt());
 
  293      QList<QPointF> points;
 
  294      foreach (QPoint screenpoint, screenPoints) {
 
  298        cvp->viewportToCube(screenpoint.x(), screenpoint.y(), sample, line);
 
  300        points.append(QPointF(sample, line));
 
  325    addSource(cvp,  screenPoints,  band);
 
 
  331                                QList< QList<QPoint> > screenPoints,
 
  333    for (
int i = 0; i < cvps.size(); i++) {
 
  334      addSource(cvps.at(i), screenPoints.at(i), band.at(i));
 
  363    QMimeData *mimeData = 
new QMimeData;
 
  364    mimeData->setData(
"application/isis3-plot-curve",
 
 
  377    QByteArray classData;
 
  379    classData.append(PlotCurve::toByteArray());
 
  381    QString header(
"PLOT_TOOL_CURVE_V1");
 
  382    int size = header.size();
 
  383    classData.append(header);
 
  386    classData.append((
char *)&size, 
sizeof(
int));
 
  388    for (
int i = 0; i < size; i++) {
 
  389      int sourceCubeSize = 
m_sourceCube.at(i).toUtf8().size();
 
  390      classData.append((
char *)&sourceCubeSize, 
sizeof(
int));
 
  395    classData.append((
char *)&size, 
sizeof(
int));
 
  397    for (
int i = 0; i < size; i ++) {
 
  399      int npts = points.size();
 
  400      classData.append((
char *)&npts, 
sizeof(
int));
 
  402      for (
int pt = 0; pt < npts; pt++) {
 
  403        QPointF data = points[pt];
 
  407        classData.append((
char *)&x, 
sizeof(
double));
 
  408        classData.append((
char *)&y, 
sizeof(
double));
 
 
  424    bool deleteThisCurve = 
false;
 
  425    if (event->button() == Qt::LeftButton) {
 
  431      QPoint newHotSpot = drag->hotSpot();
 
  432      newHotSpot.setX(newHotSpot.x() * 2);
 
  433      drag->setHotSpot(newHotSpot);
 
  438      Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction,
 
  441      if (dropAction == Qt::MoveAction) {
 
  442        deleteThisCurve = 
true;
 
  445    else if (event->button() == Qt::RightButton) {
 
  448      QAction *cutAct = 
new QAction(QIcon::fromTheme(
"edit-cut"), 
"Cut", 
this);
 
  449      contextMenu.addAction(cutAct);
 
  450      QAction *copyAct = 
new QAction(QIcon::fromTheme(
"edit-copy"), 
"Copy",
 
  453      contextMenu.addAction(copyAct);
 
  455      contextMenu.addSeparator();
 
  457      QAction *deleteAct = 
new QAction(QIcon::fromTheme(
"edit-delete"), 
"Delete",
 
  459      contextMenu.addAction(deleteAct);
 
  461      contextMenu.addSeparator();
 
  463      QString configureIconFile =
 
  466                                          "Configure...", 
this);
 
  467      contextMenu.addAction(configureAct);
 
  469      QAction *chosenAct = contextMenu.exec(
 
  472      if (chosenAct == cutAct || chosenAct == copyAct) {
 
  475        if (chosenAct == cutAct) {
 
  476          deleteThisCurve = 
true;
 
  481      else if (chosenAct == configureAct) {
 
  486      else if (chosenAct == deleteAct) {
 
  487        deleteThisCurve = 
true;
 
  491    if (deleteThisCurve) {
 
  495      QwtPlot *plotToReplot = plot();
 
  498              this, SLOT(deleteLater()), Qt::QueuedConnection);
 
  500              plotToReplot, SLOT(replot()), Qt::QueuedConnection);
 
 
This is a plot curve with information relating it to a particular cube or region of a cube.
 
void needsRepaint()
This is emitted when the curve is modified in such a way that it would paint a viewport differently.
 
CubePlotCurve(Units xUnits, Units yUnits)
This constructs a CubePlotCurve... a subclass of PlotCurve.
 
QList< QList< QPointF > > sourceVertices() const
This method returns a list of points which are the vertices of the selected area (by the rubberband) ...
 
void copySource(const CubePlotCurve &other)
This copies the source data from another CubePlotCurve.
 
void enableAutoRenaming(bool)
This enables/disables the plot curve from changing it's title when the source data changes.
 
void paint(CubeViewport *vp, QPainter *painter)
Use information inside of the plot curve to paint onto a cube viewport.
 
QString m_originalName
This is the curve's name before any automatic renaming happened.
 
void mousePressEvent(QMouseEvent *e)
Handle various events on the legend item.
 
QStringList sourceCube() const
This method returns the cube view port associated with the curve.
 
bool m_renameAutomatically
This indicates if we are allowed to modify the title of this curve when the source (origin) data chan...
 
void removing()
This is emitted just before the cube plot curve is deleted.
 
QStringList m_sourceCube
The cube that the data is coming from.
 
QByteArray toByteArray() const
Serialize this plot curve into a binary byte array.
 
QMimeData * createMimeData() const
This converts the plot curve into a binary, clipboard-compatible storage format (QMimeData).
 
virtual QWidget * legendItem() const
This method is necessary for getting the correct (event filter altered) legend item.
 
QPointer< QWidget > m_legendItem
This is the widget legend item associated with this curve.
 
void setSource(CubeViewport *cvp, QList< QPoint > screenPoints, int band=-1)
Tell this plot curve from where its data originated.
 
void updateLegendItemWidget(QWidget *legendItem)
This creates a legend item and overrides events from it.
 
bool eventFilter(QObject *o, QEvent *e)
This will start the drag & drop operation for these curves.
 
QList< QList< QPointF > > m_pointList
List of vertices in sample,line coordinates from the rubber band.
 
Widget to display Isis cubes for qt apps.
 
File name manipulation and expansion.
 
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
 
@ Programmer
This error is for when a programmer made an API call that was illegal.
 
Adds specific functionality to C++ strings.
 
void setColor(const QColor &color)
Set the color of this curve and it's markers.
 
QColor color() const
This method returns the color of the curve.
 
QByteArray fromByteArray(const QByteArray &classData)
Construct the plot curve given the past results of toByteArray(...).
 
Units
These are all the possible units for the x or y data in a plot curve.
 
This is free and unencumbered software released into the public domain.
 
This is free and unencumbered software released into the public domain.