void trainBackgroundModel(CvCapture* capture) { CvSize frame_size; frame_size.height = (int) cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT ); frame_size.width = (int) cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH ); if(background_model != NULL) delete background_model; background_model = new pixel_data*[frame_size.height]; for(int i = 0; i < frame_size.height; i++) background_model[i] = new pixel_data[frame_size.width]; const char* title = "Training Background Model"; std::vector<const char*> lines; for(int i = 5; i >= 0; i--) { char buffer[400]; sprintf(buffer, "Starting training in %d ...", i); lines.clear(); lines.push_back(buffer); setOptions(title, lines); cvWaitKey(1000); } for(int num_frames = 0; num_frames < NUM_BACKGROUND_TRAINING_FRAMES; num_frames++) { char buffer[400]; sprintf(buffer, "%g%%", ((double)num_frames/NUM_BACKGROUND_TRAINING_FRAMES*100.0)); lines.clear(); lines.push_back(buffer); setOptions(title, lines); /* get a frame */ IplImage* frame = cvQueryFrame( capture ); RgbImage img(frame); for(int i = 0; i < frame->height; i++) { for(int j = 0; j < frame->width; j++) { background_model[i][j].addDataPoint(img[i][j].r, img[i][j].g, img[i][j].b); } } /* always check */ if( !frame ) break; cvShowImage(MAIN_WINDOW, frame); cvWaitKey(10); } lines.push_back("Done"); setOptions(title, lines); cvWaitKey(3000); }
KstCurveDifferentiateI::KstCurveDifferentiateI(QWidget* parent, const char* name, bool modal, WFlags fl) : KstCurveDifferentiate(parent, name, modal, fl) { availableListBox->clear(); selectedListBox->clear(); availableListBox->insertItem(i18n("Line Color")); availableListBox->insertItem(i18n("Point Style")); availableListBox->insertItem(i18n("Line Style")); availableListBox->insertItem(i18n("Line Width")); connect(Cancel_2, SIGNAL(clicked()), this, SLOT(close())); connect(OK_2, SIGNAL(clicked()), this, SLOT(apply())); // more connections to emulate kactionselector behaviour connect(leftButton, SIGNAL(clicked()), this, SLOT(leftButtonClicked())); connect(rightButton, SIGNAL(clicked()), this, SLOT(rightButtonClicked())); connect(upButton, SIGNAL(clicked()), this, SLOT(upButtonClicked())); connect(downButton, SIGNAL(clicked()), this, SLOT(downButtonClicked())); connect(availableListBox, SIGNAL(highlighted(int)), this, SLOT(updateButtons())); connect(selectedListBox, SIGNAL(highlighted(int)), this, SLOT(updateButtons())); maxLineWidth->setMaxValue(KSTLINEWIDTH_MAX); maxLineWidth->setMinValue(1); _radioButtonRepeatPlot->setChecked(true); _radioButtonApplyAllWindows->setChecked(true); loadProperties(); setOptions(); updateCurveDifferentiate(); }
BOOL SettingsDialog::run_dlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM /*lParam*/) { switch(message) { case WM_INITDIALOG: _hSelf = hWnd; initialiseOptions(); return TRUE; case WM_COMMAND: { switch(LOWORD(wParam)) { case IDOK: setOptions(); case IDCANCEL: ::EndDialog(hWnd, 0); } return TRUE; } default: return FALSE; } }
GameMode::GameMode(std::string name, std::string description, std::vector<std::string> options) { setName(name); setDescription(description); setOptions(options); setType("multiChoice"); }
int main(int argc, char *argv[]) { register int n; int Nlambda, result; double *lambda; FILE *fp; /* --- Read input data and initialize -- -------------- */ setOptions(argc, argv); SetFPEtraps(); readInput(); MULTIatmos(&atmos, &geometry); readAtomicModels(); readMolecularModels(); if ((fp = fopen(CONTR_INPUT_FILE, "r")) == NULL) { sprintf(messageStr, "Unable to open inputfile %s", CONTR_INPUT_FILE); Error(ERROR_LEVEL_2, argv[0], messageStr); } result = fscanf(fp, "%d", &Nlambda); lambda = (double *) malloc(Nlambda * sizeof(double)); for (n = 0; n < Nlambda; n++) result = fscanf(fp, "%lf", &lambda[n]); fclose(fp); backgrOpac(Nlambda, lambda); free(lambda); }
bool parseOptions(int ac, char** av, ProgramOptions& options) { po::positional_options_description positional_options; po::options_description desc; positional_options.add("compress", 1); desc.add_options() ("help,h", "this help message") ("output,o", po::value<std::string>(), "for compression: output file (default is 'output.arch'), for extraction: output directory (current directory by default).") ("extract,x", po::value<std::string>(), "extract archive") ("compress", po::value<std::string>(), "compress file or folder"); std::stringstream ss; ss << desc; options.setHelpString(ss.str()); po::variables_map vm; try { po::store( po::command_line_parser(ac, av).options(desc).positional( positional_options).run(), vm); po::notify(vm); return setOptions(vm, options); } catch (std::exception & ex) { std::cerr << ex.what() << std::endl; return false; } }
GeneratedObjectsWizard::GeneratedObjectsWizard( GeneratedObjectsWizardPage * page, QWidget * parent): QWizard(parent), page_(page) { setWindowTitle( tr("Generated") +" "+ page_->objectTypePlural() + " | " + MAIN_WINDOW->windowTitle() ); page_->setTitle(tr("Random generated")+" "+ page_->objectTypePlural() ); page_->setSubTitle( tr( "Change count of generated objects of some kinds and" " confirm the settings. If there is not the object" " you want, try load new object, but remember that" " in this page are viewed only")+" "+ page_->objectTypePlural() +"."); setOptions( QWizard::NoBackButtonOnStartPage | QWizard::HaveCustomButton1); setButtonText(QWizard::CustomButton1, tr("Load new map object")); connect(this, SIGNAL(customButtonClicked(int)), this, SLOT(loadMapObject()) ); addPage(page); connect(this, SIGNAL(accepted()), page, SLOT(setCountInMap()) ); }
void optionInit(int *pArgc, char *argv[], struct optionSpec *optionSpecs) /* Read options in command line into options hash. * Options come in three forms: * -option words starting with dash * option=val words with = in the middle * -option=val combining the two. * The resulting hash will be keyed by the option name with the val * string for value. For '-option' types the value is 'on'. * The words in argv are parsed in assending order. If a word of * "--" is encountered, argument parsing stops. * If optionSpecs is not NULL, it is an array of optionSpec that are * used to validate the options. An option must exist in the array * and the value must be convertable to the type specified in flags. * Boolean options must no value, all other options must have one. * Array is terminated by a optionSpec with a NULL name. * If array NULL, no validation is done. */ { if (options == NULL) { struct hash *hash = parseOptions(pArgc, argv, FALSE, optionSpecs); setOptions(hash); optionSpecification = optionSpecs; } }
PlanetC_VideoPlayer::PlanetC_VideoPlayer(QGraphicsView* p_view) : QMediaPlayer(0, QMediaPlayer::VideoSurface) { posX = 0; posY = 0; sizeW = 100; sizeH = 100; rotationAngle = 0.; //Create a QGraphicsVideoItem object to display the videow video = new QGraphicsVideoItem(); video->setVisible(true); video->setAspectRatioMode(Qt::KeepAspectRatio); //Add QGraphicsVideoItem object to the main scene view = p_view; view->scene()->addItem(video); //Connect the player to the video item setVideoOutput(video); video->setVisible(true); //Once geometry properties are available (width, height) set the GraphicsVideoItem geometry connect(this, SIGNAL(metaDataChanged(QString,QVariant)), this, SLOT(setOptions(QString,QVariant))); }
UIWizard::UIWizard(QWidget *pParent, UIWizardType type, UIWizardMode mode) : QIWithRetranslateUI<QWizard>(pParent) , m_type(type) , m_mode(mode == UIWizardMode_Auto ? loadModeForType(m_type) : mode) { #ifdef Q_WS_WIN /* Hide window icon: */ setWindowIcon(QIcon()); #endif /* Q_WS_WIN */ #ifdef Q_WS_MAC /* Since wizards are now represented as Mac OS X Sheets * we would like to have possibility to cancel them. */ setOption(QWizard::NoCancelButton, false); /* I'm really not sure why there shouldn't be any default button on Mac OS X. * This prevents the using of Enter to jump to the next page. */ setOptions(options() ^ QWizard::NoDefaultButton); #endif /* Q_WS_MAC */ /* All our wizards would like to have window-modality, * Under Mac OS it will be represented as Mac OS Sheet. */ setWindowModality(Qt::WindowModal); /* Setup connections: */ connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(sltCurrentIdChanged(int))); connect(this, SIGNAL(customButtonClicked(int)), this, SLOT(sltCustomButtonClicked(int))); }
void LayerListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyleOptionViewItem opt = setOptions(index, option); painter->save(); const auto &layer = index.data().value<paintcore::LayerInfo>(); const int myId = static_cast<const canvas::LayerListModel*>(index.model())->myId(); if(layer.isLockedFor(myId)) opt.state &= ~QStyle::State_Enabled; drawBackground(painter, option, index); QRect textrect = opt.rect; // Draw layer opacity glyph QRect stylerect(opt.rect.topLeft() + QPoint(0, opt.rect.height()/2-12), QSize(24,24)); drawOpacityGlyph(stylerect, painter, layer.opacity, layer.hidden); // Draw layer name textrect.setLeft(stylerect.right()); QString title; if(m_showNumbers) title = QString("%1 - %2").arg(index.model()->rowCount() - index.row() - 1).arg(layer.title); else title = layer.title; drawDisplay(painter, opt, textrect, title); painter->restore(); }
void SslContext::updateProtocol(int method) { setOptions(SSL_OP_NO_SSLv2); if (!(method & SSL_v3)) setOptions(SSL_OP_NO_SSLv3); if (!(method & SSL_TLSv1)) setOptions(SSL_OP_NO_TLSv1); #ifdef SSL_OP_NO_TLSv1_1 if (!(method & SSL_TLSv11)) setOptions(SSL_OP_NO_TLSv1_1); #endif #ifdef SSL_OP_NO_TLSv1_2 if (!(method & SSL_TLSv12)) setOptions(SSL_OP_NO_TLSv1_2); #endif }
void AVFilterSubtitle::onPlayerStart() { setOptions(QString()); if (!autoLoad()) return; findAndSetFile(m_player->file()); }
/* * Main function */ int main(int argc, char* argv[]) { cout << " Producers-Consumers demo running" << endl << " --------------------------------" << endl << endl; // create an object to store and handle options run_options opt; // default parameters are set here opt.num_of_producers = 10; // threads opt.num_of_consumers = 10; // threads opt.production_duration = 500; // milliseconds opt.consumption_duration = 500; // milliseconds opt.market_buffer_size = 1000; // integers // parse and assign user-defined options (if any) setOptions(argc, argv, &opt); // display options showOptions(&opt); // create an object to simulate the producers-consumers problem Market MyMarket(&opt); // trigger the simulation MyMarket.run(); return 0; }
int main(int argc, char **argv) { // Statup wx wxInitialize(); wxString executable; executable = wxString::FromAscii(argv[0]); if (argc < 2) { usage(executable); return 1; } argc--; argv++; setOptions(argc, argv, executable); if (!runInForeground) daemonize(); MainLoop(); return 0; }
bool Socket::getTCPNoDelay( bool &noDelay ) { bool result; int tcpNoDelay=noDelay; result=setOptions( IPPROTO_TCP, TCP_NODELAY, &tcpNoDelay, sizeof(int)); noDelay=tcpNoDelay ? true : false; return result; }
/*! * Constructor is responsible for allocating memory for all the GUI, * arranging and connecting them in the right order. */ OptionsForm::OptionsForm(QWidget *aParent) : QWidget(aParent) { setWindowTitle(tr("Options")); PASCALpath_ = 0; layout_v_ = new QVBoxLayout(this); layout_PASCAL_root_ = new QHBoxLayout; layout_h_ = new QHBoxLayout; auto_color_generation_box_ = new QCheckBox(this); auto_color_generation_box_->setText(tr("Automatic label color generation")); button_set_PASCAL_root_ = new QPushButton(this); button_set_PASCAL_root_->setText(tr("set PASCAL root path")); edit_PASCAL_root_ = new QLineEdit("", this); edit_PASCAL_root_->setMinimumWidth(180); button_ok_ = new QPushButton(this); button_ok_->setText(tr("OK")); button_cancel_ = new QPushButton(this); button_cancel_->setText(tr("Cancel")); layout_v_->addWidget(auto_color_generation_box_); layout_v_->addLayout(layout_PASCAL_root_); layout_v_->addLayout(layout_h_); layout_PASCAL_root_->addWidget(button_set_PASCAL_root_); layout_PASCAL_root_->addWidget(edit_PASCAL_root_); layout_h_->addWidget(button_ok_); layout_h_->addWidget(button_cancel_); connect( button_set_PASCAL_root_, SIGNAL(clicked()), this, SLOT(newPascalPath()) ); connect( button_ok_, SIGNAL(clicked()), this, SLOT(setOptions()) ); connect( button_cancel_, SIGNAL(clicked()), this, SLOT(hide()) ); connect( edit_PASCAL_root_, SIGNAL(editingFinished()), this, SLOT(onPathEditing()) ); /* moving it to the center of the screen */ move(QApplication::desktop()->screen()->rect().center() - rect().center()); }
void LayerListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyleOptionViewItem opt = setOptions(index, option); painter->save(); drawBackground(painter, option, index); QRect textrect = opt.rect; const net::LayerListItem &layer = index.data().value<net::LayerListItem>(); const QSize locksize = _lockicon.size(); // Draw layer opacity glyph QRect stylerect(opt.rect.topLeft() + QPoint(0, opt.rect.height()/2-12), QSize(24,24)); drawOpacityGlyph(stylerect, painter, layer.opacity, layer.hidden); // Draw layer name textrect.setLeft(stylerect.right()); textrect.setWidth(textrect.width() - locksize.width()); drawDisplay(painter, opt, textrect, layer.title); // Draw lock button if(layer.isLockedFor(_client->myId())) painter->drawPixmap( opt.rect.topRight()-QPoint(locksize.width(), -opt.rect.height()/2+locksize.height()/2), _lockicon ); painter->restore(); }
static MRESULT EXPENTRY procOpts(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { ULONG ret ; switch (msg) { case WM_INITDLG : if (SessDlgCenter) { dialogAtCenter(hwnd) ; } else { dialogAtMouse(hwnd, DID_OK) ; } setOptions(hwnd) ; return (MRESULT) 0 ; case WM_COMMAND : switch (ret = SHORT1FROMMP(mp1)) { case DID_OK : case DID_CANCEL : if (getOptions(hwnd) != TRUE) { return (MRESULT) 0 ; } saveParam() ; WinDismissDlg(hwnd, ret) ; return (MRESULT) 0 ; default : return (MRESULT) 0 ; } } return WinDefDlgProc(hwnd, msg, mp1, mp2) ; }
void ToolConfig::setupGeneral() { m_configWidget->m_stackBasic->insertWidget(GBS_None, new QLabel(i18n("Use the \"Advanced\" tab to configure this tool."), this)); m_ptcw = new ProcessToolConfigWidget(m_configWidget->m_stackBasic); m_configWidget->m_stackBasic->insertWidget(GBS_Process, m_ptcw); connect(m_ptcw->m_command, SIGNAL(textChanged(const QString &)), this, SLOT(setCommand(const QString &))); connect(m_ptcw->m_options, SIGNAL(textChanged()), this, SLOT(setOptions())); m_ltcw = new LibraryToolConfigWidget(m_configWidget->m_stackBasic); m_configWidget->m_stackBasic->insertWidget(GBS_Library, m_ltcw); connect(m_ltcw->m_library, SIGNAL(textChanged(const QString &)), this, SLOT(setLibrary(const QString &))); connect(m_ltcw->m_class, SIGNAL(textChanged(const QString &)), this, SLOT(setClassName(const QString &))); connect(m_ltcw->m_options, SIGNAL(textChanged(const QString &)), this, SLOT(setLibOptions(const QString &))); m_qtcw = new QuickToolConfigWidget(m_configWidget->m_stackBasic); m_configWidget->m_stackBasic->insertWidget(GBS_Sequence, m_qtcw); connect(m_qtcw, SIGNAL(sequenceChanged(const QString &)), this, SLOT(setSequence(const QString &))); m_configWidget->m_stackBasic->insertWidget(GBS_Error, new QLabel(i18n("Unknown tool type; your configuration data is malformed.\nPerhaps it is a good idea to restore the default settings."), this)); m_configWidget->m_stackExtra->insertWidget(GES_None, new QWidget(this)); m_LaTeXtcw = new LaTeXToolConfigWidget(m_configWidget->m_stackExtra); m_configWidget->m_stackExtra->insertWidget(GES_LaTeX, m_LaTeXtcw); connect(m_LaTeXtcw->m_ckRootDoc, SIGNAL(toggled(bool)), this, SLOT(setLaTeXCheckRoot(bool))); connect(m_LaTeXtcw->m_ckJump, SIGNAL(toggled(bool)), this, SLOT(setLaTeXJump(bool))); connect(m_LaTeXtcw->m_ckAutoRun, SIGNAL(toggled(bool)), this, SLOT(setLaTeXAuto(bool))); }
AddFeedWizard::AddFeedWizard(QWidget *parent, int curFolderId) : QWizard(parent), curFolderId_(curFolderId) { setWindowFlags (windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowTitle(tr("Add Feed")); setWizardStyle(QWizard::ModernStyle); setOptions(QWizard::HaveFinishButtonOnEarlyPages | QWizard::NoBackButtonOnStartPage); addPage(createUrlFeedPage()); addPage(createNameFeedPage()); updateFeeds_ = new UpdateFeeds(this, true); connect(button(QWizard::BackButton), SIGNAL(clicked()), this, SLOT(backButtonClicked())); connect(button(QWizard::NextButton), SIGNAL(clicked()), this, SLOT(nextButtonClicked())); connect(button(QWizard::FinishButton), SIGNAL(clicked()), this, SLOT(finishButtonClicked())); connect(this, SIGNAL(currentIdChanged(int)), SLOT(slotCurrentIdChanged(int)), Qt::QueuedConnection); resize(400, 300); Settings settings; restoreGeometry(settings.value("addFeedWizard/geometry").toByteArray()); }
bool storePair(Options& opts, bool allow_long, bool allow_short, const string& name, const string& value) { bool found = false; Options::NamesMap::iterator opt_it; if (allow_long) { opt_it = opts.opt_long_map.find(name); if (opt_it != opts.opt_long_map.end()) { found = true; } } /* check for the short list */ if (allow_short && !(found && allow_long)) { opt_it = opts.opt_short_map.find(name); if (opt_it != opts.opt_short_map.end()) { found = true; } } if (!found) { /* not found */ cerr << "Unknown option: `" << name << "' (value:`" << value << "')" << endl; return false; } setOptions((*opt_it).second, value); return true; }
void DelegateInfoCheckBox::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if(index.column() == 0){ QColor color(51,51,51); QColor background(0xDA,0xDA,0xDA); QStyleOptionViewItemV2 opt = setOptions(index, option); opt.displayAlignment = Qt::AlignLeft | Qt::AlignVCenter; opt.palette.setColor(QPalette::Text,color); opt.font.setBold(true); painter->fillRect(option.rect,background); painter->setBackground(background); QItemDelegate::paint(painter, opt, index); }else if(index.column() == 1){ bool checked = index.model()->data(index, Qt::DisplayRole).toBool(); QStyleOptionButton check_box_style_option; check_box_style_option.state |= QStyle::State_Enabled; if (checked) { check_box_style_option.state |= QStyle::State_On; } else { check_box_style_option.state |= QStyle::State_Off; } check_box_style_option.rect = CheckBoxRect(option); QApplication::style()->drawControl(QStyle::CE_CheckBox,&check_box_style_option,painter); } }
int Semantic::schaum_or(String &andor, Array<List<Semantic * > > &asubc, Array<List<Semantic * > > &asubx, const String &rtype) const { // set and/or string andor = SCHAUM_OR_ANDOR; // set size of arrays asubx.setSize(arraysz(prog2)); asubc.setSize(arraysz(prog2)); // copy records Semantic *pA = new Semantic(*left); MustBeTrue(pA != NULL); Semantic *pB = new Semantic(*right); MustBeTrue(pB != NULL); Semantic *pc = new Semantic(*this); MustBeTrue(pc != NULL); // store conclusion data asubx[prog0].clear(); MustBeTrue(asubc[prog0].insertAtEnd(pA) == OK); asubx[prog1].clear(); MustBeTrue(asubc[prog1].insertAtEnd(pB) == OK); asubx[prog2].clear(); MustBeTrue(asubc[prog2].insertAtEnd(pc) == OK); // set options in conclusion list setOptions(asubc); // all done return(OK); }
QIWizard::QIWizard(QWidget *pParent) : QIWithRetranslateUI<QWizard>(pParent) { #ifdef Q_WS_MAC /* I'm really not sure why there shouldn't be any default button on Mac OS * X. This prevents the using of Enter to jump to the next page. */ setOptions(options() ^ QWizard::NoDefaultButton); #endif /* Q_WS_MAC */ }
void Font::popOptions() { if(!optionsStack.empty()) { setOptions(optionsStack.top()); optionsStack.pop(); } }
void NativeOptionDialogObject::setSelectedIndex(int index) { selectedIndex_ = index; if(buttonNames_.length() > 0) { setOptions(buttonNames_); } }
static jdwpTransportError JNICALL socketTransport_startListening(jdwpTransportEnv* env, const char* address, char** actualAddress) { struct sockaddr_in sa; int err; memset((void *)&sa,0,sizeof(struct sockaddr_in)); sa.sin_family = AF_INET; /* no address provided */ if ((address == NULL) || (address[0] == '\0')) { address = "0"; } err = parseAddress(address, &sa, INADDR_ANY); if (err != JDWPTRANSPORT_ERROR_NONE) { return err; } serverSocketFD = dbgsysSocket(AF_INET, SOCK_STREAM, 0); if (serverSocketFD < 0) { RETURN_IO_ERROR("socket creation failed"); } err = setOptions(serverSocketFD); if (err) { return err; } err = dbgsysBind(serverSocketFD, (struct sockaddr *)&sa, sizeof(sa)); if (err < 0) { RETURN_IO_ERROR("bind failed"); } err = dbgsysListen(serverSocketFD, 1); if (err < 0) { RETURN_IO_ERROR("listen failed"); } { char buf[20]; int len = sizeof(sa); jint portNum; err = dbgsysGetSocketName(serverSocketFD, (struct sockaddr *)&sa, &len); portNum = dbgsysNetworkToHostShort(sa.sin_port); sprintf(buf, "%d", portNum); *actualAddress = (*callback->alloc)((int)strlen(buf) + 1); if (*actualAddress == NULL) { RETURN_ERROR(JDWPTRANSPORT_ERROR_OUT_OF_MEMORY, "out of memory"); } else { strcpy(*actualAddress, buf); } } return JDWPTRANSPORT_ERROR_NONE; }
TextOutput::TextOutput(const TextOutput::Settings& opt) : startingNewLine(true), currentColumn(0), inDQuote(false), filename(""), indentLevel(0) { setOptions(opt); }
void PlanetC_VideoPlayer::setGeometry(float posX, float posY, float sizeW, float sizeH) { //Save input values into private state if(posX >= 0) this->posX = posX; if(posY >= 0) this->posY = posY; if(sizeW >= 0) this->sizeW = sizeW; if(sizeH >= 0) this->sizeH = sizeH; setOptions(); }