private void DataGrid_FedModels_SelectionChanged(object sender, SelectionChangedEventArgs e) { FederatedModelInfo selFedModelsItem = DataGrid_FedModels.SelectedItem as FederatedModelInfo; if (selFedModelsItem == null) { return; // do nothing, no selection made } else { modelInfos.Clear(); // clear the list first DBOperation.currFedModel = selFedModelsItem; modelInfos = _qModel.getModelInfos(DBOperation.currFedModel.FederatedID); DataGrid_ModelInfos.AutoGenerateColumns = true; DataGrid_ModelInfos.IsReadOnly = true; DataGrid_ModelInfos.ItemsSource = modelInfos; Button_RegenGeometry.IsEnabled = true; Button_EnhanceSpB.IsEnabled = true; Button_genGraph.IsEnabled = true; projectUnit projectUnit = DBOperation.getProjectUnitLength(DBOperation.currFedModel.FederatedID); DBOperation.currModelProjectUnitLength = projectUnit; if (projectUnit == projectUnit.SIUnit_Length_MilliMeter) { MathUtils.tol = 0.1; MathUtils._doubleDecimalPrecision = 1; MathUtils._floatDecimalPrecision = 1; } else if (projectUnit == projectUnit.SIUnit_Length_Meter) { MathUtils.tol = 0.0001; MathUtils._doubleDecimalPrecision = 4; MathUtils._floatDecimalPrecision = 4; } else if (projectUnit == projectUnit.Imperial_Length_Foot) { MathUtils.tol = 0.0003; MathUtils._doubleDecimalPrecision = 4; MathUtils._floatDecimalPrecision = 4; } else if (projectUnit == projectUnit.Imperial_Length_Inch) { MathUtils.tol = 0.004; MathUtils._doubleDecimalPrecision = 3; MathUtils._floatDecimalPrecision = 3; } DBOperation.currSelFedID = DBOperation.currFedModel.FederatedID; // set a static variable keeping the currently selected Fed Id DBOperation.OctreeSubdivLevel = DBOperation.currFedModel.OctreeMaxDepth; TextBox_OctreeLevel.Text = DBOperation.currFedModel.OctreeMaxDepth.ToString(); } }
public static projectUnit getProjectUnitLength(int fedID) { projectUnit projectUnit = projectUnit.SIUnit_Length_Meter; string SqlStmt = "Select PROPERTYVALUE from " + DBOperation.formatTabName("BIMRL_PROPERTIES", fedID) + " P, " + DBOperation.formatTabName("BIMRL_ELEMENT", fedID) + " E" + " where P.ELEMENTID=E.ELEMENTID and E.ELEMENTTYPE='IFCPROJECT' AND PROPERTYGROUPNAME='IFCATTRIBUTES' AND PROPERTYNAME='LENGTHUNIT'"; string currStep = SqlStmt; OracleCommand command = new OracleCommand(SqlStmt, DBConn); try { object unitS = command.ExecuteScalar(); if (unitS != null) { string unitString = unitS as string; if (string.Compare(unitString, "MILLI METRE", true) == 0) { projectUnit = projectUnit.SIUnit_Length_MilliMeter; } else if (string.Compare(unitString, "INCH", true) == 0) { projectUnit = projectUnit.Imperial_Length_Inch; } else if (string.Compare(unitString, "FOOT", true) == 0) { projectUnit = projectUnit.Imperial_Length_Foot; } } } catch (OracleException e) { string excStr = "%%Error - " + e.Message + "\n\t" + currStep; refBIMRLCommon.StackPushError(excStr); command.Dispose(); } command.Dispose(); currModelProjectUnitLength = projectUnit; return(projectUnit); }