Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Result_Engine, Graphics_Engine: Add DisplayMeshResults, MapResults, and methods for GradientOptions #2355

Merged
merged 59 commits into from
Jun 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
dca0dea
Add Query.MapResults
IsakLarbornBH Feb 2, 2021
7d3edfb
Add remaining using statement
IsakLarbornBH Feb 2, 2021
7edaf41
Add Query.DisplayMeshResults()
IsakLarbornBH Feb 2, 2021
ef81862
Correct DisplayMeshResults namespace
IsakLarbornBH Feb 2, 2021
80fd5f3
Add Query.DisplayForce()
IsakLarbornBH Feb 2, 2021
530c236
Temporarily swap out MapResultsBy Enum with string
IsakLarbornBH Feb 2, 2021
7ddda85
Update other methods to temporarily use MapResultsBy string
IsakLarbornBH Feb 2, 2021
480d80e
Temporarily substitute gradientOptions
IsakLarbornBH Feb 2, 2021
9d6eb8e
Update references
IsakLarbornBH Feb 2, 2021
bc6551d
Temporarily substitute MeshResultDisplay
IsakLarbornBH Feb 3, 2021
80fdfc4
Temporarily substitute DisplayForceSettings
IsakLarbornBH Feb 3, 2021
ae40ffc
Fixed temporary default gradient
IsakLarbornBH Feb 3, 2021
5c52b1c
Adjust temporary bar force gradient range
IsakLarbornBH Feb 3, 2021
622da18
Adjust temporary DisplayForce scale factor
IsakLarbornBH Feb 3, 2021
8af9e26
Better default substitute gradient
IsakLarbornBH Feb 4, 2021
759ac35
Better temporary default range
IsakLarbornBH Feb 4, 2021
f41c6fe
Changed Auto Adapter ID warning to event
IsakLarbornBH Feb 10, 2021
823dd6b
Changed again to note
IsakLarbornBH Feb 12, 2021
14a4d2f
Fixed comment typos
IsakLarbornBH Feb 12, 2021
944ee62
Simplify and generalise ResultToValue
IsakLarbornBH Feb 15, 2021
1875f30
Change cast to convert
IsakLarbornBH Feb 16, 2021
71abd88
Make MapResultsBy simpler and more general
IsakLarbornBH Feb 16, 2021
b1126f9
Make MapResults use generics for objects
IsakLarbornBH Feb 16, 2021
a9a2f29
Make private DisplayMeshResults method use IMesh
IsakLarbornBH Feb 16, 2021
2e8cbbf
Make private DisplayMeshResult method use IMeshElementResult
IsakLarbornBH Feb 16, 2021
2e83fb4
Update MapResults.cs
IsakLarbornBH Feb 16, 2021
b13491c
Fully switch to IMesh, though with temporary workaround
IsakLarbornBH Feb 17, 2021
6e1b6f6
Update MapResults.cs
IsakLarbornBH Feb 19, 2021
684db22
Update descriptions
IsakLarbornBH Feb 19, 2021
29561be
Delete DisplayForce.cs
IsakLarbornBH Feb 19, 2021
a950df7
Reintroduce GradientOptions
IsakLarbornBH Feb 19, 2021
7fec54b
Update Results_Engine.csproj
IsakLarbornBH Feb 19, 2021
79d7b1a
Cleanup
IsakLarbornBH Feb 19, 2021
b08500e
Add gradientOptions output
IsakLarbornBH Feb 19, 2021
c079855
Add descriptions to workaround method
IsakLarbornBH Feb 19, 2021
d4976b3
Remove structures-specific SXX default
IsakLarbornBH Feb 19, 2021
ebd8cd5
Update DisplayMeshResults.cs
IsakLarbornBH Feb 19, 2021
4fc00ea
Add PreviousVersion attributes
IsakLarbornBH Feb 22, 2021
27068bc
Remove Workaround method
IsakLarbornBH Mar 9, 2021
360127e
Add unit test
IsakLarbornBH Mar 9, 2021
950705b
Update versioning to 4.2
IsakLarbornBH Mar 31, 2021
bc905dd
Add Modify.CenterGradientAsymmetric
IsakLarbornBH Feb 19, 2021
6f93869
Add ApplyGradientOptions method.
IsakLarbornBH Feb 19, 2021
58c03f0
Update Graphics_Engine.csproj
IsakLarbornBH Feb 19, 2021
e2745da
Update Graphics_Engine.csproj
IsakLarbornBH Feb 19, 2021
1ebeca3
Add PreviousVersion attributes
IsakLarbornBH Feb 22, 2021
64114b1
Update versioning to 4.2
IsakLarbornBH Mar 31, 2021
07f9901
Corrected references
IsakLarbornBH Apr 8, 2021
6878aae
Change switch statement to avoid AppVeyor build error
IsakLarbornBH Apr 8, 2021
cc2a65c
Dummy commit to re-trigger checks
IsakLarbornBH Apr 8, 2021
d02adb2
Align with renamed GradientOptions bounds
IsakLarbornBH Apr 9, 2021
3e0142d
Rename method inputs to align with property name change
IsakLarbornBH Apr 12, 2021
50e03be
Dummy commit to re-trigger checks
IsakLarbornBH Apr 12, 2021
091525f
Remove unused references and using statements
IsakLarbornBH Apr 26, 2021
4e2c674
Remove commented out optimisation attempts
IsakLarbornBH May 10, 2021
060dc0d
Update CSProject compliance
BHoMBot May 21, 2021
4a88e59
Add null handling to GradientOptions methods
IsakLarbornBH May 24, 2021
0a58ef3
Add null handling to DisplayMeshResults and MapResults
IsakLarbornBH May 26, 2021
e33ffd1
Add missing copyright statement
IsakLarbornBH May 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci/Datasets/Result_Engine/Query/DisplayMeshResults.json

