void DivePlannerGraphics::pointInserted(const QModelIndex& parent, int start , int end) { DiveHandler *item = new DiveHandler (); scene()->addItem(item); handles << item; QGraphicsSimpleTextItem *gasChooseBtn = new QGraphicsSimpleTextItem(); scene()->addItem(gasChooseBtn); gasChooseBtn->setZValue(10); gasChooseBtn->setFlag(QGraphicsItem::ItemIgnoresTransformations); gases << gasChooseBtn; drawProfile(); }
void DivePlannerGraphics::pointInserted(const QModelIndex& parent, int start , int end) { DiveHandler *item = new DiveHandler (); scene()->addItem(item); handles << item; Button *gasChooseBtn = new Button(); scene()->addItem(gasChooseBtn); gasChooseBtn->setZValue(10); connect(gasChooseBtn, SIGNAL(clicked()), this, SLOT(prepareSelectGas())); gases << gasChooseBtn; drawProfile(); }
void ReflowPage::redrawAll() { FlashGraphics flash(_panel); // fade out (it's asynchronous and takes about a second) fadeAndClear(); // draw the lot drawButtons(flash,GuiButtons,sizeof(GuiButtons)/sizeof(GuiButtons[0])); drawTemperatureIcon(flash); drawSelection(true); drawProfile(flash); drawAxes(flash); // lights back on _panel.setBacklight(FULL_BRIGHTNESS); }
void RddcEvlDisplay::drawProfiles(){ if(this->m_dimClust==NULL) return; RddtClust* clust = this->m_dimClust->m_currentSelection; if(clust==NULL) return; if(clust->m_nRddtDims.size()<1){ return; } int size = clust->m_partitionPerVariable.size(); if(size<1) return; this->m_profileRects.clear(); int numCols = (int)(sqrt((double)size))+1; int numRows = (int)ceil((double)size/(double)numCols); double glyphWidthData = (double)1/(double)numCols; double glyphHeightData = (double)1/(double)numRows; std::vector<DataPartitions*>::iterator dataParts = clust->m_partitionPerVariable.begin(); int i = 0; for(;dataParts != clust->m_partitionPerVariable.end();++dataParts){ int hoPos = i%numCols; int verPos = i/numCols; double x = (double)hoPos/(double)numCols; double y = (double)verPos/(double)numRows; Vec2 pos(x,y); drawProfile((*dataParts), pos, glyphWidthData,glyphHeightData, i); i++; } }
DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent), activeDraggedHandler(0) { fill_profile_color(); setBackgroundBrush(profile_color[BACKGROUND].at(0)); setMouseTracking(true); setScene(new QGraphicsScene()); scene()->setSceneRect(0,0,1920,1080); verticalLine = new QGraphicsLineItem( fromPercent(0, Qt::Horizontal), fromPercent(0, Qt::Vertical), fromPercent(0, Qt::Horizontal), fromPercent(100, Qt::Vertical) ); verticalLine->setPen(QPen(Qt::DotLine)); scene()->addItem(verticalLine); horizontalLine = new QGraphicsLineItem( fromPercent(0, Qt::Horizontal), fromPercent(0, Qt::Vertical), fromPercent(100, Qt::Horizontal), fromPercent(0, Qt::Vertical) ); horizontalLine->setPen(QPen(Qt::DotLine)); scene()->addItem(horizontalLine); timeLine = new Ruler(); timeLine->setMinimum(0); timeLine->setMaximum(TIME_INITIAL_MAX); timeLine->setTickInterval(10); timeLine->setColor(getColor(TIME_GRID)); timeLine->setLine( fromPercent(10, Qt::Horizontal), fromPercent(85, Qt::Vertical), fromPercent(90, Qt::Horizontal), fromPercent(85, Qt::Vertical) ); timeLine->setOrientation(Qt::Horizontal); timeLine->setTickSize(fromPercent(1, Qt::Vertical)); timeLine->setTextColor(getColor(TIME_TEXT)); timeLine->updateTicks(); scene()->addItem(timeLine); depthLine = new Ruler(); depthLine->setMinimum(0); depthLine->setMaximum(M_OR_FT(40,120)); depthLine->setTickInterval(M_OR_FT(10,30)); depthLine->setLine( fromPercent(10, Qt::Horizontal), fromPercent(10, Qt::Vertical), fromPercent(10, Qt::Horizontal), fromPercent(85, Qt::Vertical) ); depthLine->setOrientation(Qt::Vertical); depthLine->setTickSize(fromPercent(1, Qt::Horizontal)); depthLine->setColor(getColor(DEPTH_GRID)); depthLine->setTextColor(getColor(SAMPLE_DEEP)); depthLine->updateTicks(); scene()->addItem(depthLine); timeString = new QGraphicsSimpleTextItem(); timeString->setFlag(QGraphicsItem::ItemIgnoresTransformations); timeString->setBrush(profile_color[TIME_TEXT].at(0)); scene()->addItem(timeString); depthString = new QGraphicsSimpleTextItem(); depthString->setFlag(QGraphicsItem::ItemIgnoresTransformations); depthString->setBrush(profile_color[SAMPLE_DEEP].at(0)); scene()->addItem(depthString); diveBg = new QGraphicsPolygonItem(); diveBg->setPen(QPen(QBrush(),0)); scene()->addItem(diveBg); QString incrText; if (prefs.units.length == units::METERS) incrText = tr("10m"); else incrText = tr("30ft"); timeHandler = new ExpanderGraphics(); timeHandler->increaseBtn->setPixmap(QString(":plan_plus")); timeHandler->decreaseBtn->setPixmap(QString(":plan_minus")); timeHandler->icon->setPixmap(QString(":icon_time")); connect(timeHandler->increaseBtn, SIGNAL(clicked()), this, SLOT(increaseTime())); connect(timeHandler->decreaseBtn, SIGNAL(clicked()), this, SLOT(decreaseTime())); timeHandler->setPos(fromPercent(83, Qt::Horizontal), fromPercent(100, Qt::Vertical)); timeHandler->setZValue(-2); scene()->addItem(timeHandler); depthHandler = new ExpanderGraphics(); depthHandler->increaseBtn->setPixmap(QString(":arrow_up")); depthHandler->decreaseBtn->setPixmap(QString(":arrow_down")); depthHandler->icon->setPixmap(QString(":icon_depth")); // Inverted here in the slots because the 'up' graphi should increase the depness, // and the down should decrease. connect(depthHandler->increaseBtn, SIGNAL(clicked()), this, SLOT(decreaseDepth())); connect(depthHandler->decreaseBtn, SIGNAL(clicked()), this, SLOT(increaseDepth())); depthHandler->setPos(fromPercent(0, Qt::Horizontal), fromPercent(100, Qt::Vertical)); depthHandler->setZValue(-2); scene()->addItem(depthHandler); minMinutes = TIME_INITIAL_MAX; QAction *action = NULL; #define ADD_ACTION( SHORTCUT, Slot ) \ action = new QAction(this); \ action->setShortcut( SHORTCUT ); \ action->setShortcutContext(Qt::WindowShortcut); \ addAction(action); \ connect(action, SIGNAL(triggered(bool)), this, SLOT( Slot )) ADD_ACTION(Qt::Key_Escape, keyEscAction()); ADD_ACTION(Qt::Key_Delete, keyDeleteAction()); ADD_ACTION(Qt::Key_Up, keyUpAction()); ADD_ACTION(Qt::Key_Down, keyDownAction()); ADD_ACTION(Qt::Key_Left, keyLeftAction()); ADD_ACTION(Qt::Key_Right, keyRightAction()); #undef ADD_ACTION connect(plannerModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(drawProfile())); connect(plannerModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), this, SLOT(pointInserted(const QModelIndex&, int, int))); connect(plannerModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, SLOT(pointsRemoved(const QModelIndex&, int, int))); setRenderHint(QPainter::Antialiasing); }
DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent), activeDraggedHandler(0) { fill_profile_color(); setBackgroundBrush(profile_color[BACKGROUND].at(0)); setMouseTracking(true); setScene(new QGraphicsScene()); scene()->setSceneRect(0,0,1920,1080); verticalLine = new QGraphicsLineItem( fromPercent(0, Qt::Horizontal), fromPercent(0, Qt::Vertical), fromPercent(0, Qt::Horizontal), fromPercent(100, Qt::Vertical) ); verticalLine->setPen(QPen(Qt::DotLine)); scene()->addItem(verticalLine); horizontalLine = new QGraphicsLineItem( fromPercent(0, Qt::Horizontal), fromPercent(0, Qt::Vertical), fromPercent(100, Qt::Horizontal), fromPercent(0, Qt::Vertical) ); horizontalLine->setPen(QPen(Qt::DotLine)); scene()->addItem(horizontalLine); timeLine = new Ruler(); timeLine->setMinimum(0); timeLine->setMaximum(TIME_INITIAL_MAX); timeLine->setTickInterval(10); timeLine->setColor(getColor(TIME_GRID)); timeLine->setLine( fromPercent(10, Qt::Horizontal), fromPercent(90, Qt::Vertical), fromPercent(90, Qt::Horizontal), fromPercent(90, Qt::Vertical) ); timeLine->setOrientation(Qt::Horizontal); timeLine->setTickSize(fromPercent(1, Qt::Vertical)); timeLine->setTextColor(getColor(TIME_TEXT)); timeLine->updateTicks(); scene()->addItem(timeLine); depthLine = new Ruler(); depthLine->setMinimum(0); depthLine->setMaximum(M_OR_FT(40,120)); depthLine->setTickInterval(M_OR_FT(10,30)); depthLine->setLine( fromPercent(10, Qt::Horizontal), fromPercent(10, Qt::Vertical), fromPercent(10, Qt::Horizontal), fromPercent(90, Qt::Vertical) ); depthLine->setOrientation(Qt::Vertical); depthLine->setTickSize(fromPercent(1, Qt::Horizontal)); depthLine->setColor(getColor(DEPTH_GRID)); depthLine->setTextColor(getColor(SAMPLE_DEEP)); depthLine->updateTicks(); scene()->addItem(depthLine); timeString = new QGraphicsSimpleTextItem(); timeString->setFlag(QGraphicsItem::ItemIgnoresTransformations); timeString->setBrush(profile_color[TIME_TEXT].at(0)); scene()->addItem(timeString); depthString = new QGraphicsSimpleTextItem(); depthString->setFlag(QGraphicsItem::ItemIgnoresTransformations); depthString->setBrush(profile_color[SAMPLE_DEEP].at(0)); scene()->addItem(depthString); diveBg = new QGraphicsPolygonItem(); diveBg->setPen(QPen(QBrush(),0)); scene()->addItem(diveBg); #define ADDBTN(obj, icon, text, horizontal, vertical, tooltip, value, slot) \ obj = new Button(); \ obj->setPixmap(QPixmap(icon)); \ obj->setPos(fromPercent(horizontal, Qt::Horizontal), fromPercent(vertical, Qt::Vertical)); \ obj->setToolTip(QString(tooltip.arg(value))); \ scene()->addItem(obj); \ connect(obj, SIGNAL(clicked()), this, SLOT(slot)); QString incrText; if (prefs.units.length == units::METERS) incrText = tr("10m"); else incrText = tr("30ft"); ADDBTN(plusDepth, ":plus", "" , 5, 5, tr("Increase maximum depth by %1"), incrText, increaseDepth()); ADDBTN(lessDepth, ":minimum","" , 2, 5, tr("Decreases maximum depth by %1"), incrText, decreaseDepth()); ADDBTN(plusTime, ":plus", "" , 95, 95, tr("Increase minimum time by %1"), tr("10min"), increaseTime()); ADDBTN(lessTime, ":minimum","" , 92, 95, tr("Decreases minimum time by %1"), tr("10min"), decreaseTime()); #undef ADDBTN minMinutes = TIME_INITIAL_MAX; QAction *action = NULL; #define ADD_ACTION( SHORTCUT, Slot ) \ action = new QAction(this); \ action->setShortcut( SHORTCUT ); \ action->setShortcutContext(Qt::WindowShortcut); \ addAction(action); \ connect(action, SIGNAL(triggered(bool)), this, SLOT( Slot )) ADD_ACTION(Qt::Key_Escape, keyEscAction()); ADD_ACTION(Qt::Key_Delete, keyDeleteAction()); ADD_ACTION(Qt::Key_Up, keyUpAction()); ADD_ACTION(Qt::Key_Down, keyDownAction()); ADD_ACTION(Qt::Key_Left, keyLeftAction()); ADD_ACTION(Qt::Key_Right, keyRightAction()); #undef ADD_ACTION // Prepare the stuff for the gas-choices. gasListView = new QListView(); gasListView->setWindowFlags(Qt::Popup); gasListView->setModel(GasSelectionModel::instance()); gasListView->hide(); gasListView->installEventFilter(this); connect(gasListView, SIGNAL(activated(QModelIndex)), this, SLOT(selectGas(QModelIndex))); connect(plannerModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(drawProfile())); connect(plannerModel, SIGNAL(rowsInserted(const QModelIndex&,int,int)), this, SLOT(pointInserted(const QModelIndex&, int, int))); connect(plannerModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, SLOT(pointsRemoved(const QModelIndex&, int, int))); setRenderHint(QPainter::Antialiasing); }