void Preferences::onChangeHedgeSelection(int) {
            fl::Engine* engine = Model::Default()->engine();
            if (ui->ckx_any->isChecked() and not engine->hasHedge(Any().name()))
                engine->addHedge(new Any);
            else if (not ui->ckx_any->isChecked() and engine->hasHedge(Any().name()))
                delete engine->removeHedge(Any().name());

            if (ui->ckx_extremely->isChecked() and not engine->hasHedge(Extremely().name()))
                engine->addHedge(new Extremely);
            else if (not ui->ckx_extremely->isChecked() and engine->hasHedge(Extremely().name()))
                delete engine->removeHedge(Extremely().name());

            if (ui->ckx_not->isChecked() and not engine->hasHedge(Not().name()))
                engine->addHedge(new Not);
            else if (not ui->ckx_not->isChecked() and engine->hasHedge(Not().name()))
                delete engine->removeHedge(Not().name());

            if (ui->ckx_seldom->isChecked() and not engine->hasHedge(Seldom().name()))
                engine->addHedge(new Seldom);
            else if (not ui->ckx_seldom->isChecked() and engine->hasHedge(Seldom().name()))
                delete engine->removeHedge(Seldom().name());

            if (ui->ckx_somewhat->isChecked() and not engine->hasHedge(Somewhat().name()))
                engine->addHedge(new Somewhat);
            else if (not ui->ckx_somewhat->isChecked() and engine->hasHedge(Somewhat().name()))
                delete engine->removeHedge(Somewhat().name());

            if (ui->ckx_very->isChecked() and not engine->hasHedge(Very().name()))
                engine->addHedge(new Very);
            else if (not ui->ckx_very->isChecked() and engine->hasHedge(Very().name()))
                delete engine->removeHedge(Very().name());

            Window::mainWindow()->fixDependencies();
        }
 std::string CppExporter::toString(const Hedge * hedge) const {
     if (hedge->name() == Any().name()) return "new " + fl("Any");
     if (hedge->name() == Extremely().name()) return "new " + fl("Extremely");
     if (hedge->name() == Not().name()) return "new " + fl("Not");
     if (hedge->name() == Seldom().name()) return "new " + fl("Seldom");
     if (hedge->name() == Somewhat().name()) return "new " + fl("Somewhat");
     if (hedge->name() == Very().name()) return "new " + fl("Very");
     return "new " + fl(hedge->name());
 }
Exemple #3
0
 std::string CppExporter::toString(const Hedge * hedge) const {
     if (hedge->name() == Any().name()) return "new fl::Any";
     if (hedge->name() == Extremely().name()) return "new fl::Extremely";
     if (hedge->name() == Not().name()) return "new fl::Not";
     if (hedge->name() == Seldom().name()) return "new fl::Seldom";
     if (hedge->name() == Somewhat().name()) return "new fl::Somewhat";
     if (hedge->name() == Very().name()) return "new fl::Very";
     return hedge->name();
 }
 HedgeFactory::HedgeFactory() : ConstructionFactory<Hedge*>("Hedge") {
     registerConstructor("", fl::null);
     registerConstructor(Any().name(), &(Any::constructor));
     registerConstructor(Extremely().name(), &(Extremely::constructor));
     registerConstructor(Not().name(), &(Not::constructor));
     registerConstructor(Seldom().name(), &(Seldom::constructor));
     registerConstructor(Somewhat().name(), &(Somewhat::constructor));
     registerConstructor(Very().name(), &(Very::constructor));
 }
        void Preferences::loadFromModel() {
            disconnect();
            fl::Engine* engine = Model::Default()->engine();
            if (engine->numberOfRuleBlocks() == 0) {
                QMessageBox::critical(this, "Error",
                        "Current engine has no rule blocks. "
                        "At least one ruleblock was expected.",
                        QMessageBox::Ok);
                return;
            }
            RuleBlock* ruleblock = engine->getRuleBlock(0);
            ui->cbx_tnorm->setCurrentIndex(indexOfTnorm(ruleblock->getTnorm()->className()));
            ui->cbx_snorm->setCurrentIndex(indexOfSnorm(ruleblock->getSnorm()->className()));
            ui->cbx_activation->setCurrentIndex(indexOfTnorm(ruleblock->getActivation()->className()));
            if (engine->numberOfOutputVariables() > 0) {
                OutputVariable* variable = engine->getOutputVariable(0);
                ui->cbx_defuzzifier->setCurrentIndex(
                        indexOfDefuzzifier(variable->getDefuzzifier()->className()));
                ui->sbx_divisions->setValue(variable->getDefuzzifier()->getDivisions());

                ui->cbx_accumulation->setCurrentIndex(
                        indexOfSnorm(variable->output()->getAccumulation()->className()));
            } else {
                ui->cbx_defuzzifier->setCurrentIndex(0);
                ui->sbx_divisions->setValue(fl::fuzzylite::defaultDivisions());
                ui->cbx_accumulation->setCurrentIndex(0);
            }

            ui->ckx_any->setChecked(engine->hasHedge(Any().name()));

            ui->ckx_extremely->setChecked(engine->hasHedge(Extremely().name()));
            ui->ckx_not->setChecked(engine->hasHedge(Not().name()));
            ui->ckx_seldom->setChecked(engine->hasHedge(Seldom().name()));
            ui->ckx_somewhat->setChecked(engine->hasHedge(Somewhat().name()));
            ui->ckx_very->setChecked(engine->hasHedge(Very().name()));

            connect();
        }