Logo Search packages:      
Sourcecode: ktechlab version File versions  Download package

bool Variant::changed (  )  const

Returns:
whether the current value is different to the default value.

Definition at line 193 of file variant.cpp.

References type().

Referenced by PropertyEditor::createEditor(), PropertyEditorItem::paintCell(), and PropertyEditor::updateDefaultsButton().

{
      // Have to handle double slightly differently due inperfect storage of real
      // numbers
      if ( type() == Type::Double )
      {
            double cur = value().toDouble();
            double def = defaultValue().toDouble();
            
            double diff = abs( cur - def );
            if ( diff == 0 )
                  return false;
            
            // denom cannot be zero
            double denom = max( abs( cur ), abs( def ) );
            
            // not changed if within 1e-4% of each other's value
            return ( (diff / denom) > 1e-6 );
      }
      return value() != defaultValue();
}


Generated by  Doxygen 1.6.0   Back to index