Скачать 0.89 Mb.
|
Constellations ver. 0.1"" The cross-platform aplication based on Nokia Qt. " " Writed by Ilya Tychinin. " " Send your questions and spam to " "elive@mail.ru :)" " Thanks for the viewing. "); QMessageBox::about(0, "About", translatedTextAboutQt);} void View::quit(){ this->parentWidget()->close();} void View::wheelEvent(QWheelEvent *event) { if(event->delta()>0) zoomSlider->setValue(zoomSlider->value() + 1); else zoomSlider->setValue(zoomSlider->value() - 1); } void View::mousePressEvent(QMouseEvent *event){ if (event->y()>this->size().height()-10){ rotateSlider->show(); rotateRightIcon->show(); rotateLeftIcon->show(); resetButton->show(); compView->show(); } else{ rotateSlider->hide(); rotateRightIcon->hide(); rotateLeftIcon->hide(); resetButton->hide(); compView->hide(); } if (event->x()>this->size().width()-10){ zoomSlider->show(); zoomInIcon->show(); zoomOutIcon->show();} else{ zoomSlider->hide(); zoomInIcon->hide(); zoomOutIcon->hide();} if (event->y()<10){ nextItemButton->show(); searchButton->show(); label->show(); menuButton->show(); hourButton->show();} else{ nextItemButton->hide(); searchButton->hide(); label->hide(); menuButton->hide(); hourButton->hide(); } update(); QWidget::mousePressEvent(event);} void View::mouseMoveEvent(QMouseEvent *event){ graphicsView->items().at(1)->setPos(0,(/*graphicsView->height()-20+*/graphicsView->verticalScrollBar()->sliderPosition())/qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)));} void View::mouseReleaseEvent(QMouseEvent *event) {} void View::keyPressEvent(QKeyEvent *event){ switch(event->key()){ case (Qt::Key_Up)||(Qt::Key_5):{ if (rotateSlider->isHidden()){ rotateSlider->show(); rotateRightIcon->show(); rotateLeftIcon->show(); resetButton->show(); zoomSlider->show(); zoomInIcon->show(); zoomOutIcon->show(); hourButton->show(); nextItemButton->show(); searchButton->show(); label->show(); compView->show(); } else{ rotateSlider->hide(); rotateRightIcon->hide(); rotateLeftIcon->hide(); resetButton->hide(); zoomSlider->hide(); zoomInIcon->hide(); zoomOutIcon->hide(); hourButton->hide(); nextItemButton->hide(); searchButton->hide(); label->hide(); compView->hide(); } break;} break; default:1; } update();} bool View::eventFilter(QObject* pobj, QEvent* pe){ if (rotateSlider->value() == 0 && showRule->isChecked()) { graphicsView->items().at(1)->show(); graphicsView->items().at(50)->show();} else{ graphicsView->items().at(1)->hide(); graphicsView->items().at(50)->hide();} qreal hSlidePosR = (graphicsView->horizontalScrollBar()->sliderPosition()+150*graphicsView->width()/191)/qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)); qreal hSlidePosL = (graphicsView->horizontalScrollBar()->sliderPosition()+50*graphicsView->width()/191)/qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)); qreal hSlidePosRR = (graphicsView->horizontalScrollBar()->sliderPosition()+110*graphicsView->width()/191)/qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)); qreal hSlidePosLL = (graphicsView->horizontalScrollBar()->sliderPosition()+80*graphicsView->width()/191)/qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)); qreal vSlidePosU = (graphicsView->verticalScrollBar()->sliderPosition()+150*graphicsView->height()/200)/qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)); qreal vSlidePosD = (graphicsView->verticalScrollBar()->sliderPosition()+50*graphicsView->height()/200)/qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)); qreal vSlidePosUU = (graphicsView->verticalScrollBar()->sliderPosition()+120*graphicsView->height()/200)/qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)); qreal vSlidePosDD = (graphicsView->verticalScrollBar()->sliderPosition()+70*graphicsView->height()/200)/qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)); if (graphicsView->items().at(1)->data(0) == "ruler") graphicsView->items().at(1)->setPos(0,(graphicsView->verticalScrollBar()->sliderPosition())/qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50))); if (graphicsView->items().at(50)->data(0) == "ruler") graphicsView->items().at(50)->setPos((graphicsView->horizontalScrollBar()->sliderPosition())/qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)), 0); repaint(); for (int i=2; i<50;i++) if (graphicsView->items().at(i)->data(0) == "ruler") if (graphicsView->items().at(i)->pos().x()< hSlidePosRR && graphicsView->items().at(i)->pos().x() > hSlidePosLL) graphicsView->items().at(i)->setOpacity(1); else if (graphicsView->items().at(i)->pos().x()< hSlidePosR && graphicsView->items().at(i)->pos().x() > hSlidePosL) graphicsView->items().at(i)->setOpacity(0.7); else graphicsView->items().at(i)->setOpacity(0.3); for (int i=51; i<75;i++) if (graphicsView->items().at(i)->data(0) == "ruler") if (graphicsView->items().at(i)->pos().y()< vSlidePosUU && graphicsView->items().at(i)->pos().y() > vSlidePosDD) graphicsView->items().at(i)->setOpacity(1); else if (graphicsView->items().at(i)->pos().y()< vSlidePosU && graphicsView->items().at(i)->pos().y() > vSlidePosD) graphicsView->items().at(i)->setOpacity(0.7); else graphicsView->items().at(i)->setOpacity(0.3); if (pe->type() == QEvent::KeyPress) { if (((QKeyEvent*)pe)->key() == Qt::Key_Up || ((QKeyEvent*)pe)->key() == Qt::Key_5) { if (rotateSlider->isHidden()){ rotateSlider->show(); rotateRightIcon->show(); rotateLeftIcon->show(); resetButton->show(); zoomSlider->show(); zoomInIcon->show(); zoomOutIcon->show(); nextItemButton->show(); hourButton->show(); searchButton->show(); label->show(); menuButton->show(); compView->show(); menuButton->setFocus(); } else{ rotateSlider->hide(); rotateRightIcon->hide(); rotateLeftIcon->hide(); resetButton->hide(); zoomSlider->hide(); zoomInIcon->hide(); zoomOutIcon->hide(); hourButton->hide(); nextItemButton->hide(); searchButton->hide(); label->hide(); menuButton->hide(); compView->hide(); }} return true; }else return false;} Листинг 6 ruler.h #ifndef RULER_H_ #define RULER_H_ #include #include class Ruler : public QGraphicsTextItem { public: Ruler(QString value); QRectF boundingRect() const; QPainterPath shape() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget); private: QString value; }; #endif Листинг 7 ruler.cpp #include "ruler.h" #include Ruler::Ruler(QString value){ this->value = value; setDefaultTextColor(Qt::magenta);} QRectF Ruler::boundingRect() const{ return QRectF(-100, -100, 1000, 1000);} QPainterPath Ruler::shape() const{ QPainterPath path; path.addEllipse(0, 0, 100, 100); return path;} void Ruler::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(widget); painter->setBrush(QBrush(Qt::magenta)); painter->setPen(QPen(Qt::white)); QFont font("Times", 10); font.setStyleStrategy(QFont::ForceOutline); painter->scale(1/option->levelOfDetail,1/option->levelOfDetail); painter->translate(option->levelOfDetail*10,0); if (option->levelOfDetail>1) painter->translate(option->levelOfDetail*10,option->levelOfDetail*10); painter->setFont(font); painter->drawText(0,20, value); //update();} Листинг 8 InputDialog.h #ifndef _InputDialog_h_ #define _InputDialog_h_ #include class QLineEdit; class QLabel; class QSpinBox; class InputDialog : public QDialog { Q_OBJECT private: QSpinBox* hourSpinBox; QSpinBox* gradSpinBox; public: InputDialog(QWidget* pwgt = 0); QString hour() const; QString grad () const; }; #endif Листинг 9 InputDialog.cpp #include "InputDialog.h" #include InputDialog::InputDialog(QWidget* pwgt/*= 0*/) :QDialog(pwgt, Qt::WindowTitleHint | Qt::WindowSystemMenuHint){ QLabel* hourLabel = new QLabel("&Hour(Ascension):"); QLabel* gradLabel = new QLabel("&Gradus(Declination):"); hourSpinBox = new QSpinBox; gradSpinBox = new QSpinBox; hourSpinBox->setRange(0, 23); gradSpinBox->setRange(-90, 90); hourLabel->setBuddy(hourSpinBox); gradLabel->setBuddy(gradSpinBox); QPushButton* pcmdOk = new QPushButton("&0k"); QPushButton* pcmdCancel = new QPushButton("&Cancel"); connect(pcmdOk, SIGNAL(clicked()), SLOT(accept())); connect(pcmdCancel, SIGNAL(clicked()), SLOT(reject())); //Layout setup QGridLayout* ptopLayout = new QGridLayout; ptopLayout->addWidget(hourLabel, 0, 0); ptopLayout->addWidget(gradLabel, 1, 0); ptopLayout->addWidget(hourSpinBox, 0, 1); ptopLayout->addWidget(gradSpinBox, 1, 1); ptopLayout->addWidget(pcmdOk, 2,0); ptopLayout->addWidget(pcmdCancel, 2, 1); setLayout(ptopLayout);} QString InputDialog::hour() const{ return hourSpinBox->text();} QString InputDialog::grad() const{ return gradSpinBox->text() ;} Листинг 10 star.h #ifndef STAR_H #define STAR_H #include #include class Star : public QGraphicsItem{ public: Star(QString starData, int dH, int dG); QRectF boundingRect() const; QPainterPath shape() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget); protected: void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); private: double x, y; QColor color; QList QString starData; int id; int num; qint16 raHour; qint16 raMin; qint16 raSec; bool south; qint16 decGrad; qint16 decMin; qint16 decSec; QString name; int volume; }; #endif Листинг 11 star.cpp #include "star.h" #include Star::Star(QString starData, int dH, int dG){ this->x = 0; this->y = 0; this->color = Qt::white; this->starData = starData; setZValue(10); QTextStream stream(&starData); volume = starData.right(3).toInt(); volume = qAbs(volume); volume = volume/10; starData.resize(starData.size()-3); stream >> id; stream >> num; stream >> raHour; stream >> raMin; stream >> raSec; QString strPole; stream >> strPole; if(strPole == "+") south = true; else south = false; stream >> decGrad; stream >> decMin; stream >> decSec; if (south){ decGrad = -decGrad; decMin = -decMin; decSec = -decSec;} QString name1,name2; stream >> name1; stream >> name2; name = name1 + name2; if (raHour+dH < 24) x=(raHour+dH)*3600; else x = ((raHour+dH) - 24)*3600; x+=raMin*60; x+=raSec; x=(x*3.14159)/12; // ->> Rad //сдвиг по часам больше 1, п.э. всё ок y = decGrad*3600; y+=decMin*60; y+=decSec; y=(y*3.14159)/180; // ->> Rad qreal dGr = dG*62.8318; if (dGr>=0) if (y+dGr<90*62.8318) y=y+dGr; else y=(y+dGr)-180*62.8318; if (dGr<0) if (y+dGr>-90*62.8318) y=y+dGr; else y=(y+dGr)+180*62.8318; setPos(x,y); QString strNme = name.toLower(); QVariant varId = id; setData(0,varId.toString()); setData(1,strNme); setData(2,"star"); setFlags(ItemIsSelectable /*| ItemIsMovable*/); setAcceptsHoverEvents(true);} QRectF Star::boundingRect() const { return QRectF(-40, -40, volume+40, volume+40);} QPainterPath Star::shape() const { QPainterPath path; path.addEllipse(-20, -20, volume, volume); return path;} void Star::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(widget); QColor fillColor = (option->state & QStyle::State_Selected) ? color.dark(150) : color; if (option->state & QStyle::State_MouseOver) fillColor = fillColor.light(125); QPen oldPen = painter->pen(); QPen pen = oldPen; int width = 0; if (option->state & QStyle::State_Selected) width += 2; pen.setWidth(width); QBrush b = painter->brush(); painter->setBrush(QBrush(fillColor.dark(option->state & QStyle::State_Sunken ? 120 : 100))); painter->drawEllipse(-20, -20, volume, volume); painter->setBrush(b); // Draw text if (option->levelOfDetail >= 1) { QFont font("Times", 10); font.setStyleStrategy(QFont::ForceOutline); painter->setFont(font); painter->save(); painter->setPen(QColor(Qt::black)); painter->scale(0.35, 0.35); QPointF xy = mapToScene(QPointF(0,0)); painter->drawText(-45, -25, name); painter->restore(); }} void Star::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event){ QVariant yc = y; QMessageBox::information(0, "Star's Name", starData);} Листинг 12 constellation.h #ifndef CONSTELLATION_H_ #define CONSTELLATION_H_ #include #include class Constellation : public QGraphicsItem { public: Constellation(QString name, const QColor &color); QRectF boundingRect() const; QPainterPath shape() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget); protected: void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); private: int x, y; QColor color; QString name; }; #endif Листинг 13 constellation.cpp #include "constellation.h" #include Constellation::Constellation(QString name, const QColor &color) { this->color = color; this->name = name; setZValue(2000); setData(0,name.toLower()); setData(1,"constellation"); setFlags(ItemIsSelectable /*| ItemIsMovable*/); setAcceptsHoverEvents(true);} QRectF Constellation::boundingRect() const {return QRectF(0, 0, 800, -150);} QPainterPath Constellation::shape() const { QPainterPath path; path.addRect(0, 0, 800, -100); return path;} void Constellation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(widget); painter->save(); painter->setBrush(QBrush(QColor(Qt::black))); painter->setPen(QPen(QColor(Qt::black))); painter->setOpacity(0.3); painter->drawEllipse(-160,135,580,-400); painter->restore(); painter->save(); painter->setBrush(QBrush(QColor(Qt::black))); painter->setPen(QPen(QColor(Qt::black))); painter->setOpacity(0.75); painter->drawEllipse(-70,50,410,-220); painter->restore(); QFont font("Arial", 10); font.setStyleStrategy(QFont::ForceOutline); painter->setFont(font); painter->save(); painter->setPen(QColor(Qt::white)); painter->scale(12, 12); painter->drawText(0, 0, name); painter->restore();} void Constellation::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event){ QMessageBox::information(0, "Constellation's Name", name);} Листинг 14 Constellations_win32.pro TEMPLATE = app TARGET = Constellations_win32 QT += core \ gui \ opengl HEADERS += Constellations_win32.loc \ ruler.h \ InputDialog.h \ constellation.h \ mainwindow.h \ view.h \ star.h SOURCES += Constellations_win32.rss \ Constellations_win32_reg.rss \ ruler.cpp \ InputDialog.cpp \ constellation.cpp \ star.cpp \ main.cpp \ mainwindow.cpp \ view.cpp FORMS += RESOURCES += images.qrc |
Реферат Флягина Т. А. Проблемы разработки многооконных интерфейсов,... Флягина Т. А. Проблемы разработки многооконных интерфейсов, квалификационная работа на степень бакалавра наук | Реферат: Коваленко А. Е. Разработка системы научной визуализации.... Коваленко А. Е. Разработка системы научной визуализации. Квалификационная работа на степень магистра наук по направлению «Математика.... | ||
Решение проблем, при реализации метафоры манипуляции «Волшебный скальпель» Попова А. В. Использование визуальных манипуляционных метафор при разработке информационной системы, квалификационная работа на степень... | Реферат: Шайдуров А. Г. Исследование и разработка некоторых графических... Шайдуров А. Г. Исследование и разработка некоторых графических алгоритмов. Квалификационная работа на степень магистра наук по направлению... | ||
Реферат Пояснительная записка: с., рис., табл., приложений, источников.... Пояснительная записка: с., рис., табл., приложений, источников | Литература Уросов А. П. Разработка методик визуализации для представления работы параллельных программ, квалификационная работа на степень бакалавра... | ||
Реферат в данном дипломном проекте всего: стр. 123, рис. 29, табл.... Тяговая подстанция, распределительное устройство, трансформатор, ток короткого замыкания, преобразовательный агрегат, стуктурная... | Реферат На стр., 12 частей, библ. 17 назв. Авторское право и смежные... «Разработка типовых лицензий на приобретаемые в рамках государственных контрактов фцп “Электронная Россия” (2002-2010 годы) права... | ||
Требования к письменным работам Объем текста работы Объем текста работы определяемом видом работы: выпускная квалификационная работа – 50-75 стр.; курсовая работа – 25-30 стр.; реферат... | Реферат (18 стр., рис., 3 табл.) Объектом исследования являлись системы централизованного и локального водоотведения мо ракитинское | ||
Правительство Российской Федерации Федеральное государственное автономное... Выпускная квалификационная работа. 81 с., 10 рис., 5 приложений, 26 источников литературы | Реферат Алаева В. С. Расчет и моделирование системы электросвязи.... Целью курсовой работы является расчёт и моделирование системы электросвязи в системе схемотехнического моделирования micro-cap 9 | ||
Реферат Объем: 119 стр., 16 рис., 7 табл., 7 использованных источников ... | Проекта: Разработка Web-приложений Разработка web-приложений, бизнес процесс разработки web-приложения, cms drupal, создание сайта кафедры | ||
Реферат Дипломный проект 117 с., 15 рис., 19 табл., 39 источников Цель работы – детальная разработка пункта технического обслуживания электровозов с комплексной механизацией | Реферат 3 3 Содержание 4 4 Определения 5 5 Введение 6 6 Основная... В ходе работы, в течении данного семестра мы изучали технологии веб-программирования и верстки позволяющие делать стабильные, удобные... |