Example #1
0
ChEXPORT EshOpt::Value& EshOpt::getProperty(PID in_pid, PType in_type) const
{
    ChLOG_DEBUG_START_FN;
    ChASSERT(isPropertySet(in_pid));
    ChASSERT(getPropertyType(in_pid) == in_type);
    return (const_cast<EshOpt*>(this))->m_data[in_pid];
}
Example #2
0
void FlyCamera::setProperty(CameraManager::CameraProperty* p)
{
    if(p->getType() == CameraManager::AUTOTRIGGER)
    {
        TriggerMode triggerMode;

        cam->GetTriggerMode(&triggerMode);
        triggerMode.onOff = !p->getAuto();
        triggerMode.mode = 0;
        triggerMode.parameter = 0;
        triggerMode.source = 0;
        cam->SetTriggerMode(&triggerMode);

    }else
    {
    Error error;
    Property prop;
	prop.type = getPropertyType(p);
    qDebug() << "setProp" << p->getName().c_str() << p->getAuto();
    error = cam->GetProperty(&prop);
    if (error == PGRERROR_OK)
    {
		prop.autoManualMode = p->getAuto();

		prop.absValue = p->getValue();
		prop.valueA = (int) p->getValue();
		prop.valueB = (int) p->getValue();
		
		cam->SetProperty(&prop);
    }
   }

}
Example #3
0
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Properties::load(istream& in)
{
  setDefaults();

  // Loop reading properties
  string key, value;
  for(;;)
  {
    // Get the key associated with this property
    key = readQuotedString(in);

    // Make sure the stream is still okay
    if(!in)
      return;

    // A null key signifies the end of the property list
    if(key == "")
      break;

    // Get the value associated with this property
    value = readQuotedString(in);

    // Make sure the stream is still okay
    if(!in)
      return;

    // Set the property 
    PropertyType type = getPropertyType(key);
    set(type, value);
  }
}
/** Utility function for creating and inserting layer properties
@param layer Spacescape layer
@param insertAfter Property to insert after
@param minimize Minimize this layer
@return The created / inserted property
*/
QtProperty* QtSpacescapeMainWindow::insertLayerProperties(Ogre::SpacescapeLayer* layer, QtProperty *insertAfter, bool minimize)
{
    // turn refreshing flag on so we don't process valueChanged events
    mRefreshing = true;

    // get layer params
    Ogre::NameValuePairList params = layer->getParams();

    // create the layer properties object
    QtProperty *layerProperties = mPropertyManager->addProperty(
                QtVariantPropertyManager::groupTypeId(),
                QLatin1String(layer->getName().c_str())
    );

    // insert it into the property tree early so we can minize items inside
    ui->layerProperties->insertProperty(layerProperties, insertAfter);

    // minimize the layer - speeds things up!
    if(minimize) {
        ui->layerProperties->setExpanded(ui->layerProperties->topLevelItem(layerProperties), false);
    }

    // add the common layer params to the subproperties first
    layerProperties->addSubProperty(createProperty( "name", layer->getName()));
    layerProperties->addSubProperty(createProperty( "type", layer->getLayerTypeName()));
    layerProperties->addSubProperty(createProperty( "visible", "true"));
    layerProperties->addSubProperty(createProperty( "seed", params["seed"]));

    // now add all the remaining layer params to the subproperties
    Ogre::NameValuePairList::iterator pl;
    for(pl = params.begin(); pl != params.end(); pl++) {
        // skip common params that come first
        if(pl->first == "name" || pl->first == "type" || 
            pl->first == "visible" || pl->first == "seed") {
            continue;
        }

        // create the sub property
        QtVariantProperty* subProperty = createProperty(pl->first, pl->second);
        if(!subProperty) {
            continue;
        }

        // add this sub property parameter
        layerProperties->addSubProperty(subProperty);

        // special auto hide for color types
        if(getPropertyType(pl->first) == QVariant::Color) {
            QList<QtBrowserItem *> bi = ui->layerProperties->items(subProperty);
            ui->layerProperties->setExpanded(bi.first(),false);
        }
    }

    // done adding properties
    mRefreshing = false;

    return layerProperties;
}
Example #5
0
void cMenu::handleButton( pClient ps, cClientPacket* pkg  )
{
	
	cPacketMenuSelection* p = (cPacketMenuSelection*)pkg;

	pChar pc = ps->currChar();
	if ( ! pc ) return;

	uint32_t button = p->buttonId.get();

	this->switchs = &p->switchs;
	this->textResp = &p->text_entries;
	
	uint32_t buttonReturnCode;
	if( button!=MENU_CLOSE ) { 

		buttonReturnCode = getButton( button );

		map< uint32_t, FUNCIDX >::iterator iter( buttonCallbacks.find( button ) );
		if( iter!=buttonCallbacks.end() ) {

			AmxFunction func( iter->second );
			func.Call( serial, pc->getSerial(), buttonReturnCode );
			return;

		}
	}
	else {
		buttonReturnCode = 0;
	}

	//set property if there are

	if( ( buttonReturnCode!=MENU_CLOSE ) && ( buttonReturnCode==buffer[3] ) ) { 
		map< uint32_t, int32_t >::iterator propIter( editProps.begin() ), lastProp( editProps.end() );
		for( ; propIter!=lastProp; ++propIter ) {

			int32_t props = propIter->first;
			int prop, prop2, prop3;
			getPropsFromInt( props, prop, prop2, prop3 );  

			if( getPropertyType( prop )!=T_BOOL ) {
				unistring* data = getText( propIter->second, true );
				if( data!=NULL )
					setPropertyField( buffer[0], buffer[1], prop, prop2, prop3, *data );
			}
			else {
				setPropertyField( buffer[0], buffer[1], prop, prop2, prop3, getCheckBox( propIter->second, true ) );
			}
		}
	}
	
	if( callback!=NULL )
		callback->Call( serial, pc->getSerial(), buttonReturnCode );
	else
		hard( this, ps, buttonReturnCode );
}
Example #6
0
bool GenericDataCollection::exportToCSV(CSVWriter& writer) const
{
  writer.clearHeader();
  for (int i=0; i<getPropertNames().size(); ++i)
  {
    writer.addHeader(getPropertyName(i), getPropertyTypeMeta(i));
  }
  writer.writeHeader();

  // Export the data ordered by ID
  QList<int> objKeys = m_objects.keys();
  qSort(objKeys);

  for (int idx=0; idx < objKeys.size(); ++idx)
  {
    CSVLine newLine;
    GenericDataObject* obj = m_objects.value(objKeys[idx]);
    for (int i=0; i<getPropertNames().size(); ++i)
    {
      if (obj->containsValue(getPropertyName(i)))
      {
        QMetaType::Type columnType = getPropertyTypeMeta(i);
        bool qualified = (columnType == QMetaType::QString);
        newLine.append(CSVColumn(obj->getString(getPropertyName(i)), qualified, columnType));
      }
      else
      {
        newLine.append(CSVColumn("", false, QMetaType::QString));
      }
    }
    writer.write(newLine);
  }
#if 0
  QHashIterator<int, GenericDataObject*> iterator(m_objects);
  while (iterator.hasNext())
  {
    iterator.next();
    CSVLine newLine;
    for (int i=0; i<getPropertNames().size(); ++i)
    {
      if (iterator.value()->hasValue(getPropertyName(i)))
      {
        QMetaType::Type columnType = CSVColumn::variantTypeToMetaType(getPropertyType(i));
        bool qualified = (columnType == QMetaType::QString);
        newLine.append(CSVColumn(iterator.value()->getString(getPropertyName(i)), qualified, columnType));
      }
      else
      {
        newLine.append(CSVColumn("", false, QMetaType::QString));
      }
    }
    writer.write(newLine);
  }
#endif
  return true;
}
Example #7
0
unistring cMenu::getPropertyField( uint32_t type, SERIAL obj, SERIAL prop, SERIAL subProp, SERIAL subProp2 )
{
	
	VAR_TYPE t = getPropertyType( prop );
	switch( type ) {
	
		case PROpCharACTER: {
			pChar pc = cSerializable::findCharBySerial( obj );
			if ( ! pc ) return unistring();

			switch( t ) {
				case T_CHAR :
					return toWstr( getCharCharProperty( pc, prop, subProp ) );
				case T_INT:
					return toWstr( getCharIntProperty( pc, prop, subProp ) );
				case T_SHORT:
					return toWstr( getCharShortProperty( pc, prop, subProp ) );
				case T_STRING:
					return toWstr( getCharStrProperty( pc, prop, subProp ) );
				case T_UNICODE: 
					return getCharUniProperty( pc, prop, subProp );
			}
		}
		break;
		case PROpItem : {
			pItem pi = cSerializable::findItemBySerial( obj );
			if ( ! pi ) return unistring();

			switch( t ) {
				case T_CHAR :
					return toWstr( getItemCharProperty( pi, prop, subProp ) );
				case T_INT:
					return toWstr( getItemIntProperty( pi, prop, subProp ) );
				case T_SHORT:
					return toWstr( getItemShortProperty( pi, prop, subProp ) );
				case T_STRING:
					return toWstr( getItemStrProperty( pi, prop, subProp ) );
				case T_UNICODE:
					return getItemUniProperty( pi, prop, subProp );
			}
		}
		break;
		case PROP_CALENDAR:
		case PROP_GUILD:
		default:
			return unistring(L"Not implemented yet");
	}


	return unistring( L"Error" );
}
Example #8
0
std::uint32_t ItemPropertiesBox::findPropertyIndex(const PropertyType type, const std::uint32_t itemId) const
{
    const ItemPropertyAssociation::AssociationEntries propertyIndexVector = mAssociations.getAssociationEntries(itemId);
    for (const auto& entry : propertyIndexVector)
    {
        const Box* property = mContainer.getProperty(entry.index - 1);
        const std::string boxType = property->getType();
        if (getPropertyType(property) == type)
        {
            return entry.index;
        }
    }

    return 0;
}
Example #9
0
void cMenu::addPropertyField( uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t property, uint32_t subProperty, uint32_t hue, uint32_t subProperty2 )
{
	
	VAR_TYPE t = getPropertyType( property );
	int32_t props = getIntFromProps( property, subProperty, subProperty2 );

	if( t==T_BOOL ) 
	{
		addCheckbox( x, y, 0x00D2, 0x00D3, getPropertyFieldBool( buffer[0], buffer[1], property, subProperty, subProperty2 ), props );
	}
	else
	{
		addInputField( x, y, width, height, props, getPropertyField( buffer[0], buffer[1], property, subProperty, subProperty2 ), hue );
	}
	editProps.insert( make_pair( props, rc_serialCurrent-1 ) );
	
}
Example #10
0
ItemPropertiesBox::PropertyInfos ItemPropertiesBox::getItemProperties(const std::uint32_t itemId) const
{
    PropertyInfos propertyInfoVector;
    const ItemPropertyAssociation::AssociationEntries associations = mAssociations.getAssociationEntries(itemId);

    for (const auto& entry : associations)
    {
        PropertyInfo propertyInfo;
        const Box* property = mContainer.getProperty(entry.index - 1);
        propertyInfo.type = getPropertyType(property);
        propertyInfo.index = entry.index - 1;
        propertyInfo.essential = entry.essential;
        propertyInfoVector.push_back(propertyInfo);
    }

    return propertyInfoVector;
}
Example #11
0
void FlyCamera::updateProperty(CameraManager::CameraProperty* p)
{
    if(p->getType() == CameraManager::AUTOTRIGGER)
    {
        TriggerMode triggerMode;
        cam->GetTriggerMode(&triggerMode);
        p->setAuto(triggerMode.onOff ? false:true);

    }else
    {
        Error error;
        Property prop;
        prop.type = getPropertyType(p);
        error = cam->GetProperty(&prop);
        if (error == PGRERROR_OK)
        {
            p->setAuto(prop.autoManualMode);
            p->setValue(p->getDecimals() > 0 ? prop.absValue : prop.valueA);
        }
    }
}
Example #12
0
void EshOpt::deleteComplexPropertyValue(PID in_pid)
{
    ChLOG_DEBUG_START_FN;
    PType type = getPropertyType(in_pid);
    if (type == PTYPE_STRING)
    {
        CsString* pString = m_data[in_pid].getString();
        ChDELETE(pString);
        m_data[in_pid].setString(NULL);
    }
    else if (type == PTYPE_COMPLEX)
    {
        EshPropVal* pComplex = m_data[in_pid].getComplex();
        ChDELETE(pComplex);
        m_data[in_pid].setComplex(NULL);
    }
    else if (type == PTYPE_NONE)
    {
        GenericValue* pGenericValue = m_data[in_pid].getGeneric();
        ChDELETE(pGenericValue);
        m_data[in_pid].setGeneric(NULL);
    }
}
Example #13
0
ChEXPORT void EshOpt::setProperty(PID in_pid, PType in_type, Value& in_value)
{
    ChLOG_DEBUG_START_FN;
    ChASSERT(getPropertyType(in_pid) == in_type);
    m_data[in_pid] = in_value;    
}
/** Utility function for creating a property from a key/value pair
@param key The key
@param value The value
@return the created QtProperty
*/
QtVariantProperty* QtSpacescapeMainWindow::createProperty(const Ogre::String& key, const Ogre::String& value)
{
    QStringList noiseTypes, layerTypes, blendTypes, textureSizes;
    noiseTypes << "fbm" << "ridged";
    layerTypes << "points" << "billboards" << "noise";
    blendTypes << "one" << "zero" << "dest_colour" << "src_colour" 
        << "one_minus_dest_colour" << "one_minus_src_colour" 
        << "dest_alpha" << "src_alpha" << "one_minus_dest_alpha" 
        << "one_minus_src_alpha";
    textureSizes << "64" << "128" << "256" << "512" << "1024" << "2048" << "4096" << "8192";

    int propertyType = getPropertyType(key);
    QtVariantProperty* property;

    property = mPropertyManager->addProperty(propertyType, getPropertyTitle(key));
    property->setStatusTip(getPropertyStatusTip(key));
    property->setToolTip(getPropertyStatusTip(key));

    if(propertyType == QVariant::Int) {
        property->setValue(Ogre::StringConverter::parseInt(value));
        property->setAttribute(QLatin1String("minimum"), 0);
        property->setAttribute(QLatin1String("singleStep"), 1);
    }
    else if(propertyType == QVariant::Bool) {
        property->setValue(Ogre::StringConverter::parseBool(value));
    }
    else if(propertyType == QtVariantPropertyManager::enumTypeId()) {
        QStringList *enumList = NULL;
        if(key == "destBlendFactor" || key == "sourceBlendFactor") {
            enumList = &blendTypes;
        }
        else if(key == "type") {
            enumList = &layerTypes;
        }
        else if(key == "noiseType" || key == "maskNoiseType") {
            enumList = &noiseTypes;
        }
        else if(key == "previewTextureSize") {
            enumList = &textureSizes;    
        }

        property->setAttribute(QLatin1String("enumNames"), *enumList);

        int valueIndex = 0;

        // find the selected value
        for(int i = 0; i < enumList->size(); i++) {
            if((*enumList)[i] == QString(value.c_str())) {
                valueIndex = i;
                break;
            }
        }
        
        property->setValue(valueIndex);
    }
    else if(propertyType == QVariant::Double) {
        property->setValue(Ogre::StringConverter::parseReal(value));
        property->setAttribute(QLatin1String("singleStep"), 0.01);
        property->setAttribute(QLatin1String("decimals"), 3);
    }
    else if(propertyType == QVariant::Color) {
       property->setValue(getColor(value));
    }
    else {
        // assume string
        property->setValue(value.c_str());
    }

    return property;
}
Example #15
0
void cMenu::setPropertyField( uint32_t type, SERIAL obj, SERIAL prop, SERIAL subProp, SERIAL subProp2, unistring data )
{
	VAR_TYPE t = getPropertyType( prop );
	switch( type ) {
	
		case PROpCharACTER: {
			pChar pc = cSerializable::findCharBySerial( obj );
			if ( ! pc ) return;

			switch( t ) {
				case T_CHAR : {
					char value = str2num( data );
					if( value!=getCharCharProperty( pc, prop, subProp ) )
						setCharCharProperty( pc, prop, subProp, subProp2, value );
					}
					break;
				case T_INT: {
					int value = str2num( data );
					if( value!=getCharIntProperty( pc, prop, subProp ) )
						setCharIntProperty( pc, prop, subProp, subProp2, value );
					}
					break;
				case T_SHORT: {
					short value = str2num( data );
					if( value!=getCharShortProperty( pc, prop, subProp ) )
						setCharShortProperty( pc, prop, subProp, subProp2, value );
					}
					break;
				case T_STRING: {
					string value;
					unistring2string( data, value );
					if( value!=string( getCharStrProperty( pc, prop, subProp ) ) )
						setCharStrProperty( pc, prop, subProp, subProp2, const_cast<char*>(value.c_str()) );
					}
					break;
				case T_UNICODE: {
					if( data!=getCharUniProperty( pc, prop, subProp ) )
						setCharUniProperty( pc, prop, subProp, subProp2, data );
					}
					break;
			}
		}
		break;
		case PROpItem : {
			pItem pi = cSerializable::findItemBySerial( obj );
			if ( ! pi ) return;

			switch( t ) {
				case T_CHAR : {
					char value = str2num( data );
					if( value!=getItemCharProperty( pi, prop, subProp ) )
						setItemCharProperty( pi, prop, subProp, value );
					}
					break;
				case T_INT: {
					int value = str2num( data );
					if( value!=getItemIntProperty( pi, prop, subProp ) )
						setItemIntProperty( pi, prop, subProp, value );
					}
					break;
				case T_SHORT: {
					short value = str2num( data );
					if( value!=getItemShortProperty( pi, prop, subProp ) )
						setItemShortProperty( pi, prop, subProp, value );
					}
					break;
				case T_STRING: {
					string value;
					unistring2string( data, value );
					if( value!=string( getItemStrProperty( pi, prop, subProp ) ) )
						setItemStrProperty( pi, prop, subProp, const_cast<char*>(value.c_str()) );
					}
					break;
				case T_UNICODE:
					if( data!=getItemUniProperty( pi, prop, subProp ) )
						setItemUniProperty( pi, prop, subProp, data );
					break;
			}
		}
		break;
		case PROP_CALENDAR:
		case PROP_GUILD:
		default:
			return;
	}


}