Пример #1
0
 void WorhpInternal::setQPOptions() {
   setOption("UserHM", true);
 }
Пример #2
0
	bool setOption(T &option,
			std::string flagStr,
			const std::string &shortDescription,
			bool required = false) {
		return setOption(option, flagStr, shortDescription, required, "Misc");
	}
Пример #3
0
/*!
    Sets the size of the operating system send buffer to \a size.

    The operating system send buffer size effectively limits how much
    data can be in transit at any one moment. Setting the size of the
    send buffer may have an impact on the socket's performance.

    The default value is operating system-dependent.
*/
void QNativeSocketEngine::setSendBufferSize(qint64 size)
{
    Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::setSendBufferSize(), Q_VOID);
    setOption(SendBufferSocketOption, size);
}
Пример #4
0
void Magick::Options::textInterwordSpacing(double spacing_)
{
  _drawInfo->interword_spacing=spacing_;
  setOption("interword-spacing",spacing_);
}
Пример #5
0
void Magick::Options::textUnderColor(const Magick::Color &undercolor_)
{
  _drawInfo->undercolor=undercolor_;
  setOption("undercolor",undercolor_);
}
/*!
    Initializes a QNativeSocketEngine by creating a new socket of type \a
    socketType and network layer protocol \a protocol. Returns true on
    success; otherwise returns false.

    If the socket was already initialized, this function closes the
    socket before reeinitializing it.

    The new socket is non-blocking, and for UDP sockets it's also
    broadcast enabled.
*/
bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType socketType, QAbstractSocket::NetworkLayerProtocol protocol)
{
    Q_D(QNativeSocketEngine);
    if (isValid())
        close();

#if defined(QT_NO_IPV6)
    if (protocol == QAbstractSocket::IPv6Protocol) {
        d->setError(QAbstractSocket::UnsupportedSocketOperationError,
                    QNativeSocketEnginePrivate::NoIpV6ErrorString);
        return false;
    }
#endif

    // Create the socket
    if (!d->createNewSocket(socketType, protocol)) {
#if defined (QNATIVESOCKETENGINE_DEBUG)
        QString typeStr = QLatin1String("UnknownSocketType");
        if (socketType == QAbstractSocket::TcpSocket) typeStr = QLatin1String("TcpSocket");
        else if (socketType == QAbstractSocket::UdpSocket) typeStr = QLatin1String("UdpSocket");
        QString protocolStr = QLatin1String("UnknownProtocol");
        if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = QLatin1String("IPv4Protocol");
        else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = QLatin1String("IPv6Protocol");
        qDebug("QNativeSocketEngine::initialize(type == %s, protocol == %s) failed: %s",
               typeStr.toLatin1().constData(), protocolStr.toLatin1().constData(), d->socketErrorString.toLatin1().constData());
#endif
        return false;
    }

    // Make the socket nonblocking.
    if (!setOption(NonBlockingSocketOption, 1)) {
        d->setError(QAbstractSocket::UnsupportedSocketOperationError,
                    QNativeSocketEnginePrivate::NonBlockingInitFailedErrorString);
        close();
        return false;
    }

    // Set the broadcasting flag if it's a UDP socket.
    if (socketType == QAbstractSocket::UdpSocket
        && !setOption(BroadcastSocketOption, 1)) {
        d->setError(QAbstractSocket::UnsupportedSocketOperationError,
                    QNativeSocketEnginePrivate::BroadcastingInitFailedErrorString);
        close();
        return false;
    }


    // Make sure we receive out-of-band data
    // On Symbian OS this works only with native IP stack, not with WinSock
    if (socketType == QAbstractSocket::TcpSocket
        && !setOption(ReceiveOutOfBandData, 1)) {
        qWarning("QNativeSocketEngine::initialize unable to inline out-of-band data");
    }

    // Before Qt 4.6, we always set the send and receive buffer size to 49152 as
    // this was found to be an optimal value. However, modern OS
    // all have some kind of auto tuning for this and we therefore don't set
    // this explictly anymore.
    // If it introduces any performance regressions for Qt 4.6.x (x > 0) then
    // it will be put back in.
    //
    // You can use tests/manual/qhttpnetworkconnection to test HTTP download speed
    // with this.
    //
    // pre-4.6:
    // setReceiveBufferSize(49152);
    // setSendBufferSize(49152);

    d->socketType = socketType;
    d->socketProtocol = protocol;
    return true;
}
void OptionsFunctionalityNode::copyOptions(const OptionsFunctionality& obj){
  setOption(obj.dictionary());
}
Пример #8
0
void QPlatformWindowFormat::setDoubleBuffer(bool enable)
{
    setOption(enable ? QPlatformWindowFormat::DoubleBuffer : QPlatformWindowFormat::SingleBuffer);
}
Пример #9
0
void QPlatformWindowFormat::setDepth(bool enable)
{
    setOption(enable ? QPlatformWindowFormat::DepthBuffer : QPlatformWindowFormat::NoDepthBuffer);
}
Пример #10
0
/*!
    Sets the size of the operating system receive buffer to \a size.

    The operating system receive buffer size effectively limits two
    things: how much data can be in transit at any one moment, and how
    much data can be received in one iteration of the main event loop.

    The default is operating system-dependent. A socket that receives
    large amounts of data is probably best with a buffer size of
    49152.
*/
void Q3SocketDevice::setReceiveBufferSize( uint size )
{
    setOption( ReceiveBuffer, size );
}
Пример #11
0
/*!
    Sets the size of the operating system send buffer to \a size.

    The operating system send buffer size effectively limits how much
    data can be in transit at any one moment.

    The default is operating system-dependent. A socket that sends
    large amounts of data is probably best with a buffer size of
    49152.
*/
void Q3SocketDevice::setSendBufferSize( uint size )
{
    setOption( SendBuffer, size );
}
Пример #12
0
/*!
    Sets the address of this socket to be usable by other sockets too
    if \a enable is true, and to be used exclusively by this socket if
    \a enable is false.

    When a socket is reusable, other sockets can use the same port
    number (and IP address), which is generally useful. Of course
    other sockets cannot use the same
    (address,port,peer-address,peer-port) 4-tuple as this socket, so
    there is no risk of confusing the two TCP connections.

    \sa addressReusable()
*/
void Q3SocketDevice::setAddressReusable( bool enable )
{
    setOption( ReuseAddress, enable );
}
Пример #13
0
  void WorhpInternal::setOptionsFromFile(const std::string & file) {
    int status;
    char *cpy = new char[file.size()+1] ;
    strcpy(cpy, file.c_str());
    worhp_p_.initialised = true;
    ReadParamsNoInit(&status, cpy, &worhp_p_);
    delete cpy;
    
    for (int i=0;i<WorhpGetParamCount();++i) {
      WorhpType type = WorhpGetParamType(i+1);
      const char* name = WorhpGetParamName(i+1);
      if (strcmp(name,"Ares")==0) continue;
      switch(type) {
        case WORHP_BOOL_T:
          bool default_bool;
          WorhpGetBoolParam(&worhp_p_, name, &default_bool);
          setOption(WorhpGetParamName(i+1),default_bool);
          break;
        case WORHP_DOUBLE_T:
          double default_double;
          WorhpGetDoubleParam(&worhp_p_, name, &default_double);
          setOption(WorhpGetParamName(i+1),default_double);
          break;
        case WORHP_INT_T:
          int default_int;
          WorhpGetIntParam(&worhp_p_, name, &default_int);
          setOption(WorhpGetParamName(i+1),default_int);
          break;
        default:
          break; // do nothing
      }
    } 

    
    setOption("qp_ipBarrier",worhp_p_.qp.ipBarrier);
    setOption("qp_ipComTol",worhp_p_.qp.ipComTol);
    setOption("qp_ipFracBound",worhp_p_.qp.ipFracBound);
    setOptionByEnumValue("qp_ipLsMethod",worhp_p_.qp.ipLsMethod );
    setOption("qp_ipMinAlpha",worhp_p_.qp.ipMinAlpha);
    setOption("qp_ipTryRelax",worhp_p_.qp.ipTryRelax);
    setOption("qp_ipRelaxDiv",worhp_p_.qp.ipRelaxDiv);
    setOption("qp_ipRelaxMult",worhp_p_.qp.ipRelaxMult);
    setOption("qp_ipRelaxMax",worhp_p_.qp.ipRelaxMax);
    setOption("qp_ipRelaxMin",worhp_p_.qp.ipRelaxMin);
    setOption("qp_ipResTol",worhp_p_.qp.ipResTol);
    setOption("qp_lsItMaxIter",worhp_p_.qp.lsItMaxIter);
    setOptionByEnumValue("qp_lsItMethod",worhp_p_.qp.lsItMethod );
    setOptionByEnumValue("qp_lsItPrecondMethod",worhp_p_.qp.lsItPrecondMethod );
    setOption("qp_lsRefineMaxIter",worhp_p_.qp.lsRefineMaxIter);
    setOption("qp_lsScale",worhp_p_.qp.lsScale);
    setOption("qp_lsTrySimple",worhp_p_.qp.lsTrySimple);
    setOption("qp_lsTol",worhp_p_.qp.lsTol);
    setOption("qp_maxIter",worhp_p_.qp.maxIter);
    setOptionByEnumValue("qp_method",worhp_p_.qp.method );
    setOption("qp_nsnBeta",worhp_p_.qp.nsnBeta);
    setOption("qp_nsnGradStep",worhp_p_.qp.nsnGradStep);
    setOption("qp_nsnKKT",worhp_p_.qp.nsnKKT);
    setOptionByEnumValue("qp_nsnLsMethod",worhp_p_.qp.nsnLsMethod );
    setOption("qp_nsnMinAlpha",worhp_p_.qp.nsnMinAlpha);
    setOption("qp_nsnSigma",worhp_p_.qp.nsnSigma);
    setOptionByEnumValue("qp_printLevel",worhp_p_.qp.printLevel );
    setOption("qp_scaleIntern",worhp_p_.qp.scaleIntern);
    setOption("qp_strict",worhp_p_.qp.strict);
      
    std::cout << "readparams status: " << status << std::endl;
  }
