bool
ExtremeValueAnalysisAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    ExtremeValueAnalysisAttributes defaultObject;
    bool addToParent = false;
    // Create a node for ExtremeValueAnalysisAttributes.
    DataNode *node = new DataNode("ExtremeValueAnalysisAttributes");

    if(completeSave || !FieldsEqual(ID_dataYearBegin, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("dataYearBegin", dataYearBegin));
    }

    if(completeSave || !FieldsEqual(ID_dataAnalysisYearRangeEnabled, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("dataAnalysisYearRangeEnabled", dataAnalysisYearRangeEnabled));
    }

    if(completeSave || !FieldsEqual(ID_dataAnalysisYear1, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("dataAnalysisYear1", dataAnalysisYear1));
    }

    if(completeSave || !FieldsEqual(ID_dataAnalysisYear2, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("dataAnalysisYear2", dataAnalysisYear2));
    }

    if(completeSave || !FieldsEqual(ID_ensemble, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("ensemble", ensemble));
    }

    if(completeSave || !FieldsEqual(ID_numEnsembles, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("numEnsembles", numEnsembles));
    }

    if(completeSave || !FieldsEqual(ID_dataScaling, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("dataScaling", dataScaling));
    }

    if(completeSave || !FieldsEqual(ID_extremeMethod, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("extremeMethod", ExtremeType_ToString(extremeMethod)));
    }

    if(completeSave || !FieldsEqual(ID_optimizationMethod, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("optimizationMethod", OptimizationType_ToString(optimizationMethod)));
    }

    if(completeSave || !FieldsEqual(ID_aggregation, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("aggregation", AggregationType_ToString(aggregation)));
    }

    if(completeSave || !FieldsEqual(ID_covariateModelScale, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("covariateModelScale", covariateModelScale));
    }

    if(completeSave || !FieldsEqual(ID_covariateModelLocation, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("covariateModelLocation", covariateModelLocation));
    }

    if(completeSave || !FieldsEqual(ID_covariateModelShape, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("covariateModelShape", covariateModelShape));
    }

    if(completeSave || !FieldsEqual(ID_computeReturnValues, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("computeReturnValues", computeReturnValues));
    }

    if(completeSave || !FieldsEqual(ID_returnValues, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("returnValues", returnValues));
    }

    if(completeSave || !FieldsEqual(ID_computeRVDifferences, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("computeRVDifferences", computeRVDifferences));
    }

    if(completeSave || !FieldsEqual(ID_rvDifference1, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("rvDifference1", rvDifference1));
    }

    if(completeSave || !FieldsEqual(ID_rvDifference2, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("rvDifference2", rvDifference2));
    }

    if(completeSave || !FieldsEqual(ID_displayMonth, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("displayMonth", MonthType_ToString(displayMonth)));
    }

    if(completeSave || !FieldsEqual(ID_displaySeason, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("displaySeason", SeasonType_ToString(displaySeason)));
    }

    if(completeSave || !FieldsEqual(ID_computeParamValues, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("computeParamValues", computeParamValues));
    }

    if(completeSave || !FieldsEqual(ID_dumpData, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("dumpData", dumpData));
    }

    if(completeSave || !FieldsEqual(ID_dumpDebug, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("dumpDebug", dumpDebug));
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}
bool
ConstructDataBinningAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    ConstructDataBinningAttributes defaultObject;
    bool addToParent = false;
    // Create a node for ConstructDataBinningAttributes.
    DataNode *node = new DataNode("ConstructDataBinningAttributes");

    if(completeSave || !FieldsEqual(ID_name, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("name", name));
    }

    if(completeSave || !FieldsEqual(ID_varnames, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("varnames", varnames));
    }

    if(completeSave || !FieldsEqual(ID_binType, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("binType", binType));
    }

    if(completeSave || !FieldsEqual(ID_binBoundaries, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("binBoundaries", binBoundaries));
    }

    if(completeSave || !FieldsEqual(ID_reductionOperator, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("reductionOperator", ReductionOperator_ToString(reductionOperator)));
    }

    if(completeSave || !FieldsEqual(ID_varForReductionOperator, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("varForReductionOperator", varForReductionOperator));
    }

    if(completeSave || !FieldsEqual(ID_undefinedValue, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("undefinedValue", undefinedValue));
    }

    if(completeSave || !FieldsEqual(ID_binningScheme, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("binningScheme", BinningScheme_ToString(binningScheme)));
    }

    if(completeSave || !FieldsEqual(ID_numBins, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("numBins", numBins));
    }

    if(completeSave || !FieldsEqual(ID_overTime, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("overTime", overTime));
    }

    if(completeSave || !FieldsEqual(ID_timeStart, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("timeStart", timeStart));
    }

    if(completeSave || !FieldsEqual(ID_timeEnd, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("timeEnd", timeEnd));
    }

    if(completeSave || !FieldsEqual(ID_timeStride, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("timeStride", timeStride));
    }

    if(completeSave || !FieldsEqual(ID_outOfBoundsBehavior, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("outOfBoundsBehavior", OutOfBoundsBehavior_ToString(outOfBoundsBehavior)));
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}
Beispiel #3
0
bool
LineoutAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    LineoutAttributes defaultObject;
    bool addToParent = false;
    // Create a node for LineoutAttributes.
    DataNode *node = new DataNode("LineoutAttributes");

    if(completeSave || !FieldsEqual(ID_point1, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("point1", point1, 3));
    }

    if(completeSave || !FieldsEqual(ID_point2, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("point2", point2, 3));
    }

    if(completeSave || !FieldsEqual(ID_interactive, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("interactive", interactive));
    }

    if(completeSave || !FieldsEqual(ID_ignoreGlobal, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("ignoreGlobal", ignoreGlobal));
    }

    if(completeSave || !FieldsEqual(ID_samplingOn, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("samplingOn", samplingOn));
    }

    if(completeSave || !FieldsEqual(ID_numberOfSamplePoints, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("numberOfSamplePoints", numberOfSamplePoints));
    }

    if(completeSave || !FieldsEqual(ID_reflineLabels, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("reflineLabels", reflineLabels));
    }

    if(completeSave || !FieldsEqual(ID_designator, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("designator", designator));
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}
bool
ConstructDDFAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    ConstructDDFAttributes defaultObject;
    bool addToParent = false;
    // Create a node for ConstructDDFAttributes.
    DataNode *node = new DataNode("ConstructDDFAttributes");

    if(completeSave || !FieldsEqual(ID_ddfName, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("ddfName", ddfName));
    }

    if(completeSave || !FieldsEqual(ID_varnames, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("varnames", varnames));
    }

    if(completeSave || !FieldsEqual(ID_ranges, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("ranges", ranges));
    }

    if(completeSave || !FieldsEqual(ID_codomainName, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("codomainName", codomainName));
    }

    if(completeSave || !FieldsEqual(ID_statisticalOperator, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("statisticalOperator", StatisticalOperator_ToString(statisticalOperator)));
    }

    if(completeSave || !FieldsEqual(ID_percentile, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("percentile", percentile));
    }

    if(completeSave || !FieldsEqual(ID_undefinedValue, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("undefinedValue", undefinedValue));
    }

    if(completeSave || !FieldsEqual(ID_binningScheme, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("binningScheme", BinningScheme_ToString(binningScheme)));
    }

    if(completeSave || !FieldsEqual(ID_numSamples, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("numSamples", numSamples));
    }

    if(completeSave || !FieldsEqual(ID_overTime, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("overTime", overTime));
    }

    if(completeSave || !FieldsEqual(ID_timeStart, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("timeStart", timeStart));
    }

    if(completeSave || !FieldsEqual(ID_timeEnd, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("timeEnd", timeEnd));
    }

    if(completeSave || !FieldsEqual(ID_timeStride, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("timeStride", timeStride));
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}
bool
PersistentParticlesAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    PersistentParticlesAttributes defaultObject;
    bool addToParent = false;
    // Create a node for PersistentParticlesAttributes.
    DataNode *node = new DataNode("PersistentParticlesAttributes");

    if(completeSave || !FieldsEqual(ID_startIndex, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("startIndex", startIndex));
    }

    if(completeSave || !FieldsEqual(ID_stopIndex, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("stopIndex", stopIndex));
    }

    if(completeSave || !FieldsEqual(ID_stride, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("stride", stride));
    }

    if(completeSave || !FieldsEqual(ID_startPathType, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("startPathType", PathTypeEnum_ToString(startPathType)));
    }

    if(completeSave || !FieldsEqual(ID_stopPathType, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("stopPathType", PathTypeEnum_ToString(stopPathType)));
    }

    if(completeSave || !FieldsEqual(ID_traceVariableX, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("traceVariableX", traceVariableX));
    }

    if(completeSave || !FieldsEqual(ID_traceVariableY, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("traceVariableY", traceVariableY));
    }

    if(completeSave || !FieldsEqual(ID_traceVariableZ, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("traceVariableZ", traceVariableZ));
    }

    if(completeSave || !FieldsEqual(ID_connectParticles, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("connectParticles", connectParticles));
    }

    if(completeSave || !FieldsEqual(ID_showPoints, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("showPoints", showPoints));
    }

    if(completeSave || !FieldsEqual(ID_indexVariable, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("indexVariable", indexVariable));
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}
Beispiel #6
0
void
AxesArray::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("AxesArray");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("visible")) != 0)
        SetVisible(node->AsBool());
    if((node = searchNode->GetNode("ticksVisible")) != 0)
        SetTicksVisible(node->AsBool());
    if((node = searchNode->GetNode("autoSetTicks")) != 0)
        SetAutoSetTicks(node->AsBool());
    if((node = searchNode->GetNode("autoSetScaling")) != 0)
        SetAutoSetScaling(node->AsBool());
    if((node = searchNode->GetNode("lineWidth")) != 0)
        SetLineWidth(node->AsInt());
    if((node = searchNode->GetNode("axes")) != 0)
        axes.SetFromNode(node);
}
bool
NameschemeAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    NameschemeAttributes defaultObject;
    bool addToParent = false;
    // Create a node for NameschemeAttributes.
    DataNode *node = new DataNode("NameschemeAttributes");

    if(completeSave || !FieldsEqual(ID_namescheme, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("namescheme", namescheme));
    }

    if(completeSave || !FieldsEqual(ID_externalArrayNames, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("externalArrayNames", externalArrayNames));
    }

    if(completeSave || !FieldsEqual(ID_externalArrayOffsets, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("externalArrayOffsets", externalArrayOffsets));
    }

    if(completeSave || !FieldsEqual(ID_externalArrayData, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("externalArrayData", externalArrayData));
    }

    if(completeSave || !FieldsEqual(ID_allExplicitNames, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("allExplicitNames", allExplicitNames));
    }

    if(completeSave || !FieldsEqual(ID_explicitIds, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("explicitIds", explicitIds));
    }

    if(completeSave || !FieldsEqual(ID_explicitNames, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("explicitNames", explicitNames));
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}
Beispiel #8
0
double hellocode(int seg, void* data) {



  Hello_Data *d = (Hello_Data*) data;



  int activeroute = 0;

  int k, m, n;

  double now;

  double period;



  HelloMsg *hellomsg;

  GenericNwkMsg *nwkmsg;

  RERRMsg *rerrmsg;

  DataNode *dn;

  DataNode *tmp;

  

  switch (seg) {

  case 1:

    now = ttCurrentTime();

  

    if (VERBOSE) {

      mexPrintf("Time: %f Node#%d running periodic HELLO task\n", now, d->nodeID);

    }

  

    // Determine if any active routes exist

    for (k=0; k<NBR_AODV; k++) {

      if (d->routing_table[k].valid) {

	activeroute = 1;

      }

    }

  

    period = ttGetPeriod();

    if (activeroute && (d->lastRREQ < now - period)) {

      if (VERBOSE) {

	mexPrintf("Broadcasting HELLO msg\n");

      }

      

      hellomsg = new HelloMsg;

      hellomsg->hopCnt = 0;

      hellomsg->dest = d->nodeID;

      hellomsg->destSeqNbr = d->seqNbrs[d->nodeID];

      hellomsg->src = 0;

      hellomsg->lifetime = DELETE_PERIOD; 

  

      nwkmsg = new GenericNwkMsg;

      nwkmsg->type = HELLO;

      nwkmsg->intermed = d->nodeID;

      nwkmsg->msg = hellomsg;

      ttSendMsg(0, nwkmsg, 24);

    }

    

    // Determine local connectivity

    for (k=0; k<NBR_AODV; k++) {

      if (d->nbors[k]) {

	// Node k is a neighbor

	if (now - d->lastHello[k] > DELETE_PERIOD) {

	  mexPrintf("Node#%d lost connection to Node#%d\n", d->nodeID, k+1);

                

	  d->nbors[k] = 0; // remove from neighbor list

                

	  // Send RERRs

	  for (m=0; m<NBR_AODV; m++) {

	    // Find routes that use node k as next hop

	    if (d->routing_table[m].valid) {

	      if (d->routing_table[m].nextHop == k+1) {

		// Should send RERR to all nodes in precursor list

		for (n=0; n<NBR_AODV; n++) {

		  if (d->routing_table[m].prec[n]) {

		    // Node n uses this node as next hop towards node k

		    rerrmsg = new RERRMsg;

	                                

		    rerrmsg->dest = m + 1;

		    rerrmsg->destSeqNbr = d->routing_table[m].destSeqNbr;

		    rerrmsg->receiver = n + 1;

	                                

		    d->RERRlist->appendNode(new DataNode(rerrmsg, ""));

		  }

		}

	  

		// Invalidate route

		if (VERBOSE) {

		  mexPrintf("Node#%d invalidating route to Node#%d through unreachable Node#%d\n", d->nodeID, m+1, k+1);

		}

	    

		d->routing_table[m].valid = 0;

	      }

	    }

	  }

	} 

      }

    }

  

    return 0.0001;;

  case 2:

    ttSleep(0.001);

    return 0.0001;    

  case 3:

    // Send all RERRs

    dn = (DataNode*) d->RERRlist->getFirst(); 

    if (dn != NULL) {

      rerrmsg = (RERRMsg*) dn->data;



      nwkmsg = new GenericNwkMsg;

      nwkmsg->type = RERR;

      nwkmsg->intermed = d->nodeID;

      nwkmsg->msg = rerrmsg;

            

      ttSendMsg(rerrmsg->receiver, nwkmsg, 12); 

    

      tmp = dn;

      dn = (DataNode*) dn->getNext();

      tmp->remove();

      delete tmp;

        

      ttSleep(0.001);

      return 0.0001;    

    } else {

      return FINISHED; 

    } 

  case 4:    

    ttSetNextSegment(3);

    return 0.0001; 

  }

  

  return FINISHED; // to supress compilation warnings

}
bool
MaterialAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    MaterialAttributes defaultObject;
    bool addToParent = false;
    // Create a node for MaterialAttributes.
    DataNode *node = new DataNode("MaterialAttributes");

    if(completeSave || !FieldsEqual(ID_smoothing, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("smoothing", smoothing));
    }

    if(completeSave || !FieldsEqual(ID_forceMIR, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("forceMIR", forceMIR));
    }

    if(completeSave || !FieldsEqual(ID_cleanZonesOnly, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("cleanZonesOnly", cleanZonesOnly));
    }

    if(completeSave || !FieldsEqual(ID_needValidConnectivity, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("needValidConnectivity", needValidConnectivity));
    }

    if(completeSave || !FieldsEqual(ID_algorithm, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("algorithm", Algorithm_ToString(algorithm)));
    }

    if(completeSave || !FieldsEqual(ID_iterationEnabled, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("iterationEnabled", iterationEnabled));
    }

    if(completeSave || !FieldsEqual(ID_numIterations, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("numIterations", numIterations));
    }

    if(completeSave || !FieldsEqual(ID_iterationDamping, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("iterationDamping", iterationDamping));
    }

    if(completeSave || !FieldsEqual(ID_simplifyHeavilyMixedZones, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("simplifyHeavilyMixedZones", simplifyHeavilyMixedZones));
    }

    if(completeSave || !FieldsEqual(ID_maxMaterialsPerZone, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("maxMaterialsPerZone", maxMaterialsPerZone));
    }

    if(completeSave || !FieldsEqual(ID_isoVolumeFraction, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("isoVolumeFraction", isoVolumeFraction));
    }

    if(completeSave || !FieldsEqual(ID_annealingTime, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("annealingTime", annealingTime));
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}
bool
ViewAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    ViewAttributes defaultObject;
    bool addToParent = false;
    // Create a node for ViewAttributes.
    DataNode *node = new DataNode("ViewAttributes");

    if(completeSave || !FieldsEqual(ID_viewNormal, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("viewNormal", viewNormal, 3));
    }

    if(completeSave || !FieldsEqual(ID_focus, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("focus", focus, 3));
    }

    if(completeSave || !FieldsEqual(ID_viewUp, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("viewUp", viewUp, 3));
    }

    if(completeSave || !FieldsEqual(ID_viewAngle, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("viewAngle", viewAngle));
    }

    if(completeSave || !FieldsEqual(ID_setScale, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("setScale", setScale));
    }

    if(completeSave || !FieldsEqual(ID_parallelScale, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("parallelScale", parallelScale));
    }

    if(completeSave || !FieldsEqual(ID_nearPlane, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("nearPlane", nearPlane));
    }

    if(completeSave || !FieldsEqual(ID_farPlane, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("farPlane", farPlane));
    }

    if(completeSave || !FieldsEqual(ID_imagePan, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("imagePan", imagePan, 2));
    }

    if(completeSave || !FieldsEqual(ID_imageZoom, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("imageZoom", imageZoom));
    }

    if(completeSave || !FieldsEqual(ID_perspective, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("perspective", perspective));
    }

    if(completeSave || !FieldsEqual(ID_windowCoords, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("windowCoords", windowCoords, 4));
    }

    if(completeSave || !FieldsEqual(ID_viewportCoords, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("viewportCoords", viewportCoords, 4));
    }

    if(completeSave || !FieldsEqual(ID_eyeAngle, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("eyeAngle", eyeAngle));
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}
void
ViewAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("ViewAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("viewNormal")) != 0)
        SetViewNormal(node->AsDoubleArray());
    if((node = searchNode->GetNode("focus")) != 0)
        SetFocus(node->AsDoubleArray());
    if((node = searchNode->GetNode("viewUp")) != 0)
        SetViewUp(node->AsDoubleArray());
    if((node = searchNode->GetNode("viewAngle")) != 0)
        SetViewAngle(node->AsDouble());
    if((node = searchNode->GetNode("setScale")) != 0)
        SetSetScale(node->AsBool());
    if((node = searchNode->GetNode("parallelScale")) != 0)
        SetParallelScale(node->AsDouble());
    if((node = searchNode->GetNode("nearPlane")) != 0)
        SetNearPlane(node->AsDouble());
    if((node = searchNode->GetNode("farPlane")) != 0)
        SetFarPlane(node->AsDouble());
    if((node = searchNode->GetNode("imagePan")) != 0)
        SetImagePan(node->AsDoubleArray());
    if((node = searchNode->GetNode("imageZoom")) != 0)
        SetImageZoom(node->AsDouble());
    if((node = searchNode->GetNode("perspective")) != 0)
        SetPerspective(node->AsBool());
    if((node = searchNode->GetNode("windowCoords")) != 0)
        SetWindowCoords(node->AsDoubleArray());
    if((node = searchNode->GetNode("viewportCoords")) != 0)
        SetViewportCoords(node->AsDoubleArray());
    if((node = searchNode->GetNode("eyeAngle")) != 0)
        SetEyeAngle(node->AsDouble());
}
Beispiel #12
0
void
PeaksOverThresholdAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("PeaksOverThresholdAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("dataYearBegin")) != 0)
        SetDataYearBegin(node->AsInt());
    if((node = searchNode->GetNode("dataAnalysisYearRangeEnabled")) != 0)
        SetDataAnalysisYearRangeEnabled(node->AsBool());
    if((node = searchNode->GetNode("dataAnalysisYearRange")) != 0)
        SetDataAnalysisYearRange(node->AsIntArray());
    if((node = searchNode->GetNode("aggregation")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetAggregation(AggregationType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            AggregationType value;
            if(AggregationType_FromString(node->AsString(), value))
                SetAggregation(value);
        }
    }
    if((node = searchNode->GetNode("annualPercentile")) != 0)
        SetAnnualPercentile(node->AsDouble());
    if((node = searchNode->GetNode("seasonalPercentile")) != 0)
        SetSeasonalPercentile(node->AsDoubleArray());
    if((node = searchNode->GetNode("monthlyPercentile")) != 0)
        SetMonthlyPercentile(node->AsDoubleArray());
    if((node = searchNode->GetNode("displaySeason")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 4)
                SetDisplaySeason(SeasonType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            SeasonType value;
            if(SeasonType_FromString(node->AsString(), value))
                SetDisplaySeason(value);
        }
    }
    if((node = searchNode->GetNode("displayMonth")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 12)
                SetDisplayMonth(MonthType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            MonthType value;
            if(MonthType_FromString(node->AsString(), value))
                SetDisplayMonth(value);
        }
    }
    if((node = searchNode->GetNode("cutoff")) != 0)
        SetCutoff(node->AsFloat());
    if((node = searchNode->GetNode("computeParamValues")) != 0)
        SetComputeParamValues(node->AsBool());
    if((node = searchNode->GetNode("computeCovariates")) != 0)
        SetComputeCovariates(node->AsBool());
    if((node = searchNode->GetNode("covariateReturnYears")) != 0)
        SetCovariateReturnYears(node->AsIntVector());
    if((node = searchNode->GetNode("covariateModelLocation")) != 0)
        SetCovariateModelLocation(node->AsBool());
    if((node = searchNode->GetNode("covariateModelShape")) != 0)
        SetCovariateModelShape(node->AsBool());
    if((node = searchNode->GetNode("covariateModelScale")) != 0)
        SetCovariateModelScale(node->AsBool());
    if((node = searchNode->GetNode("computeRVDifferences")) != 0)
        SetComputeRVDifferences(node->AsBool());
    if((node = searchNode->GetNode("rvDifferences")) != 0)
        SetRvDifferences(node->AsIntArray());
    if((node = searchNode->GetNode("dataScaling")) != 0)
        SetDataScaling(node->AsDouble());
    if((node = searchNode->GetNode("dumpData")) != 0)
        SetDumpData(node->AsBool());
}
Beispiel #13
0
bool
PeaksOverThresholdAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    PeaksOverThresholdAttributes defaultObject;
    bool addToParent = false;
    // Create a node for PeaksOverThresholdAttributes.
    DataNode *node = new DataNode("PeaksOverThresholdAttributes");

    if(completeSave || !FieldsEqual(ID_dataYearBegin, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("dataYearBegin", dataYearBegin));
    }

    if(completeSave || !FieldsEqual(ID_dataAnalysisYearRangeEnabled, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("dataAnalysisYearRangeEnabled", dataAnalysisYearRangeEnabled));
    }

    if(completeSave || !FieldsEqual(ID_dataAnalysisYearRange, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("dataAnalysisYearRange", dataAnalysisYearRange, 2));
    }

    if(completeSave || !FieldsEqual(ID_aggregation, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("aggregation", AggregationType_ToString(aggregation)));
    }

    if(completeSave || !FieldsEqual(ID_annualPercentile, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("annualPercentile", annualPercentile));
    }

    if(completeSave || !FieldsEqual(ID_seasonalPercentile, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("seasonalPercentile", seasonalPercentile, 4));
    }

    if(completeSave || !FieldsEqual(ID_monthlyPercentile, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("monthlyPercentile", monthlyPercentile, 12));
    }

    if(completeSave || !FieldsEqual(ID_displaySeason, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("displaySeason", SeasonType_ToString(displaySeason)));
    }

    if(completeSave || !FieldsEqual(ID_displayMonth, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("displayMonth", MonthType_ToString(displayMonth)));
    }

    if(completeSave || !FieldsEqual(ID_cutoff, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("cutoff", cutoff));
    }

    if(completeSave || !FieldsEqual(ID_computeParamValues, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("computeParamValues", computeParamValues));
    }

    if(completeSave || !FieldsEqual(ID_computeCovariates, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("computeCovariates", computeCovariates));
    }

    if(completeSave || !FieldsEqual(ID_covariateReturnYears, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("covariateReturnYears", covariateReturnYears));
    }

    if(completeSave || !FieldsEqual(ID_covariateModelLocation, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("covariateModelLocation", covariateModelLocation));
    }

    if(completeSave || !FieldsEqual(ID_covariateModelShape, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("covariateModelShape", covariateModelShape));
    }

    if(completeSave || !FieldsEqual(ID_covariateModelScale, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("covariateModelScale", covariateModelScale));
    }

    if(completeSave || !FieldsEqual(ID_computeRVDifferences, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("computeRVDifferences", computeRVDifferences));
    }

    if(completeSave || !FieldsEqual(ID_rvDifferences, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("rvDifferences", rvDifferences, 2));
    }

    if(completeSave || !FieldsEqual(ID_dataScaling, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("dataScaling", dataScaling));
    }

    if(completeSave || !FieldsEqual(ID_dumpData, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("dumpData", dumpData));
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}
void
ExtremeValueAnalysisAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("ExtremeValueAnalysisAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("dataYearBegin")) != 0)
        SetDataYearBegin(node->AsInt());
    if((node = searchNode->GetNode("dataAnalysisYearRangeEnabled")) != 0)
        SetDataAnalysisYearRangeEnabled(node->AsBool());
    if((node = searchNode->GetNode("dataAnalysisYear1")) != 0)
        SetDataAnalysisYear1(node->AsInt());
    if((node = searchNode->GetNode("dataAnalysisYear2")) != 0)
        SetDataAnalysisYear2(node->AsInt());
    if((node = searchNode->GetNode("ensemble")) != 0)
        SetEnsemble(node->AsBool());
    if((node = searchNode->GetNode("numEnsembles")) != 0)
        SetNumEnsembles(node->AsInt());
    if((node = searchNode->GetNode("dataScaling")) != 0)
        SetDataScaling(node->AsDouble());
    if((node = searchNode->GetNode("extremeMethod")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetExtremeMethod(ExtremeType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            ExtremeType value;
            if(ExtremeType_FromString(node->AsString(), value))
                SetExtremeMethod(value);
        }
    }
    if((node = searchNode->GetNode("optimizationMethod")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetOptimizationMethod(OptimizationType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            OptimizationType value;
            if(OptimizationType_FromString(node->AsString(), value))
                SetOptimizationMethod(value);
        }
    }
    if((node = searchNode->GetNode("aggregation")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetAggregation(AggregationType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            AggregationType value;
            if(AggregationType_FromString(node->AsString(), value))
                SetAggregation(value);
        }
    }
    if((node = searchNode->GetNode("covariateModelScale")) != 0)
        SetCovariateModelScale(node->AsBool());
    if((node = searchNode->GetNode("covariateModelLocation")) != 0)
        SetCovariateModelLocation(node->AsBool());
    if((node = searchNode->GetNode("covariateModelShape")) != 0)
        SetCovariateModelShape(node->AsBool());
    if((node = searchNode->GetNode("computeReturnValues")) != 0)
        SetComputeReturnValues(node->AsBool());
    if((node = searchNode->GetNode("returnValues")) != 0)
        SetReturnValues(node->AsIntVector());
    if((node = searchNode->GetNode("computeRVDifferences")) != 0)
        SetComputeRVDifferences(node->AsBool());
    if((node = searchNode->GetNode("rvDifference1")) != 0)
        SetRvDifference1(node->AsInt());
    if((node = searchNode->GetNode("rvDifference2")) != 0)
        SetRvDifference2(node->AsInt());
    if((node = searchNode->GetNode("displayMonth")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 12)
                SetDisplayMonth(MonthType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            MonthType value;
            if(MonthType_FromString(node->AsString(), value))
                SetDisplayMonth(value);
        }
    }
    if((node = searchNode->GetNode("displaySeason")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 4)
                SetDisplaySeason(SeasonType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            SeasonType value;
            if(SeasonType_FromString(node->AsString(), value))
                SetDisplaySeason(value);
        }
    }
    if((node = searchNode->GetNode("computeParamValues")) != 0)
        SetComputeParamValues(node->AsBool());
    if((node = searchNode->GetNode("dumpData")) != 0)
        SetDumpData(node->AsBool());
    if((node = searchNode->GetNode("dumpDebug")) != 0)
        SetDumpDebug(node->AsBool());
}
void
ColorTableAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("ColorTableAttributes");
    if(searchNode == 0)
        return;

    // Look for the number of color tables.
    DataNode *node = 0;
    if((node = searchNode->GetNode("Ntables")) != 0)
    {
        char tmp[100];
        int  ntables = node->AsInt();

        // Look for ntables color table nodes.
        for(int i = 0; i < ntables; ++i)
        {
            SNPRINTF(tmp, 100, "table%02d", i);
            if((node = searchNode->GetNode(tmp)) != 0)
            {
                DataNode *nameNode = node->GetNode("ctName");
                DataNode *pointNode = node->GetNode("controlPts");

                // If we have the name node and the pointNode, we can add a
                // color table.
                if(nameNode && pointNode)
                {
                    ColorControlPointList ccpl;

                    // Try and set the equal flag.
                    DataNode *tmpNode;
                    if((tmpNode = node->GetNode("equal")) != 0)
                        ccpl.SetEqualSpacingFlag(tmpNode->AsBool());
                    // Try and set the smooth flag.
                    if((tmpNode = node->GetNode("smooth")) != 0)
                        ccpl.SetSmoothingFlag(tmpNode->AsBool());
                    if((tmpNode = node->GetNode("discrete")) != 0)
                        ccpl.SetDiscreteFlag(tmpNode->AsBool());

                    // Set the color control points.
                    floatVector fvec = pointNode->AsFloatVector();
                    for(size_t j = 0; j < fvec.size() / 4; ++j)
                    {
                        // Create a control point based on the values
                        // in the float vector.
                        int index = j * 4;
                        ColorControlPoint cpt(fvec[index],
                                              (unsigned char)(fvec[index+1]),
                                              (unsigned char)(fvec[index+2]),
                                              (unsigned char)(fvec[index+3]),
                                              255);
                        ccpl.AddControlPoints(cpt);
                    }

                    // If the color table is already in the list, remove it.
                    // Then add the new color table to the list.
                    RemoveColorTable(nameNode->AsString());
                    AddColorTable(nameNode->AsString(), ccpl);
                }
            }
        } // end for i
    }

    if((node = searchNode->GetNode("activeContinuous")) != 0)
        SetActiveContinuous(node->AsString());

    if((node = searchNode->GetNode("activeDiscrete")) != 0)
        SetActiveDiscrete(node->AsString());

    // For older version compatibility...
    if((node = searchNode->GetNode("activeColorTable")) != 0)
        SetActiveContinuous(node->AsString());
}
void
MaterialAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("MaterialAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("smoothing")) != 0)
        SetSmoothing(node->AsBool());
    if((node = searchNode->GetNode("forceMIR")) != 0)
        SetForceMIR(node->AsBool());
    if((node = searchNode->GetNode("cleanZonesOnly")) != 0)
        SetCleanZonesOnly(node->AsBool());
    if((node = searchNode->GetNode("needValidConnectivity")) != 0)
        SetNeedValidConnectivity(node->AsBool());
    if((node = searchNode->GetNode("algorithm")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 5)
                SetAlgorithm(Algorithm(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Algorithm value;
            if(Algorithm_FromString(node->AsString(), value))
                SetAlgorithm(value);
        }
    }
    if((node = searchNode->GetNode("iterationEnabled")) != 0)
        SetIterationEnabled(node->AsBool());
    if((node = searchNode->GetNode("numIterations")) != 0)
        SetNumIterations(node->AsInt());
    if((node = searchNode->GetNode("iterationDamping")) != 0)
        SetIterationDamping(node->AsFloat());
    if((node = searchNode->GetNode("simplifyHeavilyMixedZones")) != 0)
        SetSimplifyHeavilyMixedZones(node->AsBool());
    if((node = searchNode->GetNode("maxMaterialsPerZone")) != 0)
        SetMaxMaterialsPerZone(node->AsInt());
    if((node = searchNode->GetNode("isoVolumeFraction")) != 0)
        SetIsoVolumeFraction(node->AsFloat());
    if((node = searchNode->GetNode("annealingTime")) != 0)
        SetAnnealingTime(node->AsInt());
}
Beispiel #17
0
bool
AxesArray::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    AxesArray defaultObject;
    bool addToParent = false;
    // Create a node for AxesArray.
    DataNode *node = new DataNode("AxesArray");

    if(completeSave || !FieldsEqual(ID_visible, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("visible", visible));
    }

    if(completeSave || !FieldsEqual(ID_ticksVisible, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("ticksVisible", ticksVisible));
    }

    if(completeSave || !FieldsEqual(ID_autoSetTicks, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("autoSetTicks", autoSetTicks));
    }

    if(completeSave || !FieldsEqual(ID_autoSetScaling, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("autoSetScaling", autoSetScaling));
    }

    if(completeSave || !FieldsEqual(ID_lineWidth, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("lineWidth", lineWidth));
    }

    if(completeSave || !FieldsEqual(ID_axes, &defaultObject))
    {
        DataNode *axesNode = new DataNode("axes");
        if(axes.CreateNode(axesNode, completeSave, false))
        {
            addToParent = true;
            node->AddNode(axesNode);
        }
        else
            delete axesNode;
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}
Beispiel #18
0
double AODVrcvcode(int seg, void* data) {
    AODVrcv_Data* d = (AODVrcv_Data*) data;
    int myID = d->nodeID;

    MailboxMsg *mailboxmsg;
    GenericNwkMsg *nwkmsg;
    DataMsg *datamsg;
    RREQMsg *rreqmsg;
    RREPMsg *rrepmsg;
    RERRMsg *rerrmsg, *rerrmsg2;
    HelloMsg *hellomsg;

    int i, dest, seqNbr, hopCnt, cond1, cond2;
    int intermed, drop, cached_RREQID, propagate, nextHop;
    double now, etime1, etime2, lifetime;
    double etime = 0.0001;

    RouteEntry *dest_entry, *src_entry;
    DataNode *dn;

    switch (seg) {
    case 1:
        nwkmsg = (GenericNwkMsg*) ttGetMsg(ZIGBEENETW);
        now = ttCurrentTime();

        ///////////////////////
        // Tmote stuff start //
        ///////////////////////
        if(nwkmsg->type == RANGE_RESPONSE) {
            if (ttCurrentTime() < d->rcv_timeout) {
                // Get data from rangeResponseMsg and then delete it
                RangeResponseMsg *rangeResp = (RangeResponseMsg *)nwkmsg->msg;

                double x, y;
                unsigned int range;

                range = rangeResp->range;
                x = rangeResp->x;
                y = rangeResp->y;

                d->responseCounter++;
                //		mexPrintf("Response counter = %d \n",d->responseCounter);

                // Remove 145 for 2ms delay
                // Add 80 for compensation for unknown error
                double dist;
                //   	dist = 34400.0 * (double)(range - 145 + 80) / 72280.0; original
                dist = 34400.0 * (double)(range - 145 + 68) / 72280.0;
                //		dist = 34400.0 * (double)(range - 145) / 72280.0;
                //		mexPrintf("Distance measurment from %d = %f \n",rangeResp->nodeID,dist);

                // Put values in data
                d->node_x = x;
                d->node_y = y;
                d->node_dist = dist;
                // DEBUG
                d->node_nodeID = rangeResp->nodeID;
                if (fabs(dist) < 300.0) {
                    // Start task that sends data to mega128
                    ttCreateJob("node_data_to_kalman");
                }
            }
        } else if (nwkmsg->type == RANGE_REQUEST) {
            d->snd_block = ttCurrentTime() + 0.310;
        }
        //////////////////////
        // Tmote stuff ends //
        //////////////////////
        else if (nwkmsg->type == DATA) {
            // Data message
            datamsg = (DataMsg*) nwkmsg->msg;
            delete nwkmsg;

            if (datamsg->dest == myID) {
                // Data message arrived at destination
                if (VERBOSE) {
                    mexPrintf("Time: %f Data message arrived at Node#%d\n", now, myID);
                }

                // Update expiry timer for route to source
                d->routing_table[datamsg->src - 1].exptime = now + ACTIVE_ROUTE_TIMEOUT;

                // Notify application
                ttTryPost("AODVRcvBox", datamsg);
                ttCreateJob("RcvTask");

                etime = 0.0001;
            } else {
                // Forward data message
                if (VERBOSE) {
                    mexPrintf("Time: %f Node#%d about to forward data to Node#%d Data: %f\n", now, myID, datamsg->dest, datamsg->data);
                }

                // Update expiry timer for route to source
                d->routing_table[datamsg->src - 1].exptime = now + ACTIVE_ROUTE_TIMEOUT;

                // Find route to destination and update expiry timer
                dest_entry = &(d->routing_table[datamsg->dest - 1]);
                dest_entry->exptime = now + ACTIVE_ROUTE_TIMEOUT;

                // Forward data message to next hop
                nwkmsg = new GenericNwkMsg;
                nwkmsg->type = DATA;
                nwkmsg->msg = datamsg;
                ttSendMsg(dest_entry->nextHop, nwkmsg, datamsg->size);

                etime = 0.0001;
            }
            updateExpiryTimer(d->routing_table, d->dataTimer, myID);
        } else {
            // AODV control message (RREQ, RREP, RERR, or HELLO)
            if (VERBOSE) {
                mexPrintf("Time: %f Node#%d processing AODV message type: %d from Node#%d\n", now, myID, nwkmsg->type, nwkmsg->intermed);
            }

            switch (nwkmsg->type) {
            case RREQ:
                rreqmsg = (RREQMsg*) nwkmsg->msg;
                intermed = nwkmsg->intermed;

                if (rreqmsg->src == myID) {
                    // Skip RREQs received by the original source

                    etime = 0.00001;
                } else {
                    // Have this RREQ already been processed?
                    cached_RREQID = d->cache[rreqmsg->src - 1];

                    drop = 0;
                    if (rreqmsg->RREQID <= cached_RREQID) {
                        // Found in cache, drop redundant RREQ
                        if (VERBOSE) {
                            mexPrintf("Time: %f Node#%d dropping redundant RREQ from Node#%d\n", now, myID, intermed);
                        }
                        drop = 1;
                    }

                    if (!drop) {
                        // process RREQ
                        if (VERBOSE) {
                            mexPrintf("Time: %f Node#%d caching RREQ with Src: %d RREQID: %d\n", now, myID, rreqmsg->src, rreqmsg->RREQID);
                        }

                        // Enter RREQID in cache
                        d->cache[rreqmsg->src - 1] = rreqmsg->RREQID;

                        // Create or update route entry to source
                        src_entry = &(d->routing_table[rreqmsg->src - 1]);

                        if (!src_entry->valid) {
                            // No entry exists or invalid
                            src_entry->destSeqNbr = rreqmsg->srcSeqNbr;
                            for (i=0; i<NBR_AODV; i++) {
                                src_entry->prec[i] = 0; // empty precursor list
                            }
                        } else {
                            // Update destination sequence number
                            src_entry->destSeqNbr = max(src_entry->destSeqNbr, rreqmsg->srcSeqNbr);
                        }
                        src_entry->dest = rreqmsg->src;
                        src_entry->nextHop = intermed;
                        src_entry->hops = rreqmsg->hopCnt + 1;
                        src_entry->exptime = now + ACTIVE_ROUTE_TIMEOUT;
                        src_entry->valid = 1;

                        updateExpiryTimer(d->routing_table, d->dataTimer, myID);

                        // Check if we have a route to destination
                        dest_entry = &(d->routing_table[rreqmsg->dest - 1]);

                        if (rreqmsg->dest==myID || dest_entry->valid) {
                            // We are the destination or we have a route to it
                            if (VERBOSE) {
                                mexPrintf("Node#%d has a route to destination#%d\n", myID, rreqmsg->dest);
                            }

                            if (rreqmsg->dest!=myID) {
                                // I am not the destination, but have a route to it
                                if (VERBOSE) {
                                    mexPrintf("Sending first RREP from node with route\n");
                                }

                                dest = dest_entry->dest;
                                seqNbr = dest_entry->destSeqNbr;
                                hopCnt = dest_entry->hops;
                                lifetime = dest_entry->exptime - now;
                                dest_entry->prec[intermed] = 1;
                            } else {
                                // I am the destination itself
                                if (VERBOSE) {
                                    mexPrintf("Sending first RREP from destination itself\n");
                                }

                                dest = myID;
                                if (d->seqNbrs[myID - 1] + 1 == rreqmsg->srcSeqNbr) {
                                    d->seqNbrs[myID - 1]++;
                                }

                                seqNbr = max(d->seqNbrs[myID - 1], rreqmsg->destSeqNbr);
                                hopCnt = 0;
                                lifetime = ACTIVE_ROUTE_TIMEOUT;
                            }

                            // Create RREP
                            rrepmsg = new RREPMsg;
                            rrepmsg->hopCnt = hopCnt;
                            rrepmsg->dest = dest;
                            rrepmsg->destSeqNbr = seqNbr;
                            rrepmsg->src = rreqmsg->src;
                            rrepmsg->lifetime = lifetime;

                            // Send RREP to previous hop
                            nwkmsg = new GenericNwkMsg;
                            nwkmsg->type = RREP;
                            nwkmsg->intermed = myID;
                            nwkmsg->msg = rrepmsg;
                            ttSendMsg(intermed, nwkmsg, 20*8);  // 20 bytes

                            etime = 0.0001;
                        } else {
                            // We do not have a route to the destination
                            if (VERBOSE) {
                                mexPrintf("Time: %f Node#%d sending new broadcast\n", now, myID);
                            }

                            // Update RREQ
                            rreqmsg->hopCnt++;
                            rreqmsg->destSeqNbr = max(d->seqNbrs[rreqmsg->dest - 1], rreqmsg->destSeqNbr);

                            // Rebroadcast RREQ
                            nwkmsg = new GenericNwkMsg;
                            nwkmsg->type = RREQ;
                            nwkmsg->intermed = myID;
                            nwkmsg->msg = rreqmsg;
                            ttSendMsg(0, nwkmsg, 24*8);  // 24 bytes

                            etime = 0.0001;
                        }
                    } else {
                        etime = 0.00001; // used if RREQ is dropped
                    }
                }
                break;

            case RREP:
                rrepmsg = (RREPMsg*) nwkmsg->msg;
                intermed = nwkmsg->intermed;

                if (VERBOSE) {
                    mexPrintf("Node#%d got an RREP from Node#%d for destination#%d\n", myID, intermed, rrepmsg->dest);
                }

                // Initialize or update forward route entry
                dest_entry = &(d->routing_table[rrepmsg->dest - 1]);

                if (!dest_entry->valid) {
                    // No valid entry exists, initialize new
                    if (VERBOSE) {
                        mexPrintf("Initializing new forward entry from Node#%d to Node#%d\n", myID, rrepmsg->dest);
                    }

                    dest_entry->dest = rrepmsg->dest;
                    dest_entry->nextHop = intermed;
                    dest_entry->hops = rrepmsg->hopCnt + 1;
                    dest_entry->destSeqNbr = rrepmsg->destSeqNbr;
                    dest_entry->exptime = now + rrepmsg->lifetime;
                    for (i=0; i<NBR_AODV; i++) {
                        dest_entry->prec[i] = 0; // empty precursor list
                    }
                    dest_entry->valid = 1;
                    propagate = 1;

                    etime2 = 0.0001;;
                } else {
                    // Valid forward entry already exists in table
                    // Should it be updated?
                    cond1 = (rrepmsg->destSeqNbr > dest_entry->destSeqNbr);
                    cond2 = ((rrepmsg->destSeqNbr == dest_entry->destSeqNbr) && (rrepmsg->hopCnt+1 < dest_entry->hops));

                    if (cond1 || cond2) {
                        // Update existing entry
                        if (VERBOSE) {
                            mexPrintf("Updating existing forward entry from Node#%d to Node#%d\n", myID, rrepmsg->dest);
                        }

                        dest_entry->nextHop = intermed;
                        dest_entry->hops = rrepmsg->hopCnt + 1;
                        dest_entry->destSeqNbr = rrepmsg->destSeqNbr;
                        dest_entry->exptime = now + rrepmsg->lifetime;

                        propagate = 1;
                        etime2 = 0.0001;
                    } else {
                        // Existing entry should be kept
                        // Do not propagate RREP
                        if (VERBOSE) {
                            mexPrintf("No entry updated in Node#%d\n", myID);
                        }

                        propagate = 0;

                        etime2 = 0.0001;;
                    }
                }

                etime1 = 0;

                if (rrepmsg->src == myID) {
                    // Original source, no reverse entry exists
                    if (VERBOSE) {
                        mexPrintf("Node#%d got final RREP for route to Node#%d\n", myID, rrepmsg->dest);
                    }

                    // Inform AODVSend to send buffered data messages
                    mailboxmsg = new MailboxMsg;
                    mailboxmsg->type = ROUTE_EST;
                    mailboxmsg->dest = rrepmsg->dest;
                    mailboxmsg->datamsg = NULL;
                    ttTryPost("AODVSndBox", mailboxmsg);

                    etime1 = 0.0001;

                } else if (propagate) {

                    // Update reverse entry from info in RREP
                    // and get next hop towards source
                    src_entry = &(d->routing_table[rrepmsg->src - 1]);
                    src_entry->exptime = now + rrepmsg->lifetime;
                    src_entry->prec[intermed-1] = 1; // the node that sent the RREP is a precursor towards the src
                    nextHop = src_entry->nextHop;

                    // Update precursor list for forward entry
                    dest_entry->prec[nextHop-1] = 1; // the node that will rcv next RREP is a precursor towards the dest

                    // Update RREP to continue back propagation
                    rrepmsg->hopCnt++;

                    nwkmsg = new GenericNwkMsg;
                    nwkmsg->type = RREP;
                    nwkmsg->intermed = myID;
                    nwkmsg->msg = rrepmsg;

                    ttSendMsg(nextHop, nwkmsg, 20*8);  // 20 bytes

                    etime1 = 0.0001;;

                }
                updateExpiryTimer(d->routing_table, d->dataTimer, myID);

                etime = etime1 + etime2;
                break;

            case RERR:

                rerrmsg = (RERRMsg*) nwkmsg->msg;
                intermed = nwkmsg->intermed;

                if (VERBOSE) {
                    mexPrintf("Node#%d got an RERR from Node#%d for destination#%d\n", myID, intermed, rerrmsg->dest);
                }

                // Propagate RERR?
                dest_entry = &(d->routing_table[rerrmsg->dest - 1]);

                if (dest_entry->valid && dest_entry->nextHop == intermed) {
                    // Should send RERR to all nodes in precursor list (neighbors)
                    for (i=0; i<NBR_AODV; i++) {
                        if (dest_entry->prec[i]) {
                            // Node i+1 uses this node as next hop towards dest, send RERR
                            rerrmsg2 = new RERRMsg;
                            rerrmsg2->dest = dest_entry->dest;
                            rerrmsg2->destSeqNbr = dest_entry->destSeqNbr;
                            rerrmsg2->receiver = i+1;

                            d->RERRlist->appendNode(new DataNode(rerrmsg2, ""));
                        }
                    }

                    // Invalidate route
                    if (VERBOSE) {
                        mexPrintf("Node#%d invalidating route to Node#%d through Node#%d\n", myID, rerrmsg->dest, intermed);
                    }

                    dest_entry->valid = 0;
                }

                etime = 0.0001;;
                break;

            case HELLO:
                hellomsg = (HelloMsg*) nwkmsg->msg;
                intermed = nwkmsg->intermed;
                //delete nwkmsg;

                if (VERBOSE) {
                    mexPrintf("Time: %f Node#%d got a hello message from Node#%d\n", now, myID, hellomsg->dest);
                }

                // Update time stamp for last HELLO msg
                d->dataHello->nbors[hellomsg->dest - 1] = 1;
                d->dataHello->lastHello[hellomsg->dest - 1] = now;

                etime = 0.0001;;
            }

        }
        return etime;

    case 2:
        // Send next RERR, if any
        dn = (DataNode*) d->RERRlist->getFirst();
        if (dn != NULL) {
            // Retrieve next RERR in list
            rerrmsg = (RERRMsg*) dn->data;

            dn->remove();
            delete dn;

            // Send RERR to receiver
            nwkmsg = new GenericNwkMsg;
            nwkmsg->type = RERR;
            nwkmsg->intermed = myID;
            nwkmsg->msg = rerrmsg;

            if (VERBOSE) {
                mexPrintf("Node#%d sending RERR to Node#%d\n", myID, rerrmsg->receiver);
            }

            ttSendMsg(rerrmsg->receiver, nwkmsg, 12*8);  // 12 bytes
            ttSleep(0.001);
            return 0.0001;
        } else {
            return FINISHED;
        }

    case 3:
        ttSetNextSegment(2);
        return 0.0001;
    }

    return FINISHED; // to supress compilation warnings
}
Beispiel #19
0
// Load a planet's description from a file.
void Planet::Load(const DataNode &node, const Set<Sale<Ship>> &ships, const Set<Sale<Outfit>> &outfits)
{
	if(node.Size() < 2)
		return;
	name = node.Token(1);
	
	// If this planet has been loaded before, these sets of items should be
	// reset if they are also defined here, instead of appending to them:
	bool resetAttributes = !attributes.empty();
	bool resetDescription = !description.empty();
	bool resetSpaceport = !spaceport.empty();
	
	for(const DataNode &child : node)
	{
		if(child.Token(0) == "landscape" && child.Size() >= 2)
			landscape = SpriteSet::Get(child.Token(1));
		else if(child.Token(0) == "attributes")
		{
			if(resetAttributes)
			{
				resetAttributes = false;
				attributes.clear();
			}
			for(int i = 1; i < child.Size(); ++i)
				attributes.insert(child.Token(i));
		}
		else if(child.Token(0) == "description" && child.Size() >= 2)
		{
			if(resetDescription)
			{
				resetDescription = false;
				description.clear();
			}
			if(!description.empty() && !child.Token(1).empty() && child.Token(1)[0] > ' ')
				description += '\t';
			description += child.Token(1);
			description += '\n';
		}
		else if(child.Token(0) == "spaceport" && child.Size() >= 2)
		{
			if(child.Token(1) == "clear")
				spaceport.clear();
			else
			{
				if(resetSpaceport)
				{
					resetSpaceport = false;
					spaceport.clear();
				}
				if(!spaceport.empty() && !child.Token(1).empty() && child.Token(1)[0] > ' ')
					spaceport += '\t';
				spaceport += child.Token(1);
				spaceport += '\n';
			}
		}
		else if(child.Token(0) == "shipyard" && child.Size() >= 2)
		{
			if(child.Token(1) == "clear")
				shipSales.clear();
			else
				shipSales.push_back(ships.Get(child.Token(1)));
		}
		else if(child.Token(0) == "outfitter" && child.Size() >= 2)
		{
			if(child.Token(1) == "clear")
				outfitSales.clear();
			else
				outfitSales.push_back(outfits.Get(child.Token(1)));
		}
		else if(child.Token(0) == "government" && child.Size() >= 2)
			government = GameData::Governments().Get(child.Token(1));
		else if(child.Token(0) == "required reputation" && child.Size() >= 2)
			requiredReputation = child.Value(1);
		else if(child.Token(0) == "bribe" && child.Size() >= 2)
			bribe = child.Value(1);
		else if(child.Token(0) == "security" && child.Size() >= 2)
			security = child.Value(1);
		else if(child.Token(0) == "tribute" && child.Size() >= 2)
		{
			tribute = child.Value(1);
			for(const DataNode &grand : child)
			{
				if(grand.Token(0) == "threshold" && grand.Size() >= 2)
					defenseThreshold = grand.Value(1);
				else if(grand.Token(0) == "fleet" && grand.Size() >= 3)
				{
					defenseCount = (grand.Size() >= 3 ? grand.Value(2) : 1);
					defenseFleet = GameData::Fleets().Get(grand.Token(1));
				}
				else
					grand.PrintTrace("Skipping unrecognized attribute:");
			}
		}
		else
			child.PrintTrace("Skipping unrecognized attribute:");
	}
}
void Conversation::Load(const DataNode &node)
{
	if(node.Token(0) != "conversation")
		return;
	if(node.Size() >= 2)
		identifier = node.Token(1);
	
	// Free any previously loaded data.
	nodes.clear();
	
	for(const DataNode &child : node)
	{
		if(child.Token(0) == "scene" && child.Size() >= 2)
		{
			nodes.emplace_back();
			int next = nodes.size();
			nodes.back().data.emplace_back("", next);
			
			nodes.back().scene = SpriteSet::Get(child.Token(1));
			nodes.back().sceneName = child.Token(1);
		}
		else if(child.Token(0) == "label" && child.Size() >= 2)
		{
			// You cannot merge text above a label with text below it.
			if(!nodes.empty())
				nodes.back().canMergeOnto = false;
			AddLabel(child.Token(1), child);
		}
		else if(child.Token(0) == "choice")
		{
			// Create a new node with one or more choices in it.
			nodes.emplace_back(true);
			for(const DataNode &grand : child)
			{
				// Store the text of this choice. By default, the choice will
				// just bring you to the next node in the script.
				nodes.back().data.emplace_back(grand.Token(0), nodes.size());
				nodes.back().data.back().first += '\n';
				
				// If this choice contains a goto, record it.
				for(const DataNode &great : grand)
				{
					int index = TokenIndex(great.Token(0));
					
					if(!index && great.Size() >= 2)
						Goto(great.Token(1), nodes.size() - 1, nodes.back().data.size() - 1);
					else if(index < 0)
						nodes.back().data.back().second = index;
					else
						continue;
					
					break;
				}
			}
			if(nodes.back().data.empty())
			{
				child.PrintTrace("Conversation contains an empty \"choice\" node:");
				nodes.pop_back();
			}
		}
		else if(child.Token(0) == "name")
			nodes.emplace_back(true);
		else if(child.Token(0) == "branch")
		{
			nodes.emplace_back();
			nodes.back().canMergeOnto = false;
			nodes.back().conditions.Load(child);
			for(int i = 1; i <= 2; ++i)
			{
				// If no link is provided, just go to the next node.
				nodes.back().data.emplace_back("", nodes.size());
				if(child.Size() > i)
				{
					int index = TokenIndex(child.Token(i));
					if(!index)
						Goto(child.Token(i), nodes.size() - 1, i - 1);
					else if(index < 0)
						nodes.back().data.back().second = index;
				}
			}
		}
		else if(child.Token(0) == "apply")
		{
			nodes.emplace_back();
			nodes.back().canMergeOnto = false;
			nodes.back().conditions.Load(child);
			nodes.back().data.emplace_back("", nodes.size());
			if(child.Size() > 1)
			{
				int index = TokenIndex(child.Token(1));
				if(!index)
					Goto(child.Token(1), nodes.size() - 1, 0);
				else if(index < 0)
					nodes.back().data.back().second = index;
			}
		}
		else
		{
			// This is just an ordinary text node.
			// If the previous node is a choice, or if the previous node ended
			// in a goto, create a new node. Otherwise, just merge this new
			// paragraph into the previous node.
			if(nodes.empty() || !nodes.back().canMergeOnto)
			{
				nodes.emplace_back();
				int next = nodes.size();
				nodes.back().data.emplace_back("", next);
			}
			
			nodes.back().data.back().first += child.Token(0);
			nodes.back().data.back().first += '\n';
			
			// Check if this node contains a "goto".
			for(const DataNode &grand : child)
			{
				int index = TokenIndex(grand.Token(0));
					
				if(!index && grand.Size() >= 2)
					Goto(grand.Token(1), nodes.size() - 1);
				else if(index < 0)
					nodes.back().data.back().second = index;
				else
					continue;
				
				nodes.back().canMergeOnto = false;
				break;
			}
		}
	}
	
	// Display a warning if a label was not resolved.
	if(!unresolved.empty())
		for(const auto &it : unresolved)
			node.PrintTrace("Conversation contains unused label \"" + it.first + "\":");
	
	// Check for any loops in the conversation.
	for(const auto &it : labels)
	{
		int nodeIndex = it.second;
		while(nodeIndex >= 0 && Choices(nodeIndex) <= 1)
		{
			nodeIndex = NextNode(nodeIndex);
			if(nodeIndex == it.second)
			{
				node.PrintTrace("Conversation contains infinite loop beginning with label \"" + it.first + "\":");
				nodes.clear();
				return;
			}
		}
	}
	
	// Free the working buffers that we no longer need.
	labels.clear();
	unresolved.clear();
}
void
NameschemeAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("NameschemeAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("namescheme")) != 0)
        SetNamescheme(node->AsString());
    if((node = searchNode->GetNode("externalArrayNames")) != 0)
        SetExternalArrayNames(node->AsStringVector());
    if((node = searchNode->GetNode("externalArrayOffsets")) != 0)
        SetExternalArrayOffsets(node->AsIntVector());
    if((node = searchNode->GetNode("externalArrayData")) != 0)
        SetExternalArrayData(node->AsIntVector());
    if((node = searchNode->GetNode("allExplicitNames")) != 0)
        SetAllExplicitNames(node->AsStringVector());
    if((node = searchNode->GetNode("explicitIds")) != 0)
        SetExplicitIds(node->AsIntVector());
    if((node = searchNode->GetNode("explicitNames")) != 0)
        SetExplicitNames(node->AsStringVector());
}
DataNode *
VLIFileManager::Import(DataNode *node)
{
    DataNode *vliNode = node->GetNode("vli");
    
    if (vliNode == NULL) return NULL;
    if ((vliNode->GetNode("axis") == NULL) || (vliNode->GetNode("nservers") == NULL) || (vliNode->GetNode("dataset") == NULL)) return NULL;
    if ((vliNode->GetNode("syscall") == NULL) || (vliNode->GetNode("server") == NULL) || (vliNode->GetNode("datafile") == NULL)) return NULL;
    
    if (vliNode->GetNode("name") != NULL) this->name = std::string(vliNode->GetNode("name")->AsString());
    if (vliNode->GetNode("axis") != NULL) this->setAxis(vliNode->GetNode("axis")->AsIntArray());
    if (vliNode->GetNode("nservers") != NULL) this->setNoDataServers(vliNode->GetNode("nservers")->AsInt());
    if (vliNode->GetNode("syscall") != NULL) this->syscall = std::string(vliNode->GetNode("syscall")->AsString());
    if (vliNode->GetNode("server") != NULL) this->server = std::string(vliNode->GetNode("server")->AsString());
    if (vliNode->GetNode("datafile") != NULL) this->datafile = std::string(vliNode->GetNode("datafile")->AsString());
    if (vliNode->GetNode("dataset") != NULL) {
        this->dataset = new VLIDataset();
        if (this->dataset->Import(vliNode->GetNode("dataset")) == false) return NULL;
    }
    
    return node;
}
void
ConstructDDFAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("ConstructDDFAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("ddfName")) != 0)
        SetDdfName(node->AsString());
    if((node = searchNode->GetNode("varnames")) != 0)
        SetVarnames(node->AsStringVector());
    if((node = searchNode->GetNode("ranges")) != 0)
        SetRanges(node->AsDoubleVector());
    if((node = searchNode->GetNode("codomainName")) != 0)
        SetCodomainName(node->AsString());
    if((node = searchNode->GetNode("statisticalOperator")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 10)
                SetStatisticalOperator(StatisticalOperator(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            StatisticalOperator value;
            if(StatisticalOperator_FromString(node->AsString(), value))
                SetStatisticalOperator(value);
        }
    }
    if((node = searchNode->GetNode("percentile")) != 0)
        SetPercentile(node->AsDouble());
    if((node = searchNode->GetNode("undefinedValue")) != 0)
        SetUndefinedValue(node->AsDouble());
    if((node = searchNode->GetNode("binningScheme")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetBinningScheme(BinningScheme(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            BinningScheme value;
            if(BinningScheme_FromString(node->AsString(), value))
                SetBinningScheme(value);
        }
    }
    if((node = searchNode->GetNode("numSamples")) != 0)
        SetNumSamples(node->AsIntVector());
    if((node = searchNode->GetNode("overTime")) != 0)
        SetOverTime(node->AsBool());
    if((node = searchNode->GetNode("timeStart")) != 0)
        SetTimeStart(node->AsInt());
    if((node = searchNode->GetNode("timeEnd")) != 0)
        SetTimeEnd(node->AsInt());
    if((node = searchNode->GetNode("timeStride")) != 0)
        SetTimeStride(node->AsInt());
}
bool
SurfaceFilterAttributes::CreateNode(DataNode *parentNode, bool completeSave, bool forceAdd)
{
    if(parentNode == 0)
        return false;

    SurfaceFilterAttributes defaultObject;
    bool addToParent = false;
    // Create a node for SurfaceFilterAttributes.
    DataNode *node = new DataNode("SurfaceFilterAttributes");

    if(completeSave || !FieldsEqual(ID_limitsMode, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("limitsMode", LimitsMode_ToString(limitsMode)));
    }

    if(completeSave || !FieldsEqual(ID_minFlag, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("minFlag", minFlag));
    }

    if(completeSave || !FieldsEqual(ID_maxFlag, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("maxFlag", maxFlag));
    }

    if(completeSave || !FieldsEqual(ID_scaling, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("scaling", Scaling_ToString(scaling)));
    }

    if(completeSave || !FieldsEqual(ID_skewFactor, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("skewFactor", skewFactor));
    }

    if(completeSave || !FieldsEqual(ID_min, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("min", min));
    }

    if(completeSave || !FieldsEqual(ID_max, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("max", max));
    }

    if(completeSave || !FieldsEqual(ID_zeroFlag, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("zeroFlag", zeroFlag));
    }

    if(completeSave || !FieldsEqual(ID_variable, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("variable", variable));
    }

    if(completeSave || !FieldsEqual(ID_useXYLimits, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("useXYLimits", useXYLimits));
    }

    if(completeSave || !FieldsEqual(ID_generateNodalOutput, &defaultObject))
    {
        addToParent = true;
        node->AddNode(new DataNode("generateNodalOutput", generateNodalOutput));
    }


    // Add the node to the parent node.
    if(addToParent || forceAdd)
        parentNode->AddNode(node);
    else
        delete node;

    return (addToParent || forceAdd);
}
void
PersistentParticlesAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("PersistentParticlesAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("startIndex")) != 0)
        SetStartIndex(node->AsInt());
    if((node = searchNode->GetNode("stopIndex")) != 0)
        SetStopIndex(node->AsInt());
    if((node = searchNode->GetNode("stride")) != 0)
        SetStride(node->AsInt());
    if((node = searchNode->GetNode("startPathType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetStartPathType(PathTypeEnum(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            PathTypeEnum value;
            if(PathTypeEnum_FromString(node->AsString(), value))
                SetStartPathType(value);
        }
    }
    if((node = searchNode->GetNode("stopPathType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetStopPathType(PathTypeEnum(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            PathTypeEnum value;
            if(PathTypeEnum_FromString(node->AsString(), value))
                SetStopPathType(value);
        }
    }
    if((node = searchNode->GetNode("traceVariableX")) != 0)
        SetTraceVariableX(node->AsString());
    if((node = searchNode->GetNode("traceVariableY")) != 0)
        SetTraceVariableY(node->AsString());
    if((node = searchNode->GetNode("traceVariableZ")) != 0)
        SetTraceVariableZ(node->AsString());
    if((node = searchNode->GetNode("connectParticles")) != 0)
        SetConnectParticles(node->AsBool());
    if((node = searchNode->GetNode("showPoints")) != 0)
        SetShowPoints(node->AsBool());
    if((node = searchNode->GetNode("indexVariable")) != 0)
        SetIndexVariable(node->AsString());
}
void
SurfaceFilterAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("SurfaceFilterAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("limitsMode")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetLimitsMode(LimitsMode(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            LimitsMode value;
            if(LimitsMode_FromString(node->AsString(), value))
                SetLimitsMode(value);
        }
    }
    if((node = searchNode->GetNode("minFlag")) != 0)
        SetMinFlag(node->AsBool());
    if((node = searchNode->GetNode("maxFlag")) != 0)
        SetMaxFlag(node->AsBool());
    if((node = searchNode->GetNode("scaling")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetScaling(Scaling(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Scaling value;
            if(Scaling_FromString(node->AsString(), value))
                SetScaling(value);
        }
    }
    if((node = searchNode->GetNode("skewFactor")) != 0)
        SetSkewFactor(node->AsDouble());
    if((node = searchNode->GetNode("min")) != 0)
        SetMin(node->AsDouble());
    if((node = searchNode->GetNode("max")) != 0)
        SetMax(node->AsDouble());
    if((node = searchNode->GetNode("zeroFlag")) != 0)
        SetZeroFlag(node->AsBool());
    if((node = searchNode->GetNode("variable")) != 0)
        SetVariable(node->AsString());
    if((node = searchNode->GetNode("useXYLimits")) != 0)
        SetUseXYLimits(node->AsBool());
    if((node = searchNode->GetNode("generateNodalOutput")) != 0)
        SetGenerateNodalOutput(node->AsBool());
}
void
ConstructDataBinningAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("ConstructDataBinningAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("name")) != 0)
        SetName(node->AsString());
    if((node = searchNode->GetNode("varnames")) != 0)
        SetVarnames(node->AsStringVector());
    if((node = searchNode->GetNode("binType")) != 0)
        SetBinType(node->AsUnsignedCharVector());
    if((node = searchNode->GetNode("binBoundaries")) != 0)
        SetBinBoundaries(node->AsDoubleVector());
    if((node = searchNode->GetNode("reductionOperator")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 9)
                SetReductionOperator(ReductionOperator(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            ReductionOperator value;
            if(ReductionOperator_FromString(node->AsString(), value))
                SetReductionOperator(value);
        }
    }
    if((node = searchNode->GetNode("varForReductionOperator")) != 0)
        SetVarForReductionOperator(node->AsString());
    if((node = searchNode->GetNode("undefinedValue")) != 0)
        SetUndefinedValue(node->AsDouble());
    if((node = searchNode->GetNode("binningScheme")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetBinningScheme(BinningScheme(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            BinningScheme value;
            if(BinningScheme_FromString(node->AsString(), value))
                SetBinningScheme(value);
        }
    }
    if((node = searchNode->GetNode("numBins")) != 0)
        SetNumBins(node->AsIntVector());
    if((node = searchNode->GetNode("overTime")) != 0)
        SetOverTime(node->AsBool());
    if((node = searchNode->GetNode("timeStart")) != 0)
        SetTimeStart(node->AsInt());
    if((node = searchNode->GetNode("timeEnd")) != 0)
        SetTimeEnd(node->AsInt());
    if((node = searchNode->GetNode("timeStride")) != 0)
        SetTimeStride(node->AsInt());
    if((node = searchNode->GetNode("outOfBoundsBehavior")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetOutOfBoundsBehavior(OutOfBoundsBehavior(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            OutOfBoundsBehavior value;
            if(OutOfBoundsBehavior_FromString(node->AsString(), value))
                SetOutOfBoundsBehavior(value);
        }
    }
}
bool
ColorTableAttributes::CreateNode(DataNode *parentNode, bool, bool)
{
    if(parentNode == 0)
        return true;

    // Create a node for ColorTableAttributes.
    DataNode *node = new DataNode("ColorTableAttributes");
    node->AddNode(new DataNode("activeContinuous", activeContinuous));
    node->AddNode(new DataNode("activeDiscrete", activeDiscrete));

    // Add each color table specially.
    char tmp[100];
    ColorControlPointList defaultObject;
    int index = 0;
    for(size_t i = 0; i < colorTables.size(); ++i)    
    {
        const ColorControlPointList &ccpl = GetColorTables(i);
        if(!ccpl.GetExternalFlag())
        {
            SNPRINTF(tmp, 100, "table%02d", index++);
            DataNode *ctNode = new DataNode(tmp);
            // Add the color table attributes to the ctNode.
            ctNode->AddNode(new DataNode("ctName", names[i]));
            if(!ccpl.FieldsEqual(ColorControlPointList::ID_equalSpacingFlag, &defaultObject))
                ctNode->AddNode(new DataNode("equal", ccpl.GetEqualSpacingFlag()));
            if(!ccpl.FieldsEqual(ColorControlPointList::ID_smoothingFlag, &defaultObject))
                ctNode->AddNode(new DataNode("smooth", ccpl.GetSmoothingFlag()));
            if(!ccpl.FieldsEqual(ColorControlPointList::ID_discreteFlag, &defaultObject))
                ctNode->AddNode(new DataNode("discrete", ccpl.GetDiscreteFlag()));

            // Add the control points to the vector that we'll save out.
            floatVector fvec;
            for(int j = 0; j < ccpl.GetNumControlPoints(); ++j)
            {
                const ColorControlPoint &cp = ccpl.operator[](j);
                fvec.push_back(cp.GetPosition());
                fvec.push_back(float(cp.GetColors()[0]));
                fvec.push_back(float(cp.GetColors()[1]));
                fvec.push_back(float(cp.GetColors()[2]));
            }
            ctNode->AddNode(new DataNode("controlPts", fvec));
            node->AddNode(ctNode);
        }
    }

    node->AddNode(new DataNode("Ntables", index));

    // Add the node to the parent node.
    parentNode->AddNode(node);

    return true;
}
Beispiel #29
0
void
LineoutAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("LineoutAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("point1")) != 0)
        SetPoint1(node->AsDoubleArray());
    if((node = searchNode->GetNode("point2")) != 0)
        SetPoint2(node->AsDoubleArray());
    if((node = searchNode->GetNode("interactive")) != 0)
        SetInteractive(node->AsBool());
    if((node = searchNode->GetNode("ignoreGlobal")) != 0)
        SetIgnoreGlobal(node->AsBool());
    if((node = searchNode->GetNode("samplingOn")) != 0)
        SetSamplingOn(node->AsBool());
    if((node = searchNode->GetNode("numberOfSamplePoints")) != 0)
        SetNumberOfSamplePoints(node->AsInt());
    if((node = searchNode->GetNode("reflineLabels")) != 0)
        SetReflineLabels(node->AsBool());
    if((node = searchNode->GetNode("designator")) != 0)
        SetDesignator(node->AsString());
}
Beispiel #30
0
QvisWindowBase::QvisWindowBase(const QString &captionString, Qt::WindowFlags f) :
    QMainWindow(parentOfEveryWindow, 
#if defined(Q_WS_WIN) || defined(Q_WS_MACX) || defined(Q_OS_WIN) || defined(Q_OS_MAC)
                Qt::Window | f)
{
    // Make each window the child of the first window that is created
    // when we run on the Windows platform. This prevents the sub-windows
    // from showing up in the taskbar.
    if(parentOfEveryWindow == 0)
        parentOfEveryWindow = this;
#else
                f)
{
#endif
    if(!captionString.isEmpty())
        setWindowTitle(captionString);
    else
        setWindowTitle("VisIt");

    saveWindowDefaults = false;
}

// ****************************************************************************
// Method: QvisWindowBase::~QvisWindowBase
//
// Purpose: 
//   Destructor for the QvisWindowBase class.
//
// Programmer: Brad Whitlock
// Creation:   Wed Aug 30 18:15:17 PST 2000
//
// Modifications:
//   
// ****************************************************************************

QvisWindowBase::~QvisWindowBase()
{
    // nothing here.
}

// ****************************************************************************
// Method: QvisWindowBase::showMinimized
//
// Purpose: 
//   Is the window is visible, this method minimizes the window.
//
// Programmer: Brad Whitlock
// Creation:   Thu Apr 19 10:36:40 PDT 2001
//
// Modifications:
//   
// ****************************************************************************

void
QvisWindowBase::showMinimized()
{
    if(isVisible())
        QMainWindow::showMinimized();
}

// ****************************************************************************
// Method: QvisWindowBase::showNormal
//
// Purpose: 
//   If the window is minimized, this method shows it normal (de-iconifies it)
//
// Programmer: Brad Whitlock
// Creation:   Thu Apr 19 10:37:14 PDT 2001
//
// Modifications:
//   
// ****************************************************************************

void
QvisWindowBase::showNormal()
{
    if(isMinimized())
        QMainWindow::showNormal();
}

// ****************************************************************************
// Method: QvisWindowBase::CreateNode
//
// Purpose: 
//   Adds the window's geometry and visibility status to the DataNode
//   tree that will be saved to the VisIt config file.
//
// Arguments:
//   parentNode : The parent node under which we'll add a node for
//                this window.
//
// Programmer: Brad Whitlock
// Creation:   Tue Oct 3 15:30:23 PST 2000
//
// Modifications:
//   Brad Whitlock, Fri Jun  6 10:29:33 PDT 2008
//   Qt 4.
//
// ****************************************************************************

void
QvisWindowBase::CreateNode(DataNode *parentNode)
{
    if(saveWindowDefaults)
    {
        DataNode *node = new DataNode(windowTitle().toStdString());
        parentNode->AddNode(node);

        // Add generic window attributes
        node->AddNode(new DataNode("x", x()));
        node->AddNode(new DataNode("y", y()));
        node->AddNode(new DataNode("width", width()));
        node->AddNode(new DataNode("height", height()));
        node->AddNode(new DataNode("visible", isVisible()));
    }
}

// ****************************************************************************
// Method: QvisWindowBase::SetFromNode
//
// Purpose: 
//   Sets the window's geometry information from the DataNode.
//
// Arguments:
//   parentNode : This a pointer to the "GUI" node.
//   borders : An array of 4 ints containing the sizes of the window
//             decorations.
//
// Programmer: Brad Whitlock
// Creation:   Tue Oct 3 15:41:34 PST 2000
//
// Modifications:
//   Brad Whitlock, Wed Sep 10 09:19:32 PDT 2003
//   Added a method to make sure that the window fits on the screen.
//
//   Hank Childs, Mon Nov 14 16:25:27 PST 2005
//   Don't allow windows to come up off the screen.
//
//   Brad Whitlock, Wed Nov 22 09:56:26 PDT 2006
//   Added code to override the window location if an anchor has been provided.
//
//   Brad Whitlock, Fri Jun  6 10:29:41 PDT 2008
//   Qt 4.
//
// ****************************************************************************

void
QvisWindowBase::SetFromNode(DataNode *parentNode, const int *borders)
{
    DataNode *winNode = parentNode->GetNode(windowTitle().toStdString());
    if(winNode == 0)
        return;

    // Indicate that the window should be saved.
    saveWindowDefaults = true;

    DataNode *node;
    bool xy_set = false, wh_set = false;
    int x = 0, y = 0;
    int w = width();
    int h = height();

    // See if any attributes are set.
    if((node = winNode->GetNode("x")) != 0)
    {
        int x_pos = node->AsInt();
        if (x_pos < 0)
            x_pos = 0;
        x = x_pos + borders[2];
        xy_set = true;
    }
    if((node = winNode->GetNode("y")) != 0)
    {
        int y_pos = node->AsInt();
        if (y_pos < 0)
            y_pos = 0;
        y = y_pos + borders[0];
        xy_set = true;
    }
    if((node = winNode->GetNode("width")) != 0)
    {
        w = node->AsInt();
        wh_set = true;
    }
    if((node = winNode->GetNode("height")) != 0)
    {
        h = node->AsInt();
        wh_set = true;
    }

    // Possibly override the window anchor location.
    xy_set |= GetWindowAnchorLocation(x, y);

    // Make sure that the window will fit on the screen.
    FitToScreen(x, y, w, h);

    // Set the window geometry.
    if(wh_set && xy_set)
        setGeometry(x, y, w, h);
    else if(xy_set)
        move(x, y);
    else if(wh_set)
        resize(w, h);

    // If the window is visible, show it.
    if((node = winNode->GetNode("visible")) != 0)
    {
        if(node->AsBool())
            show();
    }
}