Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #31 from CBenghi/master
Browse files Browse the repository at this point in the history
Initial implementation of BCFier plugin for XbimXplorer.
  • Loading branch information
teocomi authored Nov 28, 2016
2 parents e6413d5 + 845c4e0 commit 3534a4a
Show file tree
Hide file tree
Showing 19 changed files with 1,001 additions and 2 deletions.
21 changes: 19 additions & 2 deletions BCFier.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bcfier", "Bcfier\Bcfier.csproj", "{503CE2C1-09D7-4F15-BB42-86196EE01ED4}"
EndProject
Expand All @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bcfier.Win", "Bcfier.Win\Bc
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bcfier.Navisworks", "Bcfier.Navisworks\Bcfier.Navisworks.csproj", "{CAF05B60-6A81-489D-B966-7B94F0D69AC7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bcfier.XbimXplorer", "Bcfier.XbimXplorer\Bcfier.XbimXplorer.csproj", "{4CD7CA76-A40E-4DF4-831D-36B64818CC69}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -40,7 +42,6 @@ Global
{503CE2C1-09D7-4F15-BB42-86196EE01ED4}.Release-2017|Any CPU.ActiveCfg = Release|Any CPU
{503CE2C1-09D7-4F15-BB42-86196EE01ED4}.Release-2017|Any CPU.Build.0 = Release|Any CPU
{2D132990-5674-42DF-93BF-55BA8FDC6A23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D132990-5674-42DF-93BF-55BA8FDC6A23}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D132990-5674-42DF-93BF-55BA8FDC6A23}.Debug-2015|Any CPU.ActiveCfg = Debug-2015|Any CPU
{2D132990-5674-42DF-93BF-55BA8FDC6A23}.Debug-2015|Any CPU.Build.0 = Debug-2015|Any CPU
{2D132990-5674-42DF-93BF-55BA8FDC6A23}.Debug-2016|Any CPU.ActiveCfg = Debug-2016|Any CPU
Expand Down Expand Up @@ -87,6 +88,22 @@ Global
{CAF05B60-6A81-489D-B966-7B94F0D69AC7}.Release-2016|Any CPU.Build.0 = Release-2016|Any CPU
{CAF05B60-6A81-489D-B966-7B94F0D69AC7}.Release-2017|Any CPU.ActiveCfg = Release-2017|Any CPU
{CAF05B60-6A81-489D-B966-7B94F0D69AC7}.Release-2017|Any CPU.Build.0 = Release-2017|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Debug-2015|Any CPU.ActiveCfg = Debug|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Debug-2015|Any CPU.Build.0 = Debug|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Debug-2016|Any CPU.ActiveCfg = Debug|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Debug-2016|Any CPU.Build.0 = Debug|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Debug-2017|Any CPU.ActiveCfg = Debug|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Debug-2017|Any CPU.Build.0 = Debug|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Release|Any CPU.Build.0 = Release|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Release-2015|Any CPU.ActiveCfg = Release|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Release-2015|Any CPU.Build.0 = Release|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Release-2016|Any CPU.ActiveCfg = Release|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Release-2016|Any CPU.Build.0 = Release|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Release-2017|Any CPU.ActiveCfg = Release|Any CPU
{4CD7CA76-A40E-4DF4-831D-36B64818CC69}.Release-2017|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
15 changes: 15 additions & 0 deletions Bcfier.XbimXplorer/AddViewXbim.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Window
x:Class="Bcfier.XbimXplorer.AddViewXbim"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctr="clr-namespace:Bcfier.UserControls;assembly=Bcfier"
Title="Add View"
Icon="Assets/icon.ico"
SizeToContent="WidthAndHeight">
<Grid>
<ctr:AddView
x:Name="AddViewControl"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch" />
</Grid>
</Window>
100 changes: 100 additions & 0 deletions Bcfier.XbimXplorer/AddViewXbim.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;
using System.IO;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Bcfier.Bcf.Bcf2;
using log4net;
using Xbim.Presentation;

namespace Bcfier.XbimXplorer
{
/// <summary>
/// Interaction logic for AddViewRevit.xaml
/// </summary>
public partial class AddViewXbim
{
private static readonly ILog Log = LogManager.GetLogger(nameof(AddViewXbim));
private readonly DrawingControl3D _control;

public AddViewXbim(Markup issue, string bcfTempFolder, DrawingControl3D control)
{
try
{
InitializeComponent();
AddViewControl.Issue = issue;
AddViewControl.TempFolder = bcfTempFolder;
_control = control;

AddViewControl.TextBlockInfo.Text =
"3D/2D information of the current view will be included in the viewpoint";

GetRevitSnapshot();
}
catch (Exception ex)
{
MessageBox.Show("Error!", "exception: " + ex);
}
}

private static RenderTargetBitmap Get3DVisual(FrameworkElement element)
{
var width = element.ActualWidth;

var height = element.ActualHeight;
var bmpCopied = new RenderTargetBitmap((int) Math.Round(width), (int) Math.Round(height), 96, 96,
PixelFormats.Default);
var dv = new DrawingVisual();
using (var dc = dv.RenderOpen())
{
var vb = new VisualBrush(element);
dc.DrawRectangle(vb, null, new Rect(new System.Windows.Point(), new Size(width, height)));
}
bmpCopied.Render(dv);
return bmpCopied;
}

private bool SaveControlPng(FrameworkElement control, string outFile)
{
try
{
var renderTargetBitmap = Get3DVisual(control);

var bitmapEncoder = new PngBitmapEncoder();
bitmapEncoder.Frames.Add(BitmapFrame.Create(renderTargetBitmap));

using (var stream = File.Create(outFile))
{
bitmapEncoder.Save(stream);
stream.Seek(0, SeekOrigin.Begin);
}
}
catch (Exception ex)
{
Log.Error("Counld not create screenshot from model.", ex);
return false;
}
return true;
}

private void GetRevitSnapshot()
{
try
{
var tempImg = Path.Combine(Path.GetTempPath(), "BCFier", Path.GetTempFileName() + ".png");

var success = SaveControlPng(_control, tempImg);
if (!success)
{
return;
}
AddViewControl.AddViewpoint(tempImg);
File.Delete(tempImg);
}
catch (Exception ex)
{
MessageBox.Show("Error!", "exception: " + ex);
}
}
}
}
6 changes: 6 additions & 0 deletions Bcfier.XbimXplorer/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
8 changes: 8 additions & 0 deletions Bcfier.XbimXplorer/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Application x:Class="Bcfier.XbimXplorer.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
9 changes: 9 additions & 0 deletions Bcfier.XbimXplorer/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Bcfier.XbimXplorer
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App
{
}
}
Binary file added Bcfier.XbimXplorer/Assets/icon.ico
Binary file not shown.
Loading

0 comments on commit 3534a4a

Please sign in to comment.