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

2525 creating individual from MoBi (PK-Sim code changes) #2526

Merged
merged 19 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 9 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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class CLIUserSettings : Notifier, ICoreUserSettings
public int MaximumNumberOfCoresToUse { get; set; }
public PopulationAnalysisType DefaultPopulationAnalysis { get; set; }
public string TemplateDatabasePath { get; set; }
public ParameterGroupingModeId DefaultParameterGroupingMode { get; set; }

public void ResetToDefault()
{
Expand Down
5 changes: 5 additions & 0 deletions src/PKSim.Core/ICoreUserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@ public interface ICoreUserSettings : OSPSuite.Core.ICoreUserSettings
/// Path of the template database containing the template building block
/// </summary>
string TemplateDatabasePath { get; set; }

/// <summary>
/// Default grouping mode for grouping presenter
/// </summary>
ParameterGroupingModeId DefaultParameterGroupingMode { get; set; }
rwmcintosh marked this conversation as resolved.
Show resolved Hide resolved
}
}
5 changes: 0 additions & 5 deletions src/PKSim.Presentation/IUserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ public interface IUserSettings : ICoreUserSettings, IPresentationUserSettings, I
/// </summary>
bool ShouldRestoreWorkspaceLayout { get; set; }

/// <summary>
/// Default grouping mode for grouping presenter
/// </summary>
ParameterGroupingModeId DefaultParameterGroupingMode { get; set; }

/// <summary>
/// Directory map for the current user
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
using OSPSuite.Core.Services;
using OSPSuite.Presentation.Core;
using OSPSuite.Presentation.DTO;
using OSPSuite.Presentation.Presenters;
using PKSim.Core.Commands;
using PKSim.Core.Model;
using PKSim.Presentation.DTO.Core;
using PKSim.Presentation.DTO.Mappers;
using PKSim.Presentation.Views;
using PKSim.Presentation.Views.Individuals;
using OSPSuite.Presentation.Core;
using OSPSuite.Presentation.DTO;
using OSPSuite.Presentation.Presenters;
using System.Collections.Generic;
using PKSim.Presentation.Presenters.Individuals;