Пример #14
0
  WorhpInternal::WorhpInternal(const Function& nlp) : NLPSolverInternal(nlp){

    // Monitors
    addOption("monitor",            OT_STRINGVECTOR,  GenericType(),  "Monitor functions", "eval_f|eval_g|eval_jac_g|eval_grad_f|eval_h", true);
    addOption("print_time",         OT_BOOLEAN,       true,           "Print information about execution time");
  
    int status;
    InitParams(&status, &worhp_p_);
  
    std::stringstream ss;
    ss << "Armijo recovery strategies. Vector of size " << NAres;
  
    std::vector<int> ares(NAres);
    std::copy(worhp_p_.Ares,worhp_p_.Ares+NAres,ares.begin());
    addOption("Ares",OT_INTEGERVECTOR,ares,ss.str());
    
    for (int i=0;i<WorhpGetParamCount();++i) {
      WorhpType type = WorhpGetParamType(i+1);
      const char* name = WorhpGetParamName(i+1);
      if (strcmp(name,"Ares")==0) continue;
      switch(type) {
        case WORHP_BOOL_T:
          bool default_bool;
          WorhpGetBoolParam(&worhp_p_, name, &default_bool);
          addOption(WorhpGetParamName(i+1),OT_BOOLEAN,default_bool,WorhpGetParamDescription(i+1));
          break;
        case WORHP_DOUBLE_T:
          double default_double;
          WorhpGetDoubleParam(&worhp_p_, name, &default_double);
          addOption(WorhpGetParamName(i+1),OT_REAL,default_double,WorhpGetParamDescription(i+1));
          break;
        case WORHP_INT_T:
          int default_int;
          WorhpGetIntParam(&worhp_p_, name, &default_int);
          addOption(WorhpGetParamName(i+1),OT_INTEGER,default_int,WorhpGetParamDescription(i+1));
          break;
        default:
          break;// do nothing
      }
    } 
    
    addOption("qp_ipBarrier",OT_REAL,worhp_p_.qp.ipBarrier,"IP barrier parameter.");
    addOption("qp_ipComTol",OT_REAL,worhp_p_.qp.ipComTol,"IP complementarity tolerance.");
    addOption("qp_ipFracBound",OT_REAL,worhp_p_.qp.ipFracBound,"IP fraction-to-the-boundary parameter.");
    addOption("qp_ipLsMethod",OT_STRING,GenericType(),"Select the direct linear solver used by the IP method.","LAPACK::0|MA57: only available if provided by the user:1|SuperLU::2|PARDISO: only available if provided by the user, subject to license availability:3|MUMPS: currently Linux platforms only:5|WSMP: subject to license availability:6|MA86: experimental, only available if provided by the user:7|MA97:experimental, only available if provided by the user:8");
    setOptionByEnumValue("qp_ipLsMethod",worhp_p_.qp.ipLsMethod);
    addOption("qp_ipMinAlpha",OT_REAL,worhp_p_.qp.ipMinAlpha,"IP line search minimum step size.");
    addOption("qp_ipTryRelax",OT_BOOLEAN,worhp_p_.qp.ipTryRelax,"Enable relaxation strategy when encountering an error.");
    addOption("qp_ipRelaxDiv",OT_REAL,worhp_p_.qp.ipRelaxDiv,"The relaxation term is divided by this value if successful.");
    addOption("qp_ipRelaxMult",OT_REAL,worhp_p_.qp.ipRelaxMult,"The relaxation term is multiplied by this value if unsuccessful.");
    addOption("qp_ipRelaxMax",OT_REAL,worhp_p_.qp.ipRelaxMax,"Maximum relaxation value.");
    addOption("qp_ipRelaxMin",OT_REAL,worhp_p_.qp.ipRelaxMin,"Mimimum relaxation value.");
    addOption("qp_ipResTol",OT_REAL,worhp_p_.qp.ipResTol,"IP residuals tolerance.");
    addOption("qp_lsItMaxIter",OT_INTEGER,worhp_p_.qp.lsItMaxIter,"Maximum number of iterations of the iterative linear solvers.");
    addOption("qp_lsItMethod",OT_STRING,GenericType(),"Select the iterative linear solver.","none:Deactivate; use a direct linear solver.:0|CGNR::1|CGNE::2|CGS::3|BiCGSTAB::4");
    setOptionByEnumValue("qp_lsItMethod",worhp_p_.qp.lsItMethod);
    addOption("qp_lsItPrecondMethod",OT_STRING,GenericType(),"Select preconditioner for the iterative linear solver.","none:No preconditioner.:0|static:Static preconditioner (KKT-matrix with constant lower-right block).:1|full:Full KKT-matrix.:2");
    setOptionByEnumValue("qp_lsItPrecondMethod",worhp_p_.qp.lsItPrecondMethod);
    addOption("qp_lsRefineMaxIter",OT_INTEGER,worhp_p_.qp.lsRefineMaxIter,"Maximum number of iterative refinement steps of the direct linear solvers.");
    addOption("qp_lsScale",OT_BOOLEAN,worhp_p_.qp.lsScale,"Enables scaling on linear solver level.");
    addOption("qp_lsTrySimple",OT_BOOLEAN,worhp_p_.qp.lsTrySimple,"Some matrices can be solved without calling a linear equation solver.Currently only diagonal matrices are supported. Non-diagonal matrices will besolved with the chosen linear equation solver.");
    addOption("qp_lsTol",OT_REAL,worhp_p_.qp.lsTol,"Tolerance for the linear solver.");
    addOption("qp_maxIter",OT_INTEGER,worhp_p_.qp.maxIter,"Imposes an upper limit on the number of minor solver iterations, i.e. for thequadratic subproblem solver. If the limit is reached before convergence,WORHP will activate QP recovery strategies to prevent a solver breakdown.");
    addOption("qp_method",OT_STRING,GenericType(),"Select the solution method used by the QP solver.","ip:Interior-Point method.:1|nsn:Nonsmooth-Newton method.:2|automatic: Prefer IP and fall back to NSN on error.:12");
    setOptionByEnumValue("qp_method",worhp_p_.qp.method);
    addOption("qp_nsnBeta",OT_REAL,worhp_p_.qp.nsnBeta,"NSN stepsize decrease factor.");
    addOption("qp_nsnGradStep",OT_BOOLEAN,worhp_p_.qp.nsnGradStep,"Enable gradient steps in the NSN method.");
    addOption("qp_nsnKKT",OT_REAL,worhp_p_.qp.nsnKKT,"NSN KKT tolerance.");
    addOption("qp_nsnLsMethod",OT_STRING,GenericType(),"Select the direct linear solver used by the NSN method.","SuperLU::2|MA48: only available if provided by the user:4");
    setOptionByEnumValue("qp_nsnLsMethod",worhp_p_.qp.nsnLsMethod);
    addOption("qp_nsnMinAlpha",OT_REAL,worhp_p_.qp.nsnMinAlpha,"NSN line search minimum step size.");
    addOption("qp_nsnSigma",OT_REAL,worhp_p_.qp.nsnSigma,"NSN line search slope parameter.");
    addOption("qp_printLevel",OT_STRING,GenericType(),"Controls the amount of QP solver output.","none:No output.:0|warn:Print warnings and errors.:1|iterations:Print iterations.:2");
    setOptionByEnumValue("qp_printLevel",worhp_p_.qp.printLevel);
    addOption("qp_scaleIntern",OT_BOOLEAN,worhp_p_.qp.scaleIntern,"Enable scaling on QP level.");
    addOption("qp_strict",OT_BOOLEAN,worhp_p_.qp.strict,"Use strict termination criteria in IP method.");
  
    worhp_o_.initialised = false;
    worhp_w_.initialised = false;
    worhp_p_.initialised = false;
    worhp_c_.initialised = false;
  
    // WORKAROUND: Bug in scaling, set to false by default // FIXME
    setOption("ScaledObj",false);

    // WORKAROUND: Why is this needed? // FIXME
    setOption("ScaleConIter",true);
  }
Пример #15
0
void QPlatformWindowFormat::setWindowSurface(bool enable)
{
    setOption(enable ? QPlatformWindowFormat::HasWindowSurface : QPlatformWindowFormat::NoWindowSurface);
}
Пример #16
0
void QPlatformWindowFormat::setRgba(bool enable)
{
    setOption(enable ? QPlatformWindowFormat::Rgba : QPlatformWindowFormat::ColorIndex);
}
Пример #17
0
int main(int argn, char* argv[])
{
    LXQt::SingleApplication app(argn, argv);
    app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);

    // Command line options
    QCommandLineParser parser;
    parser.setApplicationDescription(QStringLiteral("LXQt Config Brightness"));
    const QString VERINFO = QStringLiteral(LXQT_CONFIG_VERSION
                                           "\nliblxqt   " LXQT_VERSION
                                           "\nQt        " QT_VERSION_STR);
    app.setApplicationVersion(VERINFO);
    QCommandLineOption increaseOption(QStringList() << "i" << "icrease",
            app.tr("Increase brightness."));
    parser.addOption(increaseOption);
    QCommandLineOption decreaseOption(QStringList() << "d" << "decrease",
            app.tr("Decrease brightness."));
    parser.addOption(decreaseOption);
    QCommandLineOption setOption(QStringList() << "s" << "set",
            app.tr("Set brightness from 1 to 100."), "brightness");
    parser.addOption(setOption);
    QCommandLineOption helpOption = parser.addHelpOption();
    parser.addOption(increaseOption);
    parser.addOption(decreaseOption);
    parser.addOption(setOption);
    parser.addOption(helpOption);
    parser.addVersionOption();

    parser.process(app);
    if( parser.isSet(increaseOption) || parser.isSet(decreaseOption) || parser.isSet(setOption) )
    {
        XRandrBrightness *brightness = new XRandrBrightness();
        QList<MonitorInfo> monitors = brightness->getMonitorsInfo();
        QList<MonitorInfo> monitorsChanged;
        float sign = parser.isSet(decreaseOption)?-1.0:1.0;
        double brightness_value = parser.value(setOption).toFloat();
        brightness_value = qMin( qMax(brightness_value, 0.0), 100.0 ) / 100.0;
        if(!parser.value(setOption).isEmpty())
            sign = 0.0;
        foreach(MonitorInfo monitor, monitors)
        {
            if( monitor.isBacklightSupported() )
            {
                long backlight = ( monitor.backlight() + sign*(monitor.backlightMax()/50 + 1) )*qAbs(sign) + brightness_value*monitor.backlightMax();
                if(backlight<monitor.backlightMax() && backlight>0)
                {
                    monitor.setBacklight(backlight);
                    monitorsChanged.append(monitor);
                }
            }
            else
            {
                float brightness = (monitor.brightness() + 0.1*sign)*qAbs(sign) + brightness_value*2.0;
                if(brightness<2.0 && brightness>0.0)
                {
                    monitor.setBrightness(brightness);
                    monitorsChanged.append(monitor);
                }
            }
        }
        brightness->setMonitorsSettings(monitorsChanged);
        return 0;
    }
