Index: cpp/frams/_demos/genooper_test.cpp =================================================================== --- cpp/frams/_demos/genooper_test.cpp (revision 530) +++ cpp/frams/_demos/genooper_test.cpp (revision 532) @@ -32,11 +32,11 @@ char format = gsrc.getFormat(); - Geno gmut = genetics.genman.Mutate(gsrc); + Geno gmut = genetics.genman.mutate(gsrc); printGenAndTitle(gmut, "mutated (gmut)"); - Geno gxover = genetics.genman.CrossOver(gsrc, gmut); + Geno gxover = genetics.genman.crossOver(gsrc, gmut); printGenAndTitle(gxover, "crossed over (gsrc and gmut)"); - Geno gsimplest = genetics.genman.GetSimplest(format); + Geno gsimplest = genetics.genman.getSimplest(format); printGenAndTitle(gsimplest, "simplest"); @@ -44,5 +44,5 @@ printGenAndTitle(ginvalid, "invalid"); - Geno gvalidated = genetics.genman.Validate(ginvalid); + Geno gvalidated = genetics.genman.validate(ginvalid); printGenAndTitle(gvalidated, "validated"); Index: cpp/frams/genetics/genman.cpp =================================================================== --- cpp/frams/genetics/genman.cpp (revision 530) +++ cpp/frams/genetics/genman.cpp (revision 532) @@ -210,8 +210,8 @@ if (check1 == GENOPER_NOOPER) //disaster: cannot check because there is no check operator { - g.setGene(g2); free(g2); canvalidate = false; return GENOPER_NOOPER; + g.setGeneOnly(g2); free(g2); canvalidate = false; return GENOPER_NOOPER; } int check2 = gf->checkValidity(g2, "validated"); - if (check2 == GENOPER_OK) g.setGene(g2); + if (check2 == GENOPER_OK) g.setGeneOnly(g2); free(g2); if (check2 == GENOPER_OK) return check1; @@ -231,5 +231,5 @@ } -Geno GenMan::Validate(const Geno& geny) +Geno GenMan::validate(const Geno& geny) { char format = geny.getFormat(); @@ -247,5 +247,5 @@ } -Geno GenMan::Mutate(const Geno& g) +Geno GenMan::mutate(const Geno& g) { float chg; //how many changes @@ -298,5 +298,5 @@ } -Geno GenMan::CrossOver(const Geno& g1, const Geno& g2) +Geno GenMan::crossOver(const Geno& g1, const Geno& g2) { char format = g1.getFormat(); @@ -364,5 +364,5 @@ } -float GenMan::Similarity(const Geno& g1, const Geno& g2) +float GenMan::similarity(const Geno& g1, const Geno& g2) { char format = g1.getFormat(); @@ -372,25 +372,46 @@ } -uint32_t GenMan::Style(const char *g, int pos) +uint32_t GenMan::getStyle(const char *g, const Geno *G, int pos) +{ + char format = G->getFormat(); + if (format == Geno::INVALID_FORMAT) + return GENSTYLE_RGBS(64, 64, 64, 0); // gray & "valid" (unknown format so we don't know what is valid and what is not) + if ((pos = G->mapStringToGen(pos)) == -1) return GENSTYLE_COMMENT; + GenoOperators *gf = getOper_f(format); + if (!gf) return GENSTYLE_CS(0, 0); //black & valid + else return gf->style(G->getGene().c_str(), pos); +} + +uint32_t GenMan::getStyle(const char *g, int pos) { Geno G(g); - if ((pos = G.mapStringToGen(pos)) == -1) return GENSTYLE_COMMENT; - GenoOperators *gf = getOper_f(G.getFormat()); - if (!gf) return GENSTYLE_CS(0, 0); //black & valid - else return gf->style(G.getGene().c_str(), pos); -} - -void GenMan::GetFullStyle(const char *g, uint32_t *styletab) -{ - Geno G(g); - GenoOperators *gf = getOper_f(G.getFormat()); - SString geny = G.getGene(); + return getStyle(g, &G, pos); +} + +void GenMan::getFullStyle(const char *g, const Geno *G, uint32_t *styletab) +{ + char format = G->getFormat(); + if (format == Geno::INVALID_FORMAT) + { + for (unsigned int pos = 0; pos < strlen(g); pos++) + styletab[pos] = GENSTYLE_RGBS(64, 64, 64, 0); // gray & "valid" (unknown format so we don't know what is valid and what is not) + return; + } + GenoOperators *gf = getOper_f(format); + SString geny=G->getGene(); for (unsigned int pos = 0; pos < strlen(g); pos++) { - int posmapped = G.mapStringToGen(pos); + int posmapped = G->mapStringToGen(pos); if (posmapped == -1) styletab[pos] = GENSTYLE_COMMENT; else if (!gf) styletab[pos] = GENSTYLE_CS(0, 0); //black & valid else styletab[pos] = gf->style(geny.c_str(), posmapped); - } + //logPrintf("GenMan", "getFullStyle", 0, "%d char='%c' (%d) format=0x%08x", pos, g[pos], g[pos], styletab[pos]); + } +} + +void GenMan::getFullStyle(const char *g, uint32_t *styletab) +{ + Geno G(g); + getFullStyle(g, &G, styletab); } @@ -406,5 +427,5 @@ bool shortened = false; uint32_t *styletab = new uint32_t[len]; - GetFullStyle(g, styletab); + getFullStyle(g, styletab); string html = "\n