namespace PKSim.Presentation.Presenters.Individuals
{
public interface ICreateIndividualPresenter : IWizardPresenter, IIndividualPresenter, ICreateBuildingBlockPresenter<PKSim.Core.Model.Individual>
public interface ICreateIndividualPresenter : IWizardPresenter, IIndividualPresenter, ICreateBuildingBlockPresenter<Individual>
{
void CreateIndividual();
}

public class CreateIndividualPresenter : PKSimWizardPresenter<ICreateIndividualView, ICreateIndividualPresenter, IIndividualItemPresenter>, ICreateIndividualPresenter
{
private ObjectBaseDTO _individualPropertiesDTO;
private readonly IBuildingBlockPropertiesMapper _propertiesMapper;
private readonly IObjectBaseDTOFactory _buildingBlockDTOFactory;

public CreateIndividualPresenter(ICreateIndividualView view, ISubPresenterItemManager<IIndividualItemPresenter> subPresenterItemManager, IDialogCreator dialogCreator,
IBuildingBlockPropertiesMapper propertiesMapper, IObjectBaseDTOFactory buildingBlockDTOFactory)
: base(view, subPresenterItemManager,IndividualItems.All, dialogCreator)
public abstract class AbstractCreateIndividualPresenter :
PKSimWizardPresenter<ICreateIndividualView, ICreateIndividualPresenter, IIndividualItemPresenter>,
ICreateIndividualPresenter
{
protected ObjectBaseDTO _individualPropertiesDTO;
protected readonly IBuildingBlockPropertiesMapper _propertiesMapper;
protected readonly IObjectBaseDTOFactory _buildingBlockDTOFactory;

protected AbstractCreateIndividualPresenter(ICreateIndividualView view, ISubPresenterItemManager<IIndividualItemPresenter> subPresenterItemManager,
IDialogCreator dialogCreator,
IBuildingBlockPropertiesMapper propertiesMapper, IObjectBaseDTOFactory buildingBlockDTOFactory, IReadOnlyList<ISubPresenterItem> subPresenterItems)
: base(view, subPresenterItemManager, subPresenterItems, dialogCreator)
{
_propertiesMapper = propertiesMapper;
_buildingBlockDTOFactory = buildingBlockDTOFactory;
Expand All @@ -32,7 +39,7 @@ public CreateIndividualPresenter(ICreateIndividualView view, ISubPresenterItemMa

public IPKSimCommand Create()
{
_individualPropertiesDTO = _buildingBlockDTOFactory.CreateFor<PKSim.Core.Model.Individual>();
_individualPropertiesDTO = _buildingBlockDTOFactory.CreateFor<Individual>();
_view.BindToProperties(_individualPropertiesDTO);

PresenterAt(IndividualItems.Settings).PrepareForCreating();
Expand All @@ -52,25 +59,16 @@ protected override bool HasData()
return PresenterAt(IndividualItems.Settings).IndividualCreated;
}

public PKSim.Core.Model.Individual BuildingBlock => Individual;
public Individual BuildingBlock => Individual;

private void updateIndividualProperties()
{
_propertiesMapper.MapProperties(_individualPropertiesDTO, Individual);
}

protected override void UpdateControls(int indexThatWillHaveFocus)
{
UpdateViewStatus();
_view.NextEnabled = PresenterAt(IndividualItems.Settings).CanClose && indexThatWillHaveFocus != IndividualItems.Expression.Index;
_view.OkEnabled = CanClose;
_view.SetControlEnabled(IndividualItems.Expression, PresenterAt(IndividualItems.Settings).IndividualCreated);
_view.SetControlEnabled(IndividualItems.Parameters, PresenterAt(IndividualItems.Settings).IndividualCreated);
}

public override bool CanClose => base.CanClose && PresenterAt(IndividualItems.Settings).IndividualCreated;

public void CreateIndividual()
public virtual void CreateIndividual()
{
if (PresenterAt(IndividualItems.Settings).IndividualCreated) return;
//reset commands before generating a new individual
Expand All @@ -92,9 +90,58 @@ public override void WizardNext(int previousIndex)
base.WizardNext(previousIndex);
}

public PKSim.Core.Model.Individual Individual
public Individual Individual
{
get { return PresenterAt(IndividualItems.Settings).Individual; }
}

}
}

public class CreateIndividualPresenter : AbstractCreateIndividualPresenter
{
public CreateIndividualPresenter(ICreateIndividualView view, ISubPresenterItemManager<IIndividualItemPresenter> subPresenterItemManager,
IDialogCreator dialogCreator,
IBuildingBlockPropertiesMapper propertiesMapper, IObjectBaseDTOFactory buildingBlockDTOFactory)
: base(view, subPresenterItemManager, dialogCreator, propertiesMapper, buildingBlockDTOFactory, IndividualItems.All)
{ }

protected override void UpdateControls(int indexThatWillHaveFocus)
{
UpdateViewStatus();
_view.NextEnabled = PresenterAt(IndividualItems.Settings).CanClose && indexThatWillHaveFocus != IndividualItems.Expression.Index;
rwmcintosh marked this conversation as resolved.
Show resolved Hide resolved
_view.OkEnabled = CanClose;
_view.SetControlEnabled(IndividualItems.Expression, PresenterAt(IndividualItems.Settings).IndividualCreated);
_view.SetControlEnabled(IndividualItems.Parameters, PresenterAt(IndividualItems.Settings).IndividualCreated);
}
}
}

//try moving to the Starter namespace
public class CreateIndividualPresenterForMoBi : AbstractCreateIndividualPresenter
rwmcintosh marked this conversation as resolved.
Show resolved Hide resolved
{
public CreateIndividualPresenterForMoBi(ICreateIndividualView view, ISubPresenterItemManager<IIndividualItemPresenter> subPresenterItemManager,
IDialogCreator dialogCreator,
IBuildingBlockPropertiesMapper propertiesMapper, IObjectBaseDTOFactory buildingBlockDTOFactory)
: base(view, subPresenterItemManager, dialogCreator, propertiesMapper, buildingBlockDTOFactory, IndividualItems.AllExceptExpression)
{}

protected override void UpdateControls(int indexThatWillHaveFocus)
{
UpdateViewStatus();
_view.NextEnabled = PresenterAt(IndividualItems.Settings).CanClose;
rwmcintosh marked this conversation as resolved.
Show resolved Hide resolved
_view.OkEnabled = CanClose;
_view.SetControlEnabled(IndividualItems.Parameters, PresenterAt(IndividualItems.Settings).IndividualCreated);
}

public override void CreateIndividual()
{
if (PresenterAt(IndividualItems.Settings).IndividualCreated) return;
//reset commands before generating a new individual
_macroCommand.Clear();
PresenterAt(IndividualItems.Settings).CreateIndividual();
if (Individual == null) return;
PresenterAt(IndividualItems.Parameters).EditIndividual(Individual);
rwmcintosh marked this conversation as resolved.
Show resolved Hide resolved
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public static class IndividualItems
public static readonly IndividualItem<IIndividualMoleculesPresenter> Expression = new IndividualItem<IIndividualMoleculesPresenter>();

public static readonly IReadOnlyList<ISubPresenterItem> All = new List<ISubPresenterItem> {Settings, Parameters, Expression};
public static readonly IReadOnlyList<ISubPresenterItem> AllExceptExpression = new List<ISubPresenterItem> { Settings, Parameters };
}

public static class ScaleIndividualItems
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using OSPSuite.Assets;
using OSPSuite.Core.Commands.Core;
using OSPSuite.Core.Services;
using OSPSuite.Presentation.Nodes;
using PKSim.Core.Model;
using PKSim.Core.Services;
using PKSim.Presentation.Nodes;
using PKSim.Presentation.Presenters.Individuals.Mappers;
using PKSim.Presentation.Presenters.Parameters;
using PKSim.Presentation.Views.Individuals;
using OSPSuite.Presentation.Presenters.ContextMenus;
using OSPSuite.Presentation.Views;
using OSPSuite.Utility.Events;
using PKSim.Presentation.Services;
using ITreeNodeFactory = PKSim.Presentation.Nodes.ITreeNodeFactory;

namespace PKSim.Presentation.Presenters.Individuals
{
Expand All @@ -16,10 +24,12 @@ public interface IIndividualMoleculesPresenter : IMoleculesPresenter, IIndividua

public class IndividualMoleculesPresenter : MoleculesPresenter<Individual>, IIndividualMoleculesPresenter
{
public IndividualMoleculesPresenter(IMoleculesView view, IEditMoleculeTask<Individual> editMoleculeTask, ITreeNodeFactory treeNodeFactory,
public IndividualMoleculesPresenter(IMoleculesView view, IEditMoleculeTask<Individual> editMoleculeTask, ITreeNodeFactory treeNodeFactory,
ITreeNodeContextMenuFactory contextMenuFactory, IDialogCreator dialogCreator, IEntityTask entityTask,
IRootNodeToIndividualExpressionsPresenterMapper<Individual> expressionsPresenterMapper, INoItemInSelectionPresenter noItemInSelectionPresenter)
: base(view, editMoleculeTask, treeNodeFactory, contextMenuFactory, dialogCreator, entityTask, expressionsPresenterMapper, noItemInSelectionPresenter)
IRootNodeToIndividualExpressionsPresenterMapper<Individual> expressionsPresenterMapper,
INoItemInSelectionPresenter noItemInSelectionPresenter)
: base(view, editMoleculeTask, treeNodeFactory, contextMenuFactory, dialogCreator, entityTask, expressionsPresenterMapper,
noItemInSelectionPresenter)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using OSPSuite.Utility.Collections;
using OSPSuite.Utility.Events;
using OSPSuite.Utility.Extensions;
using PKSim.Core;
using PKSim.Core.Model;
using PKSim.Core.Services;
using PKSim.Presentation.Mappers;
Expand Down Expand Up @@ -73,7 +74,7 @@ public class ParameterGroupsPresenter : AbstractCommandCollectorPresenter<IParam
private readonly INodeToCustomizableParametersPresenterMapper _parametersPresenterMapper;
private readonly INoItemInSelectionPresenter _noItemInSelectionPresenter;
private readonly IGroupRepository _groupRepository;
private readonly IUserSettings _userSettings;
private readonly ICoreUserSettings _userSettings;
private readonly IPresentationSettingsTask _presentationSettingsTask;
private readonly ITreeNodeContextMenuFactory _treeNodeContextMenuFactory;
private readonly ICache<ITreeNode, ICustomParametersPresenter> _parameterPresenterCache;
Expand All @@ -93,7 +94,7 @@ public ParameterGroupsPresenter(IParameterGroupsView view, IParameterGroupTask p
IParameterContainerToTreeNodeMapper containerNodeMapper,
INodeToCustomizableParametersPresenterMapper parametersPresenterMapper,
INoItemInSelectionPresenter noItemInSelectionPresenter,
ITreeNodeFactory treeNodeFactory, IGroupRepository groupRepository, IUserSettings userSettings,
ITreeNodeFactory treeNodeFactory, IGroupRepository groupRepository, ICoreUserSettings userSettings,
IPresentationSettingsTask presentationSettingsTask, ITreeNodeContextMenuFactory treeNodeContextMenuFactory)
: base(view)
{
Expand Down
Loading