示例#1
0
//--------------------------------------------------------------
void PartyCLApp::keyPressed(int key)
{
    switch (key)
    {
    case ' ':
        bPaused ^= 1;
        break;

    case '`':
        bGuiVisible ^= 1;
        break;

    case 'p':
    case 'P':
        displayMode = (ParticleRenderer::DisplayMode)((displayMode + 1) % ParticleRenderer::PARTICLE_NUM_MODES);
        break;

    case 'r':
    case 'R':
        bReset = true;
        break;

    case '[':
        presetIndex = (presetIndex == 0) ? presets.size() - 1 : (presetIndex - 1) % presets.size();
        loadPreset();
        resetSimulation();
        break;

    case ']':
        presetIndex = (presetIndex + 1) % presets.size();
        loadPreset();
        resetSimulation();
        break;

    case 'f':
    case 'F':
        ofToggleFullscreen();
        break;

    case '1':
        activeConfig = NBODY_CONFIG_SHELL;
        resetSimulation();
        break;

    case '2':
        activeConfig = NBODY_CONFIG_RANDOM;
        resetSimulation();
        break;

    case '3':
        activeConfig = NBODY_CONFIG_EXPAND;
        resetSimulation();
        break;
    }
}
void LLWaterParamManager::loadAllPresets(const std::string& file_name)
{
	std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", ""));
	LL_INFOS2("AppInit", "Shaders") << "Loading Default water settings from " << path_name << LL_ENDL;
			
	bool found = true;			
	LLDirIterator app_settings_iter(path_name, "*.xml");
	while(found) 
	{
		std::string name;
		found = app_settings_iter.next(name);
		if(found)
		{

			name=name.erase(name.length()-4);

			// bugfix for SL-46920: preventing filenames that break stuff.
			char * curl_str = curl_unescape(name.c_str(), name.size());
			std::string unescaped_name(curl_str);
			curl_free(curl_str);
			curl_str = NULL;

			LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			loadPreset(unescaped_name,FALSE);
		}
	}

	// And repeat for user presets, note the user presets will modify any system presets already loaded

	std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", ""));
	LL_INFOS2("AppInit", "Shaders") << "Loading User water settings from " << path_name2 << LL_ENDL;
			
	found = true;			
	LLDirIterator user_settings_iter(path_name2, "*.xml");
	while(found) 
	{
		std::string name;
		found = user_settings_iter.next(name);
		if(found)
		{
			name=name.erase(name.length()-4);

			// bugfix for SL-46920: preventing filenames that break stuff.
			char * curl_str = curl_unescape(name.c_str(), name.size());
			std::string unescaped_name(curl_str);
			curl_free(curl_str);
			curl_str = NULL;

			LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			loadPreset(unescaped_name,FALSE);
		}
	}

}
void AscentDayCycleManager::loadPresets(const std::string& file_name)
{
	std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/days", ""));
	LL_INFOS2("AppInit", "Shaders") << "Loading Default Day Cycle preset from " << path_name << LL_ENDL;
			
	bool found = true;			
	while(found) 
	{
		std::string name;
		found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false);
		if(found)
		{

			name=name.erase(name.length()-4);

			// bugfix for SL-46920: preventing filenames that break stuff.
			char * curl_str = curl_unescape(name.c_str(), name.size());
			std::string unescaped_name(curl_str);
			curl_free(curl_str);
			curl_str = NULL;

			LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			loadPreset(unescaped_name,FALSE);
		}
	}

	// And repeat for user presets, note the user presets will modify any system presets already loaded

	std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/days", ""));
	LL_INFOS2("AppInit", "Shaders") << "Loading User Daycycle preset from " << path_name2 << LL_ENDL;
			
	found = true;			
	while(found) 
	{
		std::string name;
		found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false);
		if(found)
		{
			name=name.erase(name.length()-4);

			// bugfix for SL-46920: preventing filenames that break stuff.
			char * curl_str = curl_unescape(name.c_str(), name.size());
			std::string unescaped_name(curl_str);
			curl_free(curl_str);
			curl_str = NULL;

			LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			loadPreset(unescaped_name,FALSE);
		}
	}

}
示例#4
0
void TestTubeSegmentationFramework::testLoadParameterFile()
{
	paramList preset = loadPreset(QString("Neuro-Vessels-USA"));

	INFO("sphere-segmentation not set to true in Neuro-Vessels-USA");
	REQUIRE(getParamBool(preset,"sphere-segmentation") == true);
}
void AddFxContextMenu::loadFx(TIStream *is, QMenu *insertFxGroup, QMenu *addFxGroup, QMenu *replaceFxGroup)
{
	while (!is->eos()) {
		string fxName;
		*is >> fxName;

		if (!fxName.empty()) {
			if (!loadPreset(fxName, insertFxGroup, addFxGroup, replaceFxGroup)) {
				QString translatedName = QString::fromStdWString(TStringTable::translate(fxName));

				QAction *insertAction = new QAction(translatedName, insertFxGroup);
				QAction *addAction = new QAction(translatedName, addFxGroup);
				QAction *replaceAction = new QAction(translatedName, replaceFxGroup);

				insertAction->setData(QVariant(QString::fromStdString(fxName)));
				addAction->setData(QVariant(QString::fromStdString(fxName)));
				replaceAction->setData(QVariant(QString::fromStdString(fxName)));

				insertFxGroup->addAction(insertAction);
				addFxGroup->addAction(addAction);
				replaceFxGroup->addAction(replaceAction);

				m_insertActionGroup->addAction(insertAction);
				m_addActionGroup->addAction(addAction);
				m_replaceActionGroup->addAction(replaceAction);
			}
		}
	}
}
bool FullColorBrushTool::onPropertyChanged(string propertyName)
{
	m_minThick = m_thickness.getValue().first;
	m_maxThick = m_thickness.getValue().second;
	if (propertyName == "Hardness:" || propertyName == "Thickness") {
		m_brushPad = ToolUtils::getBrushPad(m_thickness.getValue().second, m_hardness.getValue() * 0.01);
		TRectD rect(m_brushPos - TPointD(m_maxThick + 2, m_maxThick + 2),
					m_brushPos + TPointD(m_maxThick + 2, m_maxThick + 2));
		invalidate(rect);
	}
	/*if(propertyName == "Hardness:" || propertyName == "Opacity:")
    setWorkAndBackupImages();*/
	FullcolorBrushMinSize = m_minThick;
	FullcolorBrushMaxSize = m_maxThick;
	FullcolorPressureSensibility = m_pressure.getValue();
	FullcolorBrushHardness = m_hardness.getValue();
	FullcolorMinOpacity = m_opacity.getValue().first;
	FullcolorMaxOpacity = m_opacity.getValue().second;

	if (propertyName == "Preset:") {
		loadPreset();
		getApplication()->getCurrentTool()->notifyToolChanged();
		return true;
	}

	if (m_preset.getValue() != CUSTOM_WSTR) {
		m_preset.setValue(CUSTOM_WSTR);
		getApplication()->getCurrentTool()->notifyToolChanged();
	}

	return true;
}
示例#7
0
TEST_F(MidiControllerTest, ReceiveMessage_PotMeterCO_14BitPitchBend) {
    ConfigKey key("[Channel1]", "rate");

    const double kMinValue = -1234.5;
    const double kMaxValue = 678.9;
    const double kMiddleValue = (kMinValue + kMaxValue) * 0.5;
    ControlPotmeter potmeter(key, kMinValue, kMaxValue);
    unsigned char channel = 0x01;

    // The control is ignored in mappings for messages where the control is part
    // of the payload.
    addMapping(MidiInputMapping(MidiKey(MIDI_PITCH_BEND | channel, 0xFF),
                                MidiOptions(), key));
    loadPreset(m_preset);

    // Receive a 0x0000, MIDI parameter should map to the min value.
    receive(MIDI_PITCH_BEND | channel, 0x00, 0x00);
    EXPECT_DOUBLE_EQ(kMinValue, potmeter.get());

    // Receive a 0x3FFF, MIDI parameter should map to the potmeter max value.
    receive(MIDI_PITCH_BEND | channel, 0x7F, 0x7F);
    EXPECT_DOUBLE_EQ(kMaxValue, potmeter.get());

    // Receive a 0x2000, MIDI parameter should map to the potmeter middle value.
    receive(MIDI_PITCH_BEND | channel, 0x00, 0x40);
    EXPECT_DOUBLE_EQ(kMiddleValue, potmeter.get());

    // Check the 14-bit resolution is actually present. Receive a 0x2001, MIDI
    // parameter should map to the middle value plus a tiny amount. Scaling is
    // not quite linear for MIDI parameters so just check that incrementing the
    // LSB by 1 is greater than the middle value.
    receive(MIDI_PITCH_BEND | channel, 0x01, 0x40);
    EXPECT_LT(kMiddleValue, potmeter.get());
}
示例#8
0
TEST_F(MidiControllerTest, ReceiveMessage_ToggleCO_PushCC) {
    // Some MIDI controllers (e.g. Korg nanoKONTROL) send momentary push-buttons
    // as (CC, 0x7f) for press and (CC, 0x00) for release.
    ConfigKey key("[Channel1]", "keylock");
    ControlPushButton cpb(key);
    cpb.setButtonMode(ControlPushButton::TOGGLE);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    addMapping(MidiInputMapping(MidiKey(MIDI_CC | channel, control),
                                MidiOptions(), key));
    loadPreset(m_preset);

    // Receive an on/off, toggles the control.
    receive(MIDI_CC | channel, control, 0x7F);
    receive(MIDI_CC | channel, control, 0x00);

    EXPECT_LT(0.0, cpb.get());

    // Receive an on/off, toggles the control.
    receive(MIDI_CC | channel, control, 0x7F);
    receive(MIDI_CC | channel, control, 0x00);

    EXPECT_DOUBLE_EQ(0.0, cpb.get());
}
示例#9
0
TEST_F(MidiControllerTest, ReceiveMessage_PotMeterCO_7BitCC) {
    ConfigKey key("[Channel1]", "playposition");

    const double kMinValue = -1234.5;
    const double kMaxValue = 678.9;
    const double kMiddleValue = (kMinValue + kMaxValue) * 0.5;
    ControlPotmeter potmeter(key, kMinValue, kMaxValue);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    addMapping(MidiInputMapping(MidiKey(MIDI_CC | channel, control),
                                MidiOptions(), key));
    loadPreset(m_preset);

    // Receive a 0, MIDI parameter should map to the min value.
    receive(MIDI_CC | channel, control, 0x00);
    EXPECT_DOUBLE_EQ(kMinValue, potmeter.get());

    // Receive a 0x7F, MIDI parameter should map to the potmeter max value.
    receive(MIDI_CC | channel, control, 0x7F);
    EXPECT_DOUBLE_EQ(kMaxValue, potmeter.get());

    // Receive a 0x40, MIDI parameter should map to the potmeter middle value.
    receive(MIDI_CC | channel, control, 0x40);
    EXPECT_DOUBLE_EQ(kMiddleValue, potmeter.get());
}
示例#10
0
TEST_F(MidiControllerTest, ReceiveMessage_ToggleCO_ToggleOnOff_ButtonMidiOption) {
    // Using the button MIDI option allows you to use a MIDI toggle button as a
    // push button.
    ConfigKey key("[Channel1]", "keylock");
    ControlPushButton cpb(key);
    cpb.setButtonMode(ControlPushButton::TOGGLE);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    MidiOptions options;
    options.button = true;

    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_ON | channel, control),
                                options, key));
    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_OFF | channel, control),
                                options, key));
    loadPreset(m_preset);

    // NOTE(rryan): If the intended behavior of the button MIDI option is to
    // make a toggle MIDI button act like a push button then this isn't
    // working. The toggle on toggles the CO but the toggle off does nothing.

    // Toggle the switch on, since it is interpreted as a button press it
    // toggles the button on.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_LT(0.0, cpb.get());

    // Toggle the switch off, since it is interpreted as a button release it
    // does nothing to the toggle button.
    receive(MIDI_NOTE_OFF | channel, control, 0x00);
    EXPECT_LT(0.0, cpb.get());
}
示例#11
0
TEST_F(MidiControllerTest, ReceiveMessage_PushButtonCO_PushOnOn) {
    // Some MIDI controllers send push-buttons as (NOTE_ON, 0x7f) for press and
    // (NOTE_ON, 0x00) for release.
    ConfigKey key("[Channel1]", "hotcue_1_activate");
    ControlPushButton cpb(key);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_ON | channel, control),
                                MidiOptions(), key));
    loadPreset(m_preset);

    // Receive an on/off, sets the control on/off with each press.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_LT(0.0, cpb.get());
    receive(MIDI_NOTE_ON | channel, control, 0x00);
    EXPECT_DOUBLE_EQ(0.0, cpb.get());

    // Receive an on/off, sets the control on/off with each press.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_LT(0.0, cpb.get());
    receive(MIDI_NOTE_ON | channel, control, 0x00);
    EXPECT_DOUBLE_EQ(0.0, cpb.get());
}
示例#12
0
TEST_F(MidiControllerTest, ReceiveMessage_ToggleCO_PushOnOff) {
    // Most MIDI controller send push-buttons as (NOTE_ON, 0x7F) for press and
    // (NOTE_OFF, 0x00) for release.
    ConfigKey key("[Channel1]", "keylock");
    ControlPushButton cpb(key);
    cpb.setButtonMode(ControlPushButton::TOGGLE);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_ON | channel, control),
                                MidiOptions(), key));
    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_OFF | channel, control),
                                MidiOptions(), key));
    loadPreset(m_preset);

    // Receive an on/off, toggles the control.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    receive(MIDI_NOTE_OFF | channel, control, 0x00);

    EXPECT_LT(0.0, cpb.get());

    // Receive an on/off, toggles the control.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    receive(MIDI_NOTE_OFF | channel, control, 0x00);

    EXPECT_DOUBLE_EQ(0.0, cpb.get());
}
示例#13
0
TEST_F(MidiControllerTest, ReceiveMessage_PushButtonCO_ToggleOnOff_ButtonMidiOption) {
    // Using the button MIDI option allows you to use a MIDI toggle button as a
    // push button.
    ConfigKey key("[Channel1]", "hotcue_1_activate");
    ControlPushButton cpb(key);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    MidiOptions options;
    options.button = true;

    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_ON | channel, control),
                                options, key));
    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_OFF | channel, control),
                                options, key));
    loadPreset(m_preset);

    // NOTE(rryan): This behavior is broken!

    // Toggle the switch on, sets the push button on.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_LT(0.0, cpb.get());

    // The push button is stuck down here!

    // Toggle the switch off, sets the push button off.
    receive(MIDI_NOTE_OFF | channel, control, 0x00);
    EXPECT_DOUBLE_EQ(0.0, cpb.get());
}
示例#14
0
// Preset control.
void synthv1widget_preset::initPreset (void)
{
	synthv1_config *pConfig = synthv1_config::getInstance();
	if (pConfig && !pConfig->sPreset.isEmpty())
		loadPreset(pConfig->sPreset);
	else
		newPreset();
}
void ClassSpaceChecker::onJarFileCurrentIndexChanged(int index)
{
	if(initJarFileComboFlag_)
		return;

	QString presetId = ui.comboBox_JarFile->itemData(index).toString();
	loadPreset(presetId);
}
示例#16
0
void AbstractProducerWidget::setProducer(Mlt::Producer* producer)
{
    delete m_producer;
    m_producer = 0;
    if (producer) {
        loadPreset(*producer);
        m_producer = new Mlt::Producer(producer);
    }
}
void LLWaterParamManager::loadAllPresets(const std::string& file_name)
{
	std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "windlight/water", ""));
	LL_DEBUGS2("AppInit", "ShaderLoading") << "Loading Default water settings from " << path_name << LL_ENDL;
			
	bool found = true;			
	while(found) 
	{
		std::string name;
		found = gDirUtilp->getNextFileInDir(path_name, "*.xml", name, false);
		if(found)
		{

			name=name.erase(name.length()-4);

			std::string unescaped_name = LLCurl::unescapeSafe(name);

			LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			loadPreset(unescaped_name,FALSE);
		}
	}

	// And repeat for user presets, note the user presets will modify any system presets already loaded

	std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", ""));
	LL_DEBUGS2("AppInit", "ShaderLoading") << "Loading User water settings from " << path_name2 << LL_ENDL;
			
	found = true;			
	while(found) 
	{
		std::string name;
		found = gDirUtilp->getNextFileInDir(path_name2, "*.xml", name, false);
		if(found)
		{
			name=name.erase(name.length()-4);

			std::string unescaped_name = LLCurl::unescapeSafe(name);

			LL_DEBUGS2("AppInit", "Shaders") << "name: " << name << LL_ENDL;
			loadPreset(unescaped_name,FALSE);
		}
	}

}
示例#18
0
void togglePreset(){
	if (CURRENT_PRESET >= (MAX_PRESETS - 1)) {
		CURRENT_PRESET = 0;
	} else {
		CURRENT_PRESET++;
	}
	
	eeprom_write_byte(&EEPROM_PRESET, CURRENT_PRESET);
	
	loadPreset();
}
void KinectV2Classifier::eventLoad(ofxControlButtonEventArgs & evt)
{
    if (!foundUser) {
        ofSystem("Error! You must have a skeleton detected first before loading the preset.");
        return;
    }
    ofFileDialogResult result = ofSystemLoadDialog("Select preset", false, ofToDataPath(""));
    if (result.bSuccess) {
        loadPreset(result.filePath);
    }
}
示例#20
0
void DlgPrefController::slotApply() {
    if (m_bDirty) {
        // Apply the presets and load the resulting preset.
        if (m_pInputTableModel != NULL) {
            m_pInputTableModel->apply();
        }

        if (m_pOutputTableModel != NULL) {
            m_pOutputTableModel->apply();
        }

        // Load script info from the script table.
        m_pPreset->scripts.clear();
        for (int i = 0; i < m_ui.m_pScriptsTableWidget->rowCount(); ++i) {
            QString scriptFile = m_ui.m_pScriptsTableWidget->item(i, 0)->text();

            // Skip empty rows.
            if (scriptFile.isEmpty()) {
                continue;
            }

            QString scriptPrefix = m_ui.m_pScriptsTableWidget->item(i, 1)->text();

            bool builtin = m_ui.m_pScriptsTableWidget->item(i, 2)
                    ->checkState() == Qt::Checked;

            ControllerPreset::ScriptFileInfo info;
            info.name = scriptFile;
            info.functionPrefix = scriptPrefix;
            info.builtin = builtin;
            m_pPreset->scripts.append(info);
        }

        // Load the resulting preset (which has been mutated by the input/output
        // table models). The controller clones the preset so we aren't touching
        // the same preset.
        emit(loadPreset(m_pController, m_pPreset));

        //Select the "..." item again in the combobox.
        m_ui.comboBoxPreset->setCurrentIndex(0);

        bool wantEnabled = m_ui.chkEnabledDevice->isChecked();
        bool enabled = m_pController->isOpen();
        if (wantEnabled && !enabled) {
            enableDevice();
        } else if (!wantEnabled && enabled) {
            disableDevice();
        }

        m_bDirty = false;
    }
}
void PMUICanvasRibbonRenderer::init(int posX, int posY, bool autosize, int width, int height)
{
    PMUICanvasBaseRenderer::init(posX, posY, autosize, width, height);

    gradientImage.load("./gradients/gradient4x_512x160.png");
    numGradients = 4;

    setGlobalSliderHeight(10);
    setGlobalButtonDimension(14);

    { // Brush (basic)
        addSpacer();
        addLabel(STR_BRUSH_BASIC);
        addIntSlider(STR_BRUSH_BASIC_NUMPAINTERS, 1, 100, &numPainters);
        addIntSlider(STR_BRUSH_BASIC_WIDTH, 1, 10, &strokeWidth);
        addSlider(STR_BRUSH_BASIC_SPEED, 1.01f, 100, &speed);
        addToggle(STR_BRUSH_BASIC_ENABLEBOUNCE, &enableBounce);
    }

    { // Brush (advanced)
        addSpacer();
        addLabel(STR_BRUSH_ADVANCED);
        addSlider(STR_BRUSH_ADVANCED_DIVISIONS, 0.001, 4.5, &divisions);
//        addSlider(STR_BRUSH_ADVANCED_EASE, -1.0, 10.0, &ease);
//        addSlider("Ease Randomness",0.0,1.0,&easeRandomness);
//        addIntSlider(STR_BRUSH_ADVANCED_MAXVERT,3, 4000, &pathMaxVertices);
        addSlider("Next Position Delta",0.0,1.0,&nextPositionDelta);
    }

    { // Color mode
        addSpacer();
        addLabel(STR_BRUSH_COLORMODE);

        vector<string> colorModesNames;
        colorModesNames.push_back(STR_BRUSH_COLORMODE_MFIXEDCOLOR);
        colorModesNames.push_back(STR_BRUSH_COLORMODE_MGRSPEED);
        colorModesNames.push_back(STR_BRUSH_COLORMODE_MGREDGES);
        addRadio(STR_BRUSH_COLORMODE_RADIO, colorModesNames, OFX_UI_ORIENTATION_VERTICAL);

        addImageSampler(STR_BRUSH_COLORMODE_GRIMAGE, &gradientImage);
        addIntSlider(STR_BRUSH_COLORMODE_GRID, 1, 4, &gradientId);
        addIntSlider(STR_BRUSH_COLORMODE_GRSPEED, 1, 500, &gradientSpeed);
        addIntSlider(STR_BRUSH_COLORMODE_R, 0, 255, &colorR);
        addIntSlider(STR_BRUSH_COLORMODE_G, 0, 255, &colorG);
        addIntSlider(STR_BRUSH_COLORMODE_B, 0, 255, &colorB);
    }

    if (autosize) autoSizeToFitWidgets();

    loadPreset(selectedPreset);
}
示例#22
0
void PresetManager::setFactoryDefaults() {
  SurfaceControlManager::displayOut.isOutputOn = false;

  for (curPreset=0; curPreset < 128; curPreset++) {
    setDefaultPreset();
    storePreset(0);
  }

  loadPreset(0);
  SurfaceControlManager::displayOut.clear();
  SurfaceControlManager::displayOut.writeEepromString(factoryDefaultsStr, 0, 0);
  SurfaceControlManager::displayOut.writeEepromString(restoredStr, 1, 4);
  SurfaceControlManager::displayOut.isOutputOn = true;
}
void ClassSpaceChecker::checkAndJarFilePreset(const QString &jarPath)
{
	CPresetData preset = gSettingManager.getPresetDataWithKeyName(jarPath);

	if(preset.isEmpty()) 
	{
		ui.comboBox_JarFile->setEditText(jarPath);
		ui.lineEdit_MapFile->setText("");
	}
	else
	{
		loadPreset(preset.getId());
	}
}
示例#24
0
文件: ui.cpp 项目: tszirr/lighter
void preset_user_interface(UniversalInterface& ui, stdx::fun_ref<void(UniversalInterface&)> target
                         , char const* defaultFile, char const* activeFilePath, ui::UniversalInterface::InteractionParam<char const*> activeFileChange
                         , char const* groupName, UniqueElementIdentifier id)
{
	if (!id.value) id = UEI(preset_user_interface);

	if (auto presetGroup = ui::Group(ui, id))
	{
		uintptr_t controlIdentifier = 0;

		ui.addText(controlIdentifier++, (groupName) ? groupName : "Preset", "", nullptr);

		auto&& loadPreset = [&](char const* file)
		{
			try
			{
				activeFilePath = defaultFile = nullptr; // warning: everything may change
				if (activeFileChange) activeFileChange->updateValue(file);
				load_ini_file(file, target);
			}
			catch(...) { stdx::prompt(appx::exception_string().c_str(), "Error applying preset"); }
		};
		if (activeFilePath)
		{
			auto hiddenIdentifier = controlIdentifier++;
			if (activeFilePath[0]) ui.addHidden(hiddenIdentifier, "active", activeFilePath, loadPreset);
		}
		ui.addButton(controlIdentifier++, (activeFilePath && activeFilePath[0] && defaultFile && defaultFile[0]) ? defaultFile : "load", [&]()
		{
			auto mf = stdx::prompt_file_compat(defaultFile, "Ini files=*.ini|All files=*.*", stdx::dialog::open, true);
			for (auto&&f : mf) loadPreset(f.c_str());
		});
		

		ui.addButton(controlIdentifier++, "save", [&]()
		{
			auto mf = stdx::prompt_file_compat(defaultFile, "Ini files=*.ini|All files=*.*", stdx::dialog::save);
			for (auto&&f : mf)
			{
				try
				{
					activeFilePath = defaultFile = nullptr; // warning: everything may change
					if (activeFileChange) activeFileChange->updateValue(f.c_str());
					save_ini_file(f.c_str(), target);
				}
				catch(...) { stdx::prompt(appx::exception_string().c_str(), "Error saving preset"); }
			}
		});
	}
}
示例#25
0
TEST_F(MidiControllerTest, ReceiveMessage_ToggleCO_ToggleOnOff_SwitchMidiOption) {
    // Using the switch MIDI option interprets a MIDI toggle button as a toggle
    // button rather than a momentary push button.
    ConfigKey key("[Channel1]", "keylock");
    ControlPushButton cpb(key);
    cpb.setButtonMode(ControlPushButton::TOGGLE);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    MidiOptions options;
    options.sw = true;

    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_ON | channel, control),
                                options, key));
    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_OFF | channel, control),
                                options, key));
    loadPreset(m_preset);

    // NOTE(rryan): If the intended behavior of switch MIDI option is to make a
    // toggle MIDI button act like a toggle button then this isn't working. The
    // toggle on presses the CO and the toggle off presses the CO. This toggles
    // the control but allows it to get out of sync.

    // Toggle the switch on, since it is interpreted as a button press it
    // toggles the control on.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_LT(0.0, cpb.get());

    // Toggle the switch off, since it is interpreted as a button press it
    // toggles the control off.
    receive(MIDI_NOTE_OFF | channel, control, 0x00);
    EXPECT_DOUBLE_EQ(0.0, cpb.get());

    // Meanwhile, the GUI toggles the control on again.
    // NOTE(rryan): Now the MIDI toggle button is out of sync with the toggle
    // CO.
    cpb.set(1.0);

    // Toggle the switch on, since it is interpreted as a button press it
    // toggles the control off (since it was on).
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_DOUBLE_EQ(0.0, cpb.get());

    // Toggle the switch off, since it is interpreted as a button press it
    // toggles the control on (since it was off).
    receive(MIDI_NOTE_OFF | channel, control, 0x00);
    EXPECT_LT(0.0, cpb.get());
}
示例#26
0
void togglePreset(){
	if (CURRENT_PRESET[currentSelector] >= (MAX_PRESETS - 1)) {
		CURRENT_PRESET[currentSelector] = 0;
	} else {
		CURRENT_PRESET[currentSelector]++;
	}
	
	if (currentSelector == 0) {
		eeprom_write_byte(&EEPROM_PRESET_1, CURRENT_PRESET[0]);
	} else {
		eeprom_write_byte(&EEPROM_PRESET_2, CURRENT_PRESET[1]);
	}
	
	loadPreset();
}
示例#27
0
TEST_F(MidiControllerTest, ReceiveMessage_PushButtonCO_ToggleOnOff_SwitchMidiOption) {
    // Using the switch MIDI option interprets a MIDI toggle button as a toggle
    // button rather than a momentary push button.
    ConfigKey key("[Channel1]", "hotcue_1_activate");
    ControlPushButton cpb(key);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    MidiOptions options;
    options.sw = true;

    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_ON | channel, control),
                                options, key));
    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_OFF | channel, control),
                                options, key));
    loadPreset(m_preset);

    // NOTE(rryan): This behavior is broken!

    // Toggle the switch on, sets the push button on.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_LT(0.0, cpb.get());

    // The push button is stuck down here!

    // Toggle the switch off, sets the push button on again.
    receive(MIDI_NOTE_OFF | channel, control, 0x00);
    EXPECT_LT(0.0, cpb.get());

    // NOTE(rryan): What is supposed to happen in this case? It's an open
    // question I think. I think if you want to connect a switch MIDI control to
    // a push button CO then the switch should directly set the CO. After all,
    // the preset author asked for the switch to be interpreted as a switch. If
    // they want the switch to act like a push button, they should use the
    // button MIDI option.
    //
    // Most of our push buttons trigger behavior on press and do nothing on
    // release, and most don't care about being "stuck down" except for hotcue
    // and cue controls that have preview behavior.

    // "reverse" is an example of a push button that is a push button because we
    // want the default behavior to be momentary press and not toggle. If I
    // mapped a switch to it, I would expect the switch to enable it (set it to
    // 1) when the switch was enabled and set it to 0 when the switch was
    // disabled. So I think we should change the switch option to behave like
    // this.
}
示例#28
0
    void soundBank::loadPresetsOrInitialise(){

        string filename = "";
        ofxXmlSettings settings;

        for(int i = 0; i <= TOTAL_SLOTS; i++) {

            // initialise the 2d vector
            vector<msp::avUgen*> row;
            presetSlots.push_back(row);

            filename = "avUgen/" + avUgenNames.at(i) + ".xml";

            if(settings.loadFile(filename)){
                ofLogNotice() << filename + " loaded! +++++++++++++++++";

                settings.pushTag("avUgens", 0);
                ofLogNotice() << "Found presets in file: " << settings.getNumTags("avUgen") << endl;

                for (int j = 0; j <= TOTAL_PRESETS; j++){

                    std::ostringstream buf;                    
                    buf << avUgenNames.at(i) << "-" << j;

                    loadPreset(settings, j, buf.str(), i);
                }

                settings.popTag(); //avUgens

            } else {
                ofLogWarning() << "***********************************************************************************";
                ofLogWarning() << "* unable to load "+ filename +" check data/ folder. Initialising defaults instead.*";
                ofLogWarning() << "***********************************************************************************";

                for (int j = 0; j <= TOTAL_PRESETS; j++){

                    std::ostringstream buf;
                    buf << avUgenNames.at(i) << "-" << j;

                    avUgen *preset = new msp::avUgen(settings.getValue("avUgen:name", buf.str(), i));
                    presetSlots[i].push_back(preset);
                }

            }
            
        }

    }
示例#29
0
void synthv1widget_preset::resetPreset (void)
{
	const QString& sPreset = m_pComboBox->currentText();
	const bool bLoadPreset = (!sPreset.isEmpty()
		&& m_pComboBox->findText(sPreset) >= 0);
	if (bLoadPreset && !queryPreset())
		return;

	if (bLoadPreset) {
		loadPreset(sPreset);
	} else {
		emit resetPresetFile();
		m_iDirtyPreset = 0;
		stabilizePreset();
	}
}
示例#30
0
void DlgPrefController::slotLoadPreset(int chosenIndex) {
    if (chosenIndex == 0) {
        // User picked ...
        return;
    }

    const QString presetPath = m_ui.comboBoxPreset->itemData(chosenIndex).toString();
    // When loading the preset, we only want to load from the same dir as the
    // preset itself, otherwise when loading from the system-wide dir we'll
    // start the search in the user's dir find the existing script,
    // and do nothing.
    const QFileInfo presetFileInfo(presetPath);
    QList<QString> presetDirs;
    presetDirs.append(presetFileInfo.canonicalPath());

    ControllerPresetPointer pPreset = ControllerPresetFileHandler::loadPreset(
        presetPath, ControllerManager::getPresetPaths(m_pConfig));

    // Import the preset scripts to the user scripts folder.
    for (QList<ControllerPreset::ScriptFileInfo>::iterator it =
                 pPreset->scripts.begin(); it != pPreset->scripts.end(); ++it) {
        // No need to import builtin scripts.
        if (it->builtin) {
            continue;
        }

        QString scriptPath = ControllerManager::getAbsolutePath(
                it->name, presetDirs);


        QString importedScriptFileName;
        // If a conflict exists then importScript will provide a new filename to
        // use. If importing fails then load the preset anyway without the
        // import.
        if (m_pControllerManager->importScript(scriptPath, &importedScriptFileName)) {
            it->name = importedScriptFileName;
        }
    }

    // TODO(rryan): We really should not load the preset here. We should load it
    // into the preferences GUI and then load it to the actual controller once
    // the user hits apply.
    emit(loadPreset(m_pController, pPreset));
    slotDirty();
}