[Igarden-commit] Garden/source/LayoutDB MaterialRef.h, 1.43.2.8, 1.43.2.9 MaterialRef.cpp, 1.119.2.
Status: Beta
Brought to you by:
jlbedell
|
From: Jeffrey B. <jlb...@us...> - 2008-05-23 12:15:51
|
Update of /cvsroot/igarden/Garden/source/LayoutDB In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv12599/source/LayoutDB Modified Files: Tag: Release_branch_v1 MaterialRef.h MaterialRef.cpp Log Message: Add basic pruning capability (natural shaping to current size only) Speed up refresh when columns et is changed Index: MaterialRef.cpp =================================================================== RCS file: /cvsroot/igarden/Garden/source/LayoutDB/MaterialRef.cpp,v retrieving revision 1.119.2.36 retrieving revision 1.119.2.37 diff -C2 -d -r1.119.2.36 -r1.119.2.37 *** MaterialRef.cpp 19 Apr 2008 11:19:33 -0000 1.119.2.36 --- MaterialRef.cpp 23 May 2008 12:15:46 -0000 1.119.2.37 *************** *** 1639,1643 **** bool primary, secondary; planMonth_t planMonth; ! planLength_t usualSize, recommendedSize; long lower, upper, lval; UInt32 imageSize; --- 1639,1643 ---- bool primary, secondary; planMonth_t planMonth; ! planLength_t recommendedSize; long lower, upper, lval; UInt32 imageSize; *************** *** 1682,1699 **** glLineWidth (1); ! usualSize = GetMinimumSpacing(); ! recommendedSize = usualSize; if(_material == NULL) (void)GetMaterial(ifMissingNULL); ! if(_material != NULL) { ! if(_material->GetValueInt32Range(kPlantSpread, lower, upper)) ! { ! usualSize = upper; ! recommendedSize = lower; ! } } - if(HasDocument()) { --- 1682,1693 ---- glLineWidth (1); ! recommendedSize = GetMinimumSpacing(); if(_material == NULL) (void)GetMaterial(ifMissingNULL); ! if(_material != NULL && _material->GetValueInt32Range(kPlantSpread, lower, upper)) { ! recommendedSize = lower; } if(HasDocument()) { *************** *** 1708,1712 **** if(state->GetBoolPref(kPlanFullSize)) { ! actualSize = usualSize; } else --- 1702,1707 ---- if(state->GetBoolPref(kPlanFullSize)) { ! GetMaxPlantDimensions(&height, &spread); ! actualSize = spread; } else *************** *** 1899,1903 **** long n, numPoints; planPoint_t aPoint; ! planLength_t actualSize = 0, usualSize; long lower, upper; GLenum err; --- 1894,1898 ---- long n, numPoints; planPoint_t aPoint; ! planLength_t actualSize = 0; long lower, upper; GLenum err; *************** *** 1911,1928 **** PathElement::DrawAnchorPoints(intoView); intoView->GetYearsDisplayed(minYear, maxYear, primaryYear); - usualSize = GetMinimumSpacing(); if(_material == NULL) (void)GetMaterial(ifMissingNULL); - if(_material != NULL) - { - if(_material->GetValueInt32Range(kPlantSpread, lower, upper)) - usualSize = upper; - - } DocumentTags *state = GetActiveSavedState(GetDocument()); if(state->GetBoolPref(kPlanFullSize)) { ! actualSize = usualSize; } else --- 1906,1917 ---- PathElement::DrawAnchorPoints(intoView); intoView->GetYearsDisplayed(minYear, maxYear, primaryYear); if(_material == NULL) (void)GetMaterial(ifMissingNULL); DocumentTags *state = GetActiveSavedState(GetDocument()); if(state->GetBoolPref(kPlanFullSize)) { ! landscapeHeight_t tmpHeight; ! GetMaxPlantDimensions(&tmpHeight, &actualSize); } else *************** *** 2131,2135 **** attributeID_t instanceAttr; double yearsToMaxVal, yearOffset, sigmoidDenom; ! InstanceData *before, *after; PRECONDITION(attrID == kPlantHeight || attrID == kPlantSpread); --- 2120,2125 ---- attributeID_t instanceAttr; double yearsToMaxVal, yearOffset, sigmoidDenom; ! InstanceData *before, *after, *pruningBefore, *pruningAfter; ! pruningType_t pruningType; PRECONDITION(attrID == kPlantHeight || attrID == kPlantSpread); *************** *** 2153,2195 **** else before->GetSpread(temp, lastKnownVal); - if(maxVal != 0) - { - yearOffset = (logl(((double)maxVal/lastKnownVal)-1)-5) * (yearsToMaxVal)/-14.0; - yearOffset += (year - before->GetYear()); ! sigmoidDenom = 1 + exp(5-(14*yearOffset/yearsToMaxVal)); ! result = maxVal / sigmoidDenom; } else ! result = 0; ! if(after == before) { ! if(!before->isEmpty(instanceAttr)) { ! if(attrID == kPlantHeight) ! before->GetHeight(temp, result); ! else ! before->GetSpread(temp, result); } ! } ! else if(after != NULL && before != NULL) ! { ! planLength_t val1, val2; ! // Average before & after height/spread ! if(!before->isEmpty(instanceAttr) && !after->isEmpty(instanceAttr)) { ! if(attrID == kPlantHeight) { ! before->GetHeight(temp, val1); ! before->GetHeight(temp, val2); } ! else { ! before->GetSpread(temp, val1); ! before->GetSpread(temp, val2); } - result = (val1+val2)/2.0; } } --- 2143,2202 ---- else before->GetSpread(temp, lastKnownVal); ! BoundedInstanceData(year, kInstancePruningType, &pruningBefore, &pruningAfter); ! if(pruningBefore != NULL) ! { ! Int32 val; ! ! pruningBefore->GetInt32(kInstancePruningType, &val); ! pruningType = static_cast<pruningType_t>(val); } else ! pruningType = kPruningNone; ! if(pruningType == kPruningNaturalCurrentSize) ! result = lastKnownVal; ! else { ! if(maxVal != 0) { ! yearOffset = (logl(((double)maxVal/lastKnownVal)-1)-5) * (yearsToMaxVal)/-14.0; ! yearOffset += (year - before->GetYear()); ! ! sigmoidDenom = 1 + exp(5-(14*yearOffset/yearsToMaxVal)); ! result = maxVal / sigmoidDenom; } ! else ! result = 0; ! if(after == before) { ! if(!before->isEmpty(instanceAttr)) { ! if(attrID == kPlantHeight) ! before->GetHeight(temp, result); ! else ! before->GetSpread(temp, result); } ! } ! else if(after != NULL && before != NULL) ! { ! planLength_t val1, val2; ! ! // Average before & after height/spread ! if(!before->isEmpty(instanceAttr) && !after->isEmpty(instanceAttr)) { ! if(attrID == kPlantHeight) ! { ! before->GetHeight(temp, val1); ! before->GetHeight(temp, val2); ! } ! else ! { ! before->GetSpread(temp, val1); ! before->GetSpread(temp, val2); ! } ! result = (val1+val2)/2.0; } } } *************** *** 2211,2215 **** } } ! // printf("%s - Max %ld result = %f\n", attrID == kPlantHeight ? "height" : "spread", maxVal, result); --- 2218,2222 ---- } } ! // printf("%s - Max %ld result = %f\n", attrID == kPlantHeight ? "height" : "spread", maxVal, result); *************** *** 2219,2223 **** // --------------------------------------------------------------------------- ! /// GetPlantDimensions /// Get the height and spread of the current material, which may be anywhere within the range for the material in question. // --- 2226,2230 ---- // --------------------------------------------------------------------------- ! /// GetLatestPlantDimensions /// Get the height and spread of the current material, which may be anywhere within the range for the material in question. // *************** *** 2254,2257 **** --- 2261,2309 ---- // --------------------------------------------------------------------------- + /// GetMaxPlantDimensions + // + /// The maximum height & spread are usually determined by the MaxHeight & MaxSpread columns + /// unless it was pruned, in which case the latest pruning size is used. + // + void MaterialRef::GetMaxPlantDimensions( landscapeHeight_t * height, planLength_t * spread ) + { + pruningType_t pruningType = kPruningNone; + + *height = 0; + *spread = 0; + + if((GetMaterialType() & kMajorMaterialType) == kMaterialTypePlant) + { + if(HasDocument()) + { + InstanceData* inst = LatestInstanceData(kInstancePruningType); + sint32 val; + + if(inst!= NULL) + { + inst->GetInt32(kInstancePruningType, &val); + pruningType = static_cast<pruningType_t>(val); + } + } + + if(pruningType == kPruningNaturalCurrentSize) + { + GetLatestPlantDimensions(height, spread); + } + else + { + sint32 lower, upper; + if(GetMaterial(ifMissingNULL) != NULL) + { + if(_material->GetValueInt32Range(kPlantSpread, lower, upper)) + *spread = upper; + if(_material->GetValueInt32Range(kPlantHeight, lower, upper)) + *height = upper; + } + } + } + } + + // --------------------------------------------------------------------------- /// IsAttributeVisible // *************** *** 4048,4050 **** return test1; ! } \ No newline at end of file --- 4100,4102 ---- return test1; ! } Index: MaterialRef.h =================================================================== RCS file: /cvsroot/igarden/Garden/source/LayoutDB/MaterialRef.h,v retrieving revision 1.43.2.8 retrieving revision 1.43.2.9 diff -C2 -d -r1.43.2.8 -r1.43.2.9 *** MaterialRef.h 26 Mar 2008 22:24:56 -0000 1.43.2.8 --- MaterialRef.h 23 May 2008 12:15:46 -0000 1.43.2.9 *************** *** 152,155 **** --- 152,156 ---- void GetPlantDimensions(landscapeHeight_t * height, planLength_t * spread, short year); void GetLatestPlantDimensions(landscapeHeight_t * height, planLength_t * spread); + void GetMaxPlantDimensions( landscapeHeight_t * height, planLength_t * spread ); materialVisibility_t IsAttributeVisible(attributeID_t attribute, planMonth_t month); InstanceData* GetInstanceAttributes(bool doCreate, UInt32 year); |