[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pattern flags: Bug Fix



Thanks for pointing to the source of the flag problems -- here is my
version of the fix (your flags were off in a few places, and this code
makes it clearer what is going on here).  I actually tested this and
it works!  However, the use of the combined flags (e.g.,
TARG_EXT_FLAG) is bad because it makes anything that is just one of
these into both of them (e.g., it turns a TARG_FLAG into a
TARG_EXT_FLAG), so I'm thinking that I'll remove these other options
from the menu in a future revision.  In any case, it is probably a
good idea to avoid them unless that is all you want to be setting.

				- Randy

void EnvEditor::SetPatFlags(taivMenuEl* sel) { // set patflags from menu
  Apply(); // apply current settings
  patflags = PatternSpec::NO_FLAGS; specflags = false;
  int submnu = ((taivHierEl *) sel)->sub_no;
  if(submnu > 0) {		// submnu 1 = pattern flags, submnu 2 = global (spec) flags
    if(submnu == 2)
      specflags = true;		// global (spec) flags
    int flag_sel = sel->itm_no;	// which flag item selected (TARG_FLAG (=0) - NO_APPLY (=12))
    // can't just bit-shift because some combinations are represented and others are pure flags
    // (i.e., TARG_EXT_FLAG is OR of TARG_FLAG and EXT_FLAG, but there aren't such combinations
    // for TARG_VALUE and TARG_FLAG, for example..
    switch (flag_sel) {
    case 0: patflags = PatternSpec::TARG_FLAG; break;
    case 1: patflags = PatternSpec::EXT_FLAG; break;
    case 2: patflags = PatternSpec::TARG_EXT_FLAG; break;
    case 3: patflags = PatternSpec::COMP_FLAG; break;
    case 4: patflags = PatternSpec::COMP_TARG_FLAG; break;
    case 5: patflags = PatternSpec::COMP_EXT_FLAG; break;
    case 6: patflags = PatternSpec::COMP_TARG_EXT_FLAG; break;
    case 7: patflags = PatternSpec::TARG_VALUE; break;
    case 8: patflags = PatternSpec::EXT_VALUE; break;
    case 9: patflags = PatternSpec::TARG_EXT_VALUE; break;
    case 10: patflags = PatternSpec::NO_UNIT_FLAG; break;
    case 11: patflags = PatternSpec::NO_UNIT_VALUE; break;
    case 12: patflags = PatternSpec::NO_APPLY; break;
    }
  }
  if((patflags != PatternSpec::NO_FLAGS) &&
     (owner->auto_scale == true) && (cbar != NULL))
    cbar->SetMinMax(-1,1);
  UpdateDisplay();
}