void MainWindow::OpenImage(const QString &fileName) { QScrollArea* area = new QScrollArea(); ImageWidget* img = new ImageWidget(); // Nur les- und schreibbare Bildformate werden unterstützt if (img->OpenImage(fileName)) { QString shortFileName = ParseFileName(fileName); shortFileName = shortFileName.mid(0, shortFileName.lastIndexOf('.')); // Bild in die ScrollArea laden area->setWidget(img); area->setStyleSheet("background: qlineargradient(x1: 0, y0: 1, x2:1, y2: 0, stop: 0.96 #383838, stop: 0.99 #2e2e2e);"); // neuen Tab hinzufügen int index = ui->imagetab->addTab(area, shortFileName); ui->imagetab->setTabToolTip(index, shortFileName); ui->imagetab->setCurrentIndex(index); // schließlich Signalhandler setzen connect(this, SIGNAL(Arguments(QHash<QString,QString>)), img, SLOT(Arguments(QHash<QString,QString>))); connect(this, SIGNAL(Operation(IOperation*,QHash<QString,QString>)), img, SLOT(Operation(IOperation*,QHash<QString,QString>))); connect(this, SIGNAL(Operation(IOperation*,QHash<QString,QString>,OperationType)), img, SLOT(Operation(IOperation*,QHash<QString,QString>,OperationType))); emit Operation(mOperation, GetArgs()); }
ImageFilterExampleWidget::ImageFilterExampleWidget(QWidget* parent) { setWindowTitle(tr("OpenCL Image Filter Examples")); setFixedSize(820,500); ImageWidget *before = new ImageWidget(this); ImageWidget *oclFiltered = new ImageWidget(this); beforeW=before; afterW=oclFiltered; QLabel *beforeLabel = new QLabel(tr("Before")); beforeLabel->setAlignment(Qt::AlignHCenter); QLabel *afterLabel = new QLabel(tr("Ocl")); afterLabel->setAlignment(Qt::AlignHCenter); createMenu(); before->setFixedSize(400,400); oclFiltered->setFixedSize(400,400); QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); mainLayout->addWidget(this->menuBar); mainLayout->setMenuBar(this->menuBar); QGridLayout *layout = new QGridLayout; // layout->addWidget(menubar,0,0); layout->addWidget(before, 0, 0); layout->addWidget(oclFiltered, 0, 1); layout->addWidget(beforeLabel, 1, 0); layout->addWidget(afterLabel, 1, 1); mainLayout->addLayout(layout); }
OpenCVImageListRenderer::OpenCVImageListRenderer(QWidget* parent) : DataRenderer(parent), m_busy(false) { m_layout = new QHBoxLayout(this); ImageWidget* imageWidget = new ImageWidget; m_imageWidgets.append(imageWidget); m_layout->addWidget( imageWidget ); QImage image = QImage(320,240,QImage::Format_RGB32); image.fill( qRgb(0,0,0) ); // TODO make minimum configurable somewhere imageWidget->setMinimumSize( 160, 120 ); imageWidget->setImage( image ); this->setLayout( m_layout ); m_converter = new ImageConverter(this); qRegisterMetaType< QList<QImage> >("QList<QImage>"); connect( m_converter, SIGNAL( convertedList( QList<QImage>, int ) ), this, SLOT( updateImages( QList<QImage>, int ) ), Qt::UniqueConnection); }
int main(int argc, char *argv[]) { installLogcatMessageHandler("qimageviewer"); QApplication a(argc, argv); QFont f = a.font(); f.setPixelSize(20); a.setFont(f); ImageWidget w; w.show(); return a.exec(); }
void ImageWidget::restore(Graph *g, const QStringList& lst) { int frameStyle = 0; QPen pen = QPen(Qt::black, 1, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin); double x = 0.0, y = 0.0, right = 0.0, bottom = 0.0; QStringList::const_iterator line; QString fn; bool save_xpm = false; ImageWidget *i = NULL; for (line = lst.begin(); line != lst.end(); line++){ QString s = *line; if (s.contains("<Frame>")) frameStyle = s.remove("<Frame>").remove("</Frame>").toInt(); else if (s.contains("<Color>")) pen.setColor(QColor(s.remove("<Color>").remove("</Color>"))); else if (s.contains("<FrameWidth>")) pen.setWidth(s.remove("<FrameWidth>").remove("</FrameWidth>").toInt()); else if (s.contains("<LineStyle>")) pen.setStyle(PenStyleBox::penStyle(s.remove("<LineStyle>").remove("</LineStyle>").toInt())); else if (s.contains("<x>")) x = s.remove("<x>").remove("</x>").toDouble(); else if (s.contains("<y>")) y = s.remove("<y>").remove("</y>").toDouble(); else if (s.contains("<right>")) right = s.remove("<right>").remove("</right>").toDouble(); else if (s.contains("<bottom>")) bottom = s.remove("<bottom>").remove("</bottom>").toDouble(); else if (s.contains("<path>")) i = g->addImage(s.remove("<path>").remove("</path>")); else if (s.contains("<xpm>")){ save_xpm = true; if (!i){ QString xpm; while ( s != "</xpm>" ){ s = *(++line); xpm += s + "\n"; } QImage image; if (image.loadFromData(xpm.toAscii())) i = g->addImage(image); } } } if (i){ i->setFrameStyle(frameStyle); i->setFramePen(pen); i->setCoordinates(x, y, right, bottom); i->setSaveInternally(save_xpm); } }
ImagePlayer::ImagePlayer(QWidget *parent, QString name ) : QWidget(parent) , surface(0) , playButton(0) , positionSlider(0) { connect(&movie, SIGNAL(stateChanged(QMovie::MovieState)), this, SLOT(movieStateChanged(QMovie::MovieState))); connect(&movie, SIGNAL(frameChanged(int)), this, SLOT(frameChanged(int))); ImageWidget *imageWidget = new ImageWidget( parent ); surface = imageWidget->videoSurface(); playButton = new QPushButton; playButton->setEnabled(false); playButton->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); connect(playButton, SIGNAL(clicked()), this, SLOT(play())); positionSlider = new QSlider(Qt::Horizontal); positionSlider->setRange(0, 0); connect(positionSlider, SIGNAL(sliderMoved(int)), this, SLOT(setPosition(int))); connect(&movie, SIGNAL(frameChanged(int)), positionSlider, SLOT(setValue(int))); QBoxLayout *controlLayout = new QHBoxLayout; controlLayout->setMargin(0); //controlLayout->addWidget(openButton); controlLayout->addWidget(playButton); controlLayout->addWidget(positionSlider); QBoxLayout *layout = new QVBoxLayout; layout->addWidget( imageWidget ); layout->addLayout( controlLayout ); setLayout(layout); // _name = name; openFile(); }
Vector<Widget*> MainPage::createWidgets() { RelativeController* plc = NULL;; TextWidget* txt = NULL; Button* btn = NULL; ImageWidget* img = NULL; RelativeControllerParams imgParams(ControllerParams::MATCH_PARENT, ControllerParams::MATCH_PARENT); RelativeControllerParams button(ControllerParams::WRAP_CONTENT, ControllerParams::WRAP_CONTENT); button.setRelation(RelativeControllerParams::ALIGN_PARENT_BOTTOM); button.setRelation(RelativeControllerParams::ALIGN_PARENT_LEFT); RelativeControllerParams text(ControllerParams::WRAP_CONTENT, ControllerParams::WRAP_CONTENT); text.setRelation(RelativeControllerParams::CENTER_IN_PARENT); Vector<Widget*> widgets; for (size_t i = 0; i < 10; i++) { plc = new RelativeController(this); mWidgetPool.append(plc); img = new ImageWidget(this); mWidgetPool.append(img); img->setImageResource(gPictures[i]); img->setScaleType(ImageWidget::FIT_XY); plc->addWidget(img); img->setControllerParams(&imgParams); txt = new TextWidget(this); txt->setControllerParams(&text); mWidgetPool.append(txt); txt->setText(String::format("this is %d picture.", i + 1)); txt->setTextColor(0xffff0000); plc->addWidget(txt); btn = new Button(this); btn->setControllerParams(&button); mWidgetPool.append(btn); btn->setText(String::format("button %d", i+1)); plc->addWidget(btn); widgets.append(plc); } GLOG(LOG_TAG, LOGINFO, "widgets size %d", widgets.size()); return widgets; }
void EnrichmentDialog::setBestSize() { ImageWidget *iw = qobject_cast<ImageWidget *>(d_widget); if (iw){ iw->setSize(iw->pixmap().size()); displayCoordinates(unitBox->currentIndex()); d_plot->multiLayer()->notifyChanges(); return; } TexWidget *tw = qobject_cast<TexWidget *>(d_widget); if (tw){ tw->setBestSize(); displayCoordinates(unitBox->currentIndex()); d_plot->multiLayer()->notifyChanges(); return; } }
void EnrichmentDialog::saveImagesInternally(bool save) { ImageWidget *i = qobject_cast<ImageWidget *>(d_widget); if (i) i->setSaveInternally(boxSaveImagesInternally->isChecked()); d_plot->multiLayer()->notifyChanges(); if (save) return; QString fn = imagePathBox->text(); if (fn.isEmpty() || !QFile::exists(fn)){ QMessageBox::warning(d_app, tr("QtiPlot - Warning"), tr("The file %1 doesn't exist. The image cannot be restored when reloading the project file!").arg(fn)); chooseImageFile(); } }
void EnrichmentDialog::chooseImageFile(const QString& fn) { ApplicationWindow *app = (ApplicationWindow *)parentWidget(); if (!app) return; QString path = fn; if (path.isEmpty()) path = ApplicationWindow::getFileName(this, tr("QtiPlot - Import image from file"), app->imagesDirPath, ApplicationWindow::imageFilter(), 0, false); if (!path.isEmpty()){ ImageWidget *i = qobject_cast<ImageWidget *>(d_widget); if (i && i->load(path)){ imagePathBox->setText(path); QFileInfo fi(path); app->imagesDirPath = fi.dirPath(true); app->modifiedProject(); } } }
void MainWindow::onShowContentSmartButtonClicked() { Opc::PackagePart *part = m_package->part(ui->partNameEdit->text()); if (!part) return; if (ui->partContentSmartButton->property("smart") == "xml") { //Show formatted xml file contents MceXmlWidget *edit = new MceXmlWidget(part->getDevice()->readAll()); part->releaseDevice(); edit->setAttribute(Qt::WA_DeleteOnClose); edit->setWindowTitle(part->partName()); edit->resize(800, 600); edit->show(); } else if (ui->partContentSmartButton->property("smart") == "image") { //Show image ImageWidget *edit = new ImageWidget; edit->setAttribute(Qt::WA_DeleteOnClose); edit->setWindowTitle(part->partName()); QImage image = QImage::fromData(part->getDevice()->readAll()); part->releaseDevice(); edit->setPixmap(QPixmap::fromImage(image)); edit->resize(800, 600); edit->show(); } }
int main(int argc, char** argv) { QApplication app(argc, argv); MainWindow mw; mw.show(); #if 0 try { ImageSource * src; src = new ImageSource("test.jpg"); Image img = src->getImage(); FilterManager<CpuGrayFilter> filterCPU; filterCPU.process(img); std::cout<< "filter CPU time:" << filterCPU.getTime().total_microseconds() <<"us"<< std::endl; ImageWidget foo; foo.setImage(img); foo.setWindowTitle("Vis - CPU"); foo.show(); #ifdef USE_CUDA Image img2 = src->getImage(); FilterManager<GpuGrayFilter> filterGPU; filterGPU.process(img2); std::cout<< "filter GPU time:" << filterGPU.getTime().total_microseconds()<<"us" << std::endl; ImageWidget foo2; foo2.setImage(img2); foo2.setWindowTitle("Vis - GPU"); foo2.show(); #endif } catch(IException & ex) { std::cout <<ex.getMessage().toStdString() << std::endl; return 1; } #endif return app.exec(); }
ImageWidget::ImageWidget(const ImageWidget& obj) : sf::Sprite(*(obj.getTexture())) {}
void EnrichmentDialog::setWidget(QWidget *w) { if (!w || !d_app) return; d_widget = w; FrameWidget *fw = qobject_cast<FrameWidget *>(d_widget); if (fw){ #ifndef QT_MAC_USE_COCOA if (d_plot) d_plot->deselectMarker(); #endif frameBox->blockSignals(true); frameBox->setCurrentIndex(fw->frameStyle()); frameBox->blockSignals(false); frameColorBtn->blockSignals(true); frameColorBtn->setColor(fw->frameColor()); frameColorBtn->blockSignals(false); boxFrameLineStyle->blockSignals(true); boxFrameLineStyle->setStyle(fw->framePen().style()); boxFrameLineStyle->blockSignals(false); boxFrameWidth->blockSignals(true); if (d_widget_type == Ellipse) boxFrameWidth->setValue(fw->framePen().widthF()); else boxFrameWidth->setValue(fw->framePen().width()); boxFrameWidth->blockSignals(false); unitBox->setCurrentIndex(d_app->d_frame_geometry_unit); attachToBox->setCurrentIndex((int)fw->attachPolicy()); displayCoordinates(d_app->d_frame_geometry_unit); } else { unitBox->setCurrentIndex(FrameWidget::Pixel); displayCoordinates(FrameWidget::Pixel); } if (d_widget_type == Text){ LegendWidget *l = qobject_cast<LegendWidget *>(d_widget); if (l){ setText(textEditBox, l->text()); textFont = l->font(); QFont fnt = textFont; fnt.setPointSize(QFont().pointSize() + 2); textEditBox->setFont(fnt); textColorBtn->blockSignals(true); textColorBtn->setColor(l->textColor()); textColorBtn->blockSignals(false); QColor bc = l->backgroundColor(); boxBackgroundTransparency->blockSignals(true); boxBackgroundTransparency->setValue(100*bc.alphaF()); boxBackgroundTransparency->blockSignals(false); transparencySlider->blockSignals(true); transparencySlider->setValue(boxBackgroundTransparency->value()); transparencySlider->blockSignals(false); textBackgroundBtn->blockSignals(true); textBackgroundBtn->setEnabled(bc.alpha()); bc.setAlpha(255); textBackgroundBtn->setColor(bc); textBackgroundBtn->blockSignals(false); boxTextAngle->blockSignals(true); boxTextAngle->setValue(l->angle()); boxTextAngle->blockSignals(false); autoUpdateTextBox->setChecked(l->isAutoUpdateEnabled()); texOutputBox->setChecked(l->hasTeXOutput()); updateButtons(); } } else if (d_widget_type == Tex){ TexWidget *tw = qobject_cast<TexWidget *>(d_widget); if (tw){ setText(equationEditor, tw->formula()); outputLabel->setPixmap(tw->pixmap()); bestSizeButton->show(); } return; } else if (d_widget_type == Image){ ImageWidget *i = qobject_cast<ImageWidget *>(d_widget); if (i){ imagePathBox->setText(i->fileName()); boxSaveImagesInternally->blockSignals(true); boxSaveImagesInternally->setChecked(i->saveInternally()); boxSaveImagesInternally->blockSignals(false); bestSizeButton->show(); } } else if (d_widget_type == Frame || d_widget_type == Ellipse){ QColor bc = fw->backgroundColor(); boxTransparency->blockSignals(true); boxTransparency->setValue(100.0*bc.alphaF()); boxTransparency->blockSignals(false); fillTransparencySlider->blockSignals(true); fillTransparencySlider->setValue(boxTransparency->value()); fillTransparencySlider->blockSignals(false); bc.setAlpha(255); backgroundColorBtn->blockSignals(true); backgroundColorBtn->setColor(bc); backgroundColorBtn->blockSignals(false); patternBox->blockSignals(true); patternBox->setPattern(fw->brush().style()); patternBox->blockSignals(false); patternColorBtn->blockSignals(true); patternColorBtn->setColor(fw->brush().color()); patternColorBtn->blockSignals(false); } }
/////////////////////////////////////////////////////////////////////////////// // // Handle commands entered in input box. // /////////////////////////////////////////////////////////////////////////////// void ImageWidget::CommandCallback(Fl_Widget* pWidget, void* pData) { ImageWidget* pImageWidget = static_cast<ImageWidget*>(pData); CScriptHandler::HandleCommand(static_cast<Fl_Input*>(pWidget)->value(), pImageWidget->m_pImage); pImageWidget->Redraw(); }// CommandCallback
void EnrichmentDialog::setWidget(QWidget *w) { if (!w) return; ApplicationWindow *app = (ApplicationWindow *)parent(); if (!app) return; d_widget = w; FrameWidget *fw = qobject_cast<FrameWidget *>(d_widget); if (fw){ frameBox->blockSignals(true); frameBox->setCurrentIndex(fw->frameStyle()); frameBox->blockSignals(false); frameColorBtn->blockSignals(true); frameColorBtn->setColor(fw->frameColor()); frameColorBtn->blockSignals(false); boxFrameLineStyle->blockSignals(true); boxFrameLineStyle->setStyle(fw->framePen().style()); boxFrameLineStyle->blockSignals(false); boxFrameWidth->blockSignals(true); if (d_widget_type == Ellipse) boxFrameWidth->setValue(fw->framePen().widthF()); else boxFrameWidth->setValue(fw->framePen().width()); boxFrameWidth->blockSignals(false); unitBox->setCurrentIndex(app->d_frame_geometry_unit); attachToBox->setCurrentIndex((int)fw->attachPolicy()); displayCoordinates(app->d_frame_geometry_unit); } else { unitBox->setCurrentIndex(FrameWidget::Pixel); displayCoordinates(FrameWidget::Pixel); } if (d_widget_type == Text){ LegendWidget *l = qobject_cast<LegendWidget *>(d_widget); if (l){ setText(textEditBox, l->text()); textFont = l->font(); QFont fnt = textFont; fnt.setPointSize(QFont().pointSize() + 2); textEditBox->setFont(fnt); textColorBtn->blockSignals(true); textColorBtn->setColor(l->textColor()); textColorBtn->blockSignals(false); QColor bc = l->backgroundColor(); boxBackgroundTransparency->blockSignals(true); boxBackgroundTransparency->setValue(bc.alpha()); boxBackgroundTransparency->blockSignals(false); textBackgroundBtn->blockSignals(true); textBackgroundBtn->setEnabled(bc.alpha()); textBackgroundBtn->setColor(bc); textBackgroundBtn->blockSignals(false); boxTextAngle->blockSignals(true); boxTextAngle->setValue(l->angle()); boxTextAngle->blockSignals(false); autoUpdateTextBox->setChecked(l->isAutoUpdateEnabled()); texOutputBox->setChecked(l->hasTeXOutput()); } } else if (d_widget_type == Tex){ TexWidget *tw = qobject_cast<TexWidget *>(d_widget); if (tw){ setText(equationEditor, tw->formula()); outputLabel->setPixmap(tw->pixmap()); bestSizeButton->show(); } return; } else if (d_widget_type == Image){ ImageWidget *i = qobject_cast<ImageWidget *>(d_widget); if (i){ imagePathBox->setText(i->fileName()); boxSaveImagesInternally->blockSignals(true); boxSaveImagesInternally->setChecked(i->saveInternally()); boxSaveImagesInternally->blockSignals(false); } } else if (d_widget_type == Frame){ RectangleWidget *r = qobject_cast<RectangleWidget *>(d_widget); if (r){ backgroundColorBtn->blockSignals(true); backgroundColorBtn->setColor(r->backgroundColor()); backgroundColorBtn->blockSignals(false); boxTransparency->blockSignals(true); boxTransparency->setValue(r->backgroundColor().alpha()); boxTransparency->blockSignals(false); patternBox->blockSignals(true); patternBox->setPattern(r->brush().style()); patternBox->blockSignals(false); patternColorBtn->blockSignals(true); patternColorBtn->setColor(r->brush().color()); patternColorBtn->blockSignals(false); } } else if (d_widget_type == Ellipse){ EllipseWidget *r = qobject_cast<EllipseWidget *>(d_widget); if (r){ backgroundColorBtn->blockSignals(true); backgroundColorBtn->setColor(r->backgroundColor()); backgroundColorBtn->blockSignals(false); boxTransparency->blockSignals(true); boxTransparency->setValue(r->backgroundColor().alpha()); boxTransparency->blockSignals(false); patternBox->blockSignals(true); patternBox->setPattern(r->brush().style()); patternBox->blockSignals(false); patternColorBtn->blockSignals(true); patternColorBtn->setColor(r->brush().color()); patternColorBtn->blockSignals(false); } } }
ClipExample:: ClipExample(cmd_line_type *cmd_line): DemoKernel(cmd_line), m_shader_hoard(WRATHGLShader::shader_source() .add_source("wobbly.vert.glsl", WRATHGLShader::from_resource), WRATHGLShader::shader_source() .add_source("wobbly.frag.glsl", WRATHGLShader::from_resource)), m_first_frame(true) { /* Create the WRATHTripleBufferEnabler object which our visual items will use to sync */ m_tr=WRATHNew WRATHTripleBufferEnabler(); /* Create the WRATHLayer which will contain and draw our shape */ m_layer=WRATHNew WRATHLayer(m_tr); /* these are the transforms that will be applied to all elements contained in the WRATHLayer: + a 3D transform + a Projection transform For the purpose of this example the 3D transform will be the identity matrix. In other words no transform will be applied to the vertex data. Projection will be orthographic */ float_orthogonal_projection_params proj_params(0, width(), height(), 0); m_layer->simulation_matrix(WRATHLayer::projection_matrix, float4x4(proj_params)); /* now we make a child layer of m_layer */ m_child_layer=WRATHNew WRATHLayer(m_layer); const int num_clip_widgets=cmd_line->m_num_clip_widgets.m_value; const int num_widgets=cmd_line->m_num_widgets.m_value; /* create our clip widgets, we will set their z_order values so that: - m_ring_widget is in order of ctor - m_clip_out_widget of each is above all m_ring_widget AND below all elements in m_widgets - m_clip_in_widget is above all m_clip_out_widget So what happens is that when 2 clipwidget intesect their rings are not drawn over the clip inside region of either one. */ for(int i=0; i<num_clip_widgets; ++i) { ClipWidget *N; vec2 pos; float r1, r2; r1=static_cast<float>(rand())/static_cast<float>(RAND_MAX); r2=static_cast<float>(rand())/static_cast<float>(RAND_MAX); pos=vec2( r1*width(), r2*height()); N=WRATHNew ClipWidget(pos, m_shader_hoard, m_layer, m_child_layer, vec4(0.0f, 0.0f, 0.0f, 1.0f)); N->m_ring_widget->z_order(-i); N->m_clip_out_widget->z_order(-i-num_clip_widgets); N->m_clip_in_widget->z_order(-i-2*num_clip_widgets); m_clip_widgets.push_back(N); } load_images(); //make a background widget for m_layer: m_background_widget=make_image_widget(m_layer, m_images[0]); m_background_widget->z_order(1); //below everything in m_layer. //make a background widget for m_child_layer m_background_widget2=make_image_widget(m_child_layer, m_images[1]); m_background_widget2->z_order(-3*num_clip_widgets); //below everything in m_child_layer. for(int i=0, zi=-3*num_clip_widgets-1; i<num_widgets; ++i, --zi) { ImageWidget *widget; WRATHImage *img; img=m_images[rand()%m_images.size()]; widget=make_widget<ImageWidget>(m_child_layer, m_shader_hoard, WRATHDrawType::opaque_pass(), img); widget->translation(vec2(rand()%width(), rand()%height()) ); // widget->rotation( static_cast<float>(rand())/RAND_MAX*M_PI); widget->m_velocity=vec2( (float)rand()/RAND_MAX*190.0f - 95.0f, (float)rand()/RAND_MAX*190.0f - 95.0f); widget->m_inner_radius=rand()%100; widget->m_outer_radius=100 + rand()%100; //make the z-order of widget decrease from -1, //thus layer widgets are drawn on top. widget->z_order(zi); m_widgets.push_back(widget); } glClearColor(1.0, 1.0, 1.0, 1.0); }