Exemple #1
0
void Graphics::drawText(const char_t* text, ulong_t length, const Point& topLeft, bool inverted)
{
    FontEffects fx = font_.effects();    
    PalmUnderlineSetter setUnderline(convertUnderlineMode(fx.underline()));

    ScalingSetter setScaling(*this);

    uint_t height = fontHeight();
    uint_t top=topLeft.y;
    if (fx.subscript())
        top+=(height/3);
    if (inverted)
        WinDrawInvertedChars(text, length, topLeft.x, top);
    else         
        WinDrawChars(text, length, topLeft.x, top);

    if (fx.strikeOut())
    {
        uint_t baseline = fontBaseline();
        top=topLeft.y + (baseline*2)/3;
        uint_t width = FntCharsWidth(text, length);
        Color_t color=setTextColor(0);
        setTextColor(color); // Quite strange method of querying current text color...
        color=setForegroundColor(color);
        WinDrawOperation old;
        if (inverted)
            old=WinSetDrawMode(winInvert);
        drawLine(topLeft.x, top, topLeft.x+width, top);
        if (inverted)
            WinSetDrawMode(old);
        setForegroundColor(color);
    }
  }
Exemple #2
0
        FormIO(GUI::Context& mCtx)
            : GUI::Form{mCtx, "IO", Vec2f{300.f, 300.f}, Vec2f{100.f, 100.f}},
              mainStrip(create<GUI::Strip>(
                  GUI::At::Top, GUI::At::Bottom, GUI::At::Bottom)),
              lblCurrentPath(mainStrip.create<GUI::Label>("CURRENT: null")),
              tboxFilename(mainStrip.create<GUI::TextBox>(
                  getStyle().getBtnSizePerChar(14))),
              stripBtns(mainStrip.create<GUI::Strip>(
                  GUI::At::Left, GUI::At::Right, GUI::At::Right)),
              btnSave(stripBtns.create<GUI::Button>(
                  "save", getStyle().getBtnSizePerChar(6))),
              btnLoad(stripBtns.create<GUI::Button>(
                  "load", getStyle().getBtnSizePerChar(6)))
        {
            setScaling(GUI::Scaling::FitToChildren);
            setResizable(false);
            setPadding(2.f);

            mainStrip.attach(GUI::At::Center, *this, GUI::At::Center);
            mainStrip.setPadding(2.f);

            tboxFilename.setString("./level.lvl");

            btnSave.onLeftClick += [this]
            {
                if(!tboxFilename.getString().empty())
                    onSave(tboxFilename.getString());
            };
            btnLoad.onLeftClick += [this]
            {
                if(!tboxFilename.getString().empty())
                    onLoad(tboxFilename.getString());
            };
        }
Exemple #3
0
ulong_t Graphics::wordWrap(const char_t* text, uint_t availableDx, uint_t& textDx)
{
    ScalingSetter setScaling(*this);

    ulong_t charsThatFit = FntWordWrap(text, availableDx);

    textDx = textWidth(text, charsThatFit);
    return charsThatFit;
}
Exemple #4
0
void Graphics::charsInWidth(const char_t* text, ulong_t& length, uint_t& width)
{

    ScalingSetter setScaling(*this);

    Int16 w=width;
//        Int16 len=length;
//        Boolean dontMind;
//        FntCharsInWidth(text, &w, &len, &dontMind);
//        length=len;
    length = FntWidthToOffset(text, length, width, NULL, &w);
    width=w;

}
Exemple #5
0
PathPlanner::PathPlanner(const char* bitmap,int scaling = -1) {
	std::fstream file(bitmap, std::ios::in | std::ios::out | std::ios::binary);

	file.seekg(0);
	width=0;
	while(file.get() != '\n')
		width++;

	file.seekg( 0, std::ios::end );
	height = file.tellg()/(width+1);
	file.seekg(0);

	nodeMap = new Node*[width];
	for(int i=0; i<width;i++) {
		for(int j=0;j<height;j++) {
			nodeMap[i] = new Node[height];
		}
	}

	char readchar;

	for(int j=0; j<height;j++) {
		for(int i=0;i<width;i++) {
			nodeMap[i][j].x = i;
			nodeMap[i][j].y = j;

			if( ( readchar = file.get()) == 'X') {
				nodeMap[i][j].state = UNREACHABLE;
			} else {
				nodeMap[i][j].state = NEW;
				nodeMap[i][j].single_cost = readchar - '0';
			}

		}
		file.get();

	}


	file.close();

	if(scaling > 0) {
		setScaling(scaling);
	}
}
Exemple #6
0
int Process(ParametersType *Parameters, MatrixDataType *MatrixData, FemStructsType *FemStructs, 
	    FemFunctionsType *FemFunctions, FemOtherFunctionsType *FemOtherFunctions)
{
	int (*Predictor)(ParametersType *, MatrixDataType *, FemStructsType *, FemFunctionsType *, FemOtherFunctionsType *);
	
	setProblem(Parameters, FemFunctions);
	setMatrixVectorProductType(Parameters, FemFunctions);
	setSolver(Parameters,FemOtherFunctions);
	setPreconditioner(Parameters, FemFunctions);
	setScaling(Parameters, FemFunctions);
	setStabilizationForm(Parameters, FemFunctions, FemOtherFunctions, &Predictor);
	setDimensionlessness(Parameters, FemFunctions);
	set_BC_no_penetrability(Parameters, FemFunctions);
	setStopCriteria(Parameters, FemFunctions);
	Predictor(Parameters, MatrixData, FemStructs, FemFunctions, FemOtherFunctions);
	
	return 0;
}
void DMFT::configure(config::Configuration& configuration) {
    m_configuration = &configuration;
    try {
        m_U = configuration.getDouble("DMFT.U");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_mu = configuration.getDouble("DMFT.mu");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_T = configuration.getDouble("DMFT.temperature");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_delta = configuration.getDouble("DMFT.delta");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_scaling = configuration.getDouble("DMFT.scaling");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_tolerance = configuration.getDouble("DMFT.tolerance");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_maxIterations = configuration.getInteger("DMFT.maxIterations");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        m_startWithDelta = configuration.getBool("DMFT.startWithDelta");
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        std::string initialD = configuration.getString("DMFT.initialD");
        math::CFunction D;
        D.readBinary(initialD);
        setHybridizationFunction(D);
    } catch( libconfig::SettingNotFoundException& e ) {}
    try {
        std::string initialS = configuration.getString("DMFT.initialS");
        math::CFunction S;
        S.readBinary(initialS);
        setSelfEnergy(S);
        double scaling = -S.getArgument(0);
        setScaling(scaling);
    } catch( libconfig::SettingNotFoundException& e ) {}
}
Exemple #8
0
Graphics::Font_t Graphics::setFont(const Graphics::Font_t& font)
{
    Font_t oldOne = font_;
    font_ = font;
    FontID id = font_.withEffects();
    bool wantsScaling = 0 != (id & fontScalingDisabled);
    disableFontScaling_ = wantsScaling && useFontScaling();
    if (wantsScaling && !disableFontScaling_)
        id =stdFont;
    ScalingSetter setScaling(*this);
    FntSetFont(FontID(id & ~fontScalingDisabled));
    effectiveLineHeight_ = lineHeight_ = FntLineHeight();
    FontEffects fx=font_.effects();
    if (fx.superscript() || fx.subscript())
    {
        effectiveLineHeight_*=4;
        effectiveLineHeight_/=3;
    }
    effectiveBaseline_=baseline_ = FntBaseLine();
    if (font_.effects().superscript())
        effectiveBaseline_ += (lineHeight_/3);
    return oldOne;
}
Exemple #9
0
void SFMatrix::setScaling(SFVec3f *vector) 
{
	setScaling(vector->getX(), vector->getY(), vector->getZ());
}
Exemple #10
0
void PlotCanvas::updateScale()
{
    qDebug() << "Scale updated" << QGuiApplication::primaryScreen()->devicePixelRatio();
    setScaling(QGuiApplication::primaryScreen()->devicePixelRatio());
}
VariableSettings::VariableSettings( const VariableSettings& rhs )
{
	uint i;

	dim = rhs.dim;
	type = rhs.type;

	if ( rhs.names != 0 )
	{
		names = (char**) calloc( dim,sizeof(char*) );
		for( i=0; i<dim; ++i )
		{
			names[i] = new char[MAX_LENGTH_NAME+1];
			setName( i,rhs.names[i] );
		}
	}
	else
	{
		names = 0;
	}

	if ( rhs.units != 0 )
	{
		units = (char**) calloc( dim,sizeof(char*) );
		for( i=0; i<dim; ++i )
		{
			units[i] = new char[MAX_LENGTH_NAME+1];
			setUnit( i,rhs.units[i] );
		}
	}
	else
	{
		units = 0;
	}


	if ( rhs.scaling.isEmpty( ) == BT_FALSE )
	{
		scaling.init( dim );
		setScaling( rhs.scaling );
	}
	else
	{
		scaling.init( );
	}

	if ( rhs.lb.isEmpty( ) == BT_FALSE )
	{
		lb.init( dim );
		setLowerBounds( rhs.lb );
	}
	else
	{
		lb.init( );
	}

	if ( rhs.ub.isEmpty( ) == BT_FALSE )
	{
		ub.init( dim );
		setUpperBounds( rhs.ub );
	}
	else
	{
		ub.init( );
	}

	autoInit = rhs.autoInit;
}
Exemple #12
0
void Body::setScaling(GLfloat x, GLfloat y, GLfloat z)
{
	setScaling(vec3(x, y, z));
}
Exemple #13
0
ulong_t Graphics::wordWrap(const char_t* text, uint_t width)
{
    ScalingSetter setScaling(*this);
    return FntWordWrap(text, width);
}
Exemple #14
0
uint_t Graphics::textWidth(const char_t* text, ulong_t length)
{
    ScalingSetter setScaling(*this);
    return FntCharsWidth(text, length);
}
Exemple #15
0
void SFMatrix::setScaling(float value[]) 
{
	init();
	setScaling(value[0], value[1], value[2]);
}
Exemple #16
0
int
main()
{
    DenseVector     sings;
    GeMat           deltas(3,2);

    std::vector<GeMat> _deltas;
    Function        x2f(x2, sings);
    Function        onef(one, sings);
    Function        x3f(x3, sings);
    Function        cosf(mycos, sings);
    Function        sinf(mysin, sings);
    Function        expf(myexp, sings);
    Basis           basis(4);
    basis.template enforceBoundaryCondition<lawa::DirichletBC>();
    IndexSet        indexset;
    Coeff1D         coeff;

    std::vector<Function> fvec;

    int rank = 2;
    int dim  = 64;

    for (int i=1; i<=32; ++i) {
        fvec.push_back(cosf);
        fvec.push_back(onef);
        fvec.push_back(x2f);
        fvec.push_back(onef);
    }

    SepCoeff        coeffs(rank, dim);
    IndexSetVec     indexsetvec(dim);
    lawa::SeparableFunctionD<T> F(fvec, rank, dim);
    MatInt                      derivs(rank, dim);
    for (int i=1; i<=rank; ++i) {
        for (int j=1; j<=dim; ++j) {
            derivs(i,j) = 0;
            _deltas.push_back(deltas);
        }
    }

    lawa::SeparableRHSD<T, Basis>   Fint(basis, F, _deltas, derivs);

    getFullIndexSet(basis, indexset, 2);

    std::cout << "The index set size is\n" << indexset.size()
              << std::endl;

    for (int l=0; (unsigned)l<indexsetvec.size(); ++l) {
        indexsetvec[l] = indexset;
    }

    /* Map */
    lawa::Mapwavind<Index1D> map(dim);
    map.rehash(50);

    genCoefficients(coeffs, Fint, indexsetvec);
    lawa::HTCoefficients<T, Basis>    f(dim, basis, map);
    lawa::HTCoefficients<T, Basis>    u(dim, basis, map);
    lawa::HTCoefficients<T, Basis>    r(dim, basis, map);

    Laplace1D       LaplaceBil(basis);
    RefLaplace1D    RefLaplaceBil(basis.refinementbasis);
    Identity1D      IdentityBil(basis);
    RefIdentity1D   RefIdentityBil(basis.refinementbasis);
    LOp_Lapl1D      lapl(basis, basis, RefLaplaceBil, LaplaceBil);

    Sepop A(lapl, dim, dim);

    lawa::Sepdiagscal<Basis>    S(dim, basis);
    setScaling(S, 0.5);

    lawa::HTAWGM_Params  params;
    params.maxit_pcg  = 100;
    params.maxit_awgm = 100;
    params.tol_awgm   = 1e-08;
    params.delta1_pcg = 1e-01;
    params.delta2_pcg = 1e-01;
    params.delta3_pcg = 1e-01;
    params.alpha      = 0.95;
    params.recompr    = 1e-02;
    params.gamma      = 0.1;
    params.theta      = 1e-08;


    std::cout << "HTAWGM params =\n";
    std::cout << params << std::endl;

    unsigned its;
    double   res;

    its = htawgm(A, S, u, Fint, indexsetvec, res, params);

    std::cout << "htawgm took " << its << " iterations to reach "
              << res << " accuracy" << std::endl;
    std::cout << "Final scaling set to\n" << S << std::endl;

    return 0;
}
bool AkVCam::PluginInterface::createDevice(const std::string &deviceId,
                                           const std::wstring &description,
                                           const std::vector<VideoFormat> &formats)
{
    AkLoggerLog("AkVCam::PluginInterface::createDevice");

    StreamPtr stream;

    // Create one device.
    auto pluginRef = reinterpret_cast<CMIOHardwarePlugInRef>(this->d);
    auto device = std::make_shared<Device>(pluginRef);
    device->setDeviceId(deviceId);
    device->connectAddListener(this, &PluginInterface::addListener);
    device->connectRemoveListener(this, &PluginInterface::removeListener);
    this->m_devices.push_back(device);

    // Define device properties.
    device->properties().setProperty(kCMIOObjectPropertyName,
                                     description.c_str());
    device->properties().setProperty(kCMIOObjectPropertyManufacturer,
                                     CMIO_PLUGIN_VENDOR);
    device->properties().setProperty(kCMIODevicePropertyModelUID,
                                     CMIO_PLUGIN_PRODUCT);
    device->properties().setProperty(kCMIODevicePropertyLinkedCoreAudioDeviceUID,
                                     "");
    device->properties().setProperty(kCMIODevicePropertyLinkedAndSyncedCoreAudioDeviceUID,
                                     "");
    device->properties().setProperty(kCMIODevicePropertySuspendedByUser,
                                     UInt32(0));
    device->properties().setProperty(kCMIODevicePropertyHogMode,
                                     pid_t(-1),
                                     false);
    device->properties().setProperty(kCMIODevicePropertyDeviceMaster,
                                     pid_t(-1));
    device->properties().setProperty(kCMIODevicePropertyExcludeNonDALAccess,
                                     UInt32(0));
    device->properties().setProperty(kCMIODevicePropertyDeviceIsAlive,
                                     UInt32(1));
    device->properties().setProperty(kCMIODevicePropertyDeviceUID,
                                     deviceId.c_str());
    device->properties().setProperty(kCMIODevicePropertyTransportType,
                                     UInt32(kIOAudioDeviceTransportTypePCI));
    device->properties().setProperty(kCMIODevicePropertyDeviceIsRunningSomewhere,
                                     UInt32(0));

    if (device->createObject() != kCMIOHardwareNoError)
        goto createDevice_failed;

    stream = device->addStream();

    // Register one stream for this device.
    if (!stream)
        goto createDevice_failed;

    stream->setFormats(formats);
    stream->properties().setProperty(kCMIOStreamPropertyDirection, UInt32(0));

    if (device->registerStreams() != kCMIOHardwareNoError) {
        device->registerStreams(false);

        goto createDevice_failed;
    }

    // Register the device.
    if (device->registerObject() != kCMIOHardwareNoError) {
        device->registerObject(false);
        device->registerStreams(false);

        goto createDevice_failed;
    }

    device->setBroadcasting(this->d->m_ipcBridge.broadcaster(deviceId));
    device->setMirror(this->d->m_ipcBridge.isHorizontalMirrored(deviceId),
                      this->d->m_ipcBridge.isVerticalMirrored(deviceId));
    device->setScaling(this->d->m_ipcBridge.scalingMode(deviceId));
    device->setAspectRatio(this->d->m_ipcBridge.aspectRatioMode(deviceId));
    device->setSwapRgb(this->d->m_ipcBridge.swapRgb(deviceId));

    return true;

createDevice_failed:
    this->m_devices.erase(std::prev(this->m_devices.end()));

    return false;
}