void cv::cuda::meanShiftSegmentation(InputArray _src, OutputArray _dst, int sp, int sr, int minsize, TermCriteria criteria) { GpuMat src = _src.getGpuMat(); CV_Assert( src.type() == CV_8UC4 ); const int nrows = src.rows; const int ncols = src.cols; const int hr = sr; const int hsp = sp; // Perform mean shift procedure and obtain region and spatial maps GpuMat d_rmap, d_spmap; cuda::meanShiftProc(src, d_rmap, d_spmap, sp, sr, criteria); Mat rmap(d_rmap); Mat spmap(d_spmap); Graph<SegmLinkVal> g(nrows * ncols, 4 * (nrows - 1) * (ncols - 1) + (nrows - 1) + (ncols - 1)); // Make region adjacent graph from image Vec4b r1; Vec4b r2[4]; Vec2s sp1; Vec2s sp2[4]; int dr[4]; int dsp[4]; for (int y = 0; y < nrows - 1; ++y) { Vec4b* ry = rmap.ptr<Vec4b>(y); Vec4b* ryp = rmap.ptr<Vec4b>(y + 1); Vec2s* spy = spmap.ptr<Vec2s>(y); Vec2s* spyp = spmap.ptr<Vec2s>(y + 1); for (int x = 0; x < ncols - 1; ++x) { r1 = ry[x]; sp1 = spy[x]; r2[0] = ry[x + 1]; r2[1] = ryp[x]; r2[2] = ryp[x + 1]; r2[3] = ryp[x]; sp2[0] = spy[x + 1]; sp2[1] = spyp[x]; sp2[2] = spyp[x + 1]; sp2[3] = spyp[x]; dr[0] = dist2(r1, r2[0]); dr[1] = dist2(r1, r2[1]); dr[2] = dist2(r1, r2[2]); dsp[0] = dist2(sp1, sp2[0]); dsp[1] = dist2(sp1, sp2[1]); dsp[2] = dist2(sp1, sp2[2]); r1 = ry[x + 1]; sp1 = spy[x + 1]; dr[3] = dist2(r1, r2[3]); dsp[3] = dist2(sp1, sp2[3]); g.addEdge(pix(y, x, ncols), pix(y, x + 1, ncols), SegmLinkVal(dr[0], dsp[0])); g.addEdge(pix(y, x, ncols), pix(y + 1, x, ncols), SegmLinkVal(dr[1], dsp[1])); g.addEdge(pix(y, x, ncols), pix(y + 1, x + 1, ncols), SegmLinkVal(dr[2], dsp[2])); g.addEdge(pix(y, x + 1, ncols), pix(y + 1, x, ncols), SegmLinkVal(dr[3], dsp[3])); } } for (int y = 0; y < nrows - 1; ++y) { r1 = rmap.at<Vec4b>(y, ncols - 1); r2[0] = rmap.at<Vec4b>(y + 1, ncols - 1); sp1 = spmap.at<Vec2s>(y, ncols - 1); sp2[0] = spmap.at<Vec2s>(y + 1, ncols - 1); dr[0] = dist2(r1, r2[0]); dsp[0] = dist2(sp1, sp2[0]); g.addEdge(pix(y, ncols - 1, ncols), pix(y + 1, ncols - 1, ncols), SegmLinkVal(dr[0], dsp[0])); } for (int x = 0; x < ncols - 1; ++x) { r1 = rmap.at<Vec4b>(nrows - 1, x); r2[0] = rmap.at<Vec4b>(nrows - 1, x + 1); sp1 = spmap.at<Vec2s>(nrows - 1, x); sp2[0] = spmap.at<Vec2s>(nrows - 1, x + 1); dr[0] = dist2(r1, r2[0]); dsp[0] = dist2(sp1, sp2[0]); g.addEdge(pix(nrows - 1, x, ncols), pix(nrows - 1, x + 1, ncols), SegmLinkVal(dr[0], dsp[0])); } DjSets comps(g.numv); // Find adjacent components for (int v = 0; v < g.numv; ++v) { for (int e_it = g.start[v]; e_it != -1; e_it = g.edges[e_it].next) { int c1 = comps.find(v); int c2 = comps.find(g.edges[e_it].to); if (c1 != c2 && g.edges[e_it].val.dr < hr && g.edges[e_it].val.dsp < hsp) comps.merge(c1, c2); } } std::vector<SegmLink> edges; edges.reserve(g.numv); // Prepare edges connecting differnet components for (int v = 0; v < g.numv; ++v) { int c1 = comps.find(v); for (int e_it = g.start[v]; e_it != -1; e_it = g.edges[e_it].next) { int c2 = comps.find(g.edges[e_it].to); if (c1 != c2) edges.push_back(SegmLink(c1, c2, g.edges[e_it].val)); } } // Sort all graph's edges connecting differnet components (in asceding order) std::sort(edges.begin(), edges.end()); // Exclude small components (starting from the nearest couple) for (size_t i = 0; i < edges.size(); ++i) { int c1 = comps.find(edges[i].from); int c2 = comps.find(edges[i].to); if (c1 != c2 && (comps.size[c1] < minsize || comps.size[c2] < minsize)) comps.merge(c1, c2); } // Compute sum of the pixel's colors which are in the same segment Mat h_src(src); std::vector<Vec4i> sumcols(nrows * ncols, Vec4i(0, 0, 0, 0)); for (int y = 0; y < nrows; ++y) { Vec4b* h_srcy = h_src.ptr<Vec4b>(y); for (int x = 0; x < ncols; ++x) { int parent = comps.find(pix(y, x, ncols)); Vec4b col = h_srcy[x]; Vec4i& sumcol = sumcols[parent]; sumcol[0] += col[0]; sumcol[1] += col[1]; sumcol[2] += col[2]; } } // Create final image, color of each segment is the average color of its pixels _dst.create(src.size(), src.type()); Mat dst = _dst.getMat(); for (int y = 0; y < nrows; ++y) { Vec4b* dsty = dst.ptr<Vec4b>(y); for (int x = 0; x < ncols; ++x) { int parent = comps.find(pix(y, x, ncols)); const Vec4i& sumcol = sumcols[parent]; Vec4b& dstcol = dsty[x]; dstcol[0] = static_cast<uchar>(sumcol[0] / comps.size[parent]); dstcol[1] = static_cast<uchar>(sumcol[1] / comps.size[parent]); dstcol[2] = static_cast<uchar>(sumcol[2] / comps.size[parent]); dstcol[3] = 255; } } }
void Data_analysis_gui::save_as_image( const QString& filename, const QString& format, bool show_stats, bool show_grid ) { // get a file name and the name of the filter to use to save the image. // 3 filters are available: PNG, BMP, and Postscript. Postscript is not // available on Windows (Qt limitation). // Create a blank image of the correct dimensions int extra_width = 15; int min_height = 0; if( show_stats ) { extra_width = 200; min_height = 250; } QSize total_size( plot_->size().width() + extra_width, std::max( min_height, plot_->size().height()+10 ) ); QPixmap pix( total_size ); pix.fill(); QPainter painter( &pix ); // draw the content of the plot QwtPlotPrintFilter filter; if( show_grid ) filter.setOptions( QwtPlotPrintFilter::PrintTitle | QwtPlotPrintFilter::PrintGrid ); else filter.setOptions( QwtPlotPrintFilter::PrintTitle ); QRect rect = plot_->rect(); rect.setY( rect.y() + 10 ); plot_->print( &painter, rect, filter ); // Add the summary statistics to the image if requested if( show_stats ) { QFont font = plot_->axisFont( QwtPlot::xBottom ); painter.setFont( font ); int text_y_start = std::max( 40, total_size.height()/2 - 100 ); painter.translate( plot_->size().width()+15 , text_y_start ); paint_stats( painter ); } // Finally, save the pixmap in the required format if( format == "Postscript" || format == "PS" ) { /* #if defined(WIN32) || defined(_WIN32) if (show_stats) build_stats(); SimplePs ps(filename,plot_, _stats,show_stats); if (!ps.isopen()){ QMessageBox::warning(this,"Unable to save file", "Failed to save ps file",QMessageBox::Ok, Qt::NoButton); return; } savePostScript(ps); #else */ QPrinter printer; printer.setOutputFormat(QPrinter::PostScriptFormat); printer.setOutputFileName( filename ); printer.setPageSize( QPrinter::A6 ); printer.setFullPage( true ); printer.setOrientation( QPrinter::Landscape ); plot_->print(printer, filter); QPainter P(&printer); //P.begin(&printer); //paint_stats(P); P.drawPixmap(QPoint(0,0),pix); //#endif } else { QByteArray tmp = format.toLatin1(); pix.save( filename, tmp.constData() ); } }
int MusicUserRecordWidget::exec() { QPixmap pix(M_BG_MANAGER->getMBackground()); ui->background->setPixmap(pix.scaled( size() )); return MusicAbstractMoveDialog::exec();; }
bool Curve2DWidget::LoadFromCurveSpec(const CPlotItem * curve) { if (!curve) { // We need to reset the widget to defaults mpEditTitle->setText(""); mpObjectX = NULL; mpEditX->setText(""); mpObjectY = NULL; mpEditY->setText(""); mpBoxType->setCurrentIndex(0); mpBoxLineSubType->setCurrentIndex(0); mpBoxColor->clear(); mpCheckBefore->setChecked(false); mpCheckDuring->setChecked(true); mpCheckAfter->setChecked(false); return true; } if (curve->getType() != CPlotItem::curve2d) return false; //if (curve->getChannels().getSize != 2) return false; mpEditTitle->setText(FROM_UTF8(curve->getTitle())); //TODO: check if objects exist.... CCopasiDataModel* pDataModel = mpModel->getObjectDataModel(); assert(pDataModel != NULL); mpObjectX = mpObjectY = NULL; if (curve->getChannels().size() >= 1) mpObjectX = CObjectInterface::DataObject(pDataModel->getObjectFromCN(curve->getChannels()[0])); if (curve->getChannels().size() >= 2) mpObjectY = CObjectInterface::DataObject(pDataModel->getObjectFromCN(curve->getChannels()[1])); if (mpObjectX) mpEditX->setText(FROM_UTF8(mpObjectX->getObjectDisplayName())); else mpEditX->clear(); if (mpObjectY) mpEditY->setText(FROM_UTF8(mpObjectY->getObjectDisplayName())); else mpEditY->clear(); //Type unsigned C_INT32 linetype = curve->getValue< unsigned C_INT32 >("Line type"); mpBoxType->setCurrentIndex(linetype); typeChanged(linetype); //line subtype & width if (linetype == 0 || linetype == 3) { mpBoxLineSubType->setCurrentIndex(curve->getValue< unsigned C_INT32 >("Line subtype")); //mpBoxWidth mpSpinBoxWidth->setValue(curve->getValue< C_FLOAT64 >("Line width")); } // points if (linetype == 1) { mpSpinBoxWidth->setValue(curve->getValue< C_FLOAT64 >("Line width")); } //symbol type if (linetype == 2 || linetype == 3) { mpBoxSymbolSubType->setCurrentIndex(curve->getValue< unsigned C_INT32 >("Symbol subtype")); } //color TODO mpBoxColor->clear(); mpBoxColor->addItem("auto"); size_t i; for (i = 0; i < CQPlotColors::getNumCopasiColors(); ++i) { QColor color = CQPlotColors::getColor("auto", i); QPixmap pix(12, 12); QPainter painter(&pix); if (color.isValid()) { painter.setPen(Qt::gray); painter.setBrush(QBrush(color)); painter.drawRect(0, 0, 12, 12); } QIcon icon; icon.addPixmap(pix); mpBoxColor->addItem(icon, CQPlotColors::getCopasiColorStr(i).c_str()); } std::string colorstr = curve->getValue< std::string >("Color"); int tmpindex; if ((tmpindex = mpBoxColor->findText(colorstr.c_str())) != -1) mpBoxColor->setCurrentIndex(tmpindex); else { QColor color = QColor(colorstr.c_str()); QPixmap pix(12, 12); QPainter painter(&pix); if (color.isValid()) { painter.setPen(Qt::gray); painter.setBrush(QBrush(color)); painter.drawRect(0, 0, 12, 12); } QIcon icon; icon.addPixmap(pix); mpBoxColor->addItem(icon, colorstr.c_str()); mpBoxColor->setCurrentIndex(mpBoxColor->count() - 1); } //channel mpCheckBefore->setChecked(curve->getActivity() & COutputInterface::BEFORE); mpCheckDuring->setChecked(curve->getActivity() & COutputInterface::DURING); mpCheckAfter->setChecked(curve->getActivity() & COutputInterface::AFTER); return true; //TODO }
KPrTransEffectDia::KPrTransEffectDia( QWidget *parent, const char *name, KPrDocument *_doc, KPrView *_view ) : KDialogBase( parent, name, true, "", KDialogBase::User1|Ok|Cancel ), doc( _doc ), view( _view ), soundPlayer( 0 ) { enableButtonSeparator( true ); QWidget *page = new QWidget( this ); setMainWidget(page); QBoxLayout *topLayout = new QHBoxLayout( page, KDialog::marginHint(), KDialog::spacingHint() ); QWidget* leftpart = new QWidget( page ); topLayout->addWidget( leftpart ); QWidget* rightpart = new QWidget( page ); topLayout->addWidget( rightpart ); // right-side of the dialog, for showing effect preview QVBoxLayout *rightlayout = new QVBoxLayout( rightpart, KDialog::marginHint(), KDialog::spacingHint() ); rightlayout->setAutoAdd( true ); effectPreview = new KPrEffectPreview( rightpart, doc, view ); int pgnum = view->getCurrPgNum() - 1; // getCurrPgNum() is 1-based KPrPage* pg = doc->pageList().at( pgnum ); // pixmap for effect preview QRect rect= pg->getZoomPageRect(); QPixmap pix( rect.size() ); pix.fill( Qt::white ); view->getCanvas()->drawPageInPix( pix, pgnum, 100 ); effectPreview->setPixmap( pix ); pageEffect = pg->getPageEffect(); speed = pg->getPageEffectSpeed(); QVBoxLayout *leftlayout = new QVBoxLayout( leftpart, KDialog::marginHint(), KDialog::spacingHint() ); leftlayout->setAutoAdd( true ); new QLabel( i18n("Effect:"), leftpart ); effectList = new QListBox( leftpart ); effectList->insertItem( i18n( "No Effect" ) ); effectList->insertItem( i18n( "Close Horizontal" ) ); effectList->insertItem( i18n( "Close Vertical" ) ); effectList->insertItem( i18n( "Close From All Directions" ) ); effectList->insertItem( i18n( "Open Horizontal" ) ); effectList->insertItem( i18n( "Open Vertical" ) ); effectList->insertItem( i18n( "Open From All Directions" ) ); effectList->insertItem( i18n( "Interlocking Horizontal 1" ) ); effectList->insertItem( i18n( "Interlocking Horizontal 2" ) ); effectList->insertItem( i18n( "Interlocking Vertical 1" ) ); effectList->insertItem( i18n( "Interlocking Vertical 2" ) ); effectList->insertItem( i18n( "Surround 1" ) ); effectList->insertItem( i18n( "Fly Away 1" ) ); effectList->insertItem( i18n( "Blinds Horizontal" ) ); effectList->insertItem( i18n( "Blinds Vertical" ) ); effectList->insertItem( i18n( "Box In" ) ); effectList->insertItem( i18n( "Box Out" ) ); effectList->insertItem( i18n( "Checkerboard Across" ) ); effectList->insertItem( i18n( "Checkerboard Down" ) ); effectList->insertItem( i18n( "Cover Down" ) ); effectList->insertItem( i18n( "Uncover Down" ) ); effectList->insertItem( i18n( "Cover Up" ) ); effectList->insertItem( i18n( "Uncover Up" ) ); effectList->insertItem( i18n( "Cover Left" ) ); effectList->insertItem( i18n( "Uncover Left" ) ); effectList->insertItem( i18n( "Cover Right" ) ); effectList->insertItem( i18n( "Uncover Right" ) ); effectList->insertItem( i18n( "Cover Left-Up" ) ); effectList->insertItem( i18n( "Uncover Left-Up" ) ); effectList->insertItem( i18n( "Cover Left-Down" ) ); effectList->insertItem( i18n( "Uncover Left-Down" ) ); effectList->insertItem( i18n( "Cover Right-Up" ) ); effectList->insertItem( i18n( "Uncover Right-Up" ) ); effectList->insertItem( i18n( "Cover Right-Bottom" ) ); effectList->insertItem( i18n( "Uncover Right-Bottom" ) ); effectList->insertItem( i18n( "Dissolve" ) ); effectList->insertItem( i18n( "Strips Left-Up" ) ); effectList->insertItem( i18n( "Strips Left-Down" ) ); effectList->insertItem( i18n( "Strips Right-Up" ) ); effectList->insertItem( i18n( "Strips Right-Down" ) ); effectList->insertItem( i18n( "Melting" ) ); effectList->insertItem( i18n( "Random Transition" ) ); effectList->setCurrentItem( static_cast<int>( pageEffect ) ); // workaround, because Random Effect is always negative if( pageEffect == PEF_RANDOM ) effectList->setCurrentItem( effectList->count()-1 ); connect( effectList, SIGNAL(highlighted(int)), this, SLOT(effectChanged(int)) ); connect( effectList, SIGNAL( doubleClicked ( QListBoxItem *) ), this, SLOT( effectChanged()) ); new QLabel( i18n("Speed:"), leftpart ); QWidget* sp = new QWidget( leftpart ); QBoxLayout* speedLayout = new QHBoxLayout( sp, KDialog::marginHint(), KDialog::spacingHint() ); speedLayout->setAutoAdd( true ); speedCombo = new QComboBox( sp ); speedCombo->insertItem(i18n("Slow") ); speedCombo->insertItem(i18n("Medium") ); speedCombo->insertItem(i18n("Fast") ); speedCombo->setCurrentItem( speed ); connect( speedCombo, SIGNAL(activated(int)), this, SLOT(speedChanged(int)) ); QWidget* previewgrp = new QWidget( leftpart ); QBoxLayout* previewLayout = new QHBoxLayout( previewgrp, KDialog::marginHint(), KDialog::spacingHint() ); previewLayout->setAutoAdd( true ); automaticPreview = new QCheckBox( i18n( "Automatic preview" ), previewgrp ); automaticPreview->setChecked( true ); QWidget* previewspacer = new QWidget( previewgrp ); previewspacer->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); previewButton = new QPushButton( previewgrp ); previewButton->setText( i18n("Preview") ); connect( previewButton, SIGNAL(clicked()), this, SLOT(preview()) ); QFrame* line = new QFrame( leftpart ); line->setFrameStyle( QFrame::HLine | QFrame::Sunken ); soundFileName = pg->getPageSoundFileName(); soundEffect = pg->getPageSoundEffect(); checkSoundEffect = new QCheckBox( i18n( "Sound effect" ), leftpart ); checkSoundEffect->setChecked( soundEffect ); connect( checkSoundEffect, SIGNAL( clicked() ), this, SLOT( soundEffectChanged() ) ); QWidget* soundgrp = new QWidget( leftpart ); QBoxLayout* soundLayout = new QHBoxLayout( soundgrp, KDialog::marginHint(), KDialog::spacingHint() ); soundLayout->setAutoAdd( true ); lSoundEffect = new QLabel( i18n( "File name:" ), soundgrp ); requester = new KURLRequester( soundgrp ); requester->setURL( soundFileName ); connect( requester, SIGNAL( openFileDialog( KURLRequester * ) ), this, SLOT( slotRequesterClicked( KURLRequester * ) ) ); connect( requester, SIGNAL( textChanged( const QString& ) ), this, SLOT( slotSoundFileChanged( const QString& ) ) ); buttonTestPlaySoundEffect = new QPushButton( soundgrp ); buttonTestPlaySoundEffect->setPixmap( BarIcon("1rightarrow", KIcon::SizeSmall) ); QToolTip::add( buttonTestPlaySoundEffect, i18n("Play") ); connect( buttonTestPlaySoundEffect, SIGNAL( clicked() ), this, SLOT( playSound() ) ); buttonTestStopSoundEffect = new QPushButton( soundgrp ); buttonTestStopSoundEffect->setPixmap( BarIcon("player_stop", KIcon::SizeSmall) ); QToolTip::add( buttonTestStopSoundEffect, i18n("Stop") ); connect( buttonTestStopSoundEffect, SIGNAL( clicked() ), this, SLOT( stopSound() ) ); soundEffect = pg->getPageSoundEffect(); setButtonText(KDialogBase::User1,i18n( "Apply &Global" )); slideTime = pg->getPageTimer(); new QLabel( i18n("Automatically advance to the next slide after:"), rightpart ); timeSlider = new KIntNumInput( slideTime, rightpart ); timeSlider->setRange( 1, 600, 1 ); timeSlider->setSuffix( i18n( " seconds" ) ); connect( timeSlider, SIGNAL(valueChanged(int)), this, SLOT(timeChanged(int)) ); QWidget* rspacer = new QWidget( rightpart ); rspacer->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); QWidget* lspacer = new QWidget( leftpart ); lspacer->setMinimumSize( 10, spacingHint() ); soundEffectChanged(); }
void* blurfilter_y(void* t_param){ struct thread_data_blurfilter* thread_data = (thread_data_blurfilter*)t_param; const int xsize = thread_data->xsize; const int ysize = thread_data->ysize; pixel* src = thread_data->src; pixel* dst = thread_data->dst; const int radius = thread_data->radius; const double* w = thread_data->w; const int y_start = thread_data->y_start; const int y_end = thread_data->y_end; int x,y,y2, wi; double r,g,b,n, wc; for (y=y_start; y<y_end; y++) { for (x=0; x<xsize; x++) { r = w[0] * pix(dst, x, y, xsize)->r; g = w[0] * pix(dst, x, y, xsize)->g; b = w[0] * pix(dst, x, y, xsize)->b; n = w[0]; for ( wi=1; wi <= radius; wi++) { wc = w[wi]; y2 = y - wi; if(y2 >= 0) { r += wc * pix(dst, x, y2, xsize)->r; g += wc * pix(dst, x, y2, xsize)->g; b += wc * pix(dst, x, y2, xsize)->b; n += wc; } y2 = y + wi; if(y2 < ysize) { r += wc * pix(dst, x, y2, xsize)->r; g += wc * pix(dst, x, y2, xsize)->g; b += wc * pix(dst, x, y2, xsize)->b; n += wc; } } pix(src,x,y, xsize)->r = r/n; pix(src,x,y, xsize)->g = g/n; pix(src,x,y, xsize)->b = b/n; } } //for(y=y_start; y<y_end; y++) // printf("%d", pix(src, xsize-1, y, xsize)->r); pthread_exit(0); }
/** Loads the settings for this page */ void ChatPage::load() { Settings->beginGroup(QString("Chat")); whileBlocking(ui.checkBox_emoteprivchat)->setChecked(Settings->value("Emoteicons_PrivatChat", true).toBool()); whileBlocking(ui.checkBox_emotegroupchat)->setChecked(Settings->value("Emoteicons_GroupChat", true).toBool()); whileBlocking(ui.checkBox_enableCustomFonts)->setChecked(Settings->value("EnableCustomFonts", true).toBool()); whileBlocking(ui.checkBox_enableCustomFontSize)->setChecked(Settings->value("EnableCustomFontSize", true).toBool()); whileBlocking(ui.minimumFontSize)->setValue(Settings->value("MinimumFontSize", 10).toInt()); whileBlocking(ui.checkBox_enableBold)->setChecked(Settings->value("EnableBold", true).toBool()); whileBlocking(ui.checkBox_enableItalics)->setChecked(Settings->value("EnableItalics", true).toBool()); whileBlocking(ui.minimumContrast)->setValue(Settings->value("MinimumContrast", 4.5).toDouble()); Settings->endGroup(); // state of distant Chat combobox int index = Settings->value("DistantChat", 0).toInt(); whileBlocking(ui.distantChatComboBox)->setCurrentIndex(index); fontTempChat.fromString(Settings->getChatScreenFont()); whileBlocking(ui.sendMessageWithCtrlReturn)->setChecked(Settings->getChatSendMessageWithCtrlReturn()); whileBlocking(ui.sendAsPlainTextByDef)->setChecked(Settings->getChatSendAsPlainTextByDef()); whileBlocking(ui.loadEmbeddedImages)->setChecked(Settings->getChatLoadEmbeddedImages()); whileBlocking(ui.DontSendTyping)->setChecked(Settings->getChatDoNotSendIsTyping()); std::string advsetting; if(rsConfig->getConfigurationOption(RS_CONFIG_ADVANCED, advsetting) && (advsetting == "YES")) { } else ui.DontSendTyping->hide(); whileBlocking(ui.sbSearch_CharToStart)->setValue(Settings->getChatSearchCharToStartSearch()); whileBlocking(ui.cbSearch_CaseSensitively)->setChecked(Settings->getChatSearchCaseSensitively()); whileBlocking(ui.cbSearch_WholeWords)->setChecked(Settings->getChatSearchWholeWords()); whileBlocking(ui.cbSearch_MoveToCursor)->setChecked(Settings->getChatSearchMoveToCursor()); whileBlocking(ui.cbSearch_WithoutLimit)->setChecked(Settings->getChatSearchSearchWithoutLimit()); whileBlocking(ui.sbSearch_MaxLimitColor)->setValue(Settings->getChatSearchMaxSearchLimitColor()); rgbChatSearchFoundColor=Settings->getChatSearchFoundColor(); QPixmap pix(24, 24); pix.fill(rgbChatSearchFoundColor); ui.btSearch_FoundColor->setIcon(pix); whileBlocking(ui.publicChatLoadCount)->setValue(Settings->getPublicChatHistoryCount()); whileBlocking(ui.privateChatLoadCount)->setValue(Settings->getPrivateChatHistoryCount()); whileBlocking(ui.lobbyChatLoadCount)->setValue(Settings->getLobbyChatHistoryCount()); whileBlocking(ui.publicChatEnable)->setChecked(rsHistory->getEnable(RS_HISTORY_TYPE_PUBLIC)); whileBlocking(ui.privateChatEnable)->setChecked(rsHistory->getEnable(RS_HISTORY_TYPE_PRIVATE)); whileBlocking(ui.lobbyChatEnable)->setChecked(rsHistory->getEnable(RS_HISTORY_TYPE_LOBBY)); whileBlocking(ui.publicChatSaveCount)->setValue(rsHistory->getSaveCount(RS_HISTORY_TYPE_PUBLIC)); whileBlocking(ui.privateChatSaveCount)->setValue(rsHistory->getSaveCount(RS_HISTORY_TYPE_PRIVATE)); whileBlocking(ui.lobbyChatSaveCount)->setValue(rsHistory->getSaveCount(RS_HISTORY_TYPE_LOBBY)); // using fontTempChat.rawname() does not always work! // see http://doc.qt.digia.com/qt-maemo/qfont.html#rawName QStringList fontname = fontTempChat.toString().split(","); whileBlocking(ui.labelChatFontPreview)->setText(fontname[0]); whileBlocking(ui.labelChatFontPreview)->setFont(fontTempChat); whileBlocking(ui.max_storage_period)->setValue(rsHistory->getMaxStorageDuration()/86400) ; /* Load styles */ publicStylePath = loadStyleInfo(ChatStyle::TYPE_PUBLIC, ui.publicStyle, ui.publicComboBoxVariant, publicStyleVariant); privateStylePath = loadStyleInfo(ChatStyle::TYPE_PRIVATE, ui.privateStyle, ui.privateComboBoxVariant, privateStyleVariant); historyStylePath = loadStyleInfo(ChatStyle::TYPE_HISTORY, ui.historyStyle, ui.historyComboBoxVariant, historyStyleVariant); RsGxsId gxs_id ; rsMsgs->getDefaultIdentityForChatLobby(gxs_id) ; ui.chatLobbyIdentity_IC->setFlags(IDCHOOSER_ID_REQUIRED) ; if(!gxs_id.isNull()) ui.chatLobbyIdentity_IC->setChosenId(gxs_id); uint chatflags = Settings->getChatFlags(); whileBlocking(ui.chat_NewWindow)->setChecked(chatflags & RS_CHAT_OPEN); whileBlocking(ui.chat_Focus)->setChecked(chatflags & RS_CHAT_FOCUS); whileBlocking(ui.chat_tabbedWindow)->setChecked(chatflags & RS_CHAT_TABBED_WINDOW); whileBlocking(ui.chat_Blink)->setChecked(chatflags & RS_CHAT_BLINK); uint chatLobbyFlags = Settings->getChatLobbyFlags(); whileBlocking(ui.chatLobby_Blink)->setChecked(chatLobbyFlags & RS_CHATLOBBY_BLINK); // load personal invites // #ifdef TO_BE_DONE for(;;) { QListWidgetItem *item = new QListWidgetItem; item->setData(Qt::DisplayRole,tr("Private chat invite from")+" "+QString::fromUtf8(detail.name.c_str())) ; QString tt ; tt += tr("Name :")+" " + QString::fromUtf8(detail.name.c_str()) ; tt += "\n" + tr("PGP id :")+" " + QString::fromStdString(invites[i].destination_pgp_id.toStdString()) ; tt += "\n" + tr("Valid until :")+" " + QDateTime::fromTime_t(invites[i].time_of_validity).toString() ; item->setData(Qt::UserRole,QString::fromStdString(invites[i].pid.toStdString())) ; item->setToolTip(tt) ; ui._collected_contacts_LW->insertItem(0,item) ; } #endif }
/** Overloads default QWidget::paintEvent. Draws the actual * bandwidth graph. */ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) { //std::cerr << "In paint event!" << std::endl; int S = QFontMetricsF(font()).height(); /* Set current graph dimensions */ _rec = this->frameRect(); /* Start the painter */ _painter->begin(this); /* We want antialiased lines and text */ _painter->setRenderHint(QPainter::Antialiasing); _painter->setRenderHint(QPainter::TextAntialiasing); /* Fill in the background */ _painter->fillRect(_rec, QBrush(BACK_COLOR)); _painter->drawRect(_rec); // draw one line per friend. std::list<RsPeerId> ssllist ; rsPeers->getFriendList(ssllist) ; // sort list { // sort out offline peers if(mHideOffline) { RsPeerDetails peerDetails; for(std::list<RsPeerId>::iterator it = ssllist.begin(); it != ssllist.end();) { rsPeers->getPeerDetails(*it, peerDetails); switch (peerDetails.connectState) { case RS_PEER_CONNECTSTATE_OFFLINE: case RS_PEER_CONNECTSTATE_TRYING_TCP: case RS_PEER_CONNECTSTATE_TRYING_UDP: it = ssllist.erase(it); break; default: it++; break; } } } // sort by name ssllist.sort(sortRsPeerIdByNameLocation); } RsPeerServiceInfo ownServices; rsServiceControl->getOwnServices(ownServices); // Display friend names at the beginning of each column const QFont& font(_painter->font()) ; QFontMetrics fm(font); int peer_name_size = 0 ; float line_height = 2 + fm.height() ; std::vector<QString> names ; for(std::list<RsPeerId>::const_iterator it(ssllist.begin());it!=ssllist.end();++it) { RsPeerDetails details ; rsPeers->getPeerDetails(*it,details) ; QString name = QString::fromUtf8(details.name.c_str()) + " (" + QString::fromUtf8(details.location.c_str()) + ")"; if(name.length() > 20) name = name.left(20)+"..." ; peer_name_size = std::max(peer_name_size, fm.width(name)) ; names.push_back(name) ; } QPen pen ; pen.setWidth(2) ; pen.setBrush(Qt::black) ; _painter->setPen(pen) ; int i=0; //int x=5/14.0*S ; int y=S*fMATRIX_START_Y ; for(std::list<RsPeerId>::const_iterator it(ssllist.begin());it!=ssllist.end();++it,++i) { float X = S*fMATRIX_START_X + peer_name_size - fm.width(names[i]) ; float Y = S*fMATRIX_START_Y + (i+0.5)*S*fROW_SIZE + line_height/2.0f-2 ; _painter->drawText(QPointF(X,Y),names[i]) ; if(*it == _current_peer_id) _painter->drawLine(QPointF(X,Y+3),QPointF(X+fm.width(names[i]),Y+3)) ; y += line_height ; } matrix_start_x = S*5/14.0 + S*fMATRIX_START_X + peer_name_size ; // now draw the service names i=0 ; std::vector<int> last_width(10,0) ; for(std::map<uint32_t, RsServiceInfo>::const_iterator it(ownServices.mServiceList.begin());it!=ownServices.mServiceList.end();++it,++i) { QString name = QString::fromUtf8(it->second.mServiceName.c_str()) ; int text_width = fm.width(name) ; int X = matrix_start_x + S*fCOL_SIZE/2 - 2 + i*S*fCOL_SIZE - text_width/2; int height_index = 0 ; while(last_width[height_index] > X-5 && height_index < ((int)last_width.size()-1) ) ++height_index ; int Y = S*fMATRIX_START_Y - S*fICON_SIZE_Y - 2 - line_height * height_index; last_width[height_index] = X + text_width ; // draw a half-transparent rectangle QBrush brush ; brush.setColor(QColor::fromHsvF(0.0f,0.0f,1.0f,0.8f)); brush.setStyle(Qt::SolidPattern) ; QPen pen ; pen.setWidth(2) ; if(_current_service_id == it->second.mServiceType) pen.setBrush(Qt::black) ; else pen.setBrush(Qt::gray) ; _painter->setPen(pen) ; QRect info_pos( X-5,Y-line_height-2, text_width + 10, line_height + 5) ; //_painter->fillRect(info_pos,brush) ; //_painter->drawRect(info_pos) ; _painter->drawLine(QPointF(X,Y+3),QPointF(X+text_width,Y+3)) ; _painter->drawLine(QPointF(X+text_width/2, Y+3), QPointF(X+text_width/2,S*fMATRIX_START_Y+peer_ids.size()*S*fROW_SIZE - S*fROW_SIZE+5)) ; pen.setBrush(Qt::black) ; _painter->setPen(pen) ; _painter->drawText(QPointF(X,Y),name); } // Now draw the global switches. peer_ids.clear() ; for(std::list<RsPeerId>::const_iterator it(ssllist.begin());it!=ssllist.end();++it) peer_ids.push_back(*it) ; service_ids.clear() ; for(std::map<uint32_t, RsServiceInfo>::const_iterator sit(ownServices.mServiceList.begin());sit!=ownServices.mServiceList.end();++sit) service_ids.push_back(sit->first) ; static const std::string global_switch[2] = { ":/icons/global_switch_off_128.png", ":/icons/global_switch_on_128.png" } ; for(uint32_t i=0;i<service_ids.size();++i) { RsServicePermissions serv_perm ; rsServiceControl->getServicePermissions(service_ids[i],serv_perm) ; QPixmap pix(global_switch[serv_perm.mDefaultAllowed].c_str()) ; QRect position = computeNodePosition(0,i,false) ; position.setY(position.y() - S*fICON_SIZE_Y + 8/14.0*S) ; position.setX(position.x() + 3/14.0*S) ; position.setHeight(30/14.0*S) ; position.setWidth(30/14.0*S) ; _painter->drawPixmap(position,pix.scaledToHeight(S*fICON_SIZE_Y*0.9,Qt::SmoothTransformation),QRect(0,0,S*fICON_SIZE_X,S*fICON_SIZE_Y)) ; } // We draw for each service. static const std::string pixmap_names[4] = { ":/icons/switch00_128.png", ":/icons/switch01_128.png", ":/icons/switch10_128.png", ":/icons/switch11_128.png" } ; int n_col = 0 ; int n_col_selected = -1 ; int n_row_selected = -1 ; for(std::map<uint32_t, RsServiceInfo>::const_iterator sit(ownServices.mServiceList.begin());sit!=ownServices.mServiceList.end();++sit,++n_col) { RsServicePermissions service_perms ; rsServiceControl->getServicePermissions(sit->first,service_perms) ; // draw the default switch. // draw one switch per friend. int n_row = 0 ; for(std::list<RsPeerId>::const_iterator it(ssllist.begin());it!=ssllist.end();++it,++n_row) { RsPeerServiceInfo local_service_perms ; RsPeerServiceInfo remote_service_perms ; rsServiceControl->getServicesAllowed (*it, local_service_perms) ; rsServiceControl->getServicesProvided(*it,remote_service_perms) ; bool local_allowed = local_service_perms.mServiceList.find(sit->first) != local_service_perms.mServiceList.end() ; bool remote_allowed = remote_service_perms.mServiceList.find(sit->first) != remote_service_perms.mServiceList.end() ; QPixmap pix(pixmap_names[(local_allowed << 1) + remote_allowed].c_str()) ; bool selected = (sit->first == _current_service_id && *it == _current_peer_id) ; QRect position = computeNodePosition(n_row,n_col,selected) ; if(selected) { n_row_selected = n_row ; n_col_selected = n_col ; } _painter->drawPixmap(position,pix.scaledToHeight(S*fICON_SIZE_X,Qt::SmoothTransformation),QRect(0,0,S*fICON_SIZE_X,S*fICON_SIZE_Y)) ; } } // now display some info about current node. if(n_row_selected >= 0 && n_col_selected >= 0 && n_row_selected < (int)peer_ids.size() && n_col_selected < (int)service_ids.size()) { QRect position = computeNodePosition(n_row_selected,n_col_selected,false) ; // draw text info RsServicePermissions service_perms ; rsServiceControl->getServicePermissions(service_ids[n_col_selected],service_perms) ; QString service_name = tr("Service name:")+" "+QString::fromUtf8(service_perms.mServiceName.c_str()) ; QString service_default = service_perms.mDefaultAllowed?tr("Allowed by default"):tr("Denied by default"); QString peer_name = tr("Peer name:")+" " + names[n_row_selected] ; QString peer_id = tr("Peer Id:")+" "+QString::fromStdString(_current_peer_id.toStdString()) ; RsPeerServiceInfo pserv_info ; rsServiceControl->getServicesAllowed(_current_peer_id,pserv_info) ; bool locally_allowed = pserv_info.mServiceList.find(_current_service_id) != pserv_info.mServiceList.end(); bool remotely_allowed = false ; // default, if the peer is offline if(rsServiceControl->getServicesProvided(_current_peer_id,pserv_info)) remotely_allowed = pserv_info.mServiceList.find(_current_service_id) != pserv_info.mServiceList.end(); QString local_status = locally_allowed ?tr("Enabled for this peer") :tr("Disabled for this peer") ; QString remote_status = remotely_allowed?tr("Enabled by remote peer"):tr("Disabled by remote peer") ; if(!service_perms.mDefaultAllowed) local_status = tr("Globally switched Off") ; const QFont& font(_painter->font()) ; QFontMetrics fm(font); int text_size_x = 0 ; text_size_x = std::max(text_size_x,fm.width(service_name)); text_size_x = std::max(text_size_x,fm.width(peer_name)); text_size_x = std::max(text_size_x,fm.width(peer_id)); text_size_x = std::max(text_size_x,fm.width(local_status)); text_size_x = std::max(text_size_x,fm.width(remote_status)); // draw a half-transparent rectangle QBrush brush ; brush.setColor(QColor::fromHsvF(0.0f,0.0f,1.0f,0.8f)); brush.setStyle(Qt::SolidPattern) ; QPen pen ; pen.setWidth(2) ; pen.setBrush(Qt::black) ; _painter->setPen(pen) ; QRect info_pos( position.x() + 50*S/14.0, position.y() - 10*S/14.0, text_size_x + 10*S/14.0, line_height * 5 + 5*S/14.0) ; _painter->fillRect(info_pos,brush) ; _painter->drawRect(info_pos) ; // draw the text float x = info_pos.x() + 5*S/14.0 ; float y = info_pos.y() + line_height + 1*S/14.0 ; _painter->drawText(QPointF(x,y), service_name) ; y += line_height ; _painter->drawText(QPointF(x,y), peer_name) ; y += line_height ; _painter->drawText(QPointF(x,y), peer_id) ; y += line_height ; _painter->drawText(QPointF(x,y), remote_status) ; y += line_height ; _painter->drawText(QPointF(x,y), local_status) ; y += line_height ; } _max_height = S*fMATRIX_START_Y + (peer_ids.size()+3) * S*fROW_SIZE ; _max_width = matrix_start_x + (service_ids.size()+3) * S*fCOL_SIZE ; /* Stop the painter */ _painter->end(); }
void MeasureSingleShear( const std::vector<PixelList>& allpix, const std::vector<BVec>& psf, int& galorder, const ConfigFile& params, ShearLog& log, BVec& shapelet, std::complex<double>& gamma, DSmallMatrix22& cov, double& nu, long& flag) { double gal_aperture = params.read("shear_aperture",3.); double max_aperture = params.read("shear_max_aperture",0.); // Initial value, but also returned with actual final value. int galorder_init = params.read("shear_gal_order",6); galorder = galorder_init; int galorder2 = params.read("shear_gal_order2",20); int maxm = params.read("shear_maxm",galorder); int min_galorder = params.read("shear_min_gal_order",4); double min_fpsf = params.read("shear_f_psf",1.); double max_fpsf = params.read("shear_max_f_psf",min_fpsf); double min_galsize = params.read("shear_min_gal_size",0.); bool fixcen = params.read("shear_fix_centroid",false); bool fixsigma = params.keyExists("shear_force_sigma"); double fixsigma_value = params.read("shear_force_sigma",0.); bool use_fake_pixels = params.read("shear_use_fake_pixels",false); double shear_inner_fake_aperture = params.read("shear_inner_fake_aperture",gal_aperture); double shear_outer_fake_aperture = params.read("shear_outer_fake_aperture",1.e100); double inner_fake_ap = 0.; double outer_fake_ap = 0.; try { dbg<<"Start MeasureSingleShear\n"; dbg<<"allpix.size = "<<allpix.size()<<std::endl; const int nexp = allpix.size(); for(int i=0;i<nexp;++i) dbg<<"allpix["<<i<<"].size = "<<allpix[i].size()<<std::endl; dbg<<"psf.size = "<<psf.size()<<std::endl; Assert(psf.size() == allpix.size()); // Find harmonic mean of psf sizes: // MJ: Is it better to use the harmonic mean of sigma or sigma^2? // (Or something else entirely?) double sigma_p = 0.; const int npsf = psf.size(); Assert(npsf > 0); for(int i=0;i<npsf;++i) { sigma_p += 1./psf[i].getSigma(); dbg<<"psf["<<i<<"] sigma = "<<psf[i].getSigma()<<std::endl; } sigma_p = double(npsf) / sigma_p; dbg<<"Harmonic mean = "<<sigma_p<<std::endl; long flag1=0; std::complex<double> cen_offset = 0.; // // Define initial sigma and aperture. // We start with a native fit using sigma = 2*sigma_p: // Or if we are fixed, then sigma_obs^2 = sigma_p^2 + sigma^2 // double sigma = fixsigma_value; double sigpsq = pow(sigma_p,2); double sigma_obs = fixsigma ? sqrt(sigpsq + sigma*sigma) : 2.*sigma_p; double galap = gal_aperture * sigma_obs; dbg<<"galap = "<<gal_aperture<<" * "<<sigma_obs<<" = "<<galap<<std::endl; if (max_aperture > 0. && galap > max_aperture) { galap = max_aperture; dbg<<" => "<<galap<<std::endl; } dbg<<"sigma_obs = "<<sigma_obs<<", sigma_p = "<<sigma_p<<std::endl; // // Load pixels from main PixelLists. // std::vector<PixelList> pix(nexp); int npix = 0; for(int i=0;i<nexp;++i) { if (use_fake_pixels) { inner_fake_ap = shear_inner_fake_aperture * sigma_obs; outer_fake_ap = shear_outer_fake_aperture * sigma_obs; } GetSubPixList(pix[i],allpix[i],cen_offset,0.,galap, inner_fake_ap,outer_fake_ap,params,flag1); npix += pix[i].size(); } dbg<<"npix = "<<npix<<std::endl; if (npix < 10) { dbg<<"Too few pixels to continue: "<<npix<<std::endl; dbg<<"FLAG LT10PIX\n"; flag |= LT10PIX; dbg<<"FLAG SHAPELET_NOT_DECONV\n"; flag |= SHAPELET_NOT_DECONV; return; } // // Do a crude measurement based on simple pixel sums. // TODO: If we have single-epoch measurements, use those for the // starting guess rather than crudeMeasure. // Ellipse ell_init; if (fixcen) ell_init.fixCen(); if (fixsigma) ell_init.fixMu(); ell_init.fixGam(); if (!fixcen || !fixsigma) { ell_init.crudeMeasure(pix[0],sigma_obs); xdbg<<"Crude Measure: centroid = "<<ell_init.getCen()<< ", mu = "<<ell_init.getMu()<<std::endl; sigma_obs *= exp(ell_init.getMu()); ell_init.setMu(0.); } // // Correct the centroid first. // Ellipse ell_native = ell_init; if (fixcen) ell_native.fixCen(); ell_native.fixMu(); ell_native.fixGam(); if (!fixcen) { flag1 = 0; if (!ell_native.measure(pix,2,2,2,sigma_obs,flag1,0.1)) { ++log._nf_centroid; dbg<<"First centroid pass failed.\n"; flag |= flag1; dbg<<"FLAG CENTROID_FAILED\n"; flag |= CENTROID_FAILED; dbg<<"FLAG SHAPELET_NOT_DECONV\n"; flag |= SHAPELET_NOT_DECONV; return; } dbg<<"After first centroid pass: cen = "<<ell_native.getCen()<<std::endl; // redo the pixlist: cen_offset += ell_native.getCen(); ell_native.setCen(0.); dbg<<"New center = "<<cen_offset<<std::endl; npix = 0; for(int i=0;i<nexp;++i) { if (use_fake_pixels) { inner_fake_ap = shear_inner_fake_aperture * sigma_obs; outer_fake_ap = shear_outer_fake_aperture * sigma_obs; } GetSubPixList(pix[i],allpix[i],cen_offset,0.,galap, inner_fake_ap,outer_fake_ap,params,flag1); npix += pix[i].size(); } if (npix < 10) { dbg<<"Too few pixels to continue: "<<npix<<std::endl; dbg<<"FLAG LT10PIX\n"; flag |= LT10PIX; dbg<<"FLAG SHAPELET_NOT_DECONV\n"; flag |= SHAPELET_NOT_DECONV; return; } // The centroid doesn't necessarily get all the way to the perfect // centroid, so if the input guess is consistently biased in some // direction (e.g. by a different convention for the (0,0) or (1,1) // location), then this results in a bias in the shear values. // To avoid that, we first get to what we think it the correct centroid. // Then we redo the aperture from this point. Then we shift the // centroid value by 0.1 arcsec in a random direction, and resolve for // the centroid. This is all pretty fast, so it's worth doing to // avoid the subtle bias that can otherwise result. // get an offset of 0.1 arcsec in a random direction. double x_offset, y_offset, rsq_offset; do { x_offset = double(rand())*2./double(RAND_MAX) - 1.; y_offset = double(rand())*2./double(RAND_MAX) - 1.; rsq_offset = x_offset*x_offset + y_offset*y_offset; } while (rsq_offset > 1. || rsq_offset == 0.); double r_offset = sqrt(rsq_offset); x_offset /= r_offset*10.; y_offset /= r_offset*10.; ell_native.setCen(std::complex<double>(x_offset,y_offset)); dbg<<"After random offset "<<x_offset<<","<<y_offset<< ": cen = "<<ell_native.getCen()<<std::endl; // Now do it again. flag1 = 0; if (!ell_native.measure(pix,2,2,2,sigma_obs,flag1,0.1)) { ++log._nf_centroid; dbg<<"Second centroid pass failed.\n"; flag |= flag1; dbg<<"FLAG CENTROID_FAILED\n"; flag |= CENTROID_FAILED; dbg<<"FLAG SHAPELET_NOT_DECONV\n"; flag |= SHAPELET_NOT_DECONV; return; } dbg<<"After second centroid pass: cen = "<< ell_native.getCen()<<" relative to the new center: "<< cen_offset<<std::endl; ++log._ns_centroid; } // // Next find a good sigma value // if (!fixsigma) { for(int iter=1;iter<=MAX_ITER;++iter) { dbg<<"Mu iter = "<<iter<<std::endl; flag1 = 0; ell_native.unfixMu(); if (ell_native.measure(pix,2,2,2,sigma_obs,flag1,0.1)) { // Don't ++ns_native yet. Only success if also do round frame. dbg<<"Successful native fit:\n"; dbg<<"Z = "<<ell_native.getCen()<<std::endl; dbg<<"Mu = "<<ell_native.getMu()<<std::endl; } else { ++log._nf_native; dbg<<"Native measurement failed\n"; flag |= flag1; dbg<<"FLAG NATIVE_FAILED\n"; flag |= NATIVE_FAILED; dbg<<"FLAG SHAPELET_NOT_DECONV\n"; flag |= SHAPELET_NOT_DECONV; return; } // Adjust the sigma value so we can reset mu = 0. double delta_mu = ell_native.getMu(); cen_offset += ell_native.getCen(); dbg<<"New center = "<<cen_offset<<std::endl; ell_native.setCen(0.); sigma_obs *= exp(ell_native.getMu()); dbg<<"New sigma_obs = "<<sigma_obs<<std::endl; ell_native.setMu(0.); if (sigma_obs < min_galsize*sigma_p) { dbg<<"skip: galaxy is too small -- "<<sigma_obs<< " psf size = "<<sigma_p<<std::endl; ++log._nf_small; flag |= flag1; dbg<<"FLAG TOO_SMALL\n"; flag |= TOO_SMALL; dbg<<"FLAG SHAPELET_NOT_DECONV\n"; flag |= SHAPELET_NOT_DECONV; return; } // redo the pixlist: galap = sigma_obs * gal_aperture; if (max_aperture > 0. && galap > max_aperture) galap = max_aperture; npix = 0; for(int i=0;i<nexp;++i) { if (use_fake_pixels) { inner_fake_ap = shear_inner_fake_aperture * sigma_obs; outer_fake_ap = shear_outer_fake_aperture * sigma_obs; } GetSubPixList(pix[i],allpix[i],cen_offset,0.,galap, inner_fake_ap,outer_fake_ap,params,flag1); npix += pix[i].size(); } if (npix < 10) { dbg<<"Too few pixels to continue: "<<npix<<std::endl; dbg<<"FLAG LT10PIX\n"; flag |= LT10PIX; dbg<<"FLAG SHAPELET_NOT_DECONV\n"; flag |= SHAPELET_NOT_DECONV; return; } dbg<<"delta_mu = "<<delta_mu<<std::endl; if (std::abs(delta_mu) < MAX_DELTA_MU) { dbg<<"delta_mu < "<<MAX_DELTA_MU<<std::endl; break; } else if (iter < MAX_ITER) { dbg<<"delta_mu >= "<<MAX_DELTA_MU<<std::endl; continue; } else { dbg<<"delta_mu >= "<<MAX_DELTA_MU<<std::endl; dbg<<"But iter == "<<MAX_ITER<<", so stop.\n"; } } } // // Measure the isotropic significance // BVec flux(0,sigma); DMatrix flux_cov(1,1); if (!ell_native.measureShapelet(pix,psf,flux,0,0,0,&flux_cov) || !(flux(0) > 0) || !(flux_cov(0,0) > 0.) ) { dbg<<"Failed flux measurement of bad flux value: \n"; dbg<<"flux = "<<flux(0)<<std::endl; dbg<<"flux_cov = "<<flux_cov(0,0)<<std::endl; dbg<<"FLAG SHAPE_BAD_FLUX\n"; flag |= SHAPE_BAD_FLUX; } dbg<<"flux = "<<flux<<std::endl; dbg<<"flux_cov = "<<flux_cov<<std::endl; if (flux(0) > 0. && flux_cov(0,0) > 0.) { nu = flux(0) / sqrt(flux_cov(0,0)); dbg<<"nu = "<<flux(0)<<" / sqrt("<<flux_cov(0,0)<<") = "<< nu<<std::endl; } else { nu = DEFVALNEG; dbg<<"nu set to error value = "<<nu<<std::endl; } // // Reduce order if necessary so that // (order+1)*(order+2)/2 < nu // galorder = galorder_init; if (params.read("shear_base_order_on_nu",true)) { int galsize = 0; while (galorder > min_galorder) { if (maxm > galorder) maxm = galorder; galsize = (maxm+1)*(maxm+2)/2 + (2*maxm+1)*(galorder-maxm)/2; if (galsize <= nu) break; else --galorder; } if (galorder < galorder_init) { dbg<<"Reduced galorder to "<<galorder<< " so that galsize = "<<galsize<< " <= nu = "<<nu<<std::endl; } } // // Next find the frame in which the native observation is round. // Ellipse ell_round = ell_native; if (fixcen) ell_round.fixCen(); if (fixsigma) ell_round.fixMu(); for(int iter=1;iter<=MAX_ITER;++iter) { dbg<<"Round iter = "<<iter<<std::endl; flag1 = 0; std::complex<double> gamma_prev = ell_round.getGamma(); if (ell_round.measure( pix,galorder,galorder2,maxm,sigma_obs,flag1,1.e-2)) { ++log._ns_native; dbg<<"Successful round fit:\n"; dbg<<"Z = "<<ell_round.getCen()<<std::endl; dbg<<"Mu = "<<ell_round.getMu()<<std::endl; dbg<<"Gamma = "<<ell_round.getGamma()<<std::endl; } else { ++log._nf_native; dbg<<"Round measurement failed\n"; flag |= flag1; dbg<<"FLAG NATIVE_FAILED\n"; flag |= NATIVE_FAILED; dbg<<"FLAG SHAPELET_NOT_DECONV\n"; flag |= SHAPELET_NOT_DECONV; return; } // Adjust the sigma value so we can reset mu = 0. if (!fixcen) cen_offset += ell_round.getCen(); ell_round.setCen(0.); double delta_mu = ell_round.getMu(); sigma_obs *= exp(ell_round.getMu()); ell_round.setMu(0.); if (sigma_obs < min_galsize*sigma_p) { dbg<<"skip: galaxy is too small -- "<<sigma_obs<< " psf size = "<<sigma_p<<std::endl; ++log._nf_small; dbg<<"FLAG TOO_SMALL\n"; flag |= TOO_SMALL; dbg<<"FLAG SHAPELET_NOT_DECONV\n"; flag |= SHAPELET_NOT_DECONV; return; } gamma = ell_round.getGamma(); dbg<<"New center = "<<cen_offset<<std::endl; if (std::abs(cen_offset) > 1.) { dbg<<"FLAG CENTROID_SHIFT\n"; flag |= CENTROID_SHIFT; } dbg<<"New sigma_obs = "<<sigma_obs<<std::endl; dbg<<"New gamma = "<<gamma<<std::endl; std::complex<double> delta_gamma = gamma - gamma_prev; dbg<<"ell_round = "<<ell_round<<std::endl; // Get the pixels in an elliptical aperture based on the // observed shape. galap = sigma_obs * gal_aperture; if (max_aperture > 0. && galap > max_aperture) galap = max_aperture; npix = 0; for(int i=0;i<nexp;++i) { if (use_fake_pixels) { inner_fake_ap = shear_inner_fake_aperture * sigma_obs; outer_fake_ap = shear_outer_fake_aperture * sigma_obs; } GetSubPixList(pix[i],allpix[i],cen_offset,gamma,galap, inner_fake_ap,outer_fake_ap,params,flag1); npix += pix[i].size(); } dbg<<"npix = "<<npix<<std::endl; if (npix < 10) { dbg<<"Too few pixels to continue: "<<npix<<std::endl; dbg<<"FLAG LT10PIX\n"; flag |= LT10PIX; dbg<<"FLAG SHAPELET_NOT_DECONV\n"; flag |= SHAPELET_NOT_DECONV; return; } dbg<<"delta_mu = "<<delta_mu<<std::endl; dbg<<"delta_gamma = "<<delta_gamma<<std::endl; if (std::abs(delta_mu) < MAX_DELTA_MU && std::abs(delta_gamma) < MAX_DELTA_GAMMA1) { dbg<<"delta_mu < "<<MAX_DELTA_MU; dbg<<" and delta_gamma < "<<MAX_DELTA_GAMMA1<<std::endl; break; } else if (iter < MAX_ITER) { dbg<<"delta_mu >= "<<MAX_DELTA_MU; dbg<<" or delta_gamma >= "<<MAX_DELTA_GAMMA1<<std::endl; continue; } else { dbg<<"delta_mu >= "<<MAX_DELTA_MU; dbg<<" or delta_gamma >= "<<MAX_DELTA_GAMMA1<<std::endl; dbg<<"But iter == "<<MAX_ITER<<", so stop.\n"; } } if (params.read("shear_native_only",false)) return; // Start with the specified fPsf, but allow it to increase up to // max_fpsf if there are any problems. long flag0 = flag; dbg<<"min_fpsf = "<<min_fpsf<<std::endl; dbg<<"max_fpsf = "<<max_fpsf<<std::endl; Assert(min_fpsf <= max_fpsf); for(double fPsf=min_fpsf; fPsf<=max_fpsf+1.e-3; fPsf+=0.5) { flag = flag0; // In case anything was set in a previous iteration. bool lastfpsf = (fPsf + 0.5 > max_fpsf+1.e-3); dbg<<"Start fPsf loop: fPsf = "<<fPsf<<std::endl; // // Set the sigma to use for the shapelet measurement: // // The sigma to use is // sigma_s^2 = sigma_i^2 + fpsf sigma_p^2 // And sigma_i^2 = sigma_o^2 - sigma_p^2 // So sigma_s^2 = sigma_o^2 + (fpsf-1) sigma_p^2 sigma = pow(sigma_obs,2) + (fPsf-1.) * sigpsq; xdbg<<"sigma_p^2 = "<<sigpsq<<std::endl; xdbg<<"sigma_obs^2 = "<<pow(sigma_obs,2)<<std::endl; xdbg<<"sigma^2 = sigma_obs^2 + (fPsf-1) * sigmap^2 = "<<sigma<<std::endl; if (sigma < 0.1*sigpsq) { xdbg<<"sigma too small, try larger fPsf\n"; if (!lastfpsf) continue; dbg<<"FLAG TOO_SMALL\n"; flag |= TOO_SMALL; return; } sigma = sqrt(sigma); dbg<<"sigma_s = "<<sigma<<std::endl; // // Measure a deconvolving fit in the native frame. // shapelet.setSigma(sigma); DMatrix shapeCov(int(shapelet.size()),int(shapelet.size())); if (ell_native.measureShapelet( pix,psf,shapelet,galorder,galorder2,galorder,&shapeCov)) { dbg<<"Successful deconvolving fit:\n"; ++log._ns_mu; } else { dbg<<"Deconvolving measurement failed\n"; if (!lastfpsf) continue; ++log._nf_mu; dbg<<"FLAG DECONV_FAILED\n"; flag |= DECONV_FAILED; } dbg<<"Measured deconvolved b_gal = "<<shapelet.vec()<<std::endl; xdbg<<"shapeCov = "<<shapeCov<<std::endl; if (shapelet(0) >= flux(0)*3. || shapelet(0) <= flux(0)/3.) { // If the b00 value in the shapelet doesn't match the direct flux // measurement, set a flag. dbg<<"Bad flux value: \n"; dbg<<"flux = "<<flux(0)<<std::endl; dbg<<"shapelet = "<<shapelet.vec()<<std::endl; dbg<<"flux ratio = "<<flux(0)/shapelet(0)<<std::endl; } // // Next, we find the frame where the deconvolved shape of the // galaxy is round. // for(int try_order=galorder; try_order>=min_galorder; --try_order) { dbg<<"try_order = "<<try_order<<std::endl; if (try_order < galorder) { dbg<<"FLAG SHEAR_REDUCED_ORDER\n"; flag |= SHEAR_REDUCED_ORDER; } if (maxm > try_order) maxm = try_order; Ellipse ell_meas = ell_round; Ellipse ell_shear = ell_round; if (fixcen) ell_shear.fixCen(); if (fixsigma) ell_shear.fixMu(); //ell_shear.fixMu(); double w = sqrt(sigma/sigma_p); bool success = false; cov.setZero(); for(int iter=1;iter<=MAX_ITER;++iter) { dbg<<"Shear iter = "<<iter<<std::endl; flag1 = 0; std::complex<double> gamma_prev = ell_shear.getGamma(); ell_meas.setGamma( (w*ell_shear.getGamma() + ell_round.getGamma())/(w+1.)); if (ell_shear.measure( pix,psf,try_order,galorder2,maxm,sigma,flag1, 1.e-2,&cov,&ell_meas)) { dbg<<"Successful shear fit:\n"; dbg<<"Z = "<<ell_shear.getCen()<<std::endl; dbg<<"Mu = "<<ell_shear.getMu()<<std::endl; dbg<<"Gamma = "<<ell_shear.getGamma()<<std::endl; } else { dbg<<"Shear measurement failed\n"; success = false; break; } gamma = ell_shear.getGamma(); dbg<<"New gamma = "<<gamma<<std::endl; std::complex<double> delta_gamma = gamma - gamma_prev; dbg<<"ell_shear = "<<ell_shear<<std::endl; dbg<<"delta_gamma = "<<delta_gamma<<std::endl; if (std::abs(delta_gamma) < MAX_DELTA_GAMMA2) { dbg<<"delta_gamma < "<<MAX_DELTA_GAMMA2<<std::endl; success = true; flag1 = 0; break; } else if (iter == MAX_ITER) { dbg<<"delta_gamma >= "<<MAX_DELTA_GAMMA2<<std::endl; dbg<<"But iter == "<<MAX_ITER<<", so stop.\n"; success = std::abs(delta_gamma) < FAIL_DELTA_GAMMA2; } else { dbg<<"delta_gamma >= "<<MAX_DELTA_GAMMA2<<std::endl; } } if (success) { ++log._ns_gamma; dbg<<"Successful shear measurement:\n"; dbg<<"shear = "<<gamma<<std::endl; dbg<<"cov = "<<cov<<std::endl; #if 0 ell_shear.correctForBias( pix,psf,try_order,galorder2,maxm,sigma,&ell_meas); gamma = ell_shear.getGamma(); dbg<<"after correct bias: shear => "<<gamma<<std::endl; #endif return; } else { dbg<<"Unsuccessful shear measurement\n"; dbg<<"shear = "<<gamma<<std::endl; if (try_order == min_galorder) { flag |= flag1; dbg<<"flag = "<<flag<<std::endl; } } } if (!lastfpsf) continue; ++log._nf_gamma; dbg<<"FLAG SHEAR_FAILED\n"; flag |= SHEAR_FAILED; } #ifdef USE_TMV } catch (tmv::Error& e) { dbg<<"TMV Error thrown in MeasureShear\n"; dbg<<e<<std::endl; ++log._nf_tmv_error; dbg<<"FLAG TMV_EXCEPTION\n"; flag |= TMV_EXCEPTION; #endif } catch (std::exception& e) { dbg<<"std::exception thrown in MeasureShear\n"; dbg<<e.what()<<std::endl; ++log._nf_other_error; dbg<<"FLAG STD_EXCEPTION\n"; flag |= STD_EXCEPTION; } catch (...) { dbg<<"unkown exception in MeasureShear\n"; ++log._nf_other_error; dbg<<"FLAG UNKNOWN_EXCEPTION\n"; flag |= UNKNOWN_EXCEPTION; } }
QVBoxLayout* ColormapEditWidget::createButtonPanel() { QVBoxLayout* vLayout = new QVBoxLayout(); QHBoxLayout* hLayout = new QHBoxLayout(); m_cLabel = new QLabel( this ); m_sliders.clear(); QImage* image; image = createImage( this->width() - 20 ); QPixmap pix( this->width() - 20, 20 ); pix.convertFromImage( *image ); m_cLabel->setPixmap( pix ); hLayout->addStretch(); hLayout->addWidget( m_cLabel ); hLayout->addStretch(); vLayout->addLayout( hLayout ); vLayout->addSpacing( 5 ); int i = 0; { QHBoxLayout* hLayout2 = new QHBoxLayout(); PushButtonWithId* insertButton = new PushButtonWithId( "+", i ); insertButton->setStyleSheet( "QPushButton { font: bold 12px; max-width: 14px; max-height: 14px; } "); connect( insertButton, SIGNAL( signalClicked( int ) ), this, SLOT( newEntry( int ) ) ); insertButton->setDisabled( true ); PushButtonWithId* deleteButton = new PushButtonWithId( "-", i ); deleteButton->setStyleSheet( "QPushButton { font: bold 12px; max-width: 14px; max-height: 14px; } "); connect( deleteButton, SIGNAL( signalClicked( int ) ), this, SLOT( removeEntry( int ) ) ); deleteButton->setDisabled( true ); PushButtonWithId* upButton = new PushButtonWithId( "^", i ); upButton->setStyleSheet( "QPushButton { font: bold 12px; max-width: 14px; max-height: 14px; } "); upButton->setDisabled( true ); //connect( upButton, SIGNAL( signalClicked( int ) ), this, SLOT( moveUp( int ) ) ); PushButtonWithId* downButton = new PushButtonWithId( "v", i ); downButton->setStyleSheet( "QPushButton { font: bold 12px; max-width: 14px; max-height: 14px; } "); connect( downButton, SIGNAL( signalClicked( int ) ), this, SLOT( moveDown( int ) ) ); SliderWithEdit* slider = new SliderWithEdit( tr(""), Fn::Position::EAST, i ); m_sliders.push_back( slider ); slider->setMin( 0.0f ); slider->setMax( m_colormap.get( i + 1 ).value ); slider->setValue( m_colormap.get( i ).value ); connect( slider, SIGNAL( valueChanged( float, int ) ), this, SLOT( sliderChanged( float, int ) ) ); ColorWidgetWithLabel* colorWidget = new ColorWidgetWithLabel( QString::number( i ), i ); colorWidget->setValue( m_colormap.get( i ).color ); connect( colorWidget, SIGNAL( colorChanged( QColor, int ) ), this, SLOT( colorChanged( QColor, int ) ) ); hLayout2->addWidget( insertButton ); hLayout2->addWidget( deleteButton ); hLayout2->addWidget( upButton ); hLayout2->addWidget( downButton ); hLayout2->addWidget( slider ); hLayout2->addWidget( colorWidget ); vLayout->addLayout( hLayout2 ); } for ( int i = 1; i < m_colormap.size() - 1; ++i ) { QHBoxLayout* hLayout4 = new QHBoxLayout(); PushButtonWithId* insertButton = new PushButtonWithId( "+", i ); hLayout4->addWidget( insertButton ); insertButton->setStyleSheet( "QPushButton { font: bold 12px; max-width: 14px; max-height: 14px; } "); connect( insertButton, SIGNAL( signalClicked( int ) ), this, SLOT( newEntry( int ) ) ); PushButtonWithId* deleteButton = new PushButtonWithId( "-", i ); hLayout4->addWidget( deleteButton ); deleteButton->setStyleSheet( "QPushButton { font: bold 12px; max-width: 14px; max-height: 14px; } "); connect( deleteButton, SIGNAL( signalClicked( int ) ), this, SLOT( removeEntry( int ) ) ); PushButtonWithId* upButton = new PushButtonWithId( "^", i ); hLayout4->addWidget( upButton ); upButton->setStyleSheet( "QPushButton { font: bold 12px; max-width: 14px; max-height: 14px; } "); connect( upButton, SIGNAL( signalClicked( int ) ), this, SLOT( moveUp( int ) ) ); PushButtonWithId* downButton = new PushButtonWithId( "v", i ); hLayout4->addWidget( downButton ); downButton->setStyleSheet( "QPushButton { font: bold 12px; max-width: 14px; max-height: 14px; } "); connect( downButton, SIGNAL( signalClicked( int ) ), this, SLOT( moveDown( int ) ) ); SliderWithEdit* slider = new SliderWithEdit( tr(""), Fn::Position::EAST, i ); m_sliders.push_back( slider ); slider->setMin( m_colormap.get( i - 1 ).value ); slider->setMax( m_colormap.get( i + 1 ).value ); slider->setValue( m_colormap.get( i ).value ); connect( slider, SIGNAL( valueChanged( float, int ) ), this, SLOT( sliderChanged( float, int ) ) ); hLayout4->addWidget( slider ); ColorWidgetWithLabel* colorWidget = new ColorWidgetWithLabel( QString::number( i ), i ); colorWidget->setValue( m_colormap.get( i ).color ); connect( colorWidget, SIGNAL( colorChanged( QColor, int ) ), this, SLOT( colorChanged( QColor, int ) ) ); hLayout4->addWidget( colorWidget ); vLayout->addLayout( hLayout4 ); } { i = m_colormap.size() - 1; QHBoxLayout* hLayout2 = new QHBoxLayout(); PushButtonWithId* insertButton = new PushButtonWithId( "+", i ); insertButton->setStyleSheet( "QPushButton { font: bold 12px; max-width: 14px; max-height: 14px; } "); connect( insertButton, SIGNAL( signalClicked( int ) ), this, SLOT( newEntry( int ) ) ); PushButtonWithId* deleteButton = new PushButtonWithId( "-", i ); deleteButton->setStyleSheet( "QPushButton { font: bold 12px; max-width: 14px; max-height: 14px; } "); connect( deleteButton, SIGNAL( signalClicked( int ) ), this, SLOT( removeEntry( int ) ) ); deleteButton->setDisabled( true ); PushButtonWithId* upButton = new PushButtonWithId( "^", i ); upButton->setStyleSheet( "QPushButton { font: bold 12px; max-width: 14px; max-height: 14px; } "); connect( upButton, SIGNAL( signalClicked( int ) ), this, SLOT( moveUp( int ) ) ); PushButtonWithId* downButton = new PushButtonWithId( "v", i ); downButton->setStyleSheet( "QPushButton { font: bold 12px; max-width: 14px; max-height: 14px; } "); downButton->setDisabled( true ); //connect( downButton, SIGNAL( signalClicked( int ) ), this, SLOT( moveDown( int ) ) ); SliderWithEdit* slider = new SliderWithEdit( tr(""), Fn::Position::EAST, i ); m_sliders.push_back( slider ); slider->setMin( m_colormap.get( i - 1 ).value ); slider->setMax( 1.0f ); slider->setValue( m_colormap.get( i ).value ); connect( slider, SIGNAL( valueChanged( float, int ) ), this, SLOT( sliderChanged( float, int ) ) ); ColorWidgetWithLabel* colorWidget = new ColorWidgetWithLabel( QString::number( i ), i ); colorWidget->setValue( m_colormap.get( i ).color ); connect( colorWidget, SIGNAL( colorChanged( QColor, int ) ), this, SLOT( colorChanged( QColor, int ) ) ); hLayout2->addWidget( insertButton ); hLayout2->addWidget( deleteButton ); hLayout2->addWidget( upButton ); hLayout2->addWidget( downButton ); hLayout2->addWidget( slider ); hLayout2->addWidget( colorWidget ); vLayout->addLayout( hLayout2 ); } vLayout->addStretch(); return vLayout; }
int main(int argc, char** argv) { // Check config option, if showing is disabled, exit Fl_Config conf("EDE Team", "etip"); if(argc == 2 && (!strcmp(argv[1], "-f") || !strcmp(argv[1], "--force"))) { // nothing, to simplify omiting those '!' } else { bool show = true; conf.set_section("Tips"); conf.read("Show", show, true); if (!show) return 0; } conf_global = &conf; srand(time(NULL)); fl_init_locale_support("etip", PREFIX"/share/locale"); Fl_Window* win = new Fl_Window(420, 169, _("Tips...")); win->shortcut(0xff1b); win->begin(); Fl_Group* gr = new Fl_Group(5, 5, 410, 130); gr->box(FL_DOWN_BOX); Fl_Box* img = new Fl_Box(5, 5, 70, 65); Fl_Image pix(hint_xpm); img->image(pix); Fl_Box* title = new Fl_Box(80, 10, 320, 25, random_txt(title_tips, TITLE_TIPS_NUM)); title->label_font(fl_fonts+1); title->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); title->box(FL_FLAT_BOX); Fl_Box* tiptxt = new Fl_Box(80, 45, 320, 75, random_txt(tiplist, TIPS_NUM)); tiptxt->align(FL_ALIGN_LEFT|FL_ALIGN_TOP|FL_ALIGN_INSIDE|FL_ALIGN_WRAP); tiptxt->box(FL_FLAT_BOX); gr->end(); Fl_Check_Button* ch = new Fl_Check_Button(5, 140, 150, 25, _(" Do not bother me")); show_check = ch; Fl_Button* prev = new Fl_Button(160, 140, 80, 25, "<-"); prev->label_font(fl_fonts+1); prev->callback(prev_cb, tiptxt); Fl_Button* next = new Fl_Button(245, 140, 80, 25, "->"); next->label_font(fl_fonts+1); next->callback(next_cb, tiptxt); Fl_Button* close = new Fl_Button(335, 140, 80, 25, _("&Close")); close->callback(close_cb, win); win->end(); win->set_modal(); win->show(); return Fl::run(); }
void MusicDesktopWallpaperWidget::show() { QPixmap pix(M_BACKGROUND_PTR->getMBackground()); ui->background->setPixmap(pix.scaled( size() )); MusicAbstractMoveWidget::show(); }
void MapRenderer::render( QPainter* P, QMap<RenderPriority, QSet <Feature*> > theFeatures, const RendererOptions& options, MapView* aView ) { #ifndef NDEBUG QTime Start(QTime::currentTime()); #endif theView = aView; theOptions = options; QMap<RenderPriority, QSet<Feature*> >::const_iterator itm; QSet<Feature*>::const_iterator it; bool bgLayerVisible = TEST_RFLAGS(RendererOptions::BackgroundVisible); bool fgLayerVisible = TEST_RFLAGS(RendererOptions::ForegroundVisible); bool tchpLayerVisible = TEST_RFLAGS(RendererOptions::TouchupVisible); bool lblLayerVisible = TEST_RFLAGS(RendererOptions::NamesVisible); Way * R = NULL; Node * Pt = NULL; Relation * RR = NULL; QPixmap pix(theView->size()); thePainter = new QPainter(); itm = theFeatures.constBegin(); while (itm != theFeatures.constEnd()) { pix.fill(Qt::transparent); thePainter->begin(&pix); if (M_PREFS->getUseAntiAlias()) thePainter->setRenderHint(QPainter::Antialiasing); int curLayer = (itm.key()).layer(); while (itm != theFeatures.constEnd() && (itm.key()).layer() == curLayer) { for (it = itm.value().constBegin(); it != itm.value().constEnd(); ++it) { qreal alpha = (*it)->getAlpha(); thePainter->setOpacity(alpha); R = NULL; Pt = NULL; RR = NULL; if (!(R = CAST_WAY(*it))) if (!(Pt = CAST_NODE(*it))) RR = CAST_RELATION(*it); if (R) { // If there is painter at the relation level, don't paint at the way level bool draw = true; for (int i=0; i<R->sizeParents(); ++i) { if (!R->getParent(i)->isDeleted() && R->getParent(i)->hasPainter(PixelPerM)) draw = false; } if (!draw) continue; } if (!Pt) { if (bgLayerVisible) { thePainter->save(); if (R && R->area() == 0) thePainter->setCompositionMode(QPainter::CompositionMode_DestinationOver); if (R) bglayer.draw(R); else if (Pt) bglayer.draw(Pt); else if (RR) bglayer.draw(RR); thePainter->restore(); } if (fgLayerVisible) { thePainter->save(); if (R) fglayer.draw(R); else if (Pt) fglayer.draw(Pt); else if (RR) fglayer.draw(RR); thePainter->restore(); } } if (tchpLayerVisible) { thePainter->save(); if (R) tchuplayer.draw(R); else if (Pt) tchuplayer.draw(Pt); else if (RR) tchuplayer.draw(RR); thePainter->restore(); } if (lblLayerVisible) { thePainter->save(); if (R) lbllayer.draw(R); else if (Pt) lbllayer.draw(Pt); else if (RR) lbllayer.draw(RR); thePainter->restore(); } (*it)->draw(*thePainter, aView); } ++itm; } thePainter->end(); P->drawPixmap(0, 0, pix); #ifndef NDEBUG QTime Stop(QTime::currentTime()); qDebug() << Start.msecsTo(Stop) << "ms"; #endif } }
QPixmap Widget::getStatusIconPixmap(Status status, uint32_t w, uint32_t h) { QPixmap pix(w, h); pix.load(getStatusIconPath(status)); return pix; }
EditorWidget::EditorWidget(QString theme, QWidget *parent) : QWidget(parent), editor_rich_text(new EditorRichText(this)), editor_plain_text(new CodeEditor(this, CodeEditor::Html)), pag_stacked(new QStackedWidget(this)), m_state(Clean), m_initialPag(RichTextIndex) { m_theme = theme; m_color = editor_rich_text->textColor(); connect(editor_plain_text, SIGNAL(textChanged()), this, SLOT(plainTextChanged())); connect(editor_rich_text, SIGNAL(textChanged()), this, SLOT(richTextChanged())); connect(editor_rich_text, SIGNAL(simplifyRichTextChanged(bool)), this, SLOT(richTextChanged())); connect(editor_rich_text, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); connect(editor_rich_text, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); list_smile = new QListWidget(this); list_smile->setMaximumSize(QSize(155, 16777215)); list_smile->setMovement(QListView::Static); list_smile->setResizeMode(QListView::Adjust); list_smile->setViewMode(QListView::IconMode); connect(list_smile, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(list_smile_itemDoubleClicked(QListWidgetItem*))); toolbar_find_replace = new QWidget(this); toolbar_find_replace->setMinimumSize(QSize(0, 30)); QVBoxLayout *main_layout = new QVBoxLayout(this); main_layout->setContentsMargins(0, 0, 0, 0); main_layout->setSpacing(4); QHBoxLayout *toolbar_layout = new QHBoxLayout(); toolbar_layout->setContentsMargins(0, 0, 0, 0); toolbar_layout->setSpacing(10); QToolBar *toolbar_edit = new QToolBar(this); toolbar_edit->setMinimumSize(QSize(0, 30)); toolbar_edit->setIconSize(QSize(20, 20)); toolbar_edit->setStyleSheet("QToolBar{border:0px;}"); // Save Pdf /* m_pdf_action = createAction(QIcon(m_theme +"img16/pdf.png"), tr("Exportar a PDF") +"...", false, toolbar_edit); m_pdf_action->setPriority(QAction::LowPriority); m_pdf_action->setShortcut(Qt::CTRL + Qt::Key_D); connect(m_pdf_action, SIGNAL(triggered()), this, SLOT(on_edit_export_pdf())); toolbar_edit->addAction(m_pdf_action); toolbar_edit->addSeparator();*/ // combos font and size QWidget *toolbar_font_input = new QWidget(this); QHBoxLayout *combofont_layout = new QHBoxLayout(toolbar_font_input); combofont_layout->setContentsMargins(0, 0, 2, 0); m_font_input = new QFontComboBox(toolbar_edit); connect(m_font_input, SIGNAL(activated(QString)), this, SLOT(on_edit_font(QString))); combofont_layout->addWidget(m_font_input); m_font_size_input = new QComboBox(toolbar_edit); QFontDatabase font_db; foreach(int size, font_db.standardSizes()) m_font_size_input->addItem(QString::number(size)); connect(m_font_size_input, SIGNAL(activated(QString)), this, SLOT(on_edit_font_size(QString))); combofont_layout->addWidget(m_font_size_input); // combofont_layout->setStretch(0, 1); toolbar_edit->addWidget(toolbar_font_input); toolbar_edit->addSeparator(); // cut, copy, paste m_cut_action = createAction(QIcon(m_theme +"img16/edit_cut.png"), tr("Cortar"), false, toolbar_edit); m_cut_action->setPriority(QAction::LowPriority); m_cut_action->setShortcut(QKeySequence::Cut); connect(m_cut_action, SIGNAL(triggered()), this, SLOT(on_edit_cut())); toolbar_edit->addAction(m_cut_action); m_copy_action = createAction(QIcon(m_theme +"img16/edit_copy.png"), tr("Copiar"), false, toolbar_edit); m_copy_action->setPriority(QAction::LowPriority); m_copy_action->setShortcut(QKeySequence::Copy); connect(m_copy_action, SIGNAL(triggered()), this, SLOT(on_edit_copy())); toolbar_edit->addAction(m_copy_action); m_paste_action = createAction(QIcon(m_theme +"img16/edit_paste.png"), tr("Pegar"), false, toolbar_edit); m_paste_action->setPriority(QAction::LowPriority); m_paste_action->setShortcut(QKeySequence::Paste); connect(m_paste_action, SIGNAL(triggered()), this, SLOT(on_edit_paste())); toolbar_edit->addAction(m_paste_action); toolbar_edit->addSeparator(); // undo, redo m_undo_action = createAction(QIcon(m_theme +"img16/edit_deshacer.png"), tr("Deshacer"), false, toolbar_edit); m_undo_action->setShortcut(QKeySequence::Undo); connect(m_undo_action, SIGNAL(triggered()), this, SLOT(on_edit_undo())); toolbar_edit->addAction(m_undo_action); m_redo_action = createAction(QIcon(m_theme +"img16/edit_rehacer.png"), tr("Rehacer"), false, toolbar_edit); m_redo_action->setPriority(QAction::LowPriority); m_redo_action->setShortcut(QKeySequence::Redo); connect(m_redo_action, SIGNAL(triggered()), this, SLOT(on_edit_redo())); toolbar_edit->addAction(m_redo_action); toolbar_edit->addSeparator(); // bold, italic, underline, , m_bold_action = createAction(QIcon(m_theme +"img16/edit_negrita.png"), tr("Negrita"), true, toolbar_edit); m_bold_action->setPriority(QAction::LowPriority); m_bold_action->setShortcut(Qt::CTRL + Qt::Key_B); connect(m_bold_action, SIGNAL(triggered()), this, SLOT(on_edit_bold())); toolbar_edit->addAction(m_bold_action); m_italic_action = createAction(QIcon(m_theme +"img16/edit_cursiva.png"), tr("Cursiva"), true, toolbar_edit); m_italic_action->setPriority(QAction::LowPriority); m_italic_action->setShortcut(Qt::CTRL + Qt::Key_I); connect(m_italic_action, SIGNAL(triggered()), this, SLOT(on_edit_italic())); toolbar_edit->addAction(m_italic_action); m_underline_action = createAction(QIcon(m_theme +"img16/edit_subrayada.png"), tr("Subrayado"), true, toolbar_edit); m_underline_action->setPriority(QAction::LowPriority); m_underline_action->setShortcut(Qt::CTRL + Qt::Key_U); connect(m_underline_action, SIGNAL(triggered()), this, SLOT(on_edit_underline())); toolbar_edit->addAction(m_underline_action); toolbar_edit->addSeparator(); // align: left, center, right, justify QActionGroup *grp = new QActionGroup(toolbar_edit); connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(on_edit_text_align(QAction*))); if (QApplication::isLeftToRight()) { m_align_left_action = createAction(QIcon(m_theme +"img16/edit_text_left.png"), tr("Izquierdo"), true, grp); m_align_center_action = createAction(QIcon(m_theme +"img16/edit_text_center.png"), tr("Centro"), true, grp); m_align_right_action = createAction(QIcon(m_theme +"img16/edit_text_right.png"), tr("Derecho"), true, grp); } else { m_align_right_action = createAction(QIcon(m_theme +"img16/edit_text_right.png"), tr("Derecho"), true, grp); m_align_center_action = createAction(QIcon(m_theme +"img16/edit_text_center.png"), tr("Centro"), true, grp); m_align_left_action = createAction(QIcon(m_theme +"img16/edit_text_left.png"), tr("Izquierdo"), true, grp); } m_align_justify_action = createAction(QIcon(m_theme +"img16/edit_text_justify.png"), tr("Justificado"), true, grp); m_align_left_action->setPriority(QAction::LowPriority); m_align_left_action->setShortcut(Qt::CTRL + Qt::Key_L); m_align_center_action->setPriority(QAction::LowPriority); m_align_center_action->setShortcut(Qt::CTRL + Qt::Key_E); m_align_right_action->setPriority(QAction::LowPriority); m_align_right_action->setShortcut(Qt::CTRL + Qt::Key_R); m_align_justify_action->setPriority(QAction::LowPriority); m_align_justify_action->setShortcut(Qt::CTRL + Qt::Key_J); toolbar_edit->addActions(grp->actions()); toolbar_edit->addSeparator(); // superscript, subscript m_valign_sup_action = createAction(QIcon(m_theme +"img16/edit_text_super.png"), tr("Superíndice"), true, toolbar_edit); connect(m_valign_sup_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_valign_sup())); toolbar_edit->addAction(m_valign_sup_action); m_valign_sub_action = createAction(QIcon(m_theme +"img16/edit_text_subs.png"), tr("Subíndice"), true, toolbar_edit); connect(m_valign_sub_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_valign_sub())); toolbar_edit->addAction(m_valign_sub_action); toolbar_edit->addSeparator(); // image, link, color, simplify m_image_action = createAction(QIcon(m_theme +"img16/edit_imagen.png"), tr("Imagen"), false, toolbar_edit); connect(m_image_action, SIGNAL(triggered()), this, SLOT(on_edit_image())); toolbar_edit->addAction(m_image_action); m_link_action = createAction(QIcon(m_theme +"img16/edit_enlace.png"), tr("Enlace"), true, toolbar_edit); connect(m_link_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_link(bool))); toolbar_edit->addAction(m_link_action); QPixmap pix(16, 16); pix.fill(Qt::black); m_color_action = createAction(QIcon(pix), tr("Color") +"...", false, toolbar_edit); connect(m_color_action, SIGNAL(triggered()), this, SLOT(on_edit_color())); toolbar_edit->addAction(m_color_action); toolbar_edit->addSeparator(); m_simplify_richtext_action = createAction(QIcon(m_theme +"img16/edit_simplify_richtext.png"), tr("Simplificar") +" Html", true, toolbar_edit); m_simplify_richtext_action->setChecked(editor_rich_text->simplifyRichText()); connect(m_simplify_richtext_action, SIGNAL(triggered(bool)), editor_rich_text, SLOT(setSimplifyRichText(bool))); connect(editor_rich_text, SIGNAL(simplifyRichTextChanged(bool)), m_simplify_richtext_action, SLOT(setChecked(bool))); toolbar_edit->addAction(m_simplify_richtext_action); toolbar_layout->addWidget(toolbar_edit); QToolBar *toolbar_opts = new QToolBar(this); toolbar_opts->setIconSize(QSize(20, 20)); toolbar_opts->setMinimumSize(QSize(30, 30)); toolbar_opts->setStyleSheet("QToolBar{border:0px;}"); m_find_replace_text_action = createAction(QIcon(m_theme +"img16/edit_buscar.png"), tr("Buscar") +"/"+ tr("Reemplazar"), true, toolbar_opts); m_find_replace_text_action->setPriority(QAction::LowPriority); m_find_replace_text_action->setShortcut(QKeySequence::Find); connect(m_find_replace_text_action, SIGNAL(triggered(bool)), this, SLOT(on_show_find_replace(bool))); toolbar_opts->addAction(m_find_replace_text_action); m_rich_plain_action = createAction(QIcon(m_theme +"img16/script.png"), tr("Editor") +"/"+ tr("Código"), true, toolbar_opts); connect(m_rich_plain_action, SIGNAL(triggered(bool)), this, SLOT(on_show_source(bool))); toolbar_opts->addAction(m_rich_plain_action); m_smiles_action = createAction(QIcon(m_theme +"img16/smile.png"), tr("Smiles"), true, toolbar_opts); connect(m_smiles_action, SIGNAL(triggered(bool)), list_smile, SLOT(setVisible(bool))); toolbar_opts->addAction(m_smiles_action); toolbar_layout->addWidget(toolbar_opts); toolbar_layout->setStretch(0, 1); main_layout->addLayout(toolbar_layout); QHBoxLayout *edit_smiles_layout = new QHBoxLayout(); edit_smiles_layout->setContentsMargins(0, 0, 0, 0); edit_smiles_layout->setSpacing(4); QWidget *rich_edit = new QWidget(); QVBoxLayout *rich_edit_layout = new QVBoxLayout(rich_edit); rich_edit_layout->setContentsMargins(0, 0, 0, 0); rich_edit_layout->addWidget(editor_rich_text); pag_stacked->addWidget(rich_edit); QWidget *plain_edit = new QWidget(); QVBoxLayout *plain_edit_layout = new QVBoxLayout(plain_edit); plain_edit_layout->setContentsMargins(0, 0, 0, 0); plain_edit_layout->addWidget(editor_plain_text); pag_stacked->addWidget(plain_edit); connect(pag_stacked, SIGNAL(currentChanged(int)), this, SLOT(pagIndexChanged(int))); edit_smiles_layout->addWidget(pag_stacked); edit_smiles_layout->addWidget(list_smile); main_layout->addLayout(edit_smiles_layout); QGridLayout *gridLayout = new QGridLayout(toolbar_find_replace); gridLayout->setSpacing(4); gridLayout->setContentsMargins(0, 0, 0, 0); QLabel *lb_find = new QLabel(tr("Buscar")+":", toolbar_find_replace); gridLayout->addWidget(lb_find, 0, 0, 1, 1); txt_find = new QLineEdit(toolbar_find_replace); txt_find->setMinimumSize(QSize(0, 24)); connect(txt_find, SIGNAL(textChanged(QString)), this, SLOT(txtFindTextChanged(QString))); gridLayout->addWidget(txt_find, 0, 1, 1, 1); QToolButton *btnFindBack = createToolButton(QIcon(m_theme +"img16/edit_buscar_anterior.png"), tr("Buscar anterior"), toolbar_find_replace); btnFindBack->setShortcut(QKeySequence::FindPrevious); connect(btnFindBack, SIGNAL(clicked()), this, SLOT(btnFindBack_clicked())); gridLayout->addWidget(btnFindBack, 0, 2, 1, 1); QToolButton *btnFindNext = createToolButton(QIcon(m_theme +"img16/edit_buscar_siguiente.png"), tr("Buscar siguiente"), toolbar_find_replace); btnFindBack->setShortcut(QKeySequence::FindNext); connect(btnFindNext, SIGNAL(clicked()), this, SLOT(btnFindNext_clicked())); gridLayout->addWidget(btnFindNext, 0, 3, 1, 1); chkCaseSensitive = new QCheckBox(tr("Coincidir mayúsculas/minúsculas"), toolbar_find_replace); chkCaseSensitive->setChecked(false); connect(chkCaseSensitive, SIGNAL(toggled(bool)), this, SLOT(chkCaseSensitive_toggled(bool))); gridLayout->addWidget(chkCaseSensitive, 0, 5, 1, 1); QCheckBox *chkReplace = new QCheckBox(tr("Reemplazar por") +":", toolbar_find_replace); chkReplace->setChecked(false); connect(chkReplace, SIGNAL(toggled(bool)), this, SLOT(chkReplace_toggled(bool))); gridLayout->addWidget(chkReplace, 1, 0, 1, 1); txt_replace = new QLineEdit(toolbar_find_replace); txt_replace->setEnabled(false); txt_replace->setMinimumSize(QSize(0, 24)); gridLayout->addWidget(txt_replace, 1, 1, 1, 1); btnReplace = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar"), toolbar_find_replace); btnReplace->setEnabled(false); connect(btnReplace, SIGNAL(clicked()), this, SLOT(btnReplace_clicked())); gridLayout->addWidget(btnReplace, 1, 2, 1, 1); btnReplaceAndNext = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar siguiente"), toolbar_find_replace); btnReplaceAndNext->setEnabled(false); connect(btnReplaceAndNext, SIGNAL(clicked()), this, SLOT(btnReplaceAndNext_clicked())); gridLayout->addWidget(btnReplaceAndNext, 1, 3, 1, 1); btnReplaceAll = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar todo"), toolbar_find_replace); btnReplaceAll->setEnabled(false); connect(btnReplaceAll, SIGNAL(clicked()), this, SLOT(btnReplaceAll_clicked())); gridLayout->addWidget(btnReplaceAll, 1, 4, 1, 1); chkWholeWords = new QCheckBox(tr("Solo palabras completas"), toolbar_find_replace); gridLayout->addWidget(chkWholeWords, 1, 5, 1, 1); main_layout->addWidget(toolbar_find_replace); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged())); #endif showSource(m_initialPag == RichTextIndex ? false : true); showFindReplace(false); showSmiles(false); setTabStopWidth(40); fontChanged(editor_rich_text->font()); colorChanged(editor_rich_text->textColor()); alignmentChanged(editor_rich_text->alignment()); }
InputWidget::InputWidget(QWidget *parent) : AbstractItemView(parent), _networkId(0) { ui.setupUi(this); connect(ui.ownNick, SIGNAL(activated(QString)), this, SLOT(changeNick(QString))); layout()->setAlignment(ui.ownNick, Qt::AlignBottom); layout()->setAlignment(ui.inputEdit, Qt::AlignBottom); layout()->setAlignment(ui.showStyleButton, Qt::AlignBottom); layout()->setAlignment(ui.styleFrame, Qt::AlignBottom); ui.styleFrame->setVisible(false); setFocusProxy(ui.inputEdit); ui.ownNick->setFocusProxy(ui.inputEdit); ui.ownNick->setSizeAdjustPolicy(QComboBox::AdjustToContents); ui.ownNick->installEventFilter(new MouseWheelFilter(this)); ui.inputEdit->installEventFilter(this); ui.inputEdit->setMinHeight(1); ui.inputEdit->setMaxHeight(5); ui.inputEdit->setMode(MultiLineEdit::MultiLine); ui.inputEdit->setPasteProtectionEnabled(true); ui.boldButton->setIcon(SmallIcon("format-text-bold")); ui.italicButton->setIcon(SmallIcon("format-text-italic")); ui.underlineButton->setIcon(SmallIcon("format-text-underline")); ui.textcolorButton->setIcon(SmallIcon("format-text-color")); ui.highlightcolorButton->setIcon(SmallIcon("format-fill-color")); ui.encryptionIconLabel->hide(); _colorMenu = new QMenu(); _colorFillMenu = new QMenu(); QStringList names; names << tr("White") << tr("Black") << tr("Dark blue") << tr("Dark green") << tr("Red") << tr("Dark red") << tr("Dark magenta") << tr("Orange") << tr("Yellow") << tr("Green") << tr("Dark cyan") << tr("Cyan") << tr("Blue") << tr("Magenta") << tr("Dark gray") << tr("Light gray"); QPixmap pix(16, 16); for (int i = 0; i < inputLine()->mircColorMap().count(); i++) { pix.fill(inputLine()->mircColorMap().values()[i]); _colorMenu->addAction(pix, names[i])->setData(inputLine()->mircColorMap().keys()[i]); _colorFillMenu->addAction(pix, names[i])->setData(inputLine()->mircColorMap().keys()[i]); } pix.fill(Qt::transparent); _colorMenu->addAction(pix, tr("Clear Color"))->setData(""); _colorFillMenu->addAction(pix, tr("Clear Color"))->setData(""); ui.textcolorButton->setMenu(_colorMenu); connect(_colorMenu, SIGNAL(triggered(QAction *)), this, SLOT(colorChosen(QAction *))); ui.highlightcolorButton->setMenu(_colorFillMenu); connect(_colorFillMenu, SIGNAL(triggered(QAction *)), this, SLOT(colorHighlightChosen(QAction *))); new TabCompleter(ui.inputEdit); UiStyleSettings fs("Fonts"); fs.notify("UseCustomInputWidgetFont", this, SLOT(setUseCustomFont(QVariant))); fs.notify("InputWidget", this, SLOT(setCustomFont(QVariant))); if (fs.value("UseCustomInputWidgetFont", false).toBool()) setCustomFont(fs.value("InputWidget", QFont())); UiSettings s("InputWidget"); #ifdef HAVE_KDE s.notify("EnableSpellCheck", this, SLOT(setEnableSpellCheck(QVariant))); setEnableSpellCheck(s.value("EnableSpellCheck", false)); #endif s.notify("EnableEmacsMode", this, SLOT(setEnableEmacsMode(QVariant))); setEnableEmacsMode(s.value("EnableEmacsMode", false)); s.notify("ShowNickSelector", this, SLOT(setShowNickSelector(QVariant))); setShowNickSelector(s.value("ShowNickSelector", true)); s.notify("ShowStyleButtons", this, SLOT(setShowStyleButtons(QVariant))); setShowStyleButtons(s.value("ShowStyleButtons", true)); s.notify("EnablePerChatHistory", this, SLOT(setEnablePerChatHistory(QVariant))); setEnablePerChatHistory(s.value("EnablePerChatHistory", false)); s.notify("MaxNumLines", this, SLOT(setMaxLines(QVariant))); setMaxLines(s.value("MaxNumLines", 5)); s.notify("EnableScrollBars", this, SLOT(setScrollBarsEnabled(QVariant))); setScrollBarsEnabled(s.value("EnableScrollBars", true)); s.notify("EnableMultiLine", this, SLOT(setMultiLineEnabled(QVariant))); setMultiLineEnabled(s.value("EnableMultiLine", true)); ActionCollection *coll = QtUi::actionCollection(); Action *activateInputline = coll->add<Action>("FocusInputLine"); connect(activateInputline, SIGNAL(triggered()), SLOT(setFocus())); activateInputline->setText(tr("Focus Input Line")); activateInputline->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L)); connect(inputLine(), SIGNAL(textEntered(QString)), SLOT(onTextEntered(QString)), Qt::QueuedConnection); // make sure the line is already reset, bug #984 connect(inputLine(), SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat))); }
void EditorWidget::colorChanged(const QColor &c) { QPixmap pix(16, 16); pix.fill(c); m_color_action->setIcon(QIcon(pix)); }
/************************************************ * Widget Listing: * Creation of the list of drawed lovely buttons ************************************************/ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) : QListWidget( _parent ) { /* We need the parent to know the options checked */ parent = qobject_cast<ToolbarEditDialog *>(_parent); assert( parent ); /* Normal options */ setViewMode( QListView::IconMode ); setSpacing( 8 ); setGridSize( QSize(90, 50) ); setWrapping( true ); setWordWrap( true ); setTextElideMode( Qt::ElideNone ); setDragEnabled( true ); /* All the buttons do not need a special rendering */ for( int i = 0; i < BUTTON_MAX; i++ ) { QListWidgetItem *widgetItem = new QListWidgetItem( this ); widgetItem->setText( qtr( nameL[i] ) ); QPixmap pix( iconL[i] ); widgetItem->setIcon( pix.scaled( 16, 16, Qt::KeepAspectRatio, Qt::SmoothTransformation ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); } /* Spacers are yet again a different thing */ QListWidgetItem *widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ), qtr( "Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER ); addItem( widgetItem ); widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ), qtr( "Expanding Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER_EXTEND ); addItem( widgetItem ); /** * For all other widgets, we create then, do a pseudo rendering in * a pixmaps for the view, and delete the object * * A lot of code is retaken from the Abstract, but not exactly... * So, rewrite. * They are better ways to deal with this, but I doubt that this is * necessary. If you feel like you have the time, be my guest. * -- * jb **/ for( int i = SPLITTER; i < SPECIAL_MAX; i++ ) { QWidget *widget = NULL; QListWidgetItem *widgetItem = new QListWidgetItem( this ); switch( i ) { case SPLITTER: { QFrame *line = new QFrame( this ); line->setFrameShape( QFrame::VLine ); line->setFrameShadow( QFrame::Raised ); line->setLineWidth( 0 ); line->setMidLineWidth( 1 ); widget = line; } widgetItem->setText( qtr("Splitter") ); break; case INPUT_SLIDER: { SeekSlider *slider = new SeekSlider( Qt::Horizontal, this ); widget = slider; } widgetItem->setText( qtr("Time Slider") ); break; case VOLUME: { SoundWidget *snd = new SoundWidget( this, p_intf, parent->getOptions() & WIDGET_SHINY ); widget = snd; } widgetItem->setText( qtr("Volume") ); break; case VOLUME_SPECIAL: { QListWidgetItem *widgetItem = new QListWidgetItem( this ); widgetItem->setText( qtr("Small Volume") ); widgetItem->setIcon( QIcon( ":/toolbar/volume-medium" ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); } continue; case TIME_LABEL: { QLabel *timeLabel = new QLabel( "12:42/2:12:42", this ); widget = timeLabel; } widgetItem->setText( qtr("Time") ); break; case MENU_BUTTONS: { QWidget *discFrame = new QWidget( this ); //discFrame->setLineWidth( 1 ); QHBoxLayout *discLayout = new QHBoxLayout( discFrame ); discLayout->setSpacing( 0 ); discLayout->setMargin( 0 ); QToolButton *prevSectionButton = new QToolButton( discFrame ); prevSectionButton->setIcon( QIcon( ":/toolbar/dvd_prev" ) ); prevSectionButton->setToolTip( qtr("Previous chapter") ); discLayout->addWidget( prevSectionButton ); QToolButton *menuButton = new QToolButton( discFrame ); menuButton->setIcon( QIcon( ":/toolbar/dvd_menu" ) ); menuButton->setToolTip( qtr("Go to the DVD menu") ); discLayout->addWidget( menuButton ); QToolButton *nextButton = new QToolButton( discFrame ); nextButton->setIcon( QIcon( ":/toolbar/dvd_next" ) ); nextButton->setToolTip( qtr("Next chapter") ); discLayout->addWidget( nextButton ); widget = discFrame; } widgetItem->setText( qtr("DVD menus") ); break; case TELETEXT_BUTTONS: { QWidget *telexFrame = new QWidget( this ); QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame ); telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 ); QToolButton *telexOn = new QToolButton( telexFrame ); telexOn->setIcon( QIcon( ":/toolbar/tv" ) ); telexLayout->addWidget( telexOn ); QToolButton *telexTransparent = new QToolButton; telexTransparent->setIcon( QIcon( ":/toolbar/tvtelx" ) ); telexTransparent->setToolTip( qtr("Teletext transparency") ); telexLayout->addWidget( telexTransparent ); QSpinBox *telexPage = new QSpinBox; telexLayout->addWidget( telexPage ); widget = telexFrame; } widgetItem->setText( qtr("Teletext") ); break; case ADVANCED_CONTROLLER: { AdvControlsWidget *advControls = new AdvControlsWidget( p_intf, this ); widget = advControls; } widgetItem->setText( qtr("Advanced Buttons") ); break; case PLAYBACK_BUTTONS: { widget = new QWidget; DeckButtonsLayout *layout = new DeckButtonsLayout( widget ); BrowseButton *prev = new BrowseButton( widget, BrowseButton::Backward ); BrowseButton *next = new BrowseButton( widget ); RoundButton *play = new RoundButton( widget ); layout->setBackwardButton( prev ); layout->setForwardButton( next ); layout->setRoundButton( play ); } widgetItem->setText( qtr("Playback Buttons") ); break; case ASPECT_RATIO_COMBOBOX: widget = new AspectRatioComboBox( p_intf ); widgetItem->setText( qtr("Aspect ratio selector") ); break; case SPEED_LABEL: widget = new SpeedLabel( p_intf, this ); widgetItem->setText( qtr("Speed selector") ); break; case TIME_LABEL_ELAPSED: widget = new QLabel( "2:42", this ); widgetItem->setText( qtr("Elapsed time") ); break; case TIME_LABEL_REMAINING: widget = new QLabel( "-2:42", this ); widgetItem->setText( qtr("Total/Remaining time") ); break; default: msg_Warn( p_intf, "This should not happen %i", i ); break; } if( widget == NULL ) continue; widgetItem->setIcon( QIcon( QPixmap::grabWidget( widget ) ) ); widget->hide(); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); delete widget; } }
void YARPComplextrackerclonedTool::apply (YARPImageOf<YarpPixelBGR>& src, YARPImageOf<YarpPixelBGR>& dest, const YVector& jnts) { /// check whether it's a new target first. _lock.Wait (); bool _isnew = _new_target; _lock.Post (); /// timing stuff. const double now = YARPTime::GetTimeAsSeconds(); /// bool act_vector = false; /// print timing issues. _diff_total += now - _last_round; _diff_count ++; if (now - _last_reset > PRINT_TIME) { printf("Time between frames in ms is %g\n", 1000 * _diff_total / _diff_count); _diff_count = 0; _diff_total = 0; _last_reset = now; } _last_round = now; /// LATER: this might be the place to auto-reset the trackercloned in case that any timeout expired. /// /// if (now - _last_movement > 30) { setNewTarget (ISIZE/2, ISIZE/2); } /// a bit of copying. _mono.CastCopy(src); dest.PeerCopy(src); /// /// deals with the new target. if (_isnew) { _prev.PeerCopy (_mono); _lock.Wait (); _px = _tx = _ex; _py = _ty = _ey; _new_target = false; _lock.Post (); printf("*** Got new target %d %d\n", _px, _py); _last_update = now; } _trackercloned.SetBlockSize (BLOCK_SIZE, BLOCK_SIZE); _trackercloned.SetSearchWindowSize (SEARCH_SIZE, SEARCH_SIZE); _sub_trackercloned.SetBlockSize (BLOCK_SIZE, BLOCK_SIZE); _sub_trackercloned.SetSearchWindowSize (SEARCH_SIZE, SEARCH_SIZE); _gaze.update (jnts); if (!_isnew) { /// not a new target set the estimated offset. int predx = 0, predy = 0; #if defined(__QNXEurobot__) _gaze.intersectRay (YARPEurobotHeadKin::KIN_LEFT, _prevRay, predx, predy); #else // ----- #ifdef __QNXEurobot__ ----- _gaze.intersectRay (YARPBabybotHeadKin::KIN_LEFT, _prevRay, predx, predy); #endif // ----- #ifdef __QNXEurobot__ ----- ///predx += ISIZE/2; ///predy += ISIZE/2; /// YarpPixelBGR green (0, 255, 0); AddCircleOutline (dest, green, predx, predy, 5); AddCircleOutline (dest, green, predx, predy, 4); _dgx = predx - _prev_gaze_x; _dgy = predy - _prev_gaze_y; ///printf ("est vel: %lf %lf\n", _dgx, _dgy); _trackercloned.SetSearchWindowOffset ((int)(_dgx+0.5), (int)(_dgy+0.5)); _sub_trackercloned.SetSearchWindowOffset ((int)(_dgx+0.5), (int)(_dgy+0.5)); } else { _trackercloned.SetSearchWindowOffset (0, 0); _sub_trackercloned.SetSearchWindowOffset (0, 0); } _tx = _px; _ty = _py; /// checks borders. if (_tx < BXDX) _tx = BXDX; if (_tx > ISIZE-1-BXDX) _tx = ISIZE-1-BXDX; if (_ty < BXDX) _ty = BXDX; if (_ty > ISIZE-1-BXDX) _ty = ISIZE-1-BXDX; /// actual tracking. bool fell = false; double new_tx = ISIZE/2, new_ty = ISIZE/2, new_tx2 = ISIZE/2, new_ty2 = ISIZE/2; int sub_x = ISIZE/2, sub_y = ISIZE/2, sub_x2 = ISIZE/2, sub_y2 = ISIZE/2; _trackercloned.Apply (_prev, _mono, _tx, _ty); int x = _tx, y = _ty; x = _trackercloned.GetX(); y = _trackercloned.GetY(); /// predicted. double new_dx = x - (_tx + _dgx); double new_dy = y - (_ty + _dgy); /// direction of motion. double new_mag = sqrt (new_dx * new_dx + new_dy * new_dy); if (new_mag < 0.001) new_mag = 0.001; new_dx /= new_mag; new_dy /= new_mag; const double nscale = NSCALE; /// search along two directions. /// heuristic for exploring certain neighborhood of the current position. /// /// new_tx = _tx - new_dx * nscale; new_ty = _ty - new_dy * nscale; new_tx2 = _tx + new_dx * nscale; new_ty2 = _ty + new_dy * nscale; _sub_trackercloned.Apply (_prev, _mono, new_tx2, new_ty2); sub_x2 = _sub_trackercloned.GetX(); sub_y2 = _sub_trackercloned.GetY(); _sub_trackercloned.Apply (_prev, _mono, new_tx, new_ty); sub_x = _sub_trackercloned.GetX(); sub_y = _sub_trackercloned.GetY(); double sub_dx = sub_x - (new_tx + _dgx); double sub_dy = sub_y - (new_ty + _dgy); double sub_mag = sqrt (sub_dx * sub_dx + sub_dy * sub_dy); double sub_dx2 = sub_x2 - (new_tx2 + _dgx); double sub_dy2 = sub_y2 - (new_ty2 + _dgy); double sub_mag2 = sqrt (sub_dx2 * sub_dx2 + sub_dy2 * sub_dy2); if (new_mag > MAGDEFAULT) { act_vector = true; if (sub_mag > MAGDEFAULT && sub_mag2 < MAGDEFAULT) { printf("Should fall inwards\n"); x = (int)sub_x; y = (int)sub_y; fell = true; } if (sub_mag2 > MAGDEFAULT && sub_mag < MAGDEFAULT) { printf("Should fall outwards\n"); x = (int)sub_x2; y = (int)sub_y2; fell = true; } } _tx = x; _ty = y; float quality = _trackercloned.GetQuality(); bool low_quality = false; if (quality < QTHRESHOLD) { ///printf("low match quality (%g)\n", quality); if (_low_q_ct < QTHR2) { _low_q_ct++; } /// things are not going well. if (_low_q_ct > QTHR3) { low_quality = true; x = _tx = _px + _dgx; y = _ty = _py + _dgy; } } else { /// ok recovering? _low_q_ct -= 3; if (_low_q_ct < 0) _low_q_ct = 0; } _movement = false; /// to check for movement (of the target). double dist = sqrt((double)((_px-_tx)*(_px-_tx)+(_py-_ty)*(_py-_ty))); if (fell || (dist > 2) || (sqrt(_dgx * _dgx + _dgy * _dgy) > 2.0)) { _prev.PeerCopy(_mono); _px = _tx; _py = _ty; } /// target moved, all ok? if (dist > 5) { _movement = true; _last_movement = now; } /// /// /// computes the ray for the kin estimation. #if defined(__QNXEurobot__) _gaze.computeRay (YARPEurobotHeadKin::KIN_LEFT, _prevRay, x, y); ///-ISIZE/2, y-ISIZE/2); #else // ----- #ifdef __QNXEurobot__ ----- _gaze.computeRay (YARPBabybotHeadKin::KIN_LEFT, _prevRay, x, y); ///-ISIZE/2, y-ISIZE/2); #endif // ----- #ifdef __QNXEurobot__ ----- _prev_gaze_x = x; _prev_gaze_y = y; ///printf ("target: %d %d ray: %f %f %f\n", x, y, _prevRay(1), _prevRay(2), _prevRay(3)); /// /// /// just a bit of display of results. YarpPixelBGR pix(255,0,0); YarpPixelBGR pixg(0,255,0); YarpPixelBGR pixb(0,0,255); YarpPixelBGR pixr(128,64,0); YarpPixelBGR pixk(0,0,0); YarpPixelBGR pixw(255,255,255); AddCircleOutline (dest, pixw, (int)x, (int)y, 5); AddCircleOutline (dest, pixk, (int)x, (int)y, 6); AddCircle (dest, pixk, (int)x, (int)y, 4); AddCrossHair (dest, pixw, (int)x+1, (int)y, 6); AddCrossHair (dest, pixw, (int)x-1, (int)y, 6); AddCrossHair (dest, pixw, (int)x, (int)y+1, 6); AddCrossHair (dest, pixw, (int)x, (int)y-1, 6); AddCrossHair (dest, pixr, (int)x, (int)y, 6); AddCircle (dest, pixw, (int)x, (int)y, 2); if (act_vector) { AddCircle (dest, pix, (int)(new_tx + _dgx), (int)(new_ty + _dgy), 3); AddCircle (dest, pix, (int)(new_tx2 + _dgx), (int)(new_ty2 + _dgy), 3); AddCircle (dest, pixb, (int)sub_x, (int)sub_y, 2); AddCircle (dest, pixb, (int)sub_x2, (int)sub_y2, 2); } _lock.Wait(); _xx = x - ISIZE / 2; _yy = y - ISIZE / 2; _lock.Post(); }
QIcon DialogTransformVolume::MakeIcon(const QColor& color, int size) { QPixmap pix( size, size ); pix.fill( color ); return QIcon(pix); }
void ChatWidget::colorChanged() { QPixmap pix(16, 16); pix.fill(currentColor); ui->colorButton->setIcon(pix); }
UBRubberBand::enm_resizingMode UBRubberBand::determineResizingMode(QPoint pos) { if (mMouseIsPressed) return mResizingMode; QRect resizerTop (mResizingBorderHeight , 0 , rect().width()-2*mResizingBorderHeight, mResizingBorderHeight ); QRect resizerBottom (mResizingBorderHeight , rect().height() - mResizingBorderHeight, rect().width()-2*mResizingBorderHeight, mResizingBorderHeight ); QRect resizerLeft (0 , mResizingBorderHeight , mResizingBorderHeight , rect().height() - 2*mResizingBorderHeight); QRect resizerRight (rect().width()-mResizingBorderHeight, mResizingBorderHeight , mResizingBorderHeight , rect().height() - 2*mResizingBorderHeight); QRect resizerTopLeft (0 , 0 , mResizingBorderHeight, mResizingBorderHeight); QRect resizerTopRight (rect().width()-mResizingBorderHeight, 0 , mResizingBorderHeight, mResizingBorderHeight); QRect resizerBottomLeft (0 , rect().height() - mResizingBorderHeight, mResizingBorderHeight, mResizingBorderHeight); QRect resizerBottomRight(rect().width()-mResizingBorderHeight, rect().height() - mResizingBorderHeight, mResizingBorderHeight, mResizingBorderHeight); enm_resizingMode resizingMode; QTransform cursorTransrofm; if (resizerTop.contains(pos)) { resizingMode = Top; cursorTransrofm.rotate(90); } else if (resizerBottom.contains(pos)) { resizingMode = Bottom; cursorTransrofm.rotate(90); } else if (resizerLeft.contains(pos)) { resizingMode = Left; } else if (resizerRight.contains(pos)) { resizingMode = Right; } else if (resizerTopLeft.contains(pos)) { resizingMode = TopLeft; cursorTransrofm.rotate(45); } else if (resizerTopRight.contains(pos)) { resizingMode = TopRight; cursorTransrofm.rotate(-45); } else if (resizerBottomLeft.contains(pos)) { resizingMode = BottomLeft; cursorTransrofm.rotate(-45); } else if (resizerBottomRight.contains(pos)) { resizingMode = BottomRight; cursorTransrofm.rotate(45); } else resizingMode = None; if (None != resizingMode) { QPixmap pix(":/images/cursors/resize.png"); QCursor resizeCursor = QCursor(pix.transformed(cursorTransrofm, Qt::SmoothTransformation), pix.width() / 2, pix.height() / 2); setCursor(resizeCursor); } else unsetCursor(); return resizingMode; }
MRichTextEdit::MRichTextEdit(QWidget *parent) : QWidget(parent) { setupUi(this); m_lastBlockList = 0; f_textedit->setTabStopWidth(40); connect(f_textedit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(slotCurrentCharFormatChanged(QTextCharFormat))); connect(f_textedit, SIGNAL(cursorPositionChanged()), this, SLOT(slotCursorPositionChanged())); m_fontsize_h1 = 18; m_fontsize_h2 = 16; m_fontsize_h3 = 14; m_fontsize_h4 = 12; fontChanged(f_textedit->font()); bgColorChanged(f_textedit->textColor()); // paragraph formatting m_paragraphItems << tr("Standard") << tr("Heading 1") << tr("Heading 2") << tr("Heading 3") << tr("Heading 4") << tr("Monospace"); f_paragraph->addItems(m_paragraphItems); connect(f_paragraph, SIGNAL(activated(int)), this, SLOT(textStyle(int))); // undo & redo f_undo->setShortcut(QKeySequence::Undo); f_redo->setShortcut(QKeySequence::Redo); connect(f_textedit->document(), SIGNAL(undoAvailable(bool)), f_undo, SLOT(setEnabled(bool))); connect(f_textedit->document(), SIGNAL(redoAvailable(bool)), f_redo, SLOT(setEnabled(bool))); f_undo->setEnabled(f_textedit->document()->isUndoAvailable()); f_redo->setEnabled(f_textedit->document()->isRedoAvailable()); connect(f_undo, SIGNAL(clicked()), f_textedit, SLOT(undo())); connect(f_redo, SIGNAL(clicked()), f_textedit, SLOT(redo())); // cut, copy & paste f_cut->setShortcut(QKeySequence::Cut); f_copy->setShortcut(QKeySequence::Copy); f_paste->setShortcut(QKeySequence::Paste); f_cut->setEnabled(false); f_copy->setEnabled(false); connect(f_cut, SIGNAL(clicked()), f_textedit, SLOT(cut())); connect(f_copy, SIGNAL(clicked()), f_textedit, SLOT(copy())); connect(f_paste, SIGNAL(clicked()), f_textedit, SLOT(paste())); connect(f_textedit, SIGNAL(copyAvailable(bool)), f_cut, SLOT(setEnabled(bool))); connect(f_textedit, SIGNAL(copyAvailable(bool)), f_copy, SLOT(setEnabled(bool))); #ifndef QT_NO_CLIPBOARD connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slotClipboardDataChanged())); #endif // link f_link->setShortcut(Qt::CTRL + Qt::Key_L); connect(f_link, SIGNAL(clicked(bool)), this, SLOT(textLink(bool))); // bold, italic & underline f_bold->setShortcut(Qt::CTRL + Qt::Key_B); f_italic->setShortcut(Qt::CTRL + Qt::Key_I); f_underline->setShortcut(Qt::CTRL + Qt::Key_U); connect(f_bold, SIGNAL(clicked()), this, SLOT(textBold())); connect(f_italic, SIGNAL(clicked()), this, SLOT(textItalic())); connect(f_underline, SIGNAL(clicked()), this, SLOT(textUnderline())); connect(f_strikeout, SIGNAL(clicked()), this, SLOT(textStrikeout())); // lists f_list_bullet->setShortcut(Qt::CTRL + Qt::Key_Minus); f_list_ordered->setShortcut(Qt::CTRL + Qt::Key_Equal); connect(f_list_bullet, SIGNAL(clicked(bool)), this, SLOT(listBullet(bool))); connect(f_list_ordered, SIGNAL(clicked(bool)), this, SLOT(listOrdered(bool))); // indentation f_indent_dec->setShortcut(Qt::CTRL + Qt::Key_Comma); f_indent_inc->setShortcut(Qt::CTRL + Qt::Key_Period); connect(f_indent_inc, SIGNAL(clicked()), this, SLOT(increaseIndentation())); connect(f_indent_dec, SIGNAL(clicked()), this, SLOT(decreaseIndentation())); // font size QFontDatabase db; foreach(int size, db.standardSizes()) { f_fontsize->addItem(QString::number(size)); } connect(f_fontsize, SIGNAL(activated(QString)), this, SLOT(textSize(QString))); f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(QApplication::font().pointSize()))); // text background color QPixmap pix(16, 16); pix.fill(QApplication::palette().background().color()); f_bgcolor->setIcon(pix); connect(f_bgcolor, SIGNAL(clicked()), this, SLOT(textBgColor())); // images connect(f_image, SIGNAL(clicked()), this, SLOT(insertImage())); }
CollapsibleEffect::CollapsibleEffect(const QDomElement &effect, const QDomElement &original_effect, const ItemInfo &info, EffectMetaInfo *metaInfo, bool canMoveUp, bool lastEffect, QWidget * parent) : AbstractCollapsibleWidget(parent), m_paramWidget(NULL), m_effect(effect), m_itemInfo(info), m_original_effect(original_effect), m_isMovable(true), m_animation(NULL), m_regionEffect(false) { if (m_effect.attribute(QStringLiteral("tag")) == QLatin1String("region")) { m_regionEffect = true; decoframe->setObjectName(QStringLiteral("decoframegroup")); } filterWheelEvent = true; m_info.fromString(effect.attribute(QStringLiteral("kdenlive_info"))); //setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); buttonUp->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-up"))); buttonUp->setToolTip(i18n("Move effect up")); buttonDown->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-down"))); buttonDown->setToolTip(i18n("Move effect down")); buttonDel->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-deleffect"))); buttonDel->setToolTip(i18n("Delete effect")); buttonUp->setEnabled(canMoveUp); buttonDown->setEnabled(!lastEffect); if (m_effect.attribute(QStringLiteral("id")) == QLatin1String("speed")) { // Speed effect is a "pseudo" effect, cannot be moved buttonUp->setVisible(false); buttonDown->setVisible(false); m_isMovable = false; setAcceptDrops(false); } else { setAcceptDrops(true); } /*buttonReset->setIcon(KoIconUtils::themedIcon("view-refresh")); buttonReset->setToolTip(i18n("Reset effect"));*/ //checkAll->setToolTip(i18n("Enable/Disable all effects")); //buttonShowComments->setIcon(KoIconUtils::themedIcon("help-about")); //buttonShowComments->setToolTip(i18n("Show additional information for the parameters")); m_menu = new QMenu(this); m_menu->addAction(KoIconUtils::themedIcon(QStringLiteral("view-refresh")), i18n("Reset Effect"), this, SLOT(slotResetEffect())); m_menu->addAction(KoIconUtils::themedIcon(QStringLiteral("document-save")), i18n("Save Effect"), this, SLOT(slotSaveEffect())); QHBoxLayout *l = static_cast <QHBoxLayout *>(frame->layout()); m_colorIcon = new QLabel(this); l->insertWidget(0, m_colorIcon); title = new QLabel(this); l->insertWidget(2, title); m_enabledButton = new KDualAction(i18n("Disable Effect"), i18n("Enable Effect"), this); m_enabledButton->setActiveIcon(KoIconUtils::themedIcon(QStringLiteral("hint"))); m_enabledButton->setInactiveIcon(KoIconUtils::themedIcon(QStringLiteral("visibility"))); enabledButton->setDefaultAction(m_enabledButton); m_groupAction = new QAction(KoIconUtils::themedIcon(QStringLiteral("folder-new")), i18n("Create Group"), this); connect(m_groupAction, SIGNAL(triggered(bool)), this, SLOT(slotCreateGroup())); QDomElement namenode = m_effect.firstChildElement(QStringLiteral("name")); if (namenode.isNull()) { // Warning, broken effect? //qDebug()<<"// Could not create effect"; return; } QString effectname = i18n(namenode.text().toUtf8().data()); if (m_regionEffect) effectname.append(':' + QUrl(EffectsList::parameter(m_effect, QStringLiteral("resource"))).fileName()); // Create color thumb QPixmap pix(menuButton->height(), menuButton->height()); QColor col(m_effect.attribute(QStringLiteral("effectcolor"))); QFont ft = font(); ft.setBold(true); bool isAudio = m_effect.attribute(QStringLiteral("type")) == QLatin1String("audio"); if (isAudio) { pix.fill(Qt::transparent); } else { pix.fill(col); } QPainter p(&pix); if (isAudio) { p.setPen(Qt::NoPen); p.setBrush(col); p.drawEllipse(pix.rect()); p.setPen(QPen()); } p.setFont(ft); p.drawText(pix.rect(), Qt::AlignCenter, effectname.at(0)); p.end(); m_iconPix = pix; m_colorIcon->setPixmap(pix); title->setText(effectname); if (!m_regionEffect) { if (m_info.groupIndex == -1) m_menu->addAction(m_groupAction); m_menu->addAction(KoIconUtils::themedIcon(QStringLiteral("folder-new")), i18n("Create Region"), this, SLOT(slotCreateRegion())); } setupWidget(info, metaInfo); menuButton->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-menu"))); menuButton->setMenu(m_menu); if (m_effect.attribute(QStringLiteral("disable")) == QLatin1String("1")) { title->setEnabled(false); m_enabledButton->setActive(true); } else { m_enabledButton->setActive(false); } connect(collapseButton, SIGNAL(clicked()), this, SLOT(slotSwitch())); connect(m_enabledButton, SIGNAL(activeChangedByUser(bool)), this, SLOT(slotDisable(bool))); connect(buttonUp, SIGNAL(clicked()), this, SLOT(slotEffectUp())); connect(buttonDown, SIGNAL(clicked()), this, SLOT(slotEffectDown())); connect(buttonDel, SIGNAL(clicked()), this, SLOT(slotDeleteEffect())); Q_FOREACH( QSpinBox * sp, findChildren<QSpinBox*>() ) { sp->installEventFilter( this ); sp->setFocusPolicy( Qt::StrongFocus ); }
void CCharTip::showTip() { if(!itsParent->underMouse()) return; EUnicodeCategory cat(getCategory(itsItem.ucs4)); QString details("<table>"); details+="<tr><td><b>"+i18n("Category")+"</b></td><td>"+ toStr(cat)+"</td></tr>"; details+="<tr><td><b>"+i18n("UCS-4")+"</b></td><td>"+ QString().sprintf("U+%4.4X", itsItem.ucs4)+"</td></tr>"; QString str(QString::fromUcs4(&(itsItem.ucs4), 1)); details+="<tr><td><b>"+i18n("UTF-16")+"</b></td><td>"; const ushort *utf16(str.utf16()); for(int i=0; utf16[i]; ++i) { if(i) details+=' '; details+=QString().sprintf("0x%4.4X", utf16[i]); } details+="</td></tr>"; details+="<tr><td><b>"+i18n("UTF-8")+"</b></td><td>"; QByteArray utf8(str.toUtf8()); for(int i=0; i<utf8.size(); ++i) { if(i) details+=' '; details+=QString().sprintf("0x%2.2X", (unsigned char)(utf8.constData()[i])); } details+="</td></tr>"; // Note: the "<b></b> below is just to stop Qt converting the xml entry into // a character! if ((0x0001 <= itsItem.ucs4 && itsItem.ucs4 <= 0xD7FF) || (0xE000 <= itsItem.ucs4 && itsItem.ucs4 <= 0xFFFD) || (0x10000 <= itsItem.ucs4 && itsItem.ucs4 <= 0x10FFFF)) details+="<tr><td><b>"+i18n("XML Decimal Entity")+"</b></td><td>"+ QString().sprintf("&#<b></b>%d;", itsItem.ucs4)+"</td></tr>"; details+="</table>"; itsLabel->setText(details); QPixmap pix((int)(itsItem.width()*2.5), (int)(itsItem.height()*2.5)); QList<CFcEngine::TRange> range; range.append(CFcEngine::TRange(itsItem.ucs4, 0)); QColor prevBgndCol(CFcEngine::bgndCol()); CFcEngine::setBgndCol(palette().color(QPalette::Active, QPalette::Background)); if(CFcEngine::instance()->draw(itsParent->itsCurrentUrl, pix.width(), pix.height(), pix, itsParent->itsCurrentFace-1, false, range, NULL, itsParent->itsFontName, itsParent->itsStyleInfo)) itsPixmapLabel->setPixmap(pix); else itsPixmapLabel->setPixmap(QPixmap()); CFcEngine::setBgndCol(prevBgndCol); itsTimer->disconnect(this); connect(itsTimer, SIGNAL(timeout()), this, SLOT(hideTip())); itsTimer->setSingleShot(true); itsTimer->start(15000); kapp->installEventFilter(this); reposition(); show(); }
//build the VOR once void CVT::vor(cv::Mat & img) { cv::Mat dist(img.size(), CV_32F, cv::Scalar::all(FLT_MAX)); //an image with infinity distance cv::Mat root(img.size(), CV_16U, cv::Scalar::all(USHRT_MAX)); //an image of root index cv::Mat visited(img.size(), CV_8U, cv::Scalar::all(0)); //all unvisited //init std::vector< std::pair<float, cv::Point> > open; //YH open is a vector(float, cvPoint) ushort site_id = 0; for (auto& c : this->cells) { if (debug) { if (c.site.x<0 || c.site.x>img.size().height) std::cout << "! Warning: c.site.x=" << c.site.x << std::endl; if (c.site.y<0 || c.site.y>img.size().width) std::cout << "! Warning: c.site.y=" << c.site.y << std::endl; } cv::Point pix((int)c.site.x, (int)c.site.y); //YH a VOR site, pix(x,y) float d = color2dist(img, pix); //YH d is distance, color2dist convert a color intensity to distance between 0~1 dist.at<float>(pix.x, pix.y) = d; root.at<ushort>(pix.x, pix.y) = site_id++; open.push_back( std::make_pair(d, pix) ); c.coverage.clear(); } std::make_heap(open.begin(), open.end(), compareCell); // YH make min heap using the begining vector(pair) and the ending vector(pair) //propagate // YH do "while" for all cell and find the smallest distance as checking neighbors while (open.empty() == false) { std::pop_heap(open.begin(), open.end(), compareCell); //move the smallest element to the end auto cell = open.back(); //YH from hightest node, which has the smallest value, set cell auto& cpos = cell.second; //YH cell position open.pop_back(); // remove it //if(cell.first != dist.at<float>(cpos.x, cpos.y) )("first %f \t, dist %f \n", cell.first, dist.at<float>(cpos.x, cpos.y)); //check if the distance from this cell is already updated if (cell.first > dist.at<float>(cpos.x, cpos.y)) continue; //YH first = distance(intensity) if (visited.at<uchar>(cpos.x, cpos.y) > 0) continue; //visited //YH the if cpos already visited, skip this time and do next cell visited.at<uchar>(cpos.x, cpos.y) = 1; //check the neighbors for (int dx =-1; dx <= 1; dx++) //x is row { int x = cpos.x + dx; if (x < 0 || x >= img.size().height) continue; //YH check the x is inside an image for (int dy = -1; dy <= 1; dy++) //y is column { if (dx == 0 && dy == 0) continue; //itself... int y = cpos.y + dy; if (y < 0 || y >= img.size().width) continue; //YH check the y is inside an image float newd = dist.at<float>(cpos.x, cpos.y) + color2dist(img, cv::Point(x, y)); //YH new distance float oldd = dist.at<float>(x, y); //YH old distance //if((newd<oldd)&&oldd<100) printf("tot %.6f \t // old %.6f \n", newd, oldd);// color2dist(img, cv::Point(x, y)), dist.at<float>(cpos.x, cpos.y)); //cv::waitKey(1000); if (newd < oldd) //YH check new one has the smallest value and push it in the heap { dist.at<float>(x, y)=newd; root.at<ushort>(x, y) = root.at<ushort>(cpos.x, cpos.y); open.push_back(std::make_pair(newd, cv::Point(x, y))); // add the element at the next end of list container std::push_heap(open.begin(), open.end(), compareCell); } }//end for dy }//end for dx }//end while //collect cells for (int x = 0; x < img.size().height; x++) { for (int y = 0; y < img.size().width; y++) { ushort rootid = root.at<ushort>(x, y); this->cells[rootid].coverage.push_back(cv::Point(x,y)); // YH make coverage }//end y }//end x //remove empty cells... int cvt_size = this->cells.size(); for (int i = 0; i < cvt_size; i++) { if (this->cells[i].coverage.empty()) { this->cells[i] = this->cells.back(); this->cells.pop_back(); i--; cvt_size--; } }//end for i if (debug) { //this shows the progress... double min; double max; cv::minMaxIdx(dist, &min, &max); //YH finds global minimum and maximum array elements and returns their values and their locations cv::Mat adjMap; cv::convertScaleAbs(dist, adjMap, 255 / max); //YH scales array elements, computes absolute values and converts the results to 8-bit unsigned integers: dst(i)=saturate_cast<uchar>abs(src(i)*alpha+beta) //cv::applyColorMap(adjMap, adjMap, cv::COLORMAP_JET); for (auto& c : this->cells) { cv::circle(adjMap, cv::Point(c.site.y, c.site.x), 2, CV_RGB(0, 0, 255), -1); } //cv::imshow("CVT", adjMap); //cv::waitKey(5); } }
void ContextPaneWidgetImage::setPixmap(const QString &fileName) { QPixmap pix(76,76); pix.fill(Qt::black); if (m_borderImage) { QString localFileName(fileName); if (QFile(fileName).exists()) { if (fileName.endsWith(QLatin1String("sci"))) { QString pixmapFileName; int left = 0; int right = 0; int top = 0; int bottom = 0; Qt::TileRule horizontalTileRule; Qt::TileRule verticalTileRule; if (parseSciFile(fileName, pixmapFileName, left, right, top, bottom, horizontalTileRule, verticalTileRule)) { localFileName = QFileInfo(fileName).absoluteDir().absolutePath() + '/' + pixmapFileName; previewDialog()->previewLabel()->setMargins(left, top, right, bottom); } else { // sci file not parsed correctly uiBorderImage->sizeLabel->setText(""); return; } } QPixmap source(localFileName); if (source.isNull()) source = pix; previewDialog()->setPixmap(source, previewDialog()->zoom()); uiBorderImage->sizeLabel->setText(QString::number(source.width()) + 'x' + QString::number(source.height())); QPainter p(&pix); Qt::TileRule horizontalTileMode = Qt::StretchTile; Qt::TileRule verticalTileMode = Qt::StretchTile; if (uiBorderImage->horizontalTileRadioButton->isChecked()) horizontalTileMode =Qt::RepeatTile; if (uiBorderImage->horizontalTileRadioButtonNoCrop->isChecked()) horizontalTileMode =Qt::RoundTile; if (uiBorderImage->verticalTileRadioButton->isChecked()) verticalTileMode =Qt::RepeatTile; if (uiBorderImage->verticalTileRadioButtonNoCrop->isChecked()) verticalTileMode =Qt::RoundTile; QTileRules rules(horizontalTileMode, verticalTileMode); QMargins margins(previewDialog()->previewLabel()->leftMarging() ,previewDialog()->previewLabel()->topMarging() ,previewDialog()->previewLabel()->rightMarging(), previewDialog()->previewLabel()->bottomMarging()); qDrawBorderPixmap(&p, QRect(0, 0, 76, 76), margins, source, source.rect(), margins, rules); //p.drawPixmap(0,0,76,76, source); } else { uiBorderImage->sizeLabel->setText(""); } uiBorderImage->label->setPixmap(pix); } else { if (QFile(fileName).exists()) { QPixmap source(fileName); previewDialog()->setPixmap(source, 1); ui->sizeLabel->setText(QString::number(source.width()) + 'x' + QString::number(source.height())); QPainter p(&pix); if (ui->stretchRadioButton->isChecked()) { p.drawPixmap(0,0,76,76, source); } else if (ui->tileRadioButton->isChecked()) { QPixmap small = source.scaled(38,38); p.drawTiledPixmap(0,0,76,76, small); } else if (ui->horizontalStretchRadioButton->isChecked()) { QPixmap small = source.scaled(38,38); QPixmap half = pix.scaled(38, 76); QPainter p2(&half); p2.drawTiledPixmap(0,0,38,76, small); p.drawPixmap(0,0,76,76, half); } else if (ui->verticalStretchRadioButton->isChecked()) { QPixmap small = source.scaled(38,38); QPixmap half = pix.scaled(76, 38); QPainter p2(&half); p2.drawTiledPixmap(0,0,76,38, small); p.drawPixmap(0,0,76,76, half); } else if (ui->preserveAspectFitRadioButton->isChecked()) { QPixmap preserved = source.scaledToWidth(76); int offset = (76 - preserved.height()) / 2; p.drawPixmap(0, offset, 76, preserved.height(), source); } else if (ui->cropAspectFitRadioButton->isChecked()) { QPixmap cropped = source.scaledToHeight(76); int offset = (76 - cropped.width()) / 2; p.drawPixmap(offset, 0, cropped.width(), 76, source); } } else { ui->sizeLabel->setText(""); } ui->label->setPixmap(pix); } }
movie18::movie18(QWidget *parent) : QDialog(parent), ui(new Ui::movie18) { ui->setupUi(this); ui->MovieName->setStyleSheet("font: bold 30px; color:blue;"); ui->Director->setStyleSheet("font: bold 14px;"); ui->Category->setStyleSheet("font: bold 15px; color:blue"); ui->stars->setStyleSheet("font: bold 14px;"); ui->Writer->setStyleSheet("font: bold 14px;"); for(int i = 0; i < det.size(); i++){ if(det[i].movie == MD[17]){ qDebug() << det[i].movie << endl; ui->MovieName->setText(det[i].movie); ui->Category->setText(det[i].type); ui->textEdit->setText(det[i].detail); ui->Writer->setText(det[i].writers); ui->Director->setText(det[i].director); ui->stars->setText(det[i].stars); } } if(MD[17] == "Marvel's The Avengers"){ // qDebug() << "hena 1"; QPixmap pix("/home/asmaa/QT/CINAMIKA/Marvels-The-Avengers.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "The Last Exorcism"){ // qDebug() << "hena 2"; QPixmap pix("/home/asmaa/QT/CINAMIKA/The_Last_Exorcism_Poster.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "Get the Gringo"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/Get-the-Gringo_dvd_cover.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "The Lucky One"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/the-lucky-one-movie-poster-nicholas-sparks-novels-and-movies-26608347-268-398.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "Sammy's Adventures: The Secret Passage"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/25773.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "Titanic (in 3D)"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/er.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "StreetDance 3D"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/SD.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "Twilight Saga: Breaking Dawn Part 1"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/TW.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "Gone"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/gone.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "Mission: Impossible Ghost Protocol"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/GT.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "This Means War"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/mw.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "Journey 2: The Mysterious Island"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/JI.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "The Lorax"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/lorax.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "21 Jump Street"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/JS.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "Omar and Salma 3"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/Omar.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } else if(MD[17] == "X Large"){ QPixmap pix("/home/asmaa/QT/CINAMIKA/large.jpg"); ui->pictureLabel->setPixmap(pix); ui->pictureLabel->setScaledContents(true); } }
//void PieceAppearanceWidget::applyCurrentTemplate( QObject * tgt ) void PieceAppearanceWidget::applyCurrentTemplate( QGIPiece * tgt ) { if( !tgt ) return; typedef QList<QGraphicsItem*> QIL; QIL li( impl->gv->scene()->selectedItems() ); impl->pc = 0; // If there are multiple items selected, simply pick the first // selected item which has an associated piece (the order has no // meaning, however). for( QIL::iterator it = li.begin(); li.end() != it; ++it ) { QGIPiece * pvi = dynamic_cast<QGIPiece*>(*it); if( pvi ) { impl->pc = pvi; } } if( ! impl->pc ) return; /** We want to keep certain properties intact: pixmap: b/c the game client normally sets this pos: we don't want to use the template's pos dragDisabled: that property was developed to support this class. The client will almost always expect his pieces to be draggable. */ QVariant pix( tgt->property("pixmap") ); QVariant pos( tgt->property("pos") ); QVariant dragDisabled( tgt->property("dragDisabled") ); { #if 0 QObject * src = impl->pc; typedef QList<QByteArray> QL; QL ql( src->dynamicPropertyNames() ); QL::const_iterator it( ql.begin() ); QL::const_iterator et( ql.end() ); for( ; et != it; ++it ) { char const * key = it->constData(); if( !key || (*key == '_') ) continue; // Qt reserves the "_q_" prefix, so we'll elaborate on that. tgt->setProperty( key, src->property(key) ); } #else S11nNode n; impl->pc->serialize(n); // Lame kludge to ensure that we don't throw // here if tgt is a subclass of QGIType: const QString cn1( S11nNodeTraits::class_name(n).c_str() ); const QString cn2( tgt->s11nClass() ); if( cn1 != cn2 ) { S11nNodeTraits::class_name(n,cn2.toAscii().constData()); } tgt->deserialize(n); #endif } tgt->setProperty("pos", pos ); tgt->setProperty("pixmap", pix ); tgt->setProperty("dragDisabled", dragDisabled ); }
void WidgetMain::initData() { //设置TreeWidget的font大小 { auto font = treeWidget->font(); font.setPixelSize(11); treeWidget->setFont(font); } pushButtonInfor->installEventFilter(this); pDustbin_ = new Label(this);//还可以用他的hover,通过eventfilter pDustbin_->hide(); pBackStart_ = new QLabel(this); pBackStart_->installEventFilter(this); QPixmap pix("./resource/images/bb/JumpToStart_idle.png"); pBackStart_->resize(pix.size()); pBackStart_->setPixmap(pix); { int y = widgetTitle->height()+widgetMenu->height()+10+255; pBackStart_->move(widgetLeft->width()+10, y); } //pBackStart_->setOpacity(0); pBackStart_->hide(); pSerialPortToolLabel_ = new FunctionAreaWidget(this); connect(pSerialPortToolLabel_, SIGNAL(signalClick()), this, SLOT(slotCreateSerialTool())); pSerialPortToolLabel_->addData(QPixmap("./resource/images/tool_area/TopToolBar_Serial.png"), "Serial"); pSerialPortToolLabel_->move(this->width()-200, 31); pSerialPortToolLabel_->show(); { QPixmap pix("./resource/images/tool_area/TopToolBar_del"); pDustbin_->resize(pix.size()); pDustbin_->setPixmap(pix); } labelLogo->installEventFilter(this); pDustbin_->installEventFilter(this); widgetLeft->installEventFilter(this); pAllBlockMenu_ = new QMenu(this); { // 啦拉拉在这里检测所有的模块 QString path = "./resource/Blocks"; QDir dir(path); dir.setFilter(QDir::AllDirs | QDir::NoDotAndDotDot); foreach (const QString &dirName, dir.entryList()) { //ListWidgetItem QString dirPath = path + "/" +dirName; QTreeWidgetItem *pTreeItem = new QTreeWidgetItem(treeWidget, QStringList(dirName)); pTreeItem->setSizeHint(0, QSize(100,20)); pTreeItem->setData(0,Qt::UserRole+1,dirPath); map_treeWidgetItemPointer_pageIndex_.insert(pTreeItem, pageIndex_++); //menu QMenu *pMenu = pAllBlockMenu_->addMenu(dirName); scanBlocks(dirPath, pTreeItem, pMenu); } { //treeWidget->setCurrentIndex(treeWidget->indexAt(QPoint(5, 5))); } } { QPixmap pixNormal("./resource/images/common/Blocks_Begin.png"); QPixmap pixHover("./resource/images/common/Blocks_Begin_p.png"); QPixmap pixPressed("./resource/images/common/Blocks_Begin_o.png"); pixNormal.scaled(QSize(26, 26)); pixHover.scaled(QSize(26, 26)); QListWidgetItem *pItem = new QListWidgetItem(""); pItem->setSizeHint(QSize(38, 38));//26*26 BlockMenuWidget *pWidget = new BlockMenuWidget(pixNormal, pixHover, pixPressed); listWidgetMenu->addItem(pItem); listWidgetMenu->setItemWidget(pItem, pWidget); } { QPixmap pixNormal("./resource/images/common/Blocks_All.png"); QPixmap pixHover("./resource/images/common/Blocks_All_p.png"); QPixmap pixPressed("./resource/images/common/Blocks_All_o.png"); pixNormal.scaled(QSize(26, 26)); pixHover.scaled(QSize(26, 26)); QListWidgetItem *pItem = new QListWidgetItem(""); pItem->setSizeHint(QSize(38, 38)); BlockMenuWidget *pWidget = new BlockMenuWidget(pixNormal, pixHover, pixPressed); listWidgetMenu->addItem(pItem); listWidgetMenu->setItemWidget(pItem, pWidget); } connect(listWidgetMenu, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(slotCurrentItemChanged(QListWidgetItem*,QListWidgetItem*))); pEditScene_ = new EditScene(QRectF(0, 0, 840, 640), widgetShowScene); pEditScene_->setWidgetMain(this); pEditScene_->setComponentData(&hash_blockPath_blockData_); pEditScene_->addModuleTagData(map_moduleName_moduleTag_); widgetShowScene->setScenePointer(pEditScene_ ); // pEditScene_->setListWidgetModulePointer(listWidget); connect(pEditScene_, SIGNAL(signalViewOffset(QPoint)), this, SLOT(slotViewOffset(QPoint))); connect(pEditScene_, SIGNAL(signalShowSubWindows()), this, SLOT(slotShowSubWindows())); connect(pEditScene_, SIGNAL(signalFocusInLine(FlowLine*,QString,QString)), this, SLOT(slotFocusInLine(FlowLine*,QString,QString))); connect(pEditScene_, SIGNAL(signalFocusInGroup(QString)), this, SLOT(slotFocusInGroup(QString))); connect(this, SIGNAL(signalCreateGroup(QString)), pEditScene_, SLOT(slotCreateGroup(QString))); createListWidget(); pListWidget_ = static_cast<ListWidgetAdvanceBlock*>(stackedWidgetBlockType->currentWidget()); QTimer::singleShot(50, this, SLOT(slotOpenAutoUpdate())); }