Пример #18
0
void QPlatformWindowFormat::setAlpha(bool enable)
{
    setOption(enable ? QPlatformWindowFormat::AlphaChannel : QPlatformWindowFormat::NoAlphaChannel);
}
void OptionsFunctionalityNode::setOption(const Dictionary& dict){
  for(Dictionary::const_iterator it=dict.begin(); it!=dict.end(); ++it){
    setOption(it->first,it->second);
  }
}
Пример #20
0
void QPlatformWindowFormat::setAccum(bool enable)
{
    setOption(enable ? QPlatformWindowFormat::AccumBuffer : QPlatformWindowFormat::NoAccumBuffer);
}
Пример #21
0
void Magick::Options::fontWeight(size_t weight_)
{
  _drawInfo->weight=weight_;
  setOption("weight",(double) weight_);
}
Пример #22
0
void QPlatformWindowFormat::setStencil(bool enable)
{
    setOption(enable ? QPlatformWindowFormat::StencilBuffer: QPlatformWindowFormat::NoStencilBuffer);
}
Пример #23
0
void Magick::Options::textKerning(double kerning_)
{
  _drawInfo->kerning=kerning_;
  setOption("kerning",kerning_);
}
Пример #24
0
void QPlatformWindowFormat::setStereo(bool enable)
{
    setOption(enable ? QPlatformWindowFormat::StereoBuffers : QPlatformWindowFormat::NoStereoBuffers);
}
Пример #25
0
CaptureFileDialog::CaptureFileDialog(QWidget *parent, QString &fileName, QString &displayFilter) :
    QFileDialog(parent), m_fileName(fileName), m_displayFilter(displayFilter)
{
#if !defined(Q_WS_WIN)
    setWindowTitle(tr("Wireshark: Open Capture File"));
    setNameFilters(build_file_open_type_list());
    setFileMode(QFileDialog::ExistingFile);

    if (!m_fileName.isEmpty()) {
        selectFile(m_fileName);
    }

    // Add extra widgets
    // http://qt-project.org/faq/answer/how_can_i_add_widgets_to_my_qfiledialog_instance
    setOption(QFileDialog::DontUseNativeDialog, true);
    QGridLayout *fdGrid = qobject_cast<QGridLayout*>(layout());
    QHBoxLayout *hBox = new QHBoxLayout();
    QVBoxLayout *controlsBox = new QVBoxLayout();
    QGridLayout *previewGrid = new QGridLayout();
    QLabel *lbl;

    fdGrid->addWidget(new QLabel(tr("Display Filter:")), fdGrid->rowCount(), 0, 1, 1);

    m_displayFilterEdit = new DisplayFilterEdit(this, true);
    m_displayFilterEdit->setText(m_displayFilter);
    fdGrid->addWidget(m_displayFilterEdit, fdGrid->rowCount() - 1, 1, 1, 1);

    fdGrid->addLayout(hBox, fdGrid->rowCount(), 1, 1, -1);

    // Filter and resolution controls
    hBox->addLayout(controlsBox);

    m_macRes.setText(tr("&MAC name resolution"));
    m_macRes.setChecked(gbl_resolv_flags.mac_name);
    controlsBox->addWidget(&m_macRes);

    m_transportRes.setText(tr("&Transport name resolution"));
    m_transportRes.setChecked(gbl_resolv_flags.transport_name);
    controlsBox->addWidget(&m_transportRes);

    m_networkRes.setText(tr("&Network name resolution"));
    m_networkRes.setChecked(gbl_resolv_flags.network_name);
    controlsBox->addWidget(&m_networkRes);

    m_externalRes.setText(tr("&External name resolver"));
    m_externalRes.setChecked(gbl_resolv_flags.use_external_net_name_resolver);
    controlsBox->addWidget(&m_externalRes);

    // Preview
    hBox->addLayout(previewGrid);

    previewGrid->setColumnStretch(0, 0);
    previewGrid->setColumnStretch(1, 10);

    lbl = new QLabel("Format:");
    previewGrid->addWidget(lbl, 0, 0);
    previewGrid->addWidget(&m_previewFormat, 0, 1);
    m_previewLabels << lbl << &m_previewFormat;

    lbl = new QLabel("Size:");
    previewGrid->addWidget(lbl, 1, 0);
    previewGrid->addWidget(&m_previewSize, 1, 1);
    m_previewLabels << lbl << &m_previewSize;

    lbl = new QLabel("Packets:");
    previewGrid->addWidget(lbl, 2, 0);
    previewGrid->addWidget(&m_previewPackets, 2, 1);
    m_previewLabels << lbl << &m_previewPackets;

    lbl = new QLabel("First Packet:");
    previewGrid->addWidget(lbl, 3, 0);
    previewGrid->addWidget(&m_previewFirst, 3, 1);
    m_previewLabels << lbl << &m_previewFirst;

    lbl = new QLabel("Elapsed Time:");
    previewGrid->addWidget(lbl, 4, 0);
    previewGrid->addWidget(&m_previewElapsed, 4, 1);
    m_previewLabels << lbl << &m_previewElapsed;

    // Grow the dialog to account for the extra widgets.
    resize(width(), height() + hBox->minimumSize().height() + m_displayFilterEdit->minimumSize().height());

    connect(this, SIGNAL(currentChanged(const QString &)), this, SLOT(preview(const QString &)));

    preview("");

#endif
}
Пример #26
0
void QPlatformWindowFormat::setDirectRendering(bool enable)
{
    setOption(enable ? QPlatformWindowFormat::DirectRendering : QPlatformWindowFormat::IndirectRendering);
}
Пример #27
0
/*!
    Initializes a QNativeSocketEngine by creating a new socket of type \a
    socketType and network layer protocol \a protocol. Returns true on
    success; otherwise returns false.

    If the socket was already initialized, this function closes the
    socket before reeinitializing it.

    The new socket is non-blocking, and for UDP sockets it's also
    broadcast enabled.
*/
bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType socketType, QAbstractSocket::NetworkLayerProtocol protocol)
{
    Q_D(QNativeSocketEngine);
    if (isValid())
        close();

#if defined(QT_NO_IPV6)
    if (protocol == QAbstractSocket::IPv6Protocol) {
        d->setError(QAbstractSocket::UnsupportedSocketOperationError,
                    QNativeSocketEnginePrivate::NoIpV6ErrorString);
        return false;
    }
#endif

    // Create the socket
    if (!d->createNewSocket(socketType, protocol)) {
#if defined (QNATIVESOCKETENGINE_DEBUG)
        QString typeStr = QLatin1String("UnknownSocketType");
        if (socketType == QAbstractSocket::TcpSocket) typeStr = QLatin1String("TcpSocket");
        else if (socketType == QAbstractSocket::UdpSocket) typeStr = QLatin1String("UdpSocket");
        QString protocolStr = QLatin1String("UnknownProtocol");
        if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = QLatin1String("IPv4Protocol");
        else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = QLatin1String("IPv6Protocol");
        qDebug("QNativeSocketEngine::initialize(type == %s, protocol == %s) failed: %s",
               typeStr.toLatin1().constData(), protocolStr.toLatin1().constData(), d->socketErrorString.toLatin1().constData());
#endif
        return false;
    }

    // Make the socket nonblocking.
    if (!setOption(NonBlockingSocketOption, 1)) {
        d->setError(QAbstractSocket::UnsupportedSocketOperationError,
                    QNativeSocketEnginePrivate::NonBlockingInitFailedErrorString);
        close();
        return false;
    }

    // Set the broadcasting flag if it's a UDP socket.
    if (socketType == QAbstractSocket::UdpSocket
        && !setOption(BroadcastSocketOption, 1)) {
        d->setError(QAbstractSocket::UnsupportedSocketOperationError,
                    QNativeSocketEnginePrivate::BroadcastingInitFailedErrorString);
        close();
        return false;
    }

    // Make sure we receive out-of-band data
    if (socketType == QAbstractSocket::TcpSocket
        && !setOption(ReceiveOutOfBandData, 1)) {
        qWarning("QNativeSocketEngine::initialize unable to inline out-of-band data");
    }

    // Set the send and receive buffer sizes to a magic size, found
    // most optimal for our platforms.
    setReceiveBufferSize(49152);
    setSendBufferSize(49152);

    d->socketType = socketType;
    d->socketProtocol = protocol;
    return true;
}
Пример #28
0
/*!
    If \a enable is true, a GL context with multisample buffer support
    is picked; otherwise ignored.

    \sa sampleBuffers(), setSamples(), samples()
*/
void QPlatformWindowFormat::setSampleBuffers(bool enable)
{
    setOption(enable ? QPlatformWindowFormat::SampleBuffers : QPlatformWindowFormat::NoSampleBuffers);
}
Пример #29
0
void SQPInternal::init(){
  // Call the init method of the base class
  NLPSolverInternal::init();
    
  // Read options
  maxiter_ = getOption("maxiter");
  maxiter_ls_ = getOption("maxiter_ls");
  c1_ = getOption("c1");
  beta_ = getOption("beta");
  merit_memsize_ = getOption("merit_memory");
  lbfgs_memory_ = getOption("lbfgs_memory");
  tol_pr_ = getOption("tol_pr");
  tol_du_ = getOption("tol_du");
  regularize_ = getOption("regularize");
  if(getOption("hessian_approximation")=="exact")
    hess_mode_ = HESS_EXACT;
  else if(getOption("hessian_approximation")=="limited-memory")
    hess_mode_ = HESS_BFGS;
   
  if (hess_mode_== HESS_EXACT && H_.isNull()) {
    if (!getOption("generate_hessian")){
      casadi_error("SQPInternal::evaluate: you set option 'hessian_approximation' to 'exact', but no hessian was supplied. Try with option \"generate_hessian\".");
    }
  }
  
  // If the Hessian is generated, we use exact approximation by default
  if (bool(getOption("generate_hessian"))){
    setOption("hessian_approximation", "exact");
  }
  
  // Allocate a QP solver
  CRSSparsity H_sparsity = hess_mode_==HESS_EXACT ? H_.output().sparsity() : sp_dense(n_,n_);
  H_sparsity = H_sparsity + DMatrix::eye(n_).sparsity();
  CRSSparsity A_sparsity = J_.isNull() ? CRSSparsity(0,n_,false) : J_.output().sparsity();

  QPSolverCreator qp_solver_creator = getOption("qp_solver");
  qp_solver_ = qp_solver_creator(H_sparsity,A_sparsity);

  // Set options if provided
  if(hasSetOption("qp_solver_options")){
    Dictionary qp_solver_options = getOption("qp_solver_options");
    qp_solver_.setOption(qp_solver_options);
  }
  qp_solver_.init();
  
  // Lagrange multipliers of the NLP
  mu_.resize(m_);
  mu_x_.resize(n_);
  
  // Lagrange gradient in the next iterate
  gLag_.resize(n_);
  gLag_old_.resize(n_);

  // Current linearization point
  x_.resize(n_);
  x_cand_.resize(n_);
  x_old_.resize(n_);

  // Constraint function value
  gk_.resize(m_);
  gk_cand_.resize(m_);
  
  // Hessian approximation
  Bk_ = DMatrix(H_sparsity);
  
  // Jacobian
  Jk_ = DMatrix(A_sparsity);

  // Bounds of the QP
  qp_LBA_.resize(m_);
  qp_UBA_.resize(m_);
  qp_LBX_.resize(n_);
  qp_UBX_.resize(n_);

  // QP solution
  dx_.resize(n_);
  qp_DUAL_X_.resize(n_);
  qp_DUAL_A_.resize(m_);

  // Gradient of the objective
  gf_.resize(n_);

  // Create Hessian update function
  if(hess_mode_ == HESS_BFGS){
    // Create expressions corresponding to Bk, x, x_old, gLag and gLag_old
    SXMatrix Bk = ssym("Bk",H_sparsity);
    SXMatrix x = ssym("x",input(NLP_X_INIT).sparsity());
    SXMatrix x_old = ssym("x",x.sparsity());
    SXMatrix gLag = ssym("gLag",x.sparsity());
    SXMatrix gLag_old = ssym("gLag_old",x.sparsity());
    
    SXMatrix sk = x - x_old;
    SXMatrix yk = gLag - gLag_old;
    SXMatrix qk = mul(Bk, sk);
    
    // Calculating theta
    SXMatrix skBksk = inner_prod(sk, qk);
    SXMatrix omega = if_else(inner_prod(yk, sk) < 0.2 * inner_prod(sk, qk),
                             0.8 * skBksk / (skBksk - inner_prod(sk, yk)),
                             1);
    yk = omega * yk + (1 - omega) * qk;
    SXMatrix theta = 1. / inner_prod(sk, yk);
    SXMatrix phi = 1. / inner_prod(qk, sk);
    SXMatrix Bk_new = Bk + theta * mul(yk, trans(yk)) - phi * mul(qk, trans(qk));
    
    // Inputs of the BFGS update function
    vector<SXMatrix> bfgs_in(BFGS_NUM_IN);
    bfgs_in[BFGS_BK] = Bk;
    bfgs_in[BFGS_X] = x;
    bfgs_in[BFGS_X_OLD] = x_old;
    bfgs_in[BFGS_GLAG] = gLag;
    bfgs_in[BFGS_GLAG_OLD] = gLag_old;
    bfgs_ = SXFunction(bfgs_in,Bk_new);
    bfgs_.setOption("number_of_fwd_dir",0);
    bfgs_.setOption("number_of_adj_dir",0);
    bfgs_.init();
    
    // Initial Hessian approximation
    B_init_ = DMatrix::eye(n_);
  }
  
  // Header
  if(bool(getOption("print_header"))){
    cout << "-------------------------------------------" << endl;
    cout << "This is CasADi::SQPMethod." << endl;
    switch (hess_mode_) {
      case HESS_EXACT:
        cout << "Using exact Hessian" << endl;
        break;
      case HESS_BFGS:
        cout << "Using limited memory BFGS Hessian approximation" << endl;
        break;
    }
    cout << endl;
    cout << "Number of variables:                       " << setw(9) << n_ << endl;
    cout << "Number of constraints:                     " << setw(9) << m_ << endl;
    cout << "Number of nonzeros in constraint Jacobian: " << setw(9) << A_sparsity.size() << endl;
    cout << "Number of nonzeros in Lagrangian Hessian:  " << setw(9) << H_sparsity.size() << endl;
    cout << endl;
  }
}
Пример #30
0
void SocketImpl::setBroadcast(bool flag)
{
    int value = flag ? 1 : 0;
    setOption(SOL_SOCKET, SO_BROADCAST, value);
}