Large diffs are not rendered by default.

243 changes: 122 additions & 121 deletions Graphics_Engine/Graphics_Engine.csproj
Original file line number Diff line number Diff line change
@@ -1,123 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D5C7704D-F59A-4FC6-8D1E-356699A174E0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BH.Engine.Graphics</RootNamespace>
<AssemblyName>Graphics_Engine</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Build\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Build\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BHoM">
<HintPath>C:\ProgramData\BHoM\Assemblies\BHoM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Data_oM, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" />
<Reference Include="Dimensional_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Dimensional_oM.dll</HintPath>
</Reference>
<Reference Include="Geometry_oM">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\ProgramData\BHoM\Assemblies\Geometry_oM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Graphics_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Graphics_oM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Reflection_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Reflection_oM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Convert\ToRenderMesh.cs" />
<Compile Include="Create\Marker.cs" />
<Compile Include="Modify\RepresentationFragment.cs" />
<Compile Include="Modify\RepresentationFragments\Links.cs" />
<Compile Include="Modify\RepresentationFragments\Boxes.cs" />
<Compile Include="Create\Gradient.cs" />
<Compile Include="Create\Scales\IScale.cs" />
<Compile Include="Create\SVGStyle.cs" />
<Compile Include="Create\SVGObject.cs" />
<Compile Include="Create\SVGDocument.cs" />
<Compile Include="Convert\ColourFromObject.cs" />
<Compile Include="Modify\Transform.cs" />
<Compile Include="Modify\View\View.cs" />
<Compile Include="Query\Color.cs" />
<Compile Include="Query\Bounds.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Convert\ToSVGString.cs" />
<Compile Include="Convert\GetDataList.cs" />
<Compile Include="Query\IsNumericType.cs" />
<Compile Include="Query\Scales\Scale.cs" />
<Compile Include="Modify\View\DependencyChart.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BHoM_Engine\BHoM_Engine.csproj">
<Project>{1AD45C88-DD54-48E5-951F-55EDFEB70E35}</Project>
<Name>BHoM_Engine</Name>
</ProjectReference>
<ProjectReference Include="..\Data_Engine\Data_Engine.csproj">
<Project>{8082ca2a-ac5c-4690-9f09-960e0d3e4102}</Project>
<Name>Data_Engine</Name>
</ProjectReference>
<ProjectReference Include="..\Geometry_Engine\Geometry_Engine.csproj">
<Project>{89ab2dcb-ef87-4cba-b59c-c16a8a71d333}</Project>
<Name>Geometry_Engine</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\Reflection_Engine\Reflection_Engine.csproj">
<Project>{b0154405-9390-472d-9b5c-a2280823b18d}</Project>
<Name>Reflection_Engine</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTarget="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D5C7704D-F59A-4FC6-8D1E-356699A174E0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BH.Engine.Graphics</RootNamespace>
<AssemblyName>Graphics_Engine</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Build\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Build\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BHoM">
<HintPath>C:\ProgramData\BHoM\Assemblies\BHoM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Data_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Data_oM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Dimensional_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Dimensional_oM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Geometry_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Geometry_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Graphics_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Graphics_oM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Reflection_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Reflection_oM.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Convert\ToRenderMesh.cs" />
<Compile Include="Create\Marker.cs" />
<Compile Include="Modify\ApplyGradientOptions.cs" />
<Compile Include="Modify\CenterGradientAsymmetric.cs" />
<Compile Include="Modify\RepresentationFragment.cs" />
<Compile Include="Modify\RepresentationFragments\Links.cs" />
<Compile Include="Modify\RepresentationFragments\Boxes.cs" />
<Compile Include="Create\Gradient.cs" />
<Compile Include="Create\Scales\IScale.cs" />
<Compile Include="Create\SVGStyle.cs" />
<Compile Include="Create\SVGObject.cs" />
<Compile Include="Create\SVGDocument.cs" />
<Compile Include="Convert\ColourFromObject.cs" />
<Compile Include="Modify\Transform.cs" />
<Compile Include="Modify\View\View.cs" />
<Compile Include="Query\Color.cs" />
<Compile Include="Query\Bounds.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Convert\ToSVGString.cs" />
<Compile Include="Convert\GetDataList.cs" />
<Compile Include="Query\IsNumericType.cs" />
<Compile Include="Query\Scales\Scale.cs" />
<Compile Include="Modify\View\DependencyChart.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BHoM_Engine\BHoM_Engine.csproj">
<Project>{1AD45C88-DD54-48E5-951F-55EDFEB70E35}</Project>
<Name>BHoM_Engine</Name>
</ProjectReference>
<ProjectReference Include="..\Data_Engine\Data_Engine.csproj">
<Project>{8082ca2a-ac5c-4690-9f09-960e0d3e4102}</Project>
<Name>Data_Engine</Name>
</ProjectReference>
<ProjectReference Include="..\Geometry_Engine\Geometry_Engine.csproj">
<Project>{89ab2dcb-ef87-4cba-b59c-c16a8a71d333}</Project>
<Name>Geometry_Engine</Name>
</ProjectReference>
<ProjectReference Include="..\Library_Engine\Library_Engine.csproj">
<Project>{fb4ed5c8-e7cc-44b3-95eb-95c304d54e5d}</Project>
<Name>Library_Engine</Name>
</ProjectReference>
<ProjectReference Include="..\Reflection_Engine\Reflection_Engine.csproj">
<Project>{b0154405-9390-472d-9b5c-a2280823b18d}</Project>
<Name>Reflection_Engine</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" Condition="" />
<PropertyGroup>
<PostBuildEvent>
xcopy "$(TargetDir)$(TargetFileName)" "C:\ProgramData\BHoM\Assemblies" /Y
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
</PropertyGroup>
</Project>
105 changes: 105 additions & 0 deletions Graphics_Engine/Modify/ApplyGradientOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2021, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.Engine.Base;
using BH.oM.Graphics;
using BH.oM.Graphics.Colours;
using BH.oM.Graphics.Enums;
using BH.oM.Reflection.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace BH.Engine.Graphics
{
public static partial class Modify
{
/***************************************************/
/**** Public Methods ****/
/***************************************************/

[Description("Sets up the properties of a GradientOptions object for usage.")]
[Input("gradientOptions", "GradientOptions object to modify.")]
[Input("allValues", "The values to set gradient auto range from. Optional if range is already set.")]
[Input("defaultGradient", "Sets which gradient to use as default if no gradient is already set. Defaults to BlueToRed.")]
[Output("gradientOptions", "A GradientOptions object which is ready for usage.")]
[PreviousVersion("4.2", "BH.Engine.Graphics.Query.AutoRange(BH.oM.Graphics.GradientOptions, System.Collections.Generic.IEnumerable<System.Double>)")]
[PreviousVersion("4.2", "BH.Engine.Graphics.Query.CenteringOptions(BH.oM.Graphics.GradientOptions)")]
[PreviousVersion("4.2", "BH.Engine.Graphics.Query.DefaultGradient(BH.oM.Graphics.GradientOptions, System.String)")]
public static GradientOptions ApplyGradientOptions(this GradientOptions gradientOptions, IEnumerable<double> allValues = null, string defaultGradient = "BlueToRed")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there really 3 previous versions?

Copy link
Contributor Author

@IsakLarbornBH IsakLarbornBH Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally they were 3 separate methods doing three steps of the process, but they were made in a very particular way and essentially had to be used together in a certain order, so I merged them into one. I doubt anybody was calling them from the UI anyway, so versioning might not be necessary, but if they were it does actually make sense to version them all to this merged one since it's made in such a way as to not override manually set parameters.

Copy link
Contributor

@rolyhudson rolyhudson Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Yes I have seen them in the StructuralEnginnering_Toolkit. Lets see of the versioning check likes that, I've not tried it before. If not the MessageForDeleted in the versioning json file may be an option if they are not that widely used.

{

if (gradientOptions == null)
{
BH.Engine.Reflection.Compute.RecordError("Cannot apply gradientOptions because gradientOptions is null or invalid.");
return null;
}

GradientOptions result = gradientOptions.ShallowClone();

// Checks if bounds exist or can be automatically set
if ((double.IsNaN(result.UpperBound) || double.IsNaN(result.LowerBound)) && (allValues == null || allValues.Count() < 1))
{
BH.Engine.Reflection.Compute.RecordError("No bounds have been manually set for Gradient, and no values are provided by which to set them.");
return result;
}

// Optional auto-domain
if (double.IsNaN(result.LowerBound))
result.LowerBound = allValues.Min();
if (double.IsNaN(result.UpperBound))
result.UpperBound = allValues.Max();

// Sets a default gradient if none is already set
if (result.Gradient == null)
{
result.Gradient = Library.Query.Match("Gradients", defaultGradient) as Gradient;
if (result.Gradient == null)
{
Engine.Reflection.Compute.RecordError("Could not find gradient " + defaultGradient + " in the Library, make sure you have BHoM Datasets or create a custom gradient");
return null;
}
}

// Centering Options
switch (result.GradientCenteringOptions)
{
case GradientCenteringOptions.Symmetric:
result.UpperBound = Math.Max(Math.Abs(result.UpperBound), Math.Abs(result.LowerBound));
result.LowerBound = -result.UpperBound;
break;
case GradientCenteringOptions.Asymmetric:
result.Gradient = result.Gradient.CenterGradientAsymmetric(result.LowerBound, result.UpperBound);
break;
case GradientCenteringOptions.None:
default:
break;
}

return result;
}

/***************************************************/

}
}
Loading