Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 27 additions & 22 deletions src/RevitDeclarations/Models/UtpCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Autodesk.Revit.DB;

using dosymep.SimpleServices;
using dosymep.WPF.Extensions;
using dosymep.Revit;

using RevitDeclarations.ViewModels;
Expand All @@ -28,10 +27,10 @@ internal class UtpCalculator {
private readonly bool _hasBannedNames;
private readonly IEnumerable<ElementId> _roomsWithBathFamily;

private const string _utpYes = "Да";
private const string _utpNo = "Нет";
private const string _utpNamesError = "Ошибка имен помещений";
private const string _utpNullAreasError = "Ошибка нулевых площадей";
private readonly string _utpYes;
private readonly string _utpNo;
private readonly string _utpNamesError;
private readonly string _utpNullAreasError;

public UtpCalculator(ApartmentsProject project, DeclarationSettings settings, ILocalizationService localizationService) {
_project = project;
Expand All @@ -45,25 +44,30 @@ public UtpCalculator(ApartmentsProject project, DeclarationSettings settings, IL
_priorities = _settings.PrioritiesConfig;

_roomConnectionAnalyzer = new RoomConnectionAnalyzer(project, _priorities);

_utpYes = localizationService.GetLocalizedString("UtpCalculator.ValueYes");
_utpNo = localizationService.GetLocalizedString("UtpCalculator.ValueNo");
_utpNamesError = localizationService.GetLocalizedString("UtpCalculator.ErrorRoomNames");
_utpNullAreasError = localizationService.GetLocalizedString("UtpCalculator.ErrorNullAreas");
}

public void CalculateRoomsForUtp() {
_roomConnectionAnalyzer.FindConnections();
}

public IReadOnlyCollection<WarningViewModel> CheckProjectForUtp() {
var areaErrorListVM = new WarningViewModel(_localizationService) {
var areaErrorListVm = new WarningViewModel(_localizationService) {
WarningType = _localizationService.GetLocalizedString("WarningWindow.Warning"),
Description = _localizationService.GetLocalizedString("WarningWindow.NullAreas"),
DocumentName = _project.Document.Name
};

if(_hasNullAreas) {
areaErrorListVM.Elements.Add(new WarningElementViewModel(_project.Document.Name,
areaErrorListVm.Elements.Add(new WarningElementViewModel(_project.Document.Name,
_localizationService.GetLocalizedString("WarningWindow.NullAreasInfo")));
}

var namesErrorListVM = new WarningViewModel(_localizationService) {
var namesErrorListVm = new WarningViewModel(_localizationService) {
WarningType = _localizationService.GetLocalizedString("WarningWindow.Warning"),
Description = _localizationService.GetLocalizedString("WarningsWindow.RoomNameErrors"),
DocumentName = _project.Document.Name
Expand All @@ -72,22 +76,22 @@ public IReadOnlyCollection<WarningViewModel> CheckProjectForUtp() {
if(_hasBannedNames) {
string names = string.Join(",", GetBannedUtpRoomNames());

namesErrorListVM.Elements.Add(new WarningElementViewModel(_project.Document.Name,
namesErrorListVm.Elements.Add(new WarningElementViewModel(_project.Document.Name,
_localizationService.GetLocalizedString("WarningsWindow.RoomNameErrorsInfo", names)));
}

var bathesErrorListVM = new WarningViewModel(_localizationService) {
var bathesErrorListVm = new WarningViewModel(_localizationService) {
WarningType = _localizationService.GetLocalizedString("WarningWindow.Warning"),
Description = _localizationService.GetLocalizedString("WarningsWindow.BathErrors"),
DocumentName = _project.Document.Name
};

if(_project.GetBathInstances().Count == 0) {
bathesErrorListVM.Elements.Add(new WarningElementViewModel(_project.Document.Name,
bathesErrorListVm.Elements.Add(new WarningElementViewModel(_project.Document.Name,
_localizationService.GetLocalizedString("WarningsWindow.BathErrorsInfo")));
}

return [areaErrorListVM, namesErrorListVM, bathesErrorListVM];
return [areaErrorListVm, namesErrorListVm, bathesErrorListVm];
}

// УТП Хайфлет.
Expand All @@ -104,7 +108,7 @@ public string CalculateHighflat(Apartment apartment) {

// УТП Две ванны.
// В квартире две и более ванны (или душевые) в разных помещениях санузлов.
// Помещения санузлов, которые относятся к мастер-спальням не учитываются.
// Помещения санузлов, которые относятся к мастер-спальням, не учитываются.
public string CalculateTwoBathes(Apartment apartment) {
if(_hasBannedNames) {
return _utpNamesError;
Expand Down Expand Up @@ -179,16 +183,15 @@ .. apartment.GetRoomsByPrior(_priorities.Loggia),
var summerRevitRooms = summerRooms.Select(x => x.RevitRoom).ToList();

return summerRooms.Any()
? ContourChecker
.CheckAnyRoomSizes(summerRevitRooms, _settings.AccuracyForArea, 0, _minBalconyDepth)
.GetDescription()
? GetLocalizedDescription(ContourChecker
.CheckAnyRoomSizes(summerRevitRooms, _settings.AccuracyForArea, 0, _minBalconyDepth))
: _utpNo;
}

// УТП Гардеробная.
// Наличие в квартире минимум одного помещения с именем "Гардеробная".
// Одна сторона помещения должна быть не менее 1000 мм, площадь от 1,8 м2.
// Помещения, которые связаны дверью с жилой комнатой не учитываются.
// Помещения, которые связаны дверью с жилой комнатой, не учитываются.
public string CalculatePantry(Apartment apartment) {
if(_hasNullAreas) {
return _utpNullAreasError;
Expand All @@ -205,9 +208,8 @@ public string CalculatePantry(Apartment apartment) {
.ToList();

return pantriesWithoutBedrooms.Any()
? ContourChecker
.CheckAnyRoomSizes(pantriesWithoutBedrooms, _settings.AccuracyForArea, _minPantryDepth)
.GetDescription()
? GetLocalizedDescription(ContourChecker
.CheckAnyRoomSizes(pantriesWithoutBedrooms, _settings.AccuracyForArea, _minPantryDepth))
: _utpNo;
}

Expand Down Expand Up @@ -250,12 +252,15 @@ .. apartment.GetRoomsByPrior(_priorities.Loggia),

return hasBalconyWithoutGlazing ? _utpYes : _utpNo;
}

private string GetLocalizedDescription(ContourCheckEnum contourCheckEnum) {
return _localizationService.GetLocalizedString($"UtpCalculator.ContourCheckEnum.{contourCheckEnum}");
}

private bool CheckUtpNullAreas() {
return _project
.Rooms
.Where(x => x.AreaRevit < 0.1)
.Any();
.Any(x => x.AreaRevit < 0.1);
}

private IEnumerable<string> GetBannedUtpRoomNames() {
Expand Down
11 changes: 11 additions & 0 deletions src/RevitDeclarations/assets/localization/Language.en-US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,15 @@
</system:String>
<system:String x:Key="ToolTip.RoomAreaParamToolTip"> Numeric parameter whose value is output to the column with the room area without coefficient.</system:String>
<system:String x:Key="ToolTip.RoomAreaCoefParamToolTip">Numeric parameter whose value is output to the column with the room area with coefficient.</system:String>

<system:String x:Key="UtpCalculator.ValueYes">Yes</system:String>
<system:String x:Key="UtpCalculator.ValueNo">No</system:String>
<system:String x:Key="UtpCalculator.ErrorRoomNames">Room name error</system:String>
<system:String x:Key="UtpCalculator.ErrorNullAreas">Zero-area error</system:String>

<system:String x:Key="UtpCalculator.ContourCheckEnum.Error">Contour error</system:String>
<system:String x:Key="UtpCalculator.ContourCheckEnum.YesCheck">Yes (verify)</system:String>
<system:String x:Key="UtpCalculator.ContourCheckEnum.Yes">Yes</system:String>
<system:String x:Key="UtpCalculator.ContourCheckEnum.NoCheck">No (verify)</system:String>
<system:String x:Key="UtpCalculator.ContourCheckEnum.No">No</system:String>
</ResourceDictionary>
11 changes: 11 additions & 0 deletions src/RevitDeclarations/assets/localization/Language.ru-RU.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,15 @@
</system:String>
<system:String x:Key="ToolTip.RoomAreaParamToolTip">Числовой параметр, значение которого выводится в столбец с площадью помещения без коэффициента.</system:String>
<system:String x:Key="ToolTip.RoomAreaCoefParamToolTip">Числовой параметр, значение которого выводится в столбец с площадью помещения с коэффициентом.</system:String>

<system:String x:Key="UtpCalculator.ValueYes">Да</system:String>
<system:String x:Key="UtpCalculator.ValueNo">Нет</system:String>
<system:String x:Key="UtpCalculator.ErrorRoomNames">Ошибка имен помещений</system:String>
<system:String x:Key="UtpCalculator.ErrorNullAreas">Ошибка нулевых площадей</system:String>

<system:String x:Key="UtpCalculator.ContourCheckEnum.Error">Ошибка контура</system:String>
<system:String x:Key="UtpCalculator.ContourCheckEnum.YesCheck">Да (проверить)</system:String>
<system:String x:Key="UtpCalculator.ContourCheckEnum.Yes">Да</system:String>
<system:String x:Key="UtpCalculator.ContourCheckEnum.NoCheck">Нет (проверить)</system:String>
<system:String x:Key="UtpCalculator.ContourCheckEnum.No">Нет</system:String>
</ResourceDictionary>
Loading