@@ -119,6 +119,53 @@ public static DebuggerEvents DebuggerEvents
119119 get { return Instance . debuggerEvents ; }
120120 }
121121
122+ public static Expression [ ] GetExpressions ( string name , char separator = ';' )
123+ {
124+ var expr = Debugger . GetExpression ( name ) ;
125+ if ( expr . IsValidValue )
126+ return new Expression [ ] { expr } ;
127+
128+ string [ ] subnames = name . Split ( separator ) ;
129+ Expression [ ] exprs = new Expression [ subnames . Length ] ;
130+ for ( int i = 0 ; i < subnames . Length ; ++ i )
131+ {
132+ exprs [ i ] = Debugger . GetExpression ( subnames [ i ] ) ;
133+ }
134+
135+ return exprs ;
136+ }
137+
138+ public static bool AllValidValues ( Expression [ ] exprs )
139+ {
140+ foreach ( Expression e in exprs )
141+ if ( ! e . IsValidValue )
142+ return false ;
143+ return true ;
144+ }
145+
146+ public static bool AnyValidValue ( Expression [ ] exprs )
147+ {
148+ foreach ( Expression e in exprs )
149+ if ( e . IsValidValue )
150+ return true ;
151+ return false ;
152+ }
153+
154+ public static string TypeFromExpressions ( Expression [ ] exprs )
155+ {
156+ string result = "" ;
157+ bool first = true ;
158+ foreach ( Expression e in exprs )
159+ {
160+ if ( first )
161+ first = false ;
162+ else
163+ result += " ; " ;
164+ result += e . Type ;
165+ }
166+ return result ;
167+ }
168+
122169 public interface KindConstraint
123170 {
124171 bool Check ( Kind kind ) ;
@@ -157,7 +204,6 @@ public static void Load(string name,
157204 out Geometry . Traits traits ,
158205 out ExpressionDrawer . IDrawable result )
159206 {
160-
161207 Load ( name , AllKinds , out traits , out result ) ;
162208 }
163209
@@ -169,27 +215,40 @@ public static void Load(string name,
169215 traits = null ;
170216 result = null ;
171217
172- Expression expr = Instance . debugger . GetExpression ( name ) ;
173- if ( ! expr . IsValidValue )
174- return ;
175-
176- Loader loader = Instance . loaders . FindByType ( expr . Name , expr . Type ) ;
177- if ( loader == null )
218+ Expression [ ] exprs = GetExpressions ( name ) ;
219+ if ( exprs . Length < 1 || ! AllValidValues ( exprs ) )
178220 return ;
221+
222+ if ( exprs . Length == 1 )
223+ {
224+ Loader loader = Instance . loaders . FindByType ( exprs [ 0 ] . Name , exprs [ 0 ] . Type ) ;
225+ if ( loader == null )
226+ return ;
179227
180- if ( ! kindConstraint . Check ( loader . Kind ( ) ) )
181- return ;
228+ if ( ! kindConstraint . Check ( loader . Kind ( ) ) )
229+ return ;
182230
183- GeneralOptionPage optionPage = Util . GetDialogPage < GeneralOptionPage > ( ) ;
184- bool accessMemory = true ;
185- if ( optionPage != null )
231+ loader . Load ( Instance . loaders , IsMemoryAccessEnabled ( ) ,
232+ Instance . debugger , exprs [ 0 ] . Name , exprs [ 0 ] . Type ,
233+ out traits , out result ) ;
234+ }
235+ else //if (exprs.Length > 1)
186236 {
187- accessMemory = optionPage . EnableDirectMemoryAccess ;
237+ // For now there is only one loader which can handle this case
238+ CoordinatesContainers loader = new CoordinatesContainers ( ) ;
239+
240+ loader . Load ( Instance . loaders , IsMemoryAccessEnabled ( ) ,
241+ Instance . debugger , exprs ,
242+ out traits , out result ) ;
188243 }
244+ }
189245
190- loader . Load ( Instance . loaders , accessMemory ,
191- Instance . debugger , expr . Name , expr . Type ,
192- out traits , out result ) ;
246+ static bool IsMemoryAccessEnabled ( )
247+ {
248+ GeneralOptionPage optionPage = Util . GetDialogPage < GeneralOptionPage > ( ) ;
249+ return optionPage != null
250+ ? optionPage . EnableDirectMemoryAccess
251+ : true ; // default
193252 }
194253
195254 static int ParseInt ( string s )
@@ -1410,6 +1469,21 @@ public override void Load(Loaders loaders, bool accessMemory,
14101469 traits = null ;
14111470 result = null ;
14121471
1472+ List < double > values = null ;
1473+ Load ( loaders , accessMemory , debugger , name , type , out traits , out values ) ;
1474+
1475+ if ( values != null )
1476+ result = new ExpressionDrawer . ValuesContainer ( values ) ;
1477+ }
1478+
1479+ public void Load ( Loaders loaders , bool accessMemory ,
1480+ Debugger debugger , string name , string type ,
1481+ out Geometry . Traits traits ,
1482+ out List < double > result )
1483+ {
1484+ traits = null ;
1485+ result = null ;
1486+
14131487 if ( accessMemory )
14141488 LoadMemory ( debugger , name , type , out result ) ;
14151489
@@ -1418,7 +1492,7 @@ public override void Load(Loaders loaders, bool accessMemory,
14181492 }
14191493
14201494 protected void LoadMemory ( Debugger debugger , string name , string type ,
1421- out ExpressionDrawer . ValuesContainer result )
1495+ out List < double > result )
14221496 {
14231497 result = null ;
14241498
@@ -1439,10 +1513,10 @@ protected void LoadMemory(Debugger debugger, string name, string type,
14391513 } ) ;
14401514
14411515 if ( ok )
1442- result = new ExpressionDrawer . ValuesContainer ( list ) ;
1516+ result = list ;
14431517 }
14441518
1445- protected void LoadParsed ( Debugger debugger , string name , out ExpressionDrawer . ValuesContainer result )
1519+ protected void LoadParsed ( Debugger debugger , string name , out List < double > result )
14461520 {
14471521 result = null ;
14481522 int size = this . LoadSize ( debugger , name ) ;
@@ -1455,10 +1529,9 @@ protected void LoadParsed(Debugger debugger, string name, out ExpressionDrawer.V
14551529 values . Add ( value ) ;
14561530 return okV ;
14571531 } ) ;
1532+
14581533 if ( ok )
1459- {
1460- result = new ExpressionDrawer . ValuesContainer ( values ) ;
1461- }
1534+ result = values ;
14621535 }
14631536 }
14641537
@@ -2366,5 +2439,91 @@ public override void Load(Loaders loaders, bool accessMemory,
23662439 }
23672440 }
23682441 }
2442+
2443+ // This is the only one loader created manually right now
2444+ // so the overrides below are not used
2445+ class CoordinatesContainers : PointRange < ExpressionDrawer . MultiPoint >
2446+ {
2447+ public CoordinatesContainers ( )
2448+ : base ( ExpressionLoader . Kind . MultiPoint )
2449+ { }
2450+
2451+ public override TypeConstraint Constraint ( ) { return null ; }
2452+
2453+ public override string Id ( ) { return null ; }
2454+
2455+ public override bool MatchType ( string type , string id )
2456+ {
2457+ return false ;
2458+ }
2459+
2460+ public override void Load ( Loaders loaders , bool accessMemory ,
2461+ Debugger debugger , string name , string type ,
2462+ out Geometry . Traits traits ,
2463+ out ExpressionDrawer . MultiPoint result )
2464+ {
2465+ traits = null ;
2466+ result = null ;
2467+ }
2468+
2469+ public void Load ( Loaders loaders , bool accessMemory ,
2470+ Debugger debugger , Expression [ ] exprs ,
2471+ out Geometry . Traits traits ,
2472+ out ExpressionDrawer . IDrawable result )
2473+ {
2474+ ExpressionDrawer . MultiPoint res = default ( ExpressionDrawer . MultiPoint ) ;
2475+ this . Load ( loaders , accessMemory , debugger , exprs , out traits , out res ) ;
2476+ result = res ;
2477+ }
2478+
2479+ public void Load ( Loaders loaders , bool accessMemory ,
2480+ Debugger debugger , Expression [ ] exprs ,
2481+ out Geometry . Traits traits ,
2482+ out ExpressionDrawer . MultiPoint result )
2483+ {
2484+ traits = null ;
2485+ result = null ;
2486+
2487+ int dimension = Math . Min ( exprs . Length , 3 ) ; // 2 or 3
2488+
2489+ traits = new Geometry . Traits ( dimension , Geometry . CoordinateSystem . Cartesian , Geometry . Unit . None ) ;
2490+
2491+ List < double > [ ] coords = new List < double > [ dimension ] ;
2492+ for ( int i = 0 ; i < dimension ; ++ i )
2493+ {
2494+ ValuesContainer containerLoader = loaders . FindByType ( ExpressionLoader . Kind . Container ,
2495+ exprs [ i ] . Name , exprs [ i ] . Type ) as ValuesContainer ;
2496+ if ( containerLoader == null )
2497+ return ;
2498+
2499+ Geometry . Traits foo = null ;
2500+ containerLoader . Load ( loaders , accessMemory ,
2501+ debugger , exprs [ i ] . Name , exprs [ i ] . Type ,
2502+ out foo , out coords [ i ] ) ;
2503+ }
2504+
2505+ int maxSize = 0 ;
2506+ foreach ( var list in coords )
2507+ {
2508+ maxSize = Math . Max ( maxSize , list . Count ) ;
2509+ }
2510+
2511+ result = new ExpressionDrawer . MultiPoint ( ) ;
2512+ for ( int i = 0 ; i < maxSize ; ++ i )
2513+ {
2514+ double [ ] coo = new double [ dimension ] ;
2515+
2516+ for ( int j = 0 ; j < dimension ; ++ j )
2517+ {
2518+ coo [ j ] = i < coords [ j ] . Count ? coords [ j ] [ i ] : 0 ;
2519+ }
2520+
2521+ Geometry . Point pt = ( dimension >= 3 )
2522+ ? new Geometry . Point ( coo [ 0 ] , coo [ 1 ] , coo [ 2 ] )
2523+ : new Geometry . Point ( coo [ 0 ] , coo [ 1 ] ) ;
2524+ result . Add ( pt ) ;
2525+ }
2526+ }
2527+ }
23692528 }
23702529}
0 commit comments