示例#1
0
string RenderingRule::getColorPropertyValue(string property) {
	int i = getPropertyIndex(property);
	if (i >= 0) {
		return colorToString(intProperties[i]);
	}
	return "";
}
示例#2
0
float RenderingRule::getFloatPropertyValue(string property) {
	int i = getPropertyIndex(property);
	if (i >= 0) {
		return floatProperties[i];
	}
	return 0;
}
示例#3
0
string RenderingRule::getStringPropertyValue(string property, RenderingRulesStorage* storage) {
	int i = getPropertyIndex(property);
	if (i >= 0) {
		return storage->getStringValue(intProperties[i]);
	}
	return "";
}
示例#4
0
int RenderingRule::getIntPropertyValue(string property) {
	int i = getPropertyIndex(property);
	if (i >= 0) {
		return intProperties[i];
	}
	return -1;
}
示例#5
0
void    Properties::propertyChanged( )
{
    if ( getTarget() == nullptr )
        return;
    // Note 20151029: Here is the magic, get the sender signal name an extract the 'property name'
    int senderSignalId = senderSignalIndex( );
    if ( ( sender( ) == this || sender() == getTarget() ) &&
         senderSignalId != -1 ) {
        QMetaMethod senderSignal{};
        if ( sender() == this )
            senderSignal = metaObject( )->method( senderSignalId );
        if ( getTarget() != nullptr && sender() == getTarget() )
            senderSignal = getTarget()->metaObject( )->method( senderSignalId );

        if ( senderSignal.isValid( ) ) {
            QString senderSignalName( senderSignal.name( ) );
            // FIXME 20151029 Document that behaviour: QuickProperties only works with xxxChanged() NOTIFY signals (this is the standard Qt "coding style").
            QStringList propertyNames = senderSignalName.split( QRegExp( "Changed" ) );
            if ( propertyNames.size( ) > 0 ) {
                QString propertyName = propertyNames.at( 0 );
                int propertyIndex = getPropertyIndex( propertyName );
                QModelIndex propertyModelIndex = index( propertyIndex );
                if ( propertyModelIndex.isValid( ) ) {
                    emit dataChanged( propertyModelIndex, propertyModelIndex );
                    emit propertiesModified( propertyName );
                }
            }
        }
    }
}
示例#6
0
/**
 * This function is called from the syntax parser in file pgmParser.c.
 * Return: 0 OK, non-zero error.
 */
int bindToProgram (void * pp,
		   const char * fileName,
		   const int    lineNumber,
		   const int    pgmnr,
		   const char * sym,
		   const char * val)
{
  struct b_programme *p = (struct b_programme *)pp;
  int prop;
  char msg[MESSAGEBUFFERSIZE];
  float fv;
  int iv;
  int rtn;
  Programme * PGM;

  /* Check the program number */

  if ((pgmnr < 0) || (MAXPROGS <= pgmnr)) {
    sprintf (msg, "Program number %d out of range", pgmnr);
    return stateMessage (fileName, lineNumber, msg, -1);
  }

  PGM = &(p->programmes[pgmnr]);

  /* If this is a new program number, clear the property flags */

  if (pgmnr != p->previousPgmNr) {
    PGM->flags[0] = 0;
    p->previousPgmNr = pgmnr;
  }

  /* Scan for a matching property symbol */

  prop = getPropertyIndex (sym);

  if (prop < 0) {
    sprintf (msg, "Unrecognized property '%s'", sym);
    return stateMessage (fileName, lineNumber, msg, -1);
  }

  switch (prop) {

  case pr_Name:
    strncpy (PGM->name, val, NAMESZ);
    PGM->name[NAMESZ-1] = '\0';
    PGM->flags[0] |= FL_INUSE;
    break;

  case pr_Drawbars:
    if (!strcasecmp (val, "random")) {
      PGM->flags[0] |= (FL_INUSE | FL_DRAWBR | FL_DRWRND);
    }
    else if (!parseDrawbarRegistration (val,
					PGM->drawbars,
					lineNumber,
					fileName)) {
      PGM->flags[0] |= (FL_INUSE|FL_DRAWBR);
    }
    else {
      return -1;
    }
    break;

  case pr_LowerDrawbars:
    if (!strcasecmp (val, "random")) {
      PGM->flags[0] |= (FL_INUSE | FL_LOWDRW | FL_DRWRND);
    } else if (!parseDrawbarRegistration (val,
					  PGM->lowerDrawbars,
					  lineNumber,
					  fileName)) {
      PGM->flags[0] |= (FL_INUSE | FL_LOWDRW);
    } else {
      return -1;
    }
    break;

  case pr_PedalDrawbars:
    if (!strcasecmp (val, "random")) {
      PGM->flags[0] |= (FL_INUSE | FL_PDLDRW | FL_DRWRND);
    } else if (!parseDrawbarRegistration (val,
					  PGM->pedalDrawbars,
					  lineNumber,
					  fileName)) {
      PGM->flags[0] |= (FL_INUSE | FL_PDLDRW);
    } else {
      return -1;
    }
    break;

  case pr_Scanner:
    if (!strcasecmp (val, "v1")) {
      PGM->scanner = (PGM->scanner & 0xFF00) | VIB1;	/* in vibrato.h */
      PGM->flags[0] |= (FL_INUSE|FL_SCANNR);
    }
    else if (!strcasecmp (val, "v2")) {
      PGM->scanner = (PGM->scanner & 0xFF00) | VIB2;	/* in vibrato.h */
      PGM->flags[0] |= (FL_INUSE|FL_SCANNR);
    }
    else if (!strcasecmp (val, "v3")) {
      PGM->scanner = (PGM->scanner & 0xFF00) | VIB3;	/* in vibrato.h */
      PGM->flags[0] |= (FL_INUSE|FL_SCANNR);
    }
    else if (!strcasecmp (val, "c1")) {
      PGM->scanner = (PGM->scanner & 0xFF00) | CHO1;	/* in vibrato.h */
      PGM->flags[0] |= (FL_INUSE|FL_SCANNR);
    }
    else if (!strcasecmp (val, "c2")) {
      PGM->scanner = (PGM->scanner & 0xFF00) | CHO2;	/* in vibrato.h */
      PGM->flags[0] |= (FL_INUSE|FL_SCANNR);
    }
    else if (!strcasecmp (val, "c3")) {
      PGM->scanner = (PGM->scanner & 0xFF00) | CHO3;	/* in vibrato.h */
      PGM->flags[0] |= (FL_INUSE|FL_SCANNR);
    }
    else {
      sprintf (msg, "Unrecognized vibrato value '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    break;

  case pr_VibratoUpper:
    if (isNegatory (val)) {
      PGM->scanner &= ~0x200;
      PGM->flags[0] |= (FL_INUSE|FL_VCRUPR);
    }
    else if (isAffirmative (val)) {
      PGM->scanner |= 0x200;
      PGM->flags[0] |= (FL_INUSE|FL_VCRUPR);
    }
    else {
      sprintf (msg, "Unrecognized keyword '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    break;			/* pr_VibratoUpper */

  case pr_VibratoLower:
    if (isNegatory (val)) {
      PGM->scanner &= ~0x100;
      PGM->flags[0] |= (FL_INUSE|FL_VCRLWR);
    }
    else if (isAffirmative (val)) {
      PGM->scanner |= 0x100;
      PGM->flags[0] |= (FL_INUSE|FL_VCRLWR);
    }
    else {
      sprintf (msg, "Unrecognized keyword '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    break;			/* pr_VibratoUpper */

  case pr_PercussionEnabled:
    if (isAffirmative (val)) {
      PGM->percussionEnabled = TRUE;
      PGM->flags[0] |= (FL_INUSE|FL_PRCENA);
    }
    else if (isNegatory (val)) {
      PGM->percussionEnabled = FALSE;
      PGM->flags[0] |= (FL_INUSE|FL_PRCENA);
    }
    else {
      sprintf (msg, "Unrecognized percussion enabled value '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    break;

  case pr_PercussionVolume:
    if (!strcasecmp (val, "normal") ||
	!strcasecmp (val, "high")   ||
	!strcasecmp (val, "hi")) {
      PGM->percussionVolume = FALSE;
      PGM->flags[0] |= (FL_INUSE|FL_PRCVOL);
    }
    else if (!strcasecmp (val, "soft") ||
	     !strcasecmp (val, "low")  ||
	     !strcasecmp (val, "lo")) {
      PGM->percussionVolume = TRUE;
      PGM->flags[0] |= (FL_INUSE|FL_PRCVOL);
    }
    else {
      sprintf (msg, "Unrecognized percussion volume argument '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    break;

  case pr_PercussionSpeed:
    if (!strcasecmp (val, "fast") ||
	!strcasecmp (val, "high") ||
	!strcasecmp (val, "hi")) {
      PGM->percussionSpeed = TRUE;
      PGM->flags[0] |= (FL_INUSE|FL_PRCSPD);
    }
    else if (!strcasecmp (val, "slow") ||
	     !strcasecmp (val, "low")  ||
	     !strcasecmp (val, "lo")) {
      PGM->percussionSpeed = FALSE;
      PGM->flags[0] |= (FL_INUSE|FL_PRCSPD);
    }
    else {
      sprintf (msg, "Unrecognized percussion speed argument '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    break;

  case pr_PercussionHarmonic:
    if (!strcasecmp (val, "second") ||
	!strcasecmp (val, "2nd")    ||
	!strcasecmp (val, "low")    ||
	!strcasecmp (val, "lo")) {
      PGM->percussionHarmonic = TRUE;
      PGM->flags[0] |= (FL_INUSE|FL_PRCHRM);
    }
    else if (!strcasecmp (val, "third") ||
	     !strcasecmp (val, "3rd")   ||
	     !strcasecmp (val, "high")  ||
	     !strcasecmp (val, "hi")) {
      PGM->percussionHarmonic = FALSE;
      PGM->flags[0] |= (FL_INUSE|FL_PRCHRM);
    }
    else {
      sprintf (msg, "Unrecognized percussion harmonic option '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    break;

  case pr_OverdriveSelect:
    if (isNegatory (val)) {
      PGM->overdriveSelect = TRUE;
      PGM->flags[0] |= (FL_INUSE|FL_OVRSEL);
    }
    else if (isAffirmative (val)) {
      PGM->overdriveSelect = FALSE;
      PGM->flags[0] |= (FL_INUSE|FL_OVRSEL);
    }
    else {
      sprintf (msg, "Unrecognized overdrive select argument '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    break;

  case pr_RotarySpeedSelect:
    if (!strcasecmp (val, "tremolo") ||
	!strcasecmp (val, "fast")    ||
	!strcasecmp (val, "high")    ||
	!strcasecmp (val, "hi")) {
      PGM->rotarySpeedSelect = WHIRL_FAST;
      PGM->flags[0] |= (FL_INUSE|FL_ROTSPS);
    }
    else if (!strcasecmp (val, "chorale") ||
	     !strcasecmp (val, "slow")    ||
	     !strcasecmp (val, "low")     ||
	     !strcasecmp (val, "lo")) {
      PGM->rotarySpeedSelect = WHIRL_SLOW;
      PGM->flags[0] |= (FL_INUSE|FL_ROTSPS);
    }
    else if (!strcasecmp (val, "stop")  ||
	     !strcasecmp (val, "zero")  ||
	     !strcasecmp (val, "break") ||
	     !strcasecmp (val, "stopped")) {
      PGM->rotarySpeedSelect = WHIRL_STOP;
      PGM->flags[0] |= (FL_INUSE|FL_ROTSPS);
    }
    else {
      sprintf (msg, "Unrecognized rotary speed argument '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    break;

  case pr_ReverbMix:
    PGM->flags[0] |= (FL_INUSE|FL_RVBMIX);
    if (sscanf (val, "%f", &fv) == 0) {
      sprintf (msg, "Unrecognized reverb mix value : '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    else if ((fv < 0.0) || (1.0 < fv)) {
      sprintf (msg, "Reverb mix value out of range : %f", fv);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    else {
      PGM->reverbMix = fv;
    }
    break;

  case pr_KeyboardSplitLower:
    PGM->flags[0] |= (FL_INUSE|FL_KSPLTL);
    if (sscanf (val, "%d", &iv) == 0) {
      sprintf (msg, "Lower split: unparsable MIDI note number : '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    else if ((iv < 0) || (127 < iv)) {
      sprintf (msg, "Lower split: MIDI note number out of range: '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    else {
      PGM->keyboardSplitLower = (short) iv;
    }
    break;

  case pr_KeyboardSplitPedals:
    PGM->flags[0] |= (FL_INUSE|FL_KSPLTP);
    if (sscanf (val, "%d", &iv) == 0) {
      sprintf (msg, "Pedal split: unparsable MIDI note number : '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    else if ((iv < 0) || (127 < iv)) {
      sprintf (msg, "Pedal split: MIDI note number out of range: '%s'", val);
      return stateMessage (fileName, lineNumber, msg, -1);
    }
    else {
      PGM->keyboardSplitPedals = (short) iv;
    }
    break;

    /*
     * A macro to avoid tedious repetition of code. The parameter F is
     * the bit in the 0th flag word for the parameter. The parameter I is
     * the index in the PGM->transpose[] array.
     * This macro is obviously very context-dependent and is therefore
     * undefined as soon as we do not need it anymore.
     */

#define SET_TRANSPOSE(F,I) PGM->flags[0] |= (FL_INUSE|(F)); \
  if ((rtn = parseTranspose (val, &iv, msg))) { \
    return stateMessage (fileName, lineNumber, msg, rtn); \
  } else { \
    PGM->transpose[(I)] = iv; \
  }

  case pr_TransposeSplitPedals:
    SET_TRANSPOSE(FL_TRA_PD, TR_CHA_PD);
    break;

  case pr_TransposeSplitLower:
    SET_TRANSPOSE(FL_TRA_LM, TR_CHA_LM);
    break;

  case pr_TransposeSplitUpper:
    SET_TRANSPOSE(FL_TRA_UM, TR_CHA_UM);
    break;

  case pr_Transpose:
    SET_TRANSPOSE(FL_TRANSP, TR_TRANSP);
    break;

  case pr_TransposeUpper:
    SET_TRANSPOSE(FL_TRCH_A, TR_CHNL_A);
    break;

  case pr_TransposeLower:
    SET_TRANSPOSE(FL_TRCH_B, TR_CHNL_B);
    break;

  case pr_TransposePedals:
    SET_TRANSPOSE(FL_TRCH_C, TR_CHNL_C);
    break;

#undef SET_TRANSPOSE

  } /* switch property */

  return 0;
}