QtGnuplotWindow::QtGnuplotWindow(int id, QtGnuplotEventHandler* eventHandler, QWidget* parent) : QMainWindow(parent) { m_eventHandler = eventHandler; m_id = id; setAttribute(Qt::WA_DeleteOnClose); setWindowIcon(QIcon(":/images/gnuplot")); // Register as the main event receiver if not already created if (m_eventHandler == 0) m_eventHandler = new QtGnuplotEventHandler(this, "qtgnuplot" + QString::number(QCoreApplication::applicationPid())); // Central widget m_widget = new QtGnuplotWidget(m_id, m_eventHandler, this); connect(m_widget, SIGNAL(statusTextChanged(const QString&)), this, SLOT(on_setStatusText(const QString&))); setCentralWidget(m_widget); // Bars m_toolBar = new QToolBar(this); addToolBar(m_toolBar); statusBar()->showMessage(tr("Qt frontend for gnuplot")); // Actions QAction* copyToClipboardAction = new QAction(QIcon(":/images/clipboard" ), tr("Copy to clipboard"), this); QAction* printAction = new QAction(QIcon(":/images/print" ), tr("Print" ), this); QAction* exportAction = new QAction(QIcon(":/images/export" ), tr("Export" ), this); QAction* exportPdfAction = new QAction(QIcon(":/images/exportPDF" ), tr("Export to PDF" ), this); QAction* exportEpsAction = new QAction(QIcon(":/images/exportVector"), tr("Export to EPS" ), this); QAction* exportSvgAction = new QAction(QIcon(":/images/exportVector"), tr("Export to SVG" ), this); QAction* exportPngAction = new QAction(QIcon(":/images/exportRaster"), tr("Export to image" ), this); QAction* settingsAction = new QAction(QIcon(":/images/settings" ), tr("Settings" ), this); connect(copyToClipboardAction, SIGNAL(triggered()), m_widget, SLOT(copyToClipboard())); connect(printAction, SIGNAL(triggered()), m_widget, SLOT(print())); connect(exportPdfAction, SIGNAL(triggered()), m_widget, SLOT(exportToPdf())); connect(exportEpsAction, SIGNAL(triggered()), m_widget, SLOT(exportToEps())); connect(exportSvgAction, SIGNAL(triggered()), m_widget, SLOT(exportToSvg())); connect(exportPngAction, SIGNAL(triggered()), m_widget, SLOT(exportToImage())); connect(settingsAction, SIGNAL(triggered()), m_widget, SLOT(showSettingsDialog())); QMenu* exportMenu = new QMenu(this); exportMenu->addAction(copyToClipboardAction); exportMenu->addAction(printAction); exportMenu->addAction(exportPdfAction); // exportMenu->addAction(exportEpsAction); exportMenu->addAction(exportSvgAction); exportMenu->addAction(exportPngAction); exportAction->setMenu(exportMenu); m_toolBar->addAction(exportAction); createAction(tr("Replot") , 'e', ":/images/replot"); createAction(tr("Show grid") , 'g', ":/images/grid"); createAction(tr("Previous zoom"), 'p', ":/images/zoomPrevious"); createAction(tr("Next zoom") , 'n', ":/images/zoomNext"); createAction(tr("Autoscale") , 'a', ":/images/autoscale"); m_toolBar->addAction(settingsAction); }
//------------------------------------------------------------------------- void MainWindow::createActions() { mSettings.mDesactiveUIElements << ADD_FROM_FILE_ACT; GraphicsSceneMainWindow::createActions(); mExportAct = new QAction(QIcon(RSC_DIR + QString("export.png")), tr("&Export...") , this); mExportAct->setShortcut( tr("Ctrl+E") ); mExportAct->setStatusTip(tr("Export the scene, an item, or use Shift+Drag&Drop to specify an export-window")); connect(mExportAct , SIGNAL(triggered()) , this , SLOT(exportToImage()) ); mAddTextAct = new QAction(QIcon(RSC_DIR + QString("addText.png")), tr("Add text item") , this); mAddTextAct->setStatusTip(tr("Add a text item to the scene")); connect(mAddTextAct , SIGNAL(triggered()) , this , SLOT(addTextItem()) ); mAddFromAnyFileAct = new QAction(QIcon(RSC_DIR + QString("addFromAnyFile.png")), tr("Add item from file...") , this); mAddFromAnyFileAct->setStatusTip("Add a new item from a file"); connect(mAddFromAnyFileAct , SIGNAL(triggered()) , this , SLOT(addItemFromAnyFile()) ); mSetPageA4PortraitAct = new QAction(tr("A4 Portrait") , this); connect(mSetPageA4PortraitAct , SIGNAL(triggered()) , this , SLOT(setPageA4Portrait()) ); mSetPageA3PortraitAct = new QAction(tr("A3 Portrait") , this); connect(mSetPageA3PortraitAct , SIGNAL(triggered()) , this , SLOT(setPageA3Portrait()) ); mSetPageA4LandscapeAct = new QAction(tr("A4 Landscape") , this); connect(mSetPageA4LandscapeAct , SIGNAL(triggered()) , this , SLOT(setPageA4Landscape()) ); mSetPageA3LandscapeAct = new QAction(tr("A3 Landscape") , this); connect(mSetPageA3LandscapeAct , SIGNAL(triggered()) , this , SLOT(setPageA3Landscape()) ); #ifdef USES_GUIDO_AR mPlayAct = new QAction(style()->standardIcon(QStyle::SP_MediaPlay), tr("Play"), this); mPlayAct->setStatusTip(tr("Play selected item")); connect( mPlayAct , SIGNAL(triggered()) , this , SLOT(playItem()) ); mPauseAct = new QAction(style()->standardIcon(QStyle::SP_MediaPause), tr("Pause"), this); mPauseAct->setStatusTip(tr("Pause selected item")); connect( mPauseAct , SIGNAL(triggered()) , this , SLOT(pauseItem()) ); mStopAct = new QAction(style()->standardIcon(QStyle::SP_MediaStop), tr("Stop"), this); mStopAct->setStatusTip(tr("Stop selected item")); connect( mStopAct , SIGNAL(triggered()) , this , SLOT(stopItem()) ); #endif }
bool DocumentController::exportToImage() { return exportToImage(_document, _dialogParent.data()); }
DataPlot::DataPlot(QString plot_name, qreal max_yy, qreal max_xx, QString yyLabel, QWidget *parent): QWidget(parent) { setMouseTracking(true); this->max_xx=max_xx; this->max_yy=max_yy; QHBoxLayout * layout = new QHBoxLayout(); this->setLayout(layout); scene = new ClickableQGraphicsScene(this); scene->setMouseTracking(true); connect(scene,SIGNAL(mouseMoved(QPointF)),SLOT(mouseMovedInScene(QPointF))); view = new QGraphicsView(scene); layout->addWidget(view); QVBoxLayout * v_layout = new QVBoxLayout(); layout->addLayout(v_layout); QPushButton* btn = new QPushButton("Export"); btn->setMaximumSize(55,25); v_layout->addWidget(btn,0,Qt::AlignTop); connect(btn,SIGNAL(clicked()),SLOT(exportToImage())); btn = new QPushButton("Show all"); btn->setMaximumSize(55,25); v_layout->addWidget(btn,0,Qt::AlignTop); connect(btn,SIGNAL(clicked()),SLOT(showAllInds())); btn = new QPushButton("Zoom in"); btn->setMaximumSize(55,25); v_layout->addWidget(btn,0,Qt::AlignTop); connect(btn,SIGNAL(clicked()),SLOT(zoomIn())); btn = new QPushButton("Zoom out"); btn->setMaximumSize(55,25); v_layout->addWidget(btn,0,Qt::AlignTop); connect(btn,SIGNAL(clicked()),SLOT(zoomOut())); currentCoordXLabel = new QLabel("x: 0"); v_layout->addWidget(currentCoordXLabel,0,Qt::AlignTop); currentCoordYLabel = new QLabel("y: 0"); v_layout->addWidget(currentCoordYLabel,0,Qt::AlignTop); v_layout->addSpacing(330); view->setRenderHint(QPainter::Antialiasing); view->setCacheMode(QGraphicsView::CacheBackground); view->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); view->setCursor(Qt::CrossCursor); //Offsets para os labels dos eixos x_offset = y_offset = 20; //Tamanho real do plot plot_height = height()-y_offset; plot_width = width()-x_offset; //Inicializa a lista de cores disponíveis available_class_colors.append(Qt::red); available_class_colors.append(Qt::blue); available_class_colors.append(Qt::green); available_class_colors.append(Qt::yellow); available_class_colors.append(Qt::cyan); available_class_colors.append(Qt::magenta); available_class_colors.append(QColor(122,27,224)); available_class_colors.append(Qt::lightGray); available_class_colors.append(Qt::darkBlue); available_class_colors.append(Qt::darkGray); available_class_colors.append(Qt::darkRed); available_class_colors.append(Qt::darkGreen); available_class_colors.append(Qt::darkMagenta); available_class_colors.append(Qt::darkCyan); available_class_colors.append(Qt::darkYellow); available_class_colors_for_line = available_class_colors; //Inicializa a lista de indices yy disponíveis para séries sem coordenada do y for(qreal i=0.05;i<=1.0;i+=0.05) availabel_yy_inds.append(i); QGraphicsTextItem * t_item; title_text_item = scene->addText(plot_name); title_text_item->setPos(width()/2,-10); if(yyLabel.length()>0){ t_item = scene->addText(QString().number(max_yy)); t_item->setPos(0,y_offset-10); } t_item = scene->addText(QString().number(max_xx)); t_item->setPos(width()-x_offset+10,height()-y_offset); t_item = scene->addText("Seconds"); t_item->setPos(width()/2,height()-y_offset); t_item = scene->addText(yyLabel); t_item->setPos(0,height()/2); t_item->setRotation(-90); t_item = scene->addText(QString().number(0)); t_item->setPos(0,height()-y_offset); scene->addLine(x_offset,y_offset,x_offset,plot_height,QPen(QBrush(Qt::black),2)); scene->addLine(x_offset,plot_height,width(),plot_height,QPen(QBrush(Qt::black),2)); setWindowTitle(plot_name); class_labels_offset=0; current_progressive_show_ind=-1; initial_width = width(); initial_height = height(); this->yyLabel=yyLabel; }
//BEGIN class ItemView ItemView::ItemView(ItemDocument * itemDocument, ViewContainer *viewContainer, uint viewAreaId, const char *name) : View(itemDocument, viewContainer, viewAreaId, name) { KActionCollection * ac = actionCollection(); KStdAction::selectAll(itemDocument, SLOT(selectAll()), ac); KStdAction::zoomIn(this, SLOT(zoomIn()), ac); KStdAction::zoomOut(this, SLOT(zoomOut()), ac); KStdAction::actualSize(this, SLOT(actualSize()), ac)->setEnabled(false); KAccel *pAccel = new KAccel(this); pAccel->insert("Cancel", i18n("Cancel"), i18n("Cancel the current operation"), Qt::Key_Escape, itemDocument, SLOT(cancelCurrentOperation())); pAccel->readSettings(); new KAction(i18n("Delete"), "editdelete", Qt::Key_Delete, itemDocument, SLOT(deleteSelection()), ac, "edit_delete"); new KAction(i18n("Export as Image..."), 0, 0, itemDocument, SLOT(exportToImage()), ac, "file_export_image"); //BEGIN Item Alignment actions new KAction(i18n("Align Horizontally"), 0, 0, itemDocument, SLOT(alignHorizontally()), ac, "align_horizontally"); new KAction(i18n("Align Vertically"), 0, 0, itemDocument, SLOT(alignVertically()), ac, "align_vertically"); new KAction(i18n("Distribute Horizontally"), 0, 0, itemDocument, SLOT(distributeHorizontally()), ac, "distribute_horizontally"); new KAction(i18n("Distribute Vertically"), 0, 0, itemDocument, SLOT(distributeVertically()), ac, "distribute_vertically"); //END Item Alignment actions //BEGIN Draw actions KToolBarPopupAction * pa = new KToolBarPopupAction(i18n("Draw"), "paintbrush", 0, 0, 0, ac, "edit_draw"); pa->setDelayed(false); KPopupMenu * m = pa->popupMenu(); m->insertTitle(i18n("Draw")); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_text", KIcon::Small), i18n("Text"), DrawPart::da_text); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_line", KIcon::Small), i18n("Line"), DrawPart::da_line); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_arrow", KIcon::Small), i18n("Arrow"), DrawPart::da_arrow); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_ellipse", KIcon::Small), i18n("Ellipse"), DrawPart::da_ellipse); m->insertItem(KGlobal::iconLoader()->loadIcon("tool_rectangle", KIcon::Small), i18n("Rectangle"), DrawPart::da_rectangle); m->insertItem(KGlobal::iconLoader()->loadIcon("imagegallery", KIcon::Small), i18n("Image"), DrawPart::da_image); connect(m, SIGNAL(activated(int)), itemDocument, SLOT(slotSetDrawAction(int))); //END Draw actions //BEGIN Item Control actions new KAction(i18n("Raise Selection"), "bring_forward", Qt::Key_PageUp, itemDocument, SLOT(raiseZ()), ac, "edit_raise"); new KAction(i18n("Lower Selection"), "send_backward", Qt::Key_PageDown, itemDocument, SLOT(lowerZ()), ac, "edit_lower"); //END Item Control actions KAction * na = new KAction("", 0, 0, 0, 0, ac, "null_action"); na->setEnabled(false); setXMLFile("ktechlabitemviewui.rc"); m_pUpdateStatusTmr = new QTimer(this); connect(m_pUpdateStatusTmr, SIGNAL(timeout()), this, SLOT(updateStatus())); connect(this, SIGNAL(unfocused()), this, SLOT(stopUpdatingStatus())); m_pDragItem = 0l; p_itemDocument = itemDocument; m_zoomLevel = 1.; m_CVBEditor = new CVBEditor(p_itemDocument->canvas(), this, "cvbEditor"); m_CVBEditor->setLineWidth(1); connect(m_CVBEditor, SIGNAL(horizontalSliderReleased()), itemDocument, SLOT(requestCanvasResize())); connect(m_CVBEditor, SIGNAL(verticalSliderReleased()), itemDocument, SLOT(requestCanvasResize())); m_layout->insertWidget(0, m_CVBEditor); setAcceptDrops(true); setFocusWidget(m_CVBEditor->viewport()); }