void QCtkXipSGWidget::setMField(const char * fieldContainerName, const char * fieldName, const char * value, int index)
{
  if(!value || !fieldContainerName || !fieldName)
    return;

  SoMField *field = getMField(fieldContainerName, fieldName);

  if (field)
  {
    if (strlen(value) > 0)
    {
      // If this is really a MF then use the index
      if (field->isOfType(SoMField::getClassTypeId()))
      {        
        // If this is really a MF then use the index
        SoMField *mfield = (SoMField*)field;
        mfield->set1(index, value);
      }
    }
    else
    {
      field->touch();
    }
  }

}
void QCtkXipSGWidget::setMFieldNumElements(const char * fieldContainerName, const char * fieldName, int num)
{
  if( !fieldContainerName || !fieldName)
    return;

  SoMField *mfield = getMField(fieldContainerName, fieldName);
  if (mfield)
    mfield->setNum(num);
}
示例#3
0
void
SoGate::evaluate()
//
////////////////////////////////////////////////////////////////////////
{
    trigger.getValue();	// Force evaluation

    // For efficiency and to reduce bloat, we don't use the standard
    // SO_ENGINE_OUTPUT macro:

    if (!output->isEnabled()) return;

    for (int i = 0; i < output->getNumConnections(); i++) {
	SoMField *outField = (SoMField *)(*output)[i];
	if (outField->isReadOnly()) continue;
	
// Handy macro for doing type-correct setValues(getValues())
#define CASE(class) \
  case class: ((SO__CONCAT(SoMF,class) *)outField)-> \
    setValues(0, input->getNum(), \
	((SO__CONCAT(SoMF,class) *)input)->getValues(0)); \
    break
				 
	switch(conversionCase) {
	    CASE(BitMask);
	    CASE(Bool);
	    CASE(Color);
	    CASE(Enum);
	    CASE(Float);
	    CASE(Int32);
	    CASE(Matrix);
	    CASE(Name);
	    CASE(Node);
	    CASE(Path);
	    CASE(Plane);
	    CASE(Rotation);
	    CASE(Short);
	    CASE(String);
	    CASE(Time);
	    CASE(UInt32);
	    CASE(UShort);
	    CASE(Vec2f);
	    CASE(Vec3f);
	    CASE(Vec4f);
#undef CASE
	  case BAD_TYPE:
	    ; // Do nothing, already complained
	    break;
	  default:
	    // Something is seriously wrong:
#ifdef DEBUG
	    SoDebugError::post("SoGate::evaluate",
			   "conversionCase is %d!", conversionCase);
#endif
	    break;
	}
	outField->setNum(input->getNum());
    }

    output->enable(enable.getValue());
}
示例#4
0
void MFieldEditor::on_buttonBox_clicked(QAbstractButton * button)
{
	if (Ui.buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole)
	{
		QString S;
		SbString oldValue;

		//Buscamos el SoMField que estamos editando
		SoMField *field = current_mfield;

		//Leemos el tipo de este campo
		SoType tipo=field->getTypeId();
		const char*nombre_tipo = tipo.getName();  

		//Actualizamos el contenido del SoMField

		//Si es necesario, ampliamos el tamaño del SoMField
		field->setNum(Ui.table->rowCount()-1);

		//Miramos cuantas columnas tiene la tabla
		int numComp = Ui.table->columnCount();

		//Tratamiento de los campos SoMFString
		if (!strcmp(nombre_tipo, "MFString") )
		{
			//Convertimos el campo a SoMFString
			SoMFString *soMFString = (SoMFString *)field;

			//Recorremos las filas de la tabla
			for(int i=0;i<Ui.table->rowCount()-1;i++)
			{
				//Extraemos el contenido de las celdas
				S = Ui.table->item(i,0)->text();

				//Aplicamos el valor al campo
				soMFString->set1Value(i, SbString(qPrintable(S)));

			} // for(int i=0;i<Ui.table->rowCount()-1;i++)
		}
		else

			//Recorremos las filas de la tabla
			for(int i=0;i<Ui.table->rowCount()-1;i++)
			{
				//Sacamos una copia del field actual, por si hay errores
				field->get1(i, oldValue);
				//qDebug("old: %s\n", oldValue.getString());

				//Extraemos el contenido de la primera celda
				S = Ui.table->item(i,0)->text();

				//Concatenamos el resto de celdas de la fila
				for (int j=1; j < numComp; j++)
				{
					S.append(' ');
					S.append(Ui.table->item(i,j)->text());
				}

				//Leemos la cadena mediante el parser de openInventor
				//fprintf(stderr, "Introduciendo: %s\n", txt);
				if (!field->set1(i, qPrintable(S)))
				{
					//Si hubo un error en la lectura, restablecemos el valor anterior
					field->set1(i, oldValue.getString() );
					QMessageBox::warning( this, tr("Warning"), tr("Error on row:")+S.setNum(i));
					qDebug("Error leyendo campo en fila %d\n", i);
				}

			}//for

	}//if (Ui.buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole)
}