mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Use the same line dimensions as the profile, on the planner.
The Planner should be 'almost' like the profile, with the possibility to use the mouse and keyboard to input a new plan, so this is a bit of 'getting there.' I don't like too much code duplication but since the current Profile Graphics is a crude cut-and-paste from the old Cairo backend, it's easyer to start from scratch and have it well organized as Qt code. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
f74799d581
commit
493f366765
3 changed files with 25 additions and 7 deletions
|
@ -5,6 +5,7 @@
|
||||||
#include "ui_diveplanner.h"
|
#include "ui_diveplanner.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "tableview.h"
|
#include "tableview.h"
|
||||||
|
#include "graphicsview-common.h"
|
||||||
|
|
||||||
#include "../dive.h"
|
#include "../dive.h"
|
||||||
#include "../divelist.h"
|
#include "../divelist.h"
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
#define TIME_INITIAL_MAX 30
|
#define TIME_INITIAL_MAX 30
|
||||||
|
|
||||||
|
@ -40,6 +42,11 @@ QString strForAir(const divedatapoint& p){
|
||||||
: QObject::tr("Choose Gas");
|
: QObject::tr("Choose Gas");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor getColor(const color_indice_t i)
|
||||||
|
{
|
||||||
|
return profile_color[i].at(0);
|
||||||
|
}
|
||||||
|
|
||||||
static DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
static DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
|
||||||
|
|
||||||
DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent), activeDraggedHandler(0)
|
DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent), activeDraggedHandler(0)
|
||||||
|
@ -66,6 +73,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
|
||||||
fromPercent(100, Qt::Horizontal),
|
fromPercent(100, Qt::Horizontal),
|
||||||
fromPercent(0, Qt::Vertical)
|
fromPercent(0, Qt::Vertical)
|
||||||
);
|
);
|
||||||
|
|
||||||
horizontalLine->setPen(QPen(Qt::DotLine));
|
horizontalLine->setPen(QPen(Qt::DotLine));
|
||||||
scene()->addItem(horizontalLine);
|
scene()->addItem(horizontalLine);
|
||||||
|
|
||||||
|
@ -73,6 +81,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
|
||||||
timeLine->setMinimum(0);
|
timeLine->setMinimum(0);
|
||||||
timeLine->setMaximum(TIME_INITIAL_MAX);
|
timeLine->setMaximum(TIME_INITIAL_MAX);
|
||||||
timeLine->setTickInterval(10);
|
timeLine->setTickInterval(10);
|
||||||
|
timeLine->setColor(getColor(TIME_GRID));
|
||||||
timeLine->setLine(
|
timeLine->setLine(
|
||||||
fromPercent(10, Qt::Horizontal),
|
fromPercent(10, Qt::Horizontal),
|
||||||
fromPercent(90, Qt::Vertical),
|
fromPercent(90, Qt::Vertical),
|
||||||
|
@ -81,7 +90,6 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
|
||||||
);
|
);
|
||||||
timeLine->setOrientation(Qt::Horizontal);
|
timeLine->setOrientation(Qt::Horizontal);
|
||||||
timeLine->setTickSize(fromPercent(1, Qt::Vertical));
|
timeLine->setTickSize(fromPercent(1, Qt::Vertical));
|
||||||
timeLine->setColor(profile_color[TIME_GRID].at(0));
|
|
||||||
timeLine->updateTicks();
|
timeLine->updateTicks();
|
||||||
scene()->addItem(timeLine);
|
scene()->addItem(timeLine);
|
||||||
|
|
||||||
|
@ -97,7 +105,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
|
||||||
);
|
);
|
||||||
depthLine->setOrientation(Qt::Vertical);
|
depthLine->setOrientation(Qt::Vertical);
|
||||||
depthLine->setTickSize(fromPercent(1, Qt::Horizontal));
|
depthLine->setTickSize(fromPercent(1, Qt::Horizontal));
|
||||||
depthLine->setColor(profile_color[DEPTH_GRID].at(0));
|
depthLine->setColor(getColor(DEPTH_GRID));
|
||||||
depthLine->updateTicks();
|
depthLine->updateTicks();
|
||||||
scene()->addItem(depthLine);
|
scene()->addItem(depthLine);
|
||||||
|
|
||||||
|
@ -749,7 +757,12 @@ double Ruler::minimum() const
|
||||||
|
|
||||||
void Ruler::setColor(const QColor& color)
|
void Ruler::setColor(const QColor& color)
|
||||||
{
|
{
|
||||||
setPen(QPen(color));
|
QPen defaultPen(color);
|
||||||
|
defaultPen.setJoinStyle(Qt::RoundJoin);
|
||||||
|
defaultPen.setCapStyle(Qt::RoundCap);
|
||||||
|
defaultPen.setWidth(2);
|
||||||
|
defaultPen.setCosmetic(true);
|
||||||
|
setPen(defaultPen);
|
||||||
}
|
}
|
||||||
|
|
||||||
Button::Button(QObject* parent): QObject(parent), QGraphicsRectItem()
|
Button::Button(QObject* parent): QObject(parent), QGraphicsRectItem()
|
||||||
|
@ -1139,12 +1152,13 @@ void DivePlannerPointsModel::createPlan()
|
||||||
createTemporaryPlan();
|
createTemporaryPlan();
|
||||||
plan(&diveplan, &cache, &tempDive, &errorString);
|
plan(&diveplan, &cache, &tempDive, &errorString);
|
||||||
mark_divelist_changed(TRUE);
|
mark_divelist_changed(TRUE);
|
||||||
diveplan.dp = NULL;
|
|
||||||
|
|
||||||
|
// Remove and clean the diveplan, so we don't delete
|
||||||
|
// the dive by mistake.
|
||||||
|
diveplan.dp = NULL;
|
||||||
beginRemoveRows(QModelIndex(), 0, rowCount() -1 );
|
beginRemoveRows(QModelIndex(), 0, rowCount() -1 );
|
||||||
divepoints.clear();
|
divepoints.clear();
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
|
||||||
// show_error(error_string);
|
|
||||||
planCreated();
|
planCreated();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,3 +55,8 @@ void fill_profile_color()
|
||||||
profile_color[CALC_CEILING_DEEP] = COLOR(APPLE1_HIGH_TRANS, BLACK1_HIGH_TRANS, APPLE1_HIGH_TRANS);
|
profile_color[CALC_CEILING_DEEP] = COLOR(APPLE1_HIGH_TRANS, BLACK1_HIGH_TRANS, APPLE1_HIGH_TRANS);
|
||||||
#undef COLOR
|
#undef COLOR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor getColor(const color_indice_t i, bool isGrayscale = false)
|
||||||
|
{
|
||||||
|
return profile_color[i].at((isGrayscale) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ typedef enum {
|
||||||
/* profile_color[color indice] = COLOR(screen color, b/w printer color, color printer}} printer & screen colours could be different */
|
/* profile_color[color indice] = COLOR(screen color, b/w printer color, color printer}} printer & screen colours could be different */
|
||||||
|
|
||||||
extern QMap<color_indice_t, QVector<QColor> > profile_color;
|
extern QMap<color_indice_t, QVector<QColor> > profile_color;
|
||||||
|
|
||||||
void fill_profile_color();
|
void fill_profile_color();
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue