ConfiguracionSimplificada
Elena 2021-07-30 15:46:23 +02:00
parent 734a79cf63
commit 55d87b0edf
13 changed files with 519 additions and 169 deletions

View File

@ -22,10 +22,11 @@ namespace OliviaAddInPro.Helper
public static string OutStr {
get
{
string val = "";
/*string val = "";
val.CopyFrom(out_str);
out_str = string.Empty; //lo borra cada vez que se consulta
return val;
return val;*/
return out_str;
}
set { out_str = value; }
}
@ -33,10 +34,12 @@ namespace OliviaAddInPro.Helper
public static string TextoSal
{
get {
string val = "";
/*string val = "";
val.CopyFrom(texto_sal);
texto_sal = string.Empty; //lo borra cada vez que se consulta
return val; }
return val; */
return texto_sal;
}
set { texto_sal = value; }
}
@ -333,6 +336,26 @@ namespace OliviaAddInPro.Helper
return attribs_st;
}));
}
/**
* Devuelve una geometría que es la suma de la inicial y la que se añade Add
*/
public static ArcGIS.Core.Geometry.Geometry IntersectGeom(ArcGIS.Core.Geometry.Geometry geomIni, ArcGIS.Core.Geometry.Geometry geomInters)
{
if (geomIni == null)
return geomInters;
if (geomInters == null)
return geomIni;
ArcGIS.Core.Geometry.Geometry geomSal = null;
try
{
geomSal=GeometryEngine.Instance.Intersection(geomIni, geomInters);
return geomSal;
}
catch
{
return null;
}
}
/**
* Devuelve una geometría que es la suma de la inicial y la que se añade Add
@ -341,7 +364,18 @@ namespace OliviaAddInPro.Helper
{
if (geomIni == null)
return geomUne;
return GeometryEngine.Instance.Union(geomIni, geomUne);
if (geomUne == null)
return geomIni;
ArcGIS.Core.Geometry.Geometry geomSal = null;
try
{
geomSal = GeometryEngine.Instance.Union(geomIni, geomUne);
return geomSal;
}
catch
{
return null;
}
}
/**
@ -349,7 +383,20 @@ namespace OliviaAddInPro.Helper
*/
public static ArcGIS.Core.Geometry.Geometry QuitaGeom(ArcGIS.Core.Geometry.Geometry geomIni, ArcGIS.Core.Geometry.Geometry geomQuita)
{
return GeometryEngine.Instance.Union(geomIni, geomQuita);
if (geomIni == null)
return geomQuita;
if (geomQuita == null)
return geomIni;
ArcGIS.Core.Geometry.Geometry geomSal = null;
try
{
geomSal = GeometryEngine.Instance.Difference(geomIni, geomQuita);
return geomSal;
}
catch
{
return null;
}
}
/**
@ -361,7 +408,18 @@ namespace OliviaAddInPro.Helper
ArcGIS.Core.Geometry.Geometry geomIni = null;
geomIni = GetGeomUnica(fclss, filter);
if (geomIni != null)
return GeometryEngine.Instance.ConvexHull(geomIni);
{
ArcGIS.Core.Geometry.Geometry geomSal = null;
try
{
geomSal = GeometryEngine.Instance.ConvexHull(geomIni);
return geomSal;
}
catch
{
return null;
}
}
else
return null;
}

View File

@ -8,7 +8,7 @@ using ArcGIS.Desktop.Internal.Layouts.Utilities;
namespace OliviaAddInPro.Model
{
class Comun
public abstract class Comun
{
/**
* Capa de ámbitos
@ -81,10 +81,12 @@ namespace OliviaAddInPro.Model
public string ErrStr
{
get {
string val = string.Empty;
/*string val = string.Empty;
val.CopyFrom(err_str);
err_str = string.Empty;
return val; }
return val; */
return err_str;
}
set { err_str = value;}
}
}

31
Model/ILimpieza.cs Normal file
View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OliviaAddInPro.Model
{
public interface ILimpieza
{
//**********************************************
//Se recogen en PaneLimpiezaSub1
/**
* Tipo de tratamiento elegidos
*/
int TipoTto { get; }
/**
* Ámbitos de trabajo elegidos
*/
bool[] AmbitosSel { get; }
/**
* Indica si respeta el sentido de circulación o no
*/
bool RespCirc { get; }
/**
* Tipo de unidades del tiempo de tto
*/
int UdsTTto { get; }
}
}

View File

@ -8,10 +8,11 @@ using OliviaAddInPro.Helper;
using System.Collections.ObjectModel;
using ArcGIS.Core.CIM;
using ArcGIS.Core.Data;
using OliviaAddInPro.Services;
namespace OliviaAddInPro.Model
{
class Limpieza : Comun
public class Limpieza : Comun
{
//**********************************************
//Se recogen en PaneLimpiezaSub1
@ -31,98 +32,18 @@ namespace OliviaAddInPro.Model
* Tipo de unidades del tiempo de tto
*/
public int UdsTTto = (int)GeneralDef.OlvTiposTto.OlvTipTtoNoDef;
/**
* Instancia para las funciones de exportación y demás
*/
public LimpiezaServ Serv = null;
/**
* Almacena la consulta para exportar los ámbitos
*/
public string ConsultaAmbs = "";
public Limpieza()
{
}
/**
* Lee la gdb y devuelve el array de ámbitos en función de si hay en la gdb o no
*/
public bool[] BuscAmbGdb()
{
string consulta;
int numero_lin;
bool[] amb_gdb = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];//se inician a false
string ftclass;
//mira a ver si hay ejes de calle
ftclass = LimpiezaDef.ftclass[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle];
consulta = LimpiezaDef.filtro_str[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle];
numero_lin = HelperGdb.GetNumElems(OliviaGlob.Paths.PathGdbNw, ftclass, consulta);
if (numero_lin > 0)
{
amb_gdb[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle] = true;
}
//mira a ver si hay el resto de capas y tienen entidades
for (int i = (int)LimpiezaDef.AmbitsTra.AmbBordLibreMec; i < (int)LimpiezaDef.AmbitsTra.AmbN; i++)
{
consulta = LimpiezaDef.filtro_str[i];
numero_lin = HelperGdb.GetNumElems(CapaElems, consulta);
if (numero_lin > 0)
{
amb_gdb[i] = true;
}
Serv = new LimpiezaServ(this);
}
return amb_gdb;
}
/**Devuelve el array de los ámbitos comunes y no comunes de las opciones de un tratamiento tto
* Es un array de longitud el número de ámbitos totales, con true en las posiciones en los que el ámbito sea común o
* no común en las opciones
*/
public bool[] DameAmbTto(int tto)
{
int i;
bool sig;
bool[] amb_com = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];
for (int j = 0; j < (int)LimpiezaDef.AmbitsTra.AmbN; j++)
{
sig = false;
for (i = 0; i < LimpiezaDef.ambs_val[tto].n_ops && !sig; i++)
{
if (LimpiezaDef.ambs_val[tto].ambs_ops[i].ambs[j]) //con que encuentre uno true lo pone y pasa al siguiente
{
amb_com[j] = sig = true;
}
}
}
return amb_com;
}
/*
* Lee la capa que se ha seleccionzdo de limpieza y se comprueba que los campos que se han editado corresponden con la capa
* (es decir, se puede leer la capa con los campos configurados)
*/
public bool CompruebaCamposLimp()
{
int NCAMPS = 2;
string[] camps;
int i;
camps = new string[NCAMPS];
camps[0] = LimpiezaDef.Campos.consulta_entidad;
camps[1] = LimpiezaDef.Campos.consulta_mecan;
FeatureClass fc = HelperGdb.GetFtClass(CapaElems);
if (fc == null)
{
ErrStr = "No se puede abrir la capa";
return false;
}
ObservableCollection<string> fields = HelperGdb.GetFields(fc).Result;
for (i = 0; i < NCAMPS; i++)
{
if (!fields.Contains(camps[i]))
{
ErrStr = "No se encuentra el campo " + camps[i];
break;
}
}
if (i < NCAMPS)
return false;
return true;
}
}
}

View File

@ -134,9 +134,11 @@
<Compile Include="Helper\HelperGdb.cs" />
<Compile Include="Helper\HelperGlobal.cs" />
<Compile Include="Model\Comun.cs" />
<Compile Include="Model\ILimpieza.cs" />
<Compile Include="Model\Limpieza.cs" />
<Compile Include="Model\LimpiezaDef.cs" />
<Compile Include="Model\OliviaDef.cs" />
<Compile Include="Services\LimpiezaServ.cs" />
<Compile Include="ViewModel\OptionsMenuItem.cs" />
<Compile Include="ViewModel\PaneEjecutarViewModel.cs" />
<Compile Include="ViewModel\PaneLimpiezaSub4ViewModel.cs" />

88
Services/LimpiezaServ.cs Normal file
View File

@ -0,0 +1,88 @@
using ArcGIS.Core.Data;
using ArcGIS.Core.Geometry;
using OliviaAddInPro.Helper;
using OliviaAddInPro.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OliviaAddInPro.Services
{
public class LimpiezaServ
{
private Limpieza limp;
public string ErrStr="";
public LimpiezaServ(Limpieza _limp)
{
limp = _limp;
}
/**
* Prepara la geometría para exportar
*/
public Geometry GetGeomAmbitsExport()
{
Geometry geomAux = null;
FeatureClass fc = HelperGdb.GetFtClass(limp.CapaElems);
QueryFilter filtro = new QueryFilter { WhereClause = limp.ConsultaAmbs };
if(fc==null)
{
ErrStr = "No se ha podido abrir la clase " + limp.CapaElems;
return null;
}
//comprueba que haya elementos que cumplen la consulta
int nElem = HelperGdb.GetNumElems(fc, limp.ConsultaAmbs).Result;
if(nElem<=0)
{
ErrStr = "No existen ámbitos que cumplan las condiciones dadas " + limp.ConsultaAmbs;
return null;
}
//Primero hace la geometría de los ámbitos que cumplen la consulta
geomAux = HelperGdb.GetGeomUnica(fc, filtro);
if(geomAux==null || geomAux.IsEmpty)
{
ErrStr = "No se ha podido generar geometría de los ámbitos" + limp.ConsultaAmbs;
return null;
}
//Hace la intersección de dicha geometría con las zonas
if (limp.GeomZon != null)
{
geomAux = HelperGdb.IntersectGeom(geomAux, limp.GeomZon);
if(geomAux==null)
{
ErrStr = "Error al intersecar con las zonas.";
return null;
}
}
//Hace la intersección de la geometría con los niveles
if (limp.GeomNiv != null)
{
geomAux = HelperGdb.IntersectGeom(geomAux, limp.GeomNiv);
if (geomAux == null)
{
ErrStr = "Error al intersecar con los niveles.";
return null;
}
}
//le quita las restricciones
if (limp.GeomRestr != null)
{
geomAux = HelperGdb.QuitaGeom(geomAux, limp.GeomRestr);
if (geomAux == null)
{
ErrStr = "Error al intersecar con las restricciones.";
return null;
}
}
return geomAux;
}
}
}

View File

@ -9,7 +9,7 @@
xmlns:viewModel="clr-namespace:OliviaAddInPro"
xmlns:view="clr-namespace:OliviaAddInPro"
mc:Ignorable="d"
d:DesignHeight="500" d:DesignWidth="300"
d:DesignHeight="390" d:DesignWidth="300"
d:DataContext="{Binding Path=ui.DockpaneLimpiezaViewModel}">
<UserControl.Resources>
<ResourceDictionary>
@ -22,7 +22,7 @@
</ResourceDictionary>
</UserControl.Resources>
<ScrollViewer Height="Auto">
<StackPanel MinWidth="300">
<StackPanel MinWidth="300" MinHeight="200">
<ContentPresenter Content="{Binding CurrentPage}"></ContentPresenter>
</StackPanel>
</ScrollViewer>

View File

@ -7,7 +7,7 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
xmlns:ui="clr-namespace:OliviaAddInPro"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
d:DesignHeight="40" d:DesignWidth="300"
d:DataContext="{Binding Path=ui.PaneLimpiezaSub3ViewModel}">
<UserControl.Resources>
<ResourceDictionary>
@ -19,12 +19,12 @@
<StackPanel Orientation="Vertical">
<Grid Margin="0,10,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Button x:Name="button_secto" Grid.Column="1" Style="{DynamicResource Esri_Button}" Content="Sectorizar" Margin="5,0,5,0"/>
<Button x:Name="button_planif" Grid.Column="2" Style="{DynamicResource Esri_Button}" Content="Planificar" Margin="5,0,5,0"/>
<Button x:Name="button_secto" Grid.Column="1" Style="{DynamicResource Esri_Button}" Content="Sectorizar" Margin="10,0,10,0"/>
<Button x:Name="button_planif" Grid.Column="2" Style="{DynamicResource Esri_Button}" Content="Planificar" Margin="10,0,10,0"/>
</Grid>
</StackPanel>

View File

@ -11,7 +11,7 @@
xmlns:frameworkControls="clr-namespace:ArcGIS.Desktop.Framework.Controls;assembly=ArcGIS.Desktop.Framework"
xmlns:ui="clr-namespace:OliviaAddInPro"
mc:Ignorable="d"
d:DesignHeight="500" d:DesignWidth="300"
d:DesignHeight="400" d:DesignWidth="300"
d:DataContext="{Binding Path=ui.PaneLimpiezaViewModel}">
<UserControl.Resources>
<ResourceDictionary>
@ -45,7 +45,7 @@
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid MinHeight="200" MinWidth="300">
<!--TextBlock Text="Add your custom content here" VerticalAlignment="Center" HorizontalAlignment="Center"></-->
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>

View File

@ -6,7 +6,7 @@
xmlns:extensions="clr-namespace:ArcGIS.Desktop.Extensions;assembly=ArcGIS.Desktop.Extensions"
xmlns:ui="clr-namespace:OliviaAddInPro"
mc:Ignorable="d" d:DesignWidth="300" Height="350"
d:DataContext="{Binding Path=ui.PaneLimpiezaSub1ViewModel}" >
d:DataContext="{Binding Path=ui.PaneLimpiezaSub1ViewModel}" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded" >
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
@ -29,12 +29,15 @@
<Label x:Name="label_capalimp" Content="{Binding Path=LblCapaLimp, Mode = TwoWay}" Grid.Column="1" HorizontalAlignment="Left" Margin="13,0,0,0" VerticalAlignment="Top" Width="221" Height="30" Grid.ColumnSpan="3"/>
</Grid>
<Label Content="Tipo de Tratamiento" HorizontalAlignment="Left" Margin="15,0,0,0" VerticalAlignment="Top" FontWeight="DemiBold"/>
<ComboBox x:Name="comboBox_tto" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" ItemsSource="{Binding Path=TiposTto, Mode = TwoWay}" HorizontalAlignment="Left" Margin="20,0,0,0" VerticalAlignment="Top" Width="260" DropDownOpened="ComboBox_DropDownOpened" SelectionChanged="comboBox_tto_SelectionChanged"/>
<ComboBox x:Name="comboBox_tto" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" ItemsSource="{Binding Path=TiposTto, Mode = TwoWay}" HorizontalAlignment="Left" Margin="20,0,0,0"
VerticalAlignment="Top" Width="260" DropDownOpened="ComboBox_DropDownOpened" SelectionChanged="comboBox_tto_SelectionChanged"
SelectedIndex="{Binding Path=SelTto, Mode = TwoWay}"/>
<Label Content="Ámbitos de Trabajo" HorizontalAlignment="Left" Margin="15,0,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.391,-0.203" FontWeight="DemiBold"/>
<ComboBox x:Name="comboBox_ambitos" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" ItemsSource="{Binding Path=OpsAmbs, Mode = TwoWay}" HorizontalAlignment="Left" Margin="20,0,0,0" VerticalAlignment="Top" Width="260" SelectionChanged="comboBox_ambitos_SelectionChanged"/>
<ComboBox x:Name="comboBox_ambitos" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" ItemsSource="{Binding Path=OpsAmbs, Mode = TwoWay}" HorizontalAlignment="Left" Margin="20,0,0,0"
VerticalAlignment="Top" Width="260" SelectionChanged="comboBox_ambitos_SelectionChanged"
SelectedIndex="{Binding Path=SelOpAmb, Mode = TwoWay}"/>
<ListBox x:Name="listBox_ambitos" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" ItemsSource="{Binding Path=Ambitos, Mode = TwoWay}" HorizontalAlignment="Left" Height="100"
ItemContainerStyle="{DynamicResource Esri_ListBoxItemHighlightBrush}" Margin="20,2,0,0" VerticalAlignment="Top" Width="260">
ItemContainerStyle="{DynamicResource Esri_ListBoxItemHighlightBrush}" Margin="20,10,0,0" VerticalAlignment="Top" Width="260">
<ListBox.ItemTemplate>
<DataTemplate>
<ListBoxItem IsEnabled="{Binding IsEnabled}">
@ -44,7 +47,7 @@
</ListBox.ItemTemplate>
</ListBox>
<CheckBox x:Name="checkBox_sentidocirc" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}"
Content="Respeta el sentido de circulación" IsChecked="{Binding RespSentCirc}" HorizontalAlignment="Left" Margin="20,2,0,0" VerticalAlignment="Top"/>
Content="Respeta el sentido de circulación" IsChecked="{Binding RespSentCirc}" HorizontalAlignment="Left" Margin="20,5,0,0" VerticalAlignment="Top"/>
<Grid Margin="0,5,0,0">
<Grid.ColumnDefinitions>

View File

@ -13,6 +13,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ArcGIS.Desktop.Core;
using ArcGIS.Desktop.Internal.Framework.Controls;
using OliviaAddInPro.Helper;
namespace OliviaAddInPro
@ -22,6 +23,8 @@ namespace OliviaAddInPro
/// </summary>
public partial class PaneLimpiezaSub1View : UserControl
{
private int oldTtoSel=-1;
private int oldAmbOpSel = -1;
public PaneLimpiezaSub1View()
{
InitializeComponent();
@ -61,20 +64,40 @@ namespace OliviaAddInPro
private void comboBox_tto_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int i = -1;
if (sender is ComboBox combo)
if (sender is System.Windows.Controls.ComboBox combo)
{
i = combo.SelectedIndex;
if(DataContext is PaneLimpiezaSub1ViewModel mod)
if (DataContext is PaneLimpiezaSub1ViewModel mod)
{
mod.ComboTtoSel(i);
oldTtoSel = i;
}
}
}
private void comboBox_ambitos_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int i = -1;
if (sender is ComboBox combo)
if (sender is System.Windows.Controls.ComboBox combo)
{
i = combo.SelectedIndex;
if (DataContext is PaneLimpiezaSub1ViewModel mod)
{
mod.ComboAmbSel(i);
oldAmbOpSel = i;
}
}
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
}
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
{
}
}
}

View File

@ -22,18 +22,15 @@ using ArcGIS.Desktop.Internal.Layouts.Utilities;
namespace OliviaAddInPro
{
internal class PaneLimpiezaSub1ViewModel : PanelViewModelBase
internal class PaneLimpiezaSub1ViewModel : PanelViewModelBase, ILimpieza
{
private ObservableCollection<string> tiposTto = new ObservableCollection<string>(LimpiezaDef.tipos_tto_str);
private int selTto = -1;
private ObservableCollection<string> opsAmbs=new ObservableCollection<string>();
private int selOpAmb = -1;
private ObservableCollection<CheckedListItem<string>> ambitos = new ObservableCollection<CheckedListItem<string>>();
private bool[] ambitosSel;
private bool capaAbierta = false;
/**
* Array de variables de tipo AmbitsList para mostrar en la lista, se rellena al elegir el tipo de tratamiento
*/
@ -55,7 +52,10 @@ namespace OliviaAddInPro
*/
bool[] amb_tra_gdb = null;
private Limpieza limp;
//implementan la interfaz Limpieza
private int selTto = -1;
private bool[] ambitosSel;
private string capaElems = "";
#region Properties
@ -109,10 +109,10 @@ namespace OliviaAddInPro
set { base.SetProperty(ref lblTimeTto, value, () => LblTimeTto); }
}
private bool respSentCirc;
public bool RespSentCirc
public bool RespCirc
{
get { return respSentCirc; }
set { base.SetProperty(ref respSentCirc, value, () => RespSentCirc); }
set { base.SetProperty(ref respSentCirc, value, () => RespCirc); }
}
public ObservableCollection<string> TiposTto
@ -124,13 +124,13 @@ namespace OliviaAddInPro
base.NotifyPropertyChanged("TiposTto");
}
}
public int SelTto
public int TipoTto
{
get { return selTto; }
set
{
selTto = value;
base.NotifyPropertyChanged("SelTto");
base.NotifyPropertyChanged("TipoTto");
}
}
public ObservableCollection<string> OpsAmbs
@ -160,6 +160,15 @@ namespace OliviaAddInPro
base.NotifyPropertyChanged("OpsAmbs");
}
}
public bool[] AmbitosSel
{
get { return ambitosSel; }
set
{
ambitosSel = value;
base.NotifyPropertyChanged("AmbitosSel");
}
}
public bool CapaAbierta
{
get { return capaAbierta; }
@ -169,11 +178,19 @@ namespace OliviaAddInPro
base.NotifyPropertyChanged("CapaAbierta");
}
}
public string CapaElems
{
get { return capaElems; }
set
{
capaElems = value;
base.NotifyPropertyChanged("CapaElems");
}
}
#endregion Properties
public PaneLimpiezaSub1ViewModel(Limpieza _limp)
public PaneLimpiezaSub1ViewModel()
{
limp = _limp;
lblCapaLimp = Resource1.String_selec_capa;
timeTto = 10;
textVeloDespl = "10";
@ -186,17 +203,17 @@ namespace OliviaAddInPro
*/
public void AbiertaCapa(string capa)
{
limp.CapaElems = capa;
capaElems = capa;
CapaAbierta = false;
//comprueba los campos de limpieza
if (!limp.CompruebaCamposLimp())
string ss = "";
if (!CompruebaCamposLimp(capa, out ss))
{
string ss = limp.ErrStr;
HelperGlobal.ponMsg(ss, System.Windows.MessageBoxImage.Warning);
return;
}
amb_tra_gdb = limp.BuscAmbGdb();
amb_tra_gdb = BuscAmbGdb(capa);
bool hay_alguno = false;
foreach (bool b in amb_tra_gdb)
{
@ -225,18 +242,18 @@ namespace OliviaAddInPro
{
if (tto < 0)
return;
SelTto = tto;
TipoTto = tto;
cambia_tiempo_tto();
ambitosSel = new bool[(int)LimpiezaDef.AmbitsTra.AmbN]; //reinicia los ambitos seleccionados
////////////////////////////////////////
//Otros cambios que dependen del tratamiento
if (SelTto != (int)LimpiezaDef.TiposTto.TtoNoDef)
if (TipoTto != (int)LimpiezaDef.TiposTto.TtoNoDef)
{
RespSentCirc = LimpiezaDef.rest_circ[SelTto];
RespCirc = LimpiezaDef.rest_circ[TipoTto];
if (LimpiezaDef.v_desplazamiento[SelTto] > 0)
TextVeloDespl = Convert.ToString(LimpiezaDef.v_desplazamiento[SelTto]);
if (LimpiezaDef.v_desplazamiento[TipoTto] > 0)
TextVeloDespl = Convert.ToString(LimpiezaDef.v_desplazamiento[TipoTto]);
else
TextVeloDespl = Resource1.String_velo_nodef;
}
@ -249,9 +266,9 @@ namespace OliviaAddInPro
OpsAmbs.Add("Genérico");
//en el caso del tratamiento customizable no se pondrán sus opciones particulares, sólo interesan las opciones globales a todos los tratamientos.
//las opciones particulares del tratamiento customizable, son realemnte las opciones globales a todos los ttos.
if ((SelTto != (int)LimpiezaDef.TiposTto.TtoNoDef) && (SelTto < (int)LimpiezaDef.TiposTto.TtoCustom))
if ((TipoTto != (int)LimpiezaDef.TiposTto.TtoNoDef) && (TipoTto < (int)LimpiezaDef.TiposTto.TtoCustom))
{
for (int i = 0; i < (LimpiezaDef.ambs_val[SelTto].n_ops); i++)
for (int i = 0; i < (LimpiezaDef.ambs_val[TipoTto].n_ops); i++)
OpsAmbs.Add("Opción " + (i + 1));
}
}
@ -261,20 +278,20 @@ namespace OliviaAddInPro
*/
private void cambia_tiempo_tto()
{
if (SelTto == (int)LimpiezaDef.TiposTto.TtoNoDef)
if (TipoTto == (int)LimpiezaDef.TiposTto.TtoNoDef)
{
//no está definido
LblTimeTto = Resource1.String_lbl_timetto;
return;
}
else if (SelTto >= (int)LimpiezaDef.TiposTto.TtoPapeVaci)
else if (TipoTto >= (int)LimpiezaDef.TiposTto.TtoPapeVaci)
{
//tipo puntual, el tiempo es en minutos
LblTimeTto = Resource1.String_lbl_timetto;
UdsTTto = (int)GeneralDef.OlvTiposTto.OlvTipTtoMin;
}
else if ((SelTto == (int)LimpiezaDef.TiposTto.TtoBarrMecCalz) ||
(SelTto == (int)LimpiezaDef.TiposTto.TtoBaldMecCalz))
else if ((TipoTto == (int)LimpiezaDef.TiposTto.TtoBarrMecCalz) ||
(TipoTto == (int)LimpiezaDef.TiposTto.TtoBaldMecCalz))
{
//tipo lineal, es velocidad en m/h
LblTimeTto = Resource1.String_lbl_velotto;
@ -287,7 +304,7 @@ namespace OliviaAddInPro
UdsTTto = (int)GeneralDef.OlvTiposTto.OlvTipTtoM2h;
}
LblUdsTimeTto = GeneralDef.UdsTto[UdsTTto];
TimeTto = (int)LimpiezaDef.tiempos_tto[(int)SelTto];
TimeTto = (int)LimpiezaDef.tiempos_tto[(int)TipoTto];
}
/**
* Realiza los cambios en los ámbitos cuando se ha seleccionado un tratamiento
@ -324,13 +341,13 @@ namespace OliviaAddInPro
{
//dependiendo del tratamiento seleccionado en la opción 0(Editable) se seleccionarán diferentes opciones del TtoCustom(diferenciando entre ttos lineales o puntuales)
//para ámbitos lineales
if (SelTto < (int)LimpiezaDef.TiposTto.TtoPapeVaci)
if (TipoTto < (int)LimpiezaDef.TiposTto.TtoPapeVaci)
{
check = LimpiezaDef.ambs_val[(int)LimpiezaDef.TiposTto.TtoCustom].ambs_ops[iop].ambs[(int)((AmbitsList)lista[i]).amb_i]
&& amb_tra_gdb[(int)((AmbitsList)lista[i]).amb_i];
}
//para ámbitos puntuales
else if ((SelTto > (int)LimpiezaDef.TiposTto.TtoCaidaHoja) && (SelTto < (int)LimpiezaDef.TiposTto.TtoCustom))
else if ((TipoTto > (int)LimpiezaDef.TiposTto.TtoCaidaHoja) && (TipoTto < (int)LimpiezaDef.TiposTto.TtoCustom))
{
//es la opción Genérica que es la opción 1 del TtoCustom, de ahi que el índice sea [iop + 1]
check = LimpiezaDef.ambs_val[(int)LimpiezaDef.TiposTto.TtoCustom].ambs_ops[iop + 1].ambs[(int)((AmbitsList)lista[i]).amb_i]
@ -349,11 +366,11 @@ namespace OliviaAddInPro
check = LimpiezaDef.ambs_val[(int)LimpiezaDef.TiposTto.TtoCustom].ambs_ops[iop + 1].ambs[(int)((AmbitsList)lista[i]).amb_i]
&& amb_tra_gdb[(int)((AmbitsList)lista[i]).amb_i];
}
else if ((iop - 2) < (LimpiezaDef.ambs_val[SelTto].n_ops))
else if ((iop - 2) < (LimpiezaDef.ambs_val[TipoTto].n_ops))
{
//pone el check si el elemento que aparece en la lista porque es común o no común
//esa opción en concreto le tiene
check = LimpiezaDef.ambs_val[SelTto].ambs_ops[iop - 2].ambs[(int)((AmbitsList)lista[i]).amb_i]
check = LimpiezaDef.ambs_val[TipoTto].ambs_ops[iop - 2].ambs[(int)((AmbitsList)lista[i]).amb_i]
&& amb_tra_gdb[(int)((AmbitsList)lista[i]).amb_i];
}
Ambitos.ElementAt(i).IsChecked = check;
@ -369,10 +386,10 @@ namespace OliviaAddInPro
bool[] amb_val_eje;
//lo hace para todos los tratamientos excepto para el Customizble ya que sólo se quieren mostrar las opciones alternaitvas al tratamiento
if (SelTto < (int)LimpiezaDef.TiposTto.TtoCustom)
if (TipoTto < (int)LimpiezaDef.TiposTto.TtoCustom)
{
//pide un array de booleanos donde es true en las posiciones de los ámbitos comunes
amb_val = limp.DameAmbTto(SelTto);
amb_val = DameAmbTto(selTto);
//crea un array con el número de elementos del array anterior que sean true
ambs_list = new ObservableCollection<AmbitsList>();//cuenta los trues
//rellena el array apuntando los índices y los textos correspondientes a los trues
@ -426,18 +443,18 @@ namespace OliviaAddInPro
ObservableCollection<AmbitsList> lista = null;
try
{
if (SelTto == (int)LimpiezaDef.TiposTto.TtoNoDef)
if (TipoTto == (int)LimpiezaDef.TiposTto.TtoNoDef)
{
return lista;
}
rellena_amb_list();
if ((SelOpAmb == 0) && ((SelTto < (int)LimpiezaDef.TiposTto.TtoPapeVaci) ||
(SelTto >= (int)LimpiezaDef.TiposTto.TtoCustom)))
if ((SelOpAmb == 0) && ((TipoTto < (int)LimpiezaDef.TiposTto.TtoPapeVaci) ||
(TipoTto >= (int)LimpiezaDef.TiposTto.TtoCustom)))
{
lista = ambs_list_tod_lin;
}
else if ((SelOpAmb == 0) && (SelTto > (int)LimpiezaDef.TiposTto.TtoCaidaHoja))
else if ((SelOpAmb == 0) && (TipoTto > (int)LimpiezaDef.TiposTto.TtoCaidaHoja))
{
lista = ambs_list_tod_pto;
}
@ -465,6 +482,178 @@ namespace OliviaAddInPro
}
}
/**
* Añade a la lista de ambitos seleccionados los que están checkeados de la lista de posibles
*/
public bool lee_ambitos()
{
ambitosSel = new bool[(int)LimpiezaDef.AmbitsTra.AmbN]; //reinicia los ambitos seleccionados
if (ambitos.Count == 0)
return false;
else if ((selOpAmb == 0) && (selTto < (int)LimpiezaDef.TiposTto.TtoPapeVaci))
{
for (int i = 0; i < ambitos.Count; i++)
{
//lo pone a true si ese elemento está checkeado, para lo que coge el índice al array de ámbitos de ese elemento
if(ambitos.ElementAt(i).IsChecked)
ambitosSel[(int)((AmbitsList)ambs_list_tod_lin[i]).amb_i] = true;
}
}
else if ((selOpAmb == 0) && (selTto >= (int)LimpiezaDef.TiposTto.TtoPapeVaci))
{
for (int i = 0; i < ambitos.Count; i++)
{
//lo pone a true si ese elemento está checkeado, para lo que coge el índice al array de ámbitos de ese elemento
if (ambitos.ElementAt(i).IsChecked)
ambitosSel[(int)((AmbitsList)ambs_list_tod_pto[i]).amb_i] = true;
}
}
else if (selOpAmb == 1)
{
for (int i = 0; i < ambitos.Count; i++)
{
//lo pone a true si ese elemento está checkeado, para lo que coge el índice al array de ámbitos de ese elemento
if (ambitos.ElementAt(i).IsChecked)
ambitosSel[(int)((AmbitsList)ambs_list_eje[i]).amb_i] = true;
}
}
else
{
for (int i = 0; i < ambitos.Count; i++)
{
//lo pone a true si ese elemento está checkeado, para lo que coge el índice al array de ámbitos de ese elemento
if (ambitos.ElementAt(i).IsChecked)
ambitosSel[(int)((AmbitsList)ambs_list[i]).amb_i] = true;
}
}
if (ambitosSel[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle])//si es ámbito tipo eje de calle
{
if (udsTTto == (int)GeneralDef.OlvTiposTto.OlvTipTtoMh)
udsTTto = (int)GeneralDef.OlvTiposTto.OlvTipTtoMh_eje;
else if (udsTTto == (int)GeneralDef.OlvTiposTto.OlvTipTtoM2h)
udsTTto = (int)GeneralDef.OlvTiposTto.OlvTipTtoM2h_eje;
}
return true;
}
/*
* Lee la capa que se ha seleccionzdo de limpieza y se comprueba que los campos que se han editado corresponden con la capa
* (es decir, se puede leer la capa con los campos configurados)
*/
public bool CompruebaCamposLimp(string pathCapa, out string err_str)
{
int NCAMPS = 2;
string[] camps;
int i;
camps = new string[NCAMPS];
camps[0] = LimpiezaDef.Campos.consulta_entidad;
camps[1] = LimpiezaDef.Campos.consulta_mecan;
FeatureClass fc = HelperGdb.GetFtClass(pathCapa);
err_str = "";
if (fc == null)
{
err_str = "No se puede abrir la capa";
return false;
}
ObservableCollection<string> fields = HelperGdb.GetFields(fc).Result;
for (i = 0; i < NCAMPS; i++)
{
if (!fields.Contains(camps[i]))
{
err_str = "No se encuentra el campo " + camps[i];
break;
}
}
if (i < NCAMPS)
return false;
return true;
}
/**
* Lee la gdb y devuelve el array de ámbitos en función de si hay en la gdb o no
*/
public bool[] BuscAmbGdb(string pathCapa)
{
string consulta;
int numero_lin;
bool[] amb_gdb = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];//se inician a false
string ftclass;
//mira a ver si hay ejes de calle
ftclass = LimpiezaDef.ftclass[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle];
consulta = LimpiezaDef.filtro_str[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle];
numero_lin = HelperGdb.GetNumElems(OliviaGlob.Paths.PathGdbNw, ftclass, consulta);
if (numero_lin > 0)
{
amb_gdb[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle] = true;
}
//mira a ver si hay el resto de capas y tienen entidades
for (int i = (int)LimpiezaDef.AmbitsTra.AmbBordLibreMec; i < (int)LimpiezaDef.AmbitsTra.AmbN; i++)
{
consulta = LimpiezaDef.filtro_str[i];
numero_lin = HelperGdb.GetNumElems(pathCapa, consulta);
if (numero_lin > 0)
{
amb_gdb[i] = true;
}
}
return amb_gdb;
}
/**Devuelve el array de los ámbitos comunes y no comunes de las opciones de un tratamiento tto
* Es un array de longitud el número de ámbitos totales, con true en las posiciones en los que el ámbito sea común o
* no común en las opciones
*/
public bool[] DameAmbTto(int tto)
{
int i;
bool sig;
bool[] amb_com = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];
for (int j = 0; j < (int)LimpiezaDef.AmbitsTra.AmbN; j++)
{
sig = false;
for (i = 0; i < LimpiezaDef.ambs_val[tto].n_ops && !sig; i++)
{
if (LimpiezaDef.ambs_val[tto].ambs_ops[i].ambs[j]) //con que encuentre uno true lo pone y pasa al siguiente
{
amb_com[j] = sig = true;
}
}
}
return amb_com;
}
/**
* Devuelve qué consulta hay que hacer, el filtro de los ámbitos y el nombre de la clase donde están
*/
public string dame_consul_amb_clas(out string ambitos, out string nom_class)
{
string consulta, orstr;
consulta = null;
ambitos = "";
orstr = null;
nom_class = null;
for (int i = 0; i < AmbitosSel.Length; i++)
{
if (AmbitosSel[i])
{
if (nom_class == null)
nom_class = LimpiezaDef.ftclass[i];
consulta = consulta + orstr + "(" + LimpiezaDef.filtro_str[i] + ")";
ambitos = ambitos + i.ToString("00");
if (orstr == null)
orstr = " OR ";
}
}
ambitos = "_A" + ambitos;
if (consulta == "()")
consulta = "";
return consulta;
}
}
/**

View File

@ -15,14 +15,18 @@ namespace OliviaAddInPro
private PaneLimpiezaSub2ViewModel _subPanel2ViewModel;
private PaneLimpiezaSub3ViewModel _subPanel3ViewModel;
private PaneLimpiezaSub4ViewModel _subPanel4ViewModel;
private PaneEjecutarViewModel _subPanelEjecutar;
private PaneEjecutarViewModel _subPanelEjec;
private PanelViewModelBase _subPanelEjecBase;
Limpieza limp;
public PaneLimpiezaViewModel()
{
_subPanel1ViewModel = new PaneLimpiezaSub1ViewModel(OliviaGlob.Limp);
limp = OliviaGlob.Limp;
_subPanel1ViewModel = new PaneLimpiezaSub1ViewModel();
_subPanel2ViewModel = new PaneLimpiezaSub2ViewModel();
_subPanel3ViewModel = new PaneLimpiezaSub3ViewModel();
_subPanel4ViewModel = new PaneLimpiezaSub4ViewModel();
_subPanelEjecutar = new PaneEjecutarViewModel();
_subPanelEjec = new PaneEjecutarViewModel();
OptionsMenu = new ObservableCollection<OptionsMenuItem>
{
@ -32,6 +36,7 @@ namespace OliviaAddInPro
new OptionsMenuItem(new BitmapImage(new Uri("pack://application:,,,/OliviaAddInPro;component/Resources/Panda32.png")), Resource1.String_tiempos, _subPanel4ViewModel)
};
SelectedOption = OptionsMenu[0];
SubPanelEjec = _subPanelEjecBase=_subPanelEjec;
}
public override string DisplayName
{
@ -51,11 +56,10 @@ namespace OliviaAddInPro
set { SetProperty(ref _currentSubPanelPage, value, () => CurrentSubPanelPage); }
}
private PanelViewModelBase _subPanelEjec;
public PanelViewModelBase SubPanelEjec
{
get { return _subPanelEjec; }
set { SetProperty(ref _subPanelEjec, value, () => SubPanelEjec); }
get { return _subPanelEjecBase; }
set { SetProperty(ref _subPanelEjecBase, value, () => SubPanelEjec); }
}
private OptionsMenuItem _selectionOption;
@ -67,5 +71,34 @@ namespace OliviaAddInPro
CurrentSubPanelPage = value.SubPanelViewModel;
}
}
public bool Lee(out string err_str)
{
err_str = "";
try
{
///Lee el primer panel
/*limp.CapaElems = _subPanel1ViewModel.CapaElems;
limp.Ttto = _subPanel1ViewModel.SelTto;
if (limp.Ttto == (int)LimpiezaDef.TiposTto.TtoNoDef)
{
err_str = "No se ha seleccionado ningún Tipo de Tratamiento";
return false;
}
//lee el ámbito seleccionado
if (!_subPanel1ViewModel.lee_ambitos())
{
err_str = "No se ha seleccionado ningún Ámbito de trabajo";
return false;
}
limp.AmbitosSel = _subPanel1ViewModel.AmbitosSel;
*/
return true;
}
catch
{
return false;
}
}
}
}