void TimeScene::drawTime(DateTime currentDay, DTime time, QModelIndex index, int groupLevel) { QSize size = sizeHint(index); int bordermargin = (size.height() * .1) / 2; QBrush b; QPen pen(QColor(0, 0, 150)); QBrush textBrush; if (groupLevel == 2) { b = QBrush(Qt::white); pen = QPen(QColor(0, 0, 150)); textBrush = QBrush(Qt::darkBlue); } if (groupLevel == 1) { b = QBrush(Qt::lightGray); pen = QPen(QColor(0, 0, 50)); textBrush = QBrush(Qt::blue); } if (groupLevel == 0) { b = QBrush(Qt::darkGray); pen = QPen(QColor(100, 100, 200)); textBrush = QBrush(Qt::white); } int daysToStart = _startDate.daysTo(currentDay); int x1 = daysToStart * _dayWidth; int y1 = _currentY + bordermargin; int x2 = x1 + _dayWidth; int y2 = _currentY + size.height() - bordermargin; // QGraphicsRectItem* item = this->addRect(x1, y1, (x2 - x1), (y2 - y1), pen, b); QRect rect(x1, y1, (x2 - x1), (y2 - y1)); GraphicsRectItem* item = new GraphicsRectItem(rect, index); this->addItem(item); item->setPen(pen); item->setBrush(b); item->setZValue(1); item->setAcceptHoverEvents(true); connect(item, SIGNAL(itemHoverEnter(QModelIndex)), this, SLOT(receiveItemHoverEnter(QModelIndex))); connect(item, SIGNAL(itemHoverLeave(QModelIndex)), this, SLOT(receiveItemHoverLeave(QModelIndex))); QFont font("Arial", 8); font.setBold((groupLevel <= 1)); font.setItalic((groupLevel == 0)); QGraphicsSimpleTextItem* text = addSimpleText(time.toQString(), font); text->setBrush(textBrush); text->setPos(x1 + 2, y1 + 1); text->setVisible(true); text->setZValue(1); }
StartScene::StartScene() { // game logo logo = new QSanSelectableItem("image/logo/logo.png", false); addItem(logo); //the website URL QFont website_font(Config.SmallFont); website_font.setStyle(QFont::StyleItalic); website_text = addSimpleText("http://qsanguosha.org", website_font); website_text->setBrush(Qt::white); server_log = NULL; }
void MyScene::slotUpdateMe() { int posx, length; posx = scene_x + ( m_timefrom->value() * scene_w) / 1440; length = ( ( m_timeto->value() - m_timefrom->value() ) * scene_w) / 1440; my_rect->setRect(posx+2, scene_y, length-4, scene_h); my_ltrim = addRect(posx, scene_y, 2, scene_h, QPen(Qt::yellow), QBrush(Qt::yellow)); my_ltrim->setFocus(); my_ltrim->setCursor(Qt::SplitHCursor); my_ltrim->setVisible(TRUE); my_ltrim->setEnabled(TRUE); my_rtrim = addRect(posx+length-1, scene_y, 2, scene_h, QPen(Qt::yellow), QBrush(Qt::yellow)); my_rtrim->setFocus(); my_rtrim->setCursor(Qt::SplitHCursor); my_rtrim->setVisible(TRUE); my_rtrim->setEnabled(TRUE); QString s; my_ltext = addSimpleText(s.sprintf("%02d:%02d",(m_timefrom->value() / 60), (m_timefrom->value() % 60))); my_ltext->setPos(posx-35, scene_y); my_ltext->setVisible(TRUE); my_ltext->setEnabled(TRUE); my_ltext->setZValue(900); my_rtext = addSimpleText(s.sprintf("%02d:%02d",(m_timeto->value() / 60), (m_timeto->value() % 60))); my_rtext->setPos(posx+length-35, scene_y); my_rtext->setVisible(TRUE); my_rtext->setEnabled(TRUE); my_rtext->setZValue(900); // kDebug() << "call with" << posx << scene_y << length; update(); }
StartScene::StartScene() { // game logo logo = new QSanSelectableItem("image/logo/logo.png", true); logo->moveBy(0, -Config.Rect.height() / 4); addItem(logo); //the website URL QFont website_font(Config.SmallFont); website_font.setStyle(QFont::StyleItalic); QGraphicsSimpleTextItem *website_text = addSimpleText("http://www.tongyuan.cc/", website_font); website_text->setBrush(Qt::white); website_text->setPos(Config.Rect.width() / 2 - website_text->boundingRect().width(), Config.Rect.height() / 2 - website_text->boundingRect().height()); server_log = NULL; }
StartScene::StartScene() { // game logo logo = new Pixmap("image/system/logo.png"); logo->shift(); logo->moveBy(0, -Config.Rect.height()/4); addItem(logo); //my e-mail address QFont email_font(Config.SmallFont); email_font.setStyle(QFont::StyleItalic); QGraphicsSimpleTextItem *email_text = addSimpleText("*****@*****.**", email_font); email_text->setBrush(Qt::white); email_text->setPos(Config.Rect.width()/2 - email_text->boundingRect().width(), Config.Rect.height()/2 - email_text->boundingRect().height()); server_log = NULL; }
StartScene::StartScene() { // game logo logo = new Pixmap("image/system/logo.png"); logo->shift(); logo->moveBy(0, -Config.Rect.height()/4); addItem(logo); //the website URL QFont website_font(Config.SmallFont); website_font.setStyle(QFont::StyleItalic); QGraphicsSimpleTextItem *website_text = addSimpleText("http://qsanguosha.com", website_font); website_text->setBrush(Qt::white); website_text->setPos(Config.Rect.width()/2 - website_text->boundingRect().width(), Config.Rect.height()/2 - website_text->boundingRect().height()); server_log = NULL; }
void MyScene::update() { this->clear(); QPen linePen; linePen.setWidth(2); QPen linePenOven; linePenOven.setColor(Qt::green); linePenOven.setWidth(3); // Draw oven temperature history if (dotListOven.count() > 2) { for (int i=1; i<dotListOven.count(); i++) { addLine(((QWidget *)this->parent())->width() * dotListOven.at(i).x() / maxTime, ((QWidget *)this->parent())->height() * dotListOven.at(i).y(), ((QWidget *)this->parent())->width() * dotListOven.at(i-1).x() / maxTime, ((QWidget *)this->parent())->height() * dotListOven.at(i-1).y(), linePenOven); } } if (dotList.count() >= 1) { // Reorder Dots from left to right qDebug() << "Printing unordered list"; for (int i=0; i<dotList.count(); i++) { qDebug() << "[" << dotList.at(i).x() << "," << dotList.at(i).y() << "]"; } for (int i=0; i<dotList.count(); i++) { for (int j=0; j<dotList.count()-1; j++) { if (dotList.at(j).x() > dotList.at(j+1).x()) { dotList.insert(j, dotList.takeAt(j+1)); } } } qDebug() << "Printing ordered list"; for (int i=0; i<dotList.count(); i++) { qDebug() << "[" << dotList.at(i).x() << "," << dotList.at(i).y() << "]"; } // Normalize dots "x" with the maximum one double maxX = dotList.last().x(); double scale = 1 / maxX; for (int i=0; i<dotList.count(); i++) { Dot d = dotList.takeFirst(); d.x(d.x() * scale); dotList.append(d); } qDebug() << "Printing normalized list"; for (int i=0; i<dotList.count(); i++) { qDebug() << "[" << dotList.at(i).x() << "," << dotList.at(i).y() << "]"; } QPen dotPen; dotPen.setWidth(2); // Draw dots for (int i=0; i<dotList.count(); i++) { if (dotList.at(i).selected()) dotPen.setColor(Qt::red); else dotPen.setColor(Qt::darkGreen); int posX = ((QWidget *)this->parent())->width() * dotList.at(i).x(); int posY = ((QWidget *)this->parent())->height() * dotList.at(i).y(); addEllipse(posX, posY, 10, 10, dotPen)->setPos(-5,-5); QString txt1, txt2; txt1.append(QString::number((int)(dotList.at(i).x() * (double)maxTime))); txt1.append(" s, "); txt2.append(QString::number((int)((1.0 - dotList.at(i).y()) * (double)maxTemp))); txt2.append(" 'C"); addSimpleText(txt1)->setPos(posX - 30, posY - 32); addSimpleText(txt2)->setPos(posX - 30, posY - 20); } // Draw lines addLine(((QWidget *)this->parent())->width() * 0, ((QWidget *)this->parent())->height() * 1, ((QWidget *)this->parent())->width() * dotList.at(0).x(), ((QWidget *)this->parent())->height() * dotList.at(0).y(), linePen); for (int i=1; i<dotList.count(); i++) { addLine(((QWidget *)this->parent())->width() * dotList.at(i).x(), ((QWidget *)this->parent())->height() * dotList.at(i).y(), ((QWidget *)this->parent())->width() * dotList.at(i-1).x(), ((QWidget *)this->parent())->height() * dotList.at(i-1).y(), linePen); } } else { double val1 = 1.0 - (double)currentTemperature / maxTemp; int y = ((QWidget *)this->parent())->height() * val1; addLine(0, y, ((QWidget *)this->parent())->width(), y, linePen); } }