Пример #1
0
FaxGenerator::FaxGenerator( QObject *parent, const QVariantList &args )
    : Generator( parent, args )
{
    setFeature( Threaded );
    setFeature( PrintNative );
    setFeature( PrintToFile );
}
Пример #2
0
    AbstractXULParser::AbstractXULParser() :
        mIgnores(0),
        mLanguage("en")
    {
        setFeature(FEATURE_EXTERNAL_GENERAL_ENTITIES, true);
        setFeature(FEATURE_EXTERNAL_PARAMETER_ENTITIES, true);

        setContentHandler(this);
        setEntityResolver(this);
    }
Пример #3
0
DviGenerator::DviGenerator( QObject *parent, const QVariantList &args ) : Okular::Generator( parent, args ),
  m_fontExtracted( false ), m_docInfo( 0 ), m_docSynopsis( 0 ), m_dviRenderer( 0 )
{
    setFeature( Threaded );
    setFeature( TextExtraction );
    setFeature( FontInfo );
    setFeature( PrintPostscript );
    if ( Okular::FilePrinter::ps2pdfAvailable() )
        setFeature( PrintToFile );
}
Пример #4
0
DjVuGenerator::DjVuGenerator( QObject *parent, const QVariantList &args )
    : Okular::Generator( parent, args ), m_docInfo( 0 ), m_docSyn( 0 )
{
    setFeature( TextExtraction );
    setFeature( Threaded );
    setFeature( PrintPostscript );
    if ( Okular::FilePrinter::ps2pdfAvailable() )
        setFeature( PrintToFile );

    m_djvu = new KDjVu();
    m_djvu->setCacheEnabled( false );
}
Пример #5
0
GeometryRenderer::GeometryRenderer()
    : g(NULL)
    , features_(kVBO|kIBO|kVAO|kMapBuffer)
    , vbo_size(0)
    , ibo_size(0)
    , ibo(QOpenGLBuffer::IndexBuffer)
    , stride(0)
{
    static bool disable_ibo = qgetenv("QTAV_NO_IBO").toInt() > 0;
    setFeature(kIBO, !disable_ibo);
    static bool disable_vbo = qgetenv("QTAV_NO_VBO").toInt() > 0;
    setFeature(kVBO, !disable_vbo);
    static bool disable_vao = qgetenv("QTAV_NO_VAO").toInt() > 0;
    setFeature(kVAO, !disable_vao);
}
Пример #6
0
QgsAttributeForm::QgsAttributeForm( QgsVectorLayer* vl, const QgsFeature &feature, const QgsAttributeEditorContext &context, QWidget* parent )
    : QWidget( parent )
    , mLayer( vl )
    , mContext( context )
    , mButtonBox( nullptr )
    , mFormNr( sFormCounter++ )
    , mIsSaving( false )
    , mIsAddDialog( false )
    , mPreventFeatureRefresh( false )
    , mEditCommandMessage( tr( "Attributes changed" ) )
{
  init();
  initPython();
  setFeature( feature );

  // Using attributeAdded() attributeDeleted() are not emitted on all fields changes (e.g. layer fields changed,
  // joined fields changed) -> use updatedFields() instead
#if 0
  connect( vl, SIGNAL( attributeAdded( int ) ), this, SLOT( onAttributeAdded( int ) ) );
  connect( vl, SIGNAL( attributeDeleted( int ) ), this, SLOT( onAttributeDeleted( int ) ) );
#endif
  connect( vl, SIGNAL( updatedFields() ), this, SLOT( onUpdatedFields() ) );
  connect( vl, SIGNAL( beforeAddingExpressionField( QString ) ), this, SLOT( preventFeatureRefresh() ) );
  connect( vl, SIGNAL( beforeRemovingExpressionField( int ) ), this, SLOT( preventFeatureRefresh() ) );
}
Пример #7
0
void Database_Privileges::load (string username, const string & data)
{
  // Clear all data for the user.
  {
    SqliteDatabase sql (database ());
    sql.add ("DELETE FROM bibles WHERE username ="******";");
    sql.execute ();
    sql.clear ();
    sql.add ("DELETE FROM features WHERE username ="******";");
    sql.execute ();
  }

  vector <string> lines = filter_string_explode (data, '\n');
  bool loading_bibles = false;
  string bible_value;
  int book_value = 0;
  bool write_value = false;
  bool loading_features = false;
  int counter = 0;

  for (auto & line : lines) {

    if (line == bibles_end ()) {
      loading_bibles = false;
    }
    if (line == features_end ()) {
      loading_features = false;
    }
  
    counter++;
    
    if (loading_bibles) {
      if (counter == 1) bible_value = line;
      if (counter == 2) book_value = convert_to_int (line);
      if (counter == 3) {
        write_value = (line == on ());
        setBibleBook (username, bible_value, book_value, write_value);
        counter = 0;
      }
    }
    
    if (loading_features) {
      setFeature (username, convert_to_int (line), true);
    }
    
    if (line == bibles_start ()) {
      loading_bibles = true;
      counter = 0;
    }
    if (line == features_start ()) {
      loading_features = true;
      counter = 0;
    }
    
  }
}
void QgsValueRelationWidgetWrapper::initWidget( QWidget *editor )
{

  mComboBox = qobject_cast<QComboBox *>( editor );
  mTableWidget = qobject_cast<QTableWidget *>( editor );
  mLineEdit = qobject_cast<QLineEdit *>( editor );

  // Read current initial form values from the editor context
  setFeature( context().formFeature() );

  if ( mComboBox )
  {
    connect( mComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
             this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ), Qt::UniqueConnection );
  }
  else if ( mTableWidget )
  {
    mTableWidget->horizontalHeader()->setResizeMode( QHeaderView::Stretch );
    mTableWidget->horizontalHeader()->setVisible( false );
    mTableWidget->verticalHeader()->setResizeMode( QHeaderView::Stretch );
    mTableWidget->verticalHeader()->setVisible( false );
    mTableWidget->setShowGrid( false );
    mTableWidget->setEditTriggers( QAbstractItemView::NoEditTriggers );
    mTableWidget->setSelectionMode( QAbstractItemView::NoSelection );
    connect( mTableWidget, &QTableWidget::itemChanged, this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ), Qt::UniqueConnection );
  }
  else if ( mLineEdit )
  {
    connect( mLineEdit, &QLineEdit::textChanged, this, [ = ]( const QString & value ) { emit valueChanged( value ); }, Qt::UniqueConnection );
  }
}
Пример #9
0
bool QUsbHid::setFeature(int reportID, const QByteArray& arr)
{
    QByteArray x;
    x.append(char(reportID));
    x.append(arr);
    return setFeature(x);
}
Пример #10
0
void FWCamera::startCapture()
{
#ifdef AVG_ENABLE_1394_2
    int err = dc1394_video_set_transmission(m_pCamera, DC1394_ON);
    AVG_ASSERT(err == DC1394_SUCCESS);

    dc1394switch_t status = DC1394_OFF;

    int i = 0;
    while (status == DC1394_OFF && i++ < 5) {
        usleep(50000);
        err = dc1394_video_get_transmission(m_pCamera, &status);
        AVG_ASSERT(err == DC1394_SUCCESS);
    }

    if (i == 5) {
        AVG_ASSERT(false);
    }
    // Default to turning off any camera sharpness manipulation.
    setFeature(CAM_FEATURE_SHARPNESS, 0);

    // Turn off possible auto exposure.
    dc1394_feature_set_mode(m_pCamera, DC1394_FEATURE_EXPOSURE, 
            DC1394_FEATURE_MODE_MANUAL);
    dc1394_feature_set_power(m_pCamera, DC1394_FEATURE_EXPOSURE, DC1394_OFF);

    AVG_TRACE(Logger::category::CONFIG, Logger::severity::INFO, "Firewire camera opened.");
    for (FeatureMap::iterator it=m_Features.begin(); it != m_Features.end(); it++) {
        setFeature(it->first, it->second, true);
    }
    setWhitebalance(m_WhitebalanceU, m_WhitebalanceV, true);
    
    if (getCamPF() == BAYER8) {
        if (strcmp(m_pCamera->model, "DFx 31BF03") == 0) {
            AVG_TRACE(Logger::category::CONFIG, Logger::severity::INFO,
                    "Applying bayer pattern fixup for IS DFx31BF03 camera");
            setCamPF(BAYER8_GRBG);
        } else if (strcmp(m_pCamera->vendor, "Point Grey Research") == 0) {
            AVG_TRACE(Logger::category::CONFIG, Logger::severity::INFO,
                    "Applying bayer pattern fixup for PointGrey cameras");
            enablePtGreyBayer();
        }
    }
#endif
}
Пример #11
0
CHMGenerator::CHMGenerator( QObject *parent, const QVariantList &args )
    : Okular::Generator( parent, args )
{
    setFeature( TextExtraction );

    m_syncGen=0;
    m_file=0;
    m_pixmapRequestZoom=1;
    m_request = 0;
}
Пример #12
0
vector<double> DataSet::convertTo1OfK(const vector<double>& features) const {
   int i = 0;
   vector<double> oneOfK = vector<double>(17, 0);

   for (auto feature = features.begin(); feature != features.end(); ++feature) {
       setFeature(oneOfK, static_cast<int>(*feature), i);
       ++i;
   }
   return oneOfK;
}
Пример #13
0
Static void setName(void)
{
  short i, FORLIM;

  if (!redefined[(long)name])
    return;
  setFeature("instrumentNames", true);
  FORLIM = ninstr;
  for (i = 0; i <= FORLIM - 1; i++) {
    GetNextWord(instr_name[i], cline[(long)name], blank_, dummy);
/* p2c: preamble.pas, line 226:
 * Note: Possible string truncation in assignment [145] */
  }
}
Пример #14
0
Static void doEnable(Char *line, boolean choice)
{
  Char word[256];
  Char STR1[256];

  do {
    GetNextWord(word, line, blank_, dummy);
    if (*word != '\0') {
      if (!setFeature(word, choice)) {
	sprintf(STR1, "No such feature: %s", word);
	error(STR1, !print);
      }
    }
  } while (*word != '\0');
}
Пример #15
0
QgsAttributeForm::QgsAttributeForm( QgsVectorLayer* vl, const QgsFeature feature, QgsAttributeEditorContext context, QWidget* parent )
    : QWidget( parent )
    , mLayer( vl )
    , mContext( context )
    , mFormNr( sFormCounter++ )
    , mIsSaving( false )
    , mIsAddDialog( false )
    , mEditCommandMessage( tr( "Attributes changed" ) )
{
  init();
  initPython();
  setFeature( feature );

  connect( vl, SIGNAL( attributeAdded( int ) ), this, SLOT( onAttributeAdded( int ) ) );
  connect( vl, SIGNAL( attributeDeleted( int ) ), this, SLOT( onAttributeDeleted( int ) ) );
}
Пример #16
0
SessionImpl::SessionImpl(const std::string& connect,
	Poco::Any maxFieldSize,
	bool enforceCapability,
	bool autoBind,
	bool autoExtract): Poco::Data::AbstractSessionImpl<SessionImpl>(connect),
		_connector(Connector::KEY),
		_maxFieldSize(maxFieldSize),
		_autoBind(autoBind),
		_autoExtract(autoExtract),
		_canTransact(ODBC_TXN_CAPABILITY_UNKNOWN),
		_inTransaction(false),
		_queryTimeout(-1)
{
	setFeature("bulk", true);
	open();
	setProperty("handle", _db.handle());
}
InputMatrix::InputMatrix(std::istream& input)
{
    START_COLLECT_TIME(readingInput, Counters::ReadingInput);
    input >> _rowsCount;

    input >> _qColsCount;
    _qMatrix = new int[_rowsCount * _qColsCount];
    _qMinimum = new int[_qColsCount];
    _qMaximum = new int[_qColsCount];
    for(auto j=0; j<_qColsCount; ++j) {
        _qMinimum[j] = DASH;
        _qMaximum[j] = DASH;
    }
    for(auto i=0; i<_rowsCount; ++i) {
        for(auto j=0; j<_qColsCount; ++j) {
            auto value = parseValue(input);
            setFeature(i, j, value);
            if (value != DASH) {
                if (_qMinimum[j] == DASH || value < _qMinimum[j])
                    _qMinimum[j] = value;
                if (_qMaximum[j] == DASH || _qMaximum[j] < value)
                    _qMaximum[j] = value;
            }
        }
    }
    
    input >> _rColsCount;
    _rMatrix = new int[_rowsCount * _rColsCount];
    for(auto i=0; i<_rowsCount; ++i) {
        for(auto j=0; j<_rColsCount; ++j) {
            setImage(i, j, parseValue(input));
        }
    }
    
    _r2Matrix = new int[_rowsCount];
    STOP_COLLECT_TIME(readingInput);

    START_COLLECT_TIME(preparingInput, Counters::PreparingInput);
    calcR2Matrix();
    sortMatrix();
    calcR2Indexes();
    STOP_COLLECT_TIME(preparingInput);
}
Пример #18
0
void FWCamera::setFeature(CameraFeature feature, int value, bool bIgnoreOldValue)
{
#ifdef AVG_ENABLE_1394_2
    if (hasFeature(feature)) { 
        if (bIgnoreOldValue || m_Features[feature] != value) {
            m_Features[feature] = value;
            if (feature == CAM_FEATURE_STROBE_DURATION) {
                try {
                    setStrobeDuration(value);
                } catch (Exception& e) {
                    AVG_LOG_WARNING(string("Camera: Setting strobe duration failed. ") + 
                            e.getStr());
                }
            } else {
                dc1394feature_t featureID = getFeatureID(feature);
                setFeature(featureID, value);
                //        dumpCameraInfo();
            }
        }
    }
#endif
}
Пример #19
0
void tst_QDockWidget::features()
{
    QDockWidget dw;

    QSignalSpy spy(&dw, SIGNAL(featuresChanged(QDockWidget::DockWidgetFeatures)));

    // default features for dock widgets
    int allDockWidgetFeatures = QDockWidget::DockWidgetClosable |
                                QDockWidget::DockWidgetMovable  |
                                QDockWidget::DockWidgetFloatable;

    // defaults
    QCOMPARE(dw.features(), allDockWidgetFeatures);
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));

    // test individual setting
    setFeature(&dw, QDockWidget::DockWidgetClosable, false);
    QCOMPARE(dw.features(), QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
    QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetClosable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
    QCOMPARE(spy.count(), 1);
    QCOMPARE((int)*(static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData())),
            (int)dw.features());
    spy.clear();
    dw.setFeatures(dw.features());
    QCOMPARE(spy.count(), 0);
    spy.clear();

    setFeature(&dw, QDockWidget::DockWidgetClosable);
    QCOMPARE(dw.features(), allDockWidgetFeatures);
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
    QCOMPARE(spy.count(), 1);
    QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
            (int)dw.features());
    spy.clear();
    dw.setFeatures(dw.features());
    QCOMPARE(spy.count(), 0);
    spy.clear();

    setFeature(&dw, QDockWidget::DockWidgetMovable, false);
    QCOMPARE(dw.features(), QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable);
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
    QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetMovable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
    QCOMPARE(spy.count(), 1);
    QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
            (int)dw.features());
    spy.clear();
    dw.setFeatures(dw.features());
    QCOMPARE(spy.count(), 0);
    spy.clear();

    setFeature(&dw, QDockWidget::DockWidgetMovable);
    QCOMPARE(dw.features(), allDockWidgetFeatures);
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
    QCOMPARE(spy.count(), 1);
    QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
            (int)dw.features());
    spy.clear();
    dw.setFeatures(dw.features());
    QCOMPARE(spy.count(), 0);
    spy.clear();

    setFeature(&dw, QDockWidget::DockWidgetFloatable, false);
    QCOMPARE(dw.features(), QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
    QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable));
    QCOMPARE(spy.count(), 1);
    QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
            (int)dw.features());
    spy.clear();
    dw.setFeatures(dw.features());
    QCOMPARE(spy.count(), 0);
    spy.clear();

    setFeature(&dw, QDockWidget::DockWidgetFloatable);
    QCOMPARE(dw.features(), allDockWidgetFeatures);
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
    QCOMPARE(spy.count(), 1);
    QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
            (int)dw.features());
    spy.clear();
    dw.setFeatures(dw.features());
    QCOMPARE(spy.count(), 0);
    spy.clear();

    // set all at once
    dw.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
    QCOMPARE(dw.features(), QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
    QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable));
    QCOMPARE(spy.count(), 1);
    QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
            (int)dw.features());
    spy.clear();
    dw.setFeatures(dw.features());
    QCOMPARE(spy.count(), 0);
    spy.clear();

    dw.setFeatures(QDockWidget::DockWidgetClosable);
    QCOMPARE(dw.features(), QDockWidget::DockWidgetClosable);
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
    QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetMovable));
    QVERIFY(!hasFeature(&dw, QDockWidget::DockWidgetFloatable));
    QCOMPARE(spy.count(), 1);
    QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
            (int)dw.features());
    spy.clear();
    dw.setFeatures(dw.features());
    QCOMPARE(spy.count(), 0);
    spy.clear();

    dw.setFeatures(QDockWidget::AllDockWidgetFeatures);
    QCOMPARE(dw.features(), QDockWidget::AllDockWidgetFeatures);
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetClosable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetMovable));
    QVERIFY(hasFeature(&dw, QDockWidget::DockWidgetFloatable));
    QCOMPARE(spy.count(), 1);
    QCOMPARE((int)*static_cast<const QDockWidget::DockWidgetFeature *>(spy.at(0).value(0).constData()),
            (int)dw.features());
    spy.clear();
    dw.setFeatures(dw.features());
    QCOMPARE(spy.count(), 0);
    spy.clear();
}
Пример #20
0
InstancePtr FeatureExtractor::extract(const Observation &obs, FeatureExtractorHistory &history) {
  TIC(total);
  assert(obs.preyInd == 0);
  InstancePtr instance(new Instance);
  
  TIC(pos);
  setFeature(instance,FeatureType::PredInd,obs.myInd - 1);
  // positions of agents
  for (unsigned int i = 0; i < obs.positions.size(); i++) {
    Point2D diff = getDifferenceToPoint(dims,obs.myPos(),obs.positions[i]);
    unsigned int key = FeatureType::Prey_dx + 2 * i;
    setFeature(instance,key,diff.x);
    setFeature(instance,key+1,diff.y);
  }
  TOC(pos);
  // derived features
  TIC(derived);
  bool next2prey = false;
  for (unsigned int a = 0; a < Action::NUM_NEIGHBORS; a++) {
    Point2D pos = movePosition(dims,obs.myPos(),(Action::Type)a);
    bool occupied = false;
    for (unsigned int i = 0; i < obs.positions.size(); i++) {
      if (i == obs.myInd)
        continue;
      if (obs.positions[i] == pos) {
        occupied = true;
        if (i == 0)
          next2prey = true;
        break;
      }
    }
    setFeature(instance,FeatureType::Occupied_0 + a, occupied);
  }
  setFeature(instance,FeatureType::NextToPrey,next2prey);
  TOC(derived);
  // actions predicted by models
  TIC(actions);
  // not currently supported
  //ActionProbs actionProbs;
  for (std::vector<FeatureAgent>::iterator it = featureAgents.begin(); it != featureAgents.end(); it++) {
    std::cerr << "FeatureExtractor can't handle featureAgents" << std::endl;
    exit(58);
    //actionProbs = it->agent->step(obs);
    //ADD_KEY(it->name + ".des");
    //setFeature(instance,actionProbs.maxAction());
  }
  TOC(actions);
  // update the history
  TIC(history);
  updateHistory(obs,history);
  // add the history features
  TIC(historyupdate);
  Action::Type action;
  for (unsigned int j = 0; j < HISTORY_SIZE; j++) {
    if (j < history.actionHistory[obs.myInd].size())
      action = history.actionHistory[obs.myInd][j];
    else
      action = Action::NUM_ACTIONS;
    setFeature(instance,FeatureType::MyHistoricalAction_0 + j,action);
  }
  TOC(historyupdate);
/*
  for (unsigned int agentInd = 0; agentInd < obs.positions.size(); agentInd++) {
    for (unsigned int j = 0; j < HISTORY_SIZE; j++) {
      if (j < history.actionHistory[agentInd].size())
        action = history.actionHistory[agentInd][j];
      else
        action = Action::NUM_ACTIONS;
      if (USE_ALL_AGENTS_HISTORY) {
        std::cerr << "FeatureExtractor can't handle all agents history" << std::endl;
        exit(58);
        //ADD_KEY("HistoricalAction" + boost::lexical_cast<std::string>(agentInd) + "." + boost::lexical_cast<std::string>(j));
        //setFeature(instance,action);
      }

      if (agentInd == obs.myInd) {
        setFeature(instance,FeatureType::MyHistoricalAction_0 + j,action);
      }

    }
  }
*/
  TOC(history);

  instance->weight = 1.0;
  TOC(total);
  //std::cout << "instance: " << *instance << std::endl;
  return instance;
}
Пример #21
0
void AgiEngine::parseFeatures() {

    /* FIXME: Seems this method doesn't really do anything. It might
       be a leftover that could be removed, except that some of its
       intended purpose may still need to be reimplemented.

    [0:29] <Fingolfin> can you tell me what the point behind AgiEngine::parseFeatures() is?
    [0:30] <_sev> when games are created with WAGI studio
    [0:31] <_sev> it creates .wag site with game-specific features such as full game title, whether to use AGIMOUSE etc
    [0:32] <Fingolfin> ... and the "features" config key is created by our detector based on the wag file, I guess?
    [0:33] <_sev> yes
    [0:33] <Fingolfin> it's just that I cant seem to find a place we do that
    [0:33] <_sev> it is used for fallback
    [0:34] <_sev> ah, perhaps it was not updated
    [0:34] <Fingolfin> I only see us check the value, but never set it
    [0:34] <Fingolfin> maybe I am grepping wrong, who knows :)
    [0:44] <Fingolfin> _sev: so, unless I miss something, it seem that function does nothing right now
    [0:45] <_sev> Fingolfin: it could be unfinished. It was part of GSoC 3 years ago
    [0:45] <Fingolfin> well
    [0:45] <_sev> I just don't remember
    [0:45] <Fingolfin> but don't we just re-parse the wag when the game is loaded anyway?
    [0:45] <_sev> but it documents the format
    [0:45] <Fingolfin> the advanced meta engine would re-run the detector, wouldn't it?
    [0:45] <_sev> yep
    [0:47] <Fingolfin> so... shouldn't we at least add a comment to the function explaining what it does and that it's unfinished etc.? maybe add a TODO to the wiki?
    [0:47] <Fingolfin> otherwise it might stay as it is for another 3 years :)
    */

    if (!ConfMan.hasKey("features"))
        return;

    char *features = strdup(ConfMan.get("features").c_str());
    const char *feature[100];
    int numFeatures = 0;

    char *tok = strtok(features, " ");
    if (tok) {
        do {
            feature[numFeatures++] = tok;
        } while ((tok = strtok(NULL, " ")) != NULL);
    } else {
        feature[numFeatures++] = features;
    }

    const struct Flags {
        const char *name;
        uint32 flag;
    } flags[] = {
        { "agimouse", GF_AGIMOUSE },
        { "agds", GF_AGDS },
        { "agi256", GF_AGI256 },
        { "agi256-2", GF_AGI256_2 },
        { "agipal", GF_AGIPAL },
        { 0, 0 }
    };

    for (int i = 0; i < numFeatures; i++) {
        for (const Flags *flag = flags; flag->name; flag++) {
            if (!scumm_stricmp(feature[i], flag->name)) {
                debug(2, "Added feature: %s", flag->name);

                setFeature(flag->flag);
                break;
            }
        }
    }

    free(features);
}
Пример #22
0
CMUCamera::CMUCamera(long long guid, bool bFW800, IntPoint size, 
        PixelFormat camPF, PixelFormat destPF, float frameRate)
    : Camera(camPF, destPF, size, frameRate),
      m_WhitebalanceU(-1),
      m_WhitebalanceV(-1),
      m_pCamera(0)
{
    m_pCamera = new C1394Camera();
    int err;
    unsigned long videoFormat, videoMode;
    getVideoFormatAndMode(getImgSize(), getCamPF(), &videoFormat, &videoMode);

    // Find and open camera
    if (m_pCamera->RefreshCameraList() <= 0) {
        throw Exception(AVG_ERR_CAMERA_NONFATAL, "No Firewire cameras found");
    }
    int i = getCamIndex(guid);
    err = m_pCamera->SelectCamera(i);
    err = m_pCamera->InitCamera(TRUE);
    AVG_ASSERT(err == CAM_SUCCESS);

    if (bFW800) {
        m_pCamera->Set1394b(true);
    }

    // Setup video format and rate
    err = m_pCamera->SetVideoFormat(videoFormat);
    checkCMUError(err, AVG_ERR_CAMERA_NONFATAL,
            string("CMUCamera: Error setting video format ") + toString(videoFormat) + 
            ", mode: " + toString(videoMode));
    err = m_pCamera->SetVideoMode(videoMode);
    checkCMUError(err, AVG_ERR_CAMERA_NONFATAL,
            string("CMUCamera: Error setting video mode ") + toString(videoMode) + 
            ", format: " + toString(videoFormat));
    err = m_pCamera->SetVideoFrameRate(getFrameRateConst(getFrameRate()));
    checkCMUError(err, AVG_ERR_CAMERA_NONFATAL, "Error setting frame rate");

    // Start capturing images
    err = m_pCamera->StartImageAcquisition();
    if (err != CAM_SUCCESS) {
        throw Exception(AVG_ERR_CAMERA_NONFATAL,
                "CMUCamera: Could not start image acquisition. " +
                CMUErrorToString(err));
    }

    // Set camera features
    for (FeatureMap::iterator it=m_Features.begin(); it != m_Features.end(); it++) {
        setFeature(it->first, it->second, true);
    }
    setWhitebalance(m_WhitebalanceU, m_WhitebalanceV, true);

    if (camPF == BAYER8) {
        char sModel[256], sVendor[256];
        m_pCamera->GetCameraName(sModel, 256);
        m_pCamera->GetCameraVendor(sVendor, 256);

        if (strcmp(sModel, "DFx 31BF03") == 0) {
            AVG_TRACE(Logger::CONFIG, "Applying bayer pattern fixup for IS DFx31BF03 camera");
            setCamPF(BAYER8_GRBG);
        } else if (strcmp(sVendor, "Point Grey Research") == 0) {
            AVG_TRACE(Logger::CONFIG, "Applying bayer pattern fixup for PointGrey cameras");
            enablePtGreyBayer();
        }
        
    }
}
Пример #23
0
void SysIBM::detect()
{
    QString path, val;

    path = IBM_BACKLIGHT_PATH;

    if (QFile::exists(path) && testR(path))
    {
        val = fieldValue("level", path);

        if (val.length() > 0)
        {
            bool ok;

            val.toInt(&ok);

            if (ok) _hasBacklight = true;
        }
    }

    path = IBM_VOLUME_PATH;

    if (QFile::exists(path) && testR(path))
    {
        val = fieldValue("level", path);

        if (val.length() > 0)
        {
            bool ok;

            val.toInt(&ok);

            if (ok) _hasVolume = true;
        }
    }

    path = IBM_BLUETOOTH_PATH;

    if (QFile::exists(path) && testR(path))
    {
        val = fieldValue("status", path);

        if (val == "enabled" || val == "disabled")
            _hasBluetooth = true;
    }

    path = IBM_LIGHT_PATH;

    if (QFile::exists(path) && testR(path))
    {
        val = fieldValue("status", path);

        if (val == "on" || val == "off")
            _hasLight = true;
    }

    path = IBM_LED_PATH;

    if (QFile::exists(path) && testR(path))
    {
        val = fieldValue("status", path);

        if (val == "supported")
        {
            _hasLEDs = true;

            setFeature(LAPSUS_FEAT_LED_ID_PREFIX "0", "",
                       I18N_NOOP("Power LED"));
            setFeature(LAPSUS_FEAT_LED_ID_PREFIX "1", "",
                       I18N_NOOP("Orange Battery LED"));
            setFeature(LAPSUS_FEAT_LED_ID_PREFIX "2", "",
                       I18N_NOOP("Green Battery LED"));
            setFeature(LAPSUS_FEAT_LED_ID_PREFIX "3", "",
                       I18N_NOOP("UltraBase LED"));
            setFeature(LAPSUS_FEAT_LED_ID_PREFIX "4", "",
                       I18N_NOOP("UltraBay LED"));
            setFeature(LAPSUS_FEAT_LED_ID_PREFIX "5", "",
                       I18N_NOOP("5th LED"));
            setFeature(LAPSUS_FEAT_LED_ID_PREFIX "6", "",
                       I18N_NOOP("6th LED"));
            setFeature(LAPSUS_FEAT_LED_ID_PREFIX "7", "",
                       I18N_NOOP("Standby LED"));
        }
    }

    path = IBM_DISPLAY_PATH;

    if (QFile::exists(path) && testR(path))
    {
        val = fieldValue("status", path);

        if (val == "supported")
            _hasDisplay = true;
    }
}
/**
 *  What to do when graphics are "initialized".
 */
void Starsphere::initialize(const int width, const int height, const Resource *font, const bool recycle)
{
	// check whether we initialize the first time or have to recycle (required for windoze)
	if(!recycle) {

		// store the font resource
		if(font) m_FontResource = font;

		// initialize the BOINC client adapter
		m_BoincAdapter.initialize();

		// inital HUD offset setup
		m_XStartPosLeft = 5;
		m_YOffsetLarge = 18;

		setFeature(STARS, true);
		setFeature(CONSTELLATIONS, true);
		setFeature(PULSARS, true);
		setFeature(SNRS, true);
		setFeature(OBSERVATORIES, true);
		setFeature(SEARCHINFO, true);
		setFeature(LOGO, true);
		setFeature(MARKER, true);
	}
	else {

		// seems that windoze also "resets" our OpenGL fonts
		// let's clean up before reinitializing them
		if(m_FontLogo1) delete m_FontLogo1;
		if(m_FontLogo2) delete m_FontLogo2;
		if(m_FontHeader)delete m_FontHeader;
		if(m_FontText)  delete m_FontText;
	}

	// we might be called to recycle even before initialization
	if(!m_FontResource) {

		// display a warning, this could be unintentionally
		cerr << "Warning: font resource still unknown! You might want to recycle at a later stage..." << endl;
	}
	else {

		// note: initialization of logo font instances is done in subclasses!

		// create medium font instances using font resource (base address + size)
		m_FontHeader = new OGLFT::TranslucentTexture(
									&m_FontResource->data()->at(0),
									m_FontResource->data()->size(),
									13, 78 );

		if ( m_FontHeader == 0 || !m_FontHeader->isValid() ) {
		     cerr << "Could not construct header font face from in memory resource!" << endl;
		     return;
		}

		m_FontHeader->setForegroundColor(1.0, 1.0, 0.0, 1.0);

		// create small font instances using font resource (base address + size)
		m_FontText = new OGLFT::TranslucentTexture(
									&m_FontResource->data()->at(0),
									m_FontResource->data()->size(),
									11, 72 );

		if ( m_FontText == 0 || !m_FontText->isValid() ) {
		     cerr << "Could not construct text font face from in memory resource!" << endl;
		     return;
		}

		m_FontText->setForegroundColor(0.75, 0.75, 0.75, 1.0);
	}

	// setup initial dimensions
	resize(width, height);

	// more font setup and optimizations
	glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
#if defined( GL_RASTER_POSITION_UNCLIPPED_IBM )
	glEnable( GL_RASTER_POSITION_UNCLIPPED_IBM );
#endif

	// drawing setup:
	glClearColor(0.0, 0.0, 0.0, 0.0); // background is black
	glEnable(GL_CULL_FACE);
	glFrontFace(GL_CCW);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	// enable opt-in quality feature
	if(m_BoincAdapter.graphicsQualitySetting() == BOINCClientAdapter::HighGraphicsQualitySetting) {
		// some polishing
		glShadeModel(GL_SMOOTH);
		glEnable(GL_POINT_SMOOTH);
		glEnable(GL_LINE_SMOOTH);
		glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
		glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
	}

	// FSAA will be enabled explicitly when needed!
	glDisable(GL_MULTISAMPLE_ARB);

	// we need alpha blending for proper font rendering
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	// enable depth buffering for 3D graphics
	glClearDepth(1.0f);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);

	// enable opt-in quality feature
	if(m_BoincAdapter.graphicsQualitySetting() == BOINCClientAdapter::MediumGraphicsQualitySetting ||
	   m_BoincAdapter.graphicsQualitySetting() == BOINCClientAdapter::HighGraphicsQualitySetting)
	{
		// fog aids depth perception
		glEnable(GL_FOG);
		glFogi(GL_FOG_MODE, GL_EXP2);
		glFogf(GL_FOG_DENSITY, 0.085);
		glHint(GL_FOG_HINT, GL_DONT_CARE);
	}

	// create pre-drawn display lists
	make_stars();
	make_constellations();
	make_pulsars();
	make_snrs();
	make_axes();
	make_globe();

	glDisable(GL_CLIP_PLANE0);
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
}
void Starsphere::keyboardPressEvent(const AbstractGraphicsEngine::KeyBoardKey keyPressed)
{
	switch(keyPressed) {
		case KeyS:
			setFeature(STARS, isFeature(STARS) ? false : true);
			break;
		case KeyC:
			setFeature(CONSTELLATIONS, isFeature(CONSTELLATIONS) ? false : true);
			break;
		case KeyO:
			setFeature(OBSERVATORIES, isFeature(OBSERVATORIES) ? false : true);
			break;
		case KeyX:
			setFeature(XRAYS, isFeature(XRAYS) ? false : true);
			break;
		case KeyP:
			setFeature(PULSARS, isFeature(PULSARS) ? false : true);
			break;
		case KeyR:
			setFeature(SNRS, isFeature(SNRS) ? false : true);
			break;
		case KeyG:
			setFeature(GLOBE, isFeature(GLOBE) ? false : true);
			break;
		case KeyA:
			setFeature(AXES, isFeature(AXES) ? false : true);
			break;
		case KeyI:
			setFeature(SEARCHINFO, isFeature(SEARCHINFO) ? false : true);
			break;
		case KeyL:
			setFeature(LOGO, isFeature(LOGO) ? false : true);
			break;
		case KeyM:
			setFeature(MARKER, isFeature(MARKER) ? false : true);
			break;
		default:
			break;
	}
}
Пример #26
0
void ofxLibdc::setShutter(unsigned int shutter) {
	setFeature(DC1394_FEATURE_SHUTTER, shutter);
}
Пример #27
0
void ofxLibdc::setExposure(unsigned int exposure) {
	setFeature(DC1394_FEATURE_EXPOSURE, exposure);
}
Пример #28
0
void ofxLibdc::setGain(unsigned int gain) {
	setFeature(DC1394_FEATURE_GAIN, gain);
}
Пример #29
0
void ofxLibdc::setGamma(unsigned int gamma) {
	setFeature(DC1394_FEATURE_GAMMA, gamma);
}
Пример #30
0
void ofxLibdc::setBrightness(unsigned int brightness) {
	setFeature(DC1394_FEATURE_BRIGHTNESS, brightness);
}