fb78493e14d00adc860723c168694958f5f2bb40
[scilab.git] / scilab / modules / scicos / src / cpp / view_scilab / GraphicsAdapter.cpp
1 /*
2  *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  *  Copyright (C) 2014-2014 - Scilab Enterprises - Clement DAVID
4  *
5  *  This file must be used under the terms of the CeCILL.
6  *  This source file is licensed as described in the file COPYING, which
7  *  you should have received as part of this distribution.  The terms
8  *  are also available at
9  *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10  *
11  */
12
13 #include <string>
14 #include <vector>
15 #include <cassert>
16
17 #include "int.hxx"
18 #include "double.hxx"
19 #include "string.hxx"
20
21 #include "Controller.hxx"
22 #include "GraphicsAdapter.hxx"
23
24 extern "C" {
25 #include "sci_malloc.h"
26 }
27
28 namespace org_scilab_modules_scicos
29 {
30 namespace view_scilab
31 {
32
33 struct orig
34 {
35
36     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
37     {
38         double* data;
39         types::Double* o = new types::Double(1, 2, &data);
40         model::Block* adaptee = adaptor.getAdaptee();
41
42         std::vector<double> geom;
43         controller.getObjectProperty(adaptee->id(), adaptee->kind(), GEOMETRY, geom);
44
45         data[0] = geom[0];
46         data[1] = geom[1];
47
48         return o;
49     }
50
51     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
52     {
53
54         if (v->getType() != types::InternalType::ScilabDouble)
55         {
56             return false;
57         }
58
59         types::Double* current = v->getAs<types::Double>();
60         if (current->getRows() != 1 || current->getCols() != 2)
61         {
62             return false;
63         }
64
65         model::Block* adaptee = adaptor.getAdaptee();
66         std::vector<double> geom;
67         controller.getObjectProperty(adaptee->id(), adaptee->kind(), GEOMETRY, geom);
68
69         geom[0] = current->get(0);
70         geom[1] = current->get(1);
71
72         controller.setObjectProperty(adaptee->id(), adaptee->kind(), GEOMETRY, geom);
73         return true;
74     }
75 };
76
77 struct sz
78 {
79
80     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
81     {
82         double* data;
83         types::Double* o = new types::Double(1, 2, &data);
84         model::Block* adaptee = adaptor.getAdaptee();
85
86         std::vector<double> geom;
87         controller.getObjectProperty(adaptee->id(), adaptee->kind(), GEOMETRY, geom);
88
89         data[0] = geom[2];
90         data[1] = geom[3];
91         return o;
92     }
93
94     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
95     {
96         if (v->getType() != types::InternalType::ScilabDouble)
97         {
98             return false;
99         }
100
101         types::Double* current = v->getAs<types::Double>();
102         if (current->getRows() != 1 || current->getCols() != 2)
103         {
104             return false;
105         }
106
107         model::Block* adaptee = adaptor.getAdaptee();
108         std::vector<double> geom;
109         controller.getObjectProperty(adaptee->id(), adaptee->kind(), GEOMETRY, geom);
110
111         geom[2] = current->get(0);
112         geom[3] = current->get(1);
113
114         controller.setObjectProperty(adaptee->id(), adaptee->kind(), GEOMETRY, geom);
115         return true;
116     }
117 };
118
119 struct flip
120 {
121
122     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
123     {
124         int* data;
125         types::Bool* o = new types::Bool(1, 1, &data);
126         model::Block* adaptee = adaptor.getAdaptee();
127
128         std::vector<double> angle;
129         controller.getObjectProperty(adaptee->id(), adaptee->kind(), ANGLE, angle);
130
131         data[0] = angle[0];
132         return o;
133     }
134
135     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
136     {
137         if (v->getType() != types::InternalType::ScilabBool)
138         {
139             return false;
140         }
141
142         types::Bool* current = v->getAs<types::Bool>();
143         if (current->isScalar() != true)
144         {
145             return false;
146         }
147
148         model::Block* adaptee = adaptor.getAdaptee();
149         std::vector<double> angle;
150         controller.getObjectProperty(adaptee->id(), adaptee->kind(), ANGLE, angle);
151
152         angle[0] = (current->get(0) == false) ? 0 : 1;
153
154         controller.setObjectProperty(adaptee->id(), adaptee->kind(), ANGLE, angle);
155         return true;
156     }
157 };
158
159 struct theta
160 {
161
162     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
163     {
164         double* data;
165         types::Double* o = new types::Double(1, 1, &data);
166         model::Block* adaptee = adaptor.getAdaptee();
167
168         std::vector<double> angle;
169         controller.getObjectProperty(adaptee->id(), adaptee->kind(), ANGLE, angle);
170
171         data[0] = angle[1];
172         return o;
173     }
174
175     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
176     {
177         if (v->getType() != types::InternalType::ScilabDouble)
178         {
179             return false;
180         }
181
182         types::Double* current = v->getAs<types::Double>();
183         if (current->isScalar() != true)
184         {
185             return false;
186         }
187
188         model::Block* adaptee = adaptor.getAdaptee();
189         std::vector<double> angle;
190         controller.getObjectProperty(adaptee->id(), adaptee->kind(), ANGLE, angle);
191
192         angle[1] = current->get(0);
193
194         controller.setObjectProperty(adaptee->id(), adaptee->kind(), ANGLE, angle);
195         return true;
196     }
197 };
198
199 struct exprs
200 {
201
202     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
203     {
204         model::Block* adaptee = adaptor.getAdaptee();
205
206         std::vector<std::string> exprs;
207         controller.getObjectProperty(adaptee->id(), adaptee->kind(), EXPRS, exprs);
208
209         types::String* o = new types::String(exprs.size(), 1);
210         for (size_t i = 0; i < exprs.size(); ++i)
211         {
212             o->set(i, exprs[i].data());
213         }
214
215         return o;
216     }
217
218     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
219     {
220         if (v->getType() == types::InternalType::ScilabString)
221         {
222             types::String* current = v->getAs<types::String>();
223             if (current->getCols() != 0 && current->getCols() != 1)
224             {
225                 return false;
226             }
227
228             model::Block* adaptee = adaptor.getAdaptee();
229             std::vector<std::string> exprs = std::vector<std::string>(current->getSize());
230             for (size_t i = 0; i < exprs.size(); ++i)
231             {
232                 char* c_str = wide_string_to_UTF8(current->get(i));
233                 exprs[i] = std::string(c_str);
234                 FREE(c_str);
235             }
236
237             controller.setObjectProperty(adaptee->id(), adaptee->kind(), EXPRS, exprs);
238             return true;
239         }
240         else if (v->getType() == types::InternalType::ScilabDouble)
241         {
242             types::Double* current = v->getAs<types::Double>();
243             if (current->getRows() != 0 || current->getCols() != 0)
244             {
245                 return false;
246             }
247
248             model::Block* adaptee = adaptor.getAdaptee();
249             std::vector<std::string> exprs;
250             controller.setObjectProperty(adaptee->id(), adaptee->kind(), EXPRS, exprs);
251             return true;
252         }
253         return false;
254     }
255 };
256
257 static types::Double* get_port(const GraphicsAdapter& adaptor, object_properties_t p, const Controller& controller)
258 {
259     model::Block* adaptee = adaptor.getAdaptee();
260
261     // retrieve the identifiers
262     std::vector<ScicosID> ids;
263     controller.getObjectProperty(adaptee->id(), adaptee->kind(), p, ids);
264
265     // allocate some space for the return value
266     double* ports;
267     types::Double* o = new types::Double(ids.size(), 1, &ports);
268
269     // translate identifiers to return values
270     for (std::vector<ScicosID>::iterator it = ids.begin(); it != ids.end(); ++it, ++ports)
271     {
272         std::vector<ScicosID> connectedSignals;
273
274         controller.getObjectProperty(*it, PORT, CONNECTED_SIGNALS, connectedSignals);
275
276         // always return the first connected signals, at scilab level a port can only be connected to one signal at a time.
277         if (connectedSignals.empty())
278         {
279             // if the port is not connected returns 0
280             *ports = 0;
281         }
282         else
283         {
284             // if the port is connected, return the index of the link in the parent diagram
285             ScicosID link = connectedSignals[0];
286
287             ScicosID parentDiagram = 0;
288             controller.getObjectProperty(link, LINK, PARENT_DIAGRAM, parentDiagram);
289
290             std::vector<ScicosID> children;
291             controller.getObjectProperty(parentDiagram, DIAGRAM, CHILDREN, children);
292
293             std::vector<ScicosID>::iterator it = std::find(children.begin(), children.end(), link);
294             if (it != children.end())
295             {
296                 int index = std::distance(children.begin(), it);
297                 *ports = index;
298             }
299             else
300             {
301                 *ports = 0;
302             }
303         }
304
305         ports++;
306     }
307
308     return o;
309 }
310
311 static types::String* get_port(const GraphicsAdapter& adaptor, object_properties_t p, const Controller& controller, object_properties_t p2)
312 {
313     model::Block* adaptee = adaptor.getAdaptee();
314
315     // Retrieve the identifiers
316     std::vector<ScicosID> ids;
317     controller.getObjectProperty(adaptee->id(), adaptee->kind(), p, ids);
318
319     // Allocate some space for the return value
320     types::String* o = new types::String(ids.size(), 1);
321
322     // Translate identifiers to return values
323     int i = 0;
324     static const wchar_t E[] = L"E";
325     static const wchar_t I[] = L"I";
326     for (std::vector<ScicosID>::iterator it = ids.begin(); it != ids.end(); ++it, ++i)
327     {
328         if (p2 == IMPLICIT)
329         {
330             bool v;
331             controller.getObjectProperty(*it, PORT, IMPLICIT, v);
332             o->set(i, (v == false) ? E : I);
333         }
334         else
335         {
336             // STYLE, LABEL
337         }
338     }
339
340     return o;
341 }
342
343 static bool set_port(const GraphicsAdapter& adaptor, types::InternalType* v, object_properties_t p, Controller& controller)
344 {
345     model::Block* adaptee = adaptor.getAdaptee();
346
347     if (v->getType() != types::InternalType::ScilabDouble)
348     {
349         return false;
350     }
351     types::Double* value = v->getAs<types::Double>();
352
353     ScicosID parentDiagram;
354     controller.getObjectProperty(adaptee->id(), BLOCK, PARENT_DIAGRAM, parentDiagram);
355
356     std::vector<ScicosID> children;
357     if (parentDiagram != 0)
358     {
359         controller.getObjectProperty(parentDiagram, DIAGRAM, CHILDREN, children);
360     }
361
362     std::vector<int> newPorts = std::vector<int>(value->getSize());
363     double* d = value->getReal();
364     for (std::vector<int>::iterator it = newPorts.begin(); it != newPorts.end(); ++it, ++d)
365     {
366         if (0 > *d && *d >= children.size())
367         {
368             return false;
369         }
370
371         *it = (int) * d;
372     }
373     std::vector<ScicosID> deletedObjects;
374
375     // retrieve old data
376     std::vector<ScicosID> oldPorts;
377     controller.getObjectProperty(adaptee->id(), adaptee->kind(), p, oldPorts);
378     std::vector<ScicosID> previousPorts = oldPorts;
379
380     // updated ports
381     while (!oldPorts.empty() || !newPorts.empty())
382     {
383         ScicosID oldPort = oldPorts.back();
384         oldPorts.pop_back();
385         int newPort = newPorts.back();
386         newPorts.pop_back();
387
388         ScicosID oldSignal;
389         controller.getObjectProperty(oldPort, PORT, CONNECTED_SIGNALS, oldSignal);
390         ScicosID newSignal = children[newPort];
391
392         if (oldSignal != newSignal)
393         {
394             // disconnect the old link
395             ScicosID oldSignalSrc;
396             controller.getObjectProperty(oldSignal, LINK, SOURCE_PORT, oldSignalSrc);
397             ScicosID oldSignalDst;
398             controller.getObjectProperty(oldSignal, LINK, DESTINATION_PORT, oldSignalDst);
399
400             ScicosID unconnected = 0;
401             if (oldSignalSrc == oldPort)
402             {
403                 controller.setObjectProperty(oldSignalDst, PORT, CONNECTED_SIGNALS, unconnected);
404             }
405             else // oldSignalDst == oldPort
406             {
407                 controller.setObjectProperty(oldSignalSrc, PORT, CONNECTED_SIGNALS, unconnected);
408             }
409             // Link de-association is not performed as the link will be removed
410
411             // connect the new link
412             controller.setObjectProperty(newSignal, LINK, SOURCE_PORT, 0);
413             controller.setObjectProperty(oldPort, PORT, CONNECTED_SIGNALS, newSignal);
414
415             children.erase(std::find(children.begin(), children.end(), oldSignal));
416             deletedObjects.push_back(oldSignal);
417         }
418     }
419
420     // removed ports
421     if (!oldPorts.empty())
422     {
423         previousPorts.erase(previousPorts.begin() + oldPorts.size(), previousPorts.end());
424
425         while (!oldPorts.empty())
426         {
427             ScicosID oldPort = oldPorts.back();
428             oldPorts.pop_back();
429
430             ScicosID signal;
431             controller.getObjectProperty(oldPort, PORT, CONNECTED_SIGNALS, signal);
432             if (signal != 0)
433             {
434                 // the link is connected, disconnect the other side
435                 ScicosID oldSignalSrc;
436                 controller.getObjectProperty(signal, LINK, SOURCE_PORT, oldSignalSrc);
437                 ScicosID oldSignalDst;
438                 controller.getObjectProperty(signal, LINK, DESTINATION_PORT, oldSignalDst);
439
440                 ScicosID unconnected = 0;
441                 if (oldSignalSrc == oldPort)
442                 {
443                     controller.setObjectProperty(oldSignalDst, PORT, CONNECTED_SIGNALS, unconnected);
444                 }
445                 else     // oldSignalDst == oldPort
446                 {
447                     controller.setObjectProperty(oldSignalSrc, PORT, CONNECTED_SIGNALS, unconnected);
448                 }
449
450                 children.erase(std::find(children.begin(), children.end(), signal));
451                 deletedObjects.push_back(signal);
452             }
453
454             deletedObjects.push_back(oldPort);
455         }
456
457         controller.setObjectProperty(adaptee->id(), BLOCK, p, previousPorts);
458     }
459
460     // added ports
461     if (!newPorts.empty())
462     {
463         while (!newPorts.empty())
464         {
465             int newPort = newPorts.back();
466             oldPorts.pop_back();
467
468             ScicosID id = controller.createObject(PORT);
469             controller.setObjectProperty(id, PORT, SOURCE_BLOCK, adaptee->id());
470             // set the connected signal if applicable
471             if (newPort != 0)
472             {
473                 ScicosID signal = children[newPort];
474                 controller.setObjectProperty(id, PORT, CONNECTED_SIGNALS, signal);
475             }
476
477             previousPorts.push_back(id);
478         }
479
480         controller.setObjectProperty(adaptee->id(), BLOCK, p, previousPorts);
481     }
482
483     // remove objects from the model after de-association
484     if (parentDiagram != 0)
485     {
486         controller.setObjectProperty(parentDiagram, DIAGRAM, CHILDREN, children);
487     }
488     for (std::vector<ScicosID>::iterator it = deletedObjects.begin(); it != deletedObjects.end(); ++it)
489     {
490         controller.deleteObject(*it);
491     }
492
493     return true;
494 }
495
496 struct pin
497 {
498
499     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
500     {
501         return get_port(adaptor, INPUTS, controller);
502     }
503
504     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
505     {
506         return set_port(adaptor, v, INPUTS, controller);
507     }
508 };
509
510 struct pout
511 {
512
513     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
514     {
515         return get_port(adaptor, OUTPUTS, controller);
516     }
517
518     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
519     {
520         return set_port(adaptor, v, OUTPUTS, controller);
521     }
522 };
523
524 struct pein
525 {
526
527     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
528     {
529         return get_port(adaptor, EVENT_INPUTS, controller);
530     }
531
532     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
533     {
534         return set_port(adaptor, v, EVENT_INPUTS, controller);
535     }
536 };
537
538 struct peout
539 {
540
541     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
542     {
543         return get_port(adaptor, EVENT_OUTPUTS, controller);
544     }
545
546     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
547     {
548         return set_port(adaptor, v, EVENT_OUTPUTS, controller);
549     }
550 };
551
552 struct gr_i
553 {
554
555     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
556     {
557         return adaptor.getGrIContent();
558     }
559
560     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
561     {
562         adaptor.setGrIContent(v->clone());
563         return true;
564     }
565 };
566
567 struct id
568 {
569
570     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
571     {
572         model::Block* adaptee = adaptor.getAdaptee();
573
574         std::string id;
575         controller.getObjectProperty(adaptee->id(), adaptee->kind(), ID, id);
576
577         types::String* o = new types::String(1, 1);
578         o->set(0, id.data());
579
580         return o;
581     }
582
583     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
584     {
585         if (v->getType() != types::InternalType::ScilabString)
586         {
587             return false;
588         }
589
590         types::String* current = v->getAs<types::String>();
591         if (current->getSize() != 1)
592         {
593             return false;
594         }
595
596         model::Block* adaptee = adaptor.getAdaptee();
597         std::string id;
598         char* c_str = wide_string_to_UTF8(current->get(0));
599         id = std::string(c_str);
600         FREE(c_str);
601
602         controller.setObjectProperty(adaptee->id(), adaptee->kind(), ID, id);
603         return true;
604     }
605 };
606
607 struct in_implicit
608 {
609
610     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
611     {
612         return get_port(adaptor, INPUTS, controller, IMPLICIT);
613     }
614
615     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
616     {
617         if (v->getType() == types::InternalType::ScilabString)
618         {
619             model::Block* adaptee = adaptor.getAdaptee();
620
621             types::String* current = v->getAs<types::String>();
622             if (current->getCols() != 0 && current->getCols() != 1)
623             {
624                 return false;
625             }
626
627             // Retrieve the ports i dentifiers
628             std::vector<ScicosID> ids;
629             size_t rows = current->getRows();
630             controller.getObjectProperty(adaptee->id(), adaptee->kind(), INPUTS, ids);
631             if (rows != ids.size())
632             {
633                 return false;
634             }
635
636             int i = 0;
637             static const wchar_t E[] = L"E";
638             static const wchar_t I[] = L"I";
639             for (std::vector<ScicosID>::iterator it = ids.begin(); it != ids.end(); ++it, ++i)
640             {
641                 if (current->get(i) == I)
642                 {
643                     controller.setObjectProperty(*it, PORT, IMPLICIT, true);
644                 }
645                 else if (current->get(i) == E)
646                 {
647                     controller.setObjectProperty(*it, PORT, IMPLICIT, false);
648                 }
649                 else
650                 {
651                     return false;
652                 }
653             }
654             return true;
655         }
656         else if (v->getType() == types::InternalType::ScilabDouble)
657         {
658             types::Double* current = v->getAs<types::Double>();
659             if (current->getRows() != 0 || current->getCols() != 0)
660             {
661                 return false;
662             }
663             types::String* o = get_port(adaptor, INPUTS, controller, IMPLICIT);
664             if (o->getSize() != 0)
665             {
666                 return false;
667             }
668             // Do nothing, because if the sizes match, then there are already zero input ports, so no input ports to update
669             delete o;
670             return true;
671         }
672         return false;
673     }
674 };
675
676 struct out_implicit
677 {
678
679     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
680     {
681         return get_port(adaptor, OUTPUTS, controller, IMPLICIT);
682     }
683
684     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
685     {
686         if (v->getType() == types::InternalType::ScilabString)
687         {
688             model::Block* adaptee = adaptor.getAdaptee();
689
690             types::String* current = v->getAs<types::String>();
691             if (current->getCols() != 0 && current->getCols() != 1)
692             {
693                 return false;
694             }
695
696             // Retrieve the ports i dentifiers
697             std::vector<ScicosID> ids;
698             size_t rows = current->getRows();
699             controller.getObjectProperty(adaptee->id(), adaptee->kind(), OUTPUTS, ids);
700             if (rows != ids.size())
701             {
702                 return false;
703             }
704
705             int i = 0;
706             static const wchar_t E[] = L"E";
707             static const wchar_t I[] = L"I";
708             for (std::vector<ScicosID>::iterator it = ids.begin(); it != ids.end(); ++it, ++i)
709             {
710                 if (current->get(i) == I)
711                 {
712                     controller.setObjectProperty(*it, PORT, IMPLICIT, true);
713                 }
714                 else if (current->get(i) == E)
715                 {
716                     controller.setObjectProperty(*it, PORT, IMPLICIT, false);
717                 }
718                 else
719                 {
720                     return false;
721                 }
722             }
723             return true;
724         }
725         else if (v->getType() == types::InternalType::ScilabDouble)
726         {
727             types::Double* current = v->getAs<types::Double>();
728             if (current->getRows() != 0 || current->getCols() != 0)
729             {
730                 return false;
731             }
732             types::String* o = get_port(adaptor, OUTPUTS, controller, IMPLICIT);
733             if (o->getSize() != 0)
734             {
735                 return false;
736             }
737             // Do nothing, because if the sizes match, then there are already zero output ports, so no output ports to update
738             delete o;
739             return true;
740         }
741         return false;
742     }
743 };
744
745 struct in_style
746 {
747
748     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
749     {
750         //FIXME: implement
751         return 0;
752     }
753
754     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
755     {
756         //FIXME: implement
757         return false;
758     }
759 };
760
761 struct out_style
762 {
763
764     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
765     {
766         //FIXME: implement
767         return 0;
768     }
769
770     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
771     {
772         //FIXME: implement
773         return false;
774     }
775 };
776
777 struct in_label
778 {
779
780     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
781     {
782         //FIXME: implement
783         return 0;
784     }
785
786     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
787     {
788         //FIXME: implement
789         return false;
790     }
791 };
792
793 struct out_label
794 {
795
796     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
797     {
798         //FIXME: implement
799         return 0;
800     }
801
802     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
803     {
804         //FIXME: implement
805         return false;
806     }
807 };
808
809 struct style
810 {
811
812     static types::InternalType* get(const GraphicsAdapter& adaptor, const Controller& controller)
813     {
814         //FIXME: implement
815         return 0;
816     }
817
818     static bool set(GraphicsAdapter& adaptor, types::InternalType* v, Controller& controller)
819     {
820         //FIXME: implement
821         return false;
822     }
823 };
824
825 template<> property<GraphicsAdapter>::props_t property<GraphicsAdapter>::fields = property<GraphicsAdapter>::props_t();
826
827 GraphicsAdapter::GraphicsAdapter(const GraphicsAdapter& o) :
828     BaseAdapter<GraphicsAdapter, org_scilab_modules_scicos::model::Block>(o),
829     gr_i_content(o.gr_i_content->clone())
830 {}
831
832 GraphicsAdapter::GraphicsAdapter(org_scilab_modules_scicos::model::Block* o) :
833     BaseAdapter<GraphicsAdapter, org_scilab_modules_scicos::model::Block>(o)
834 {
835     if (property<GraphicsAdapter>::properties_has_not_been_set())
836     {
837         property<GraphicsAdapter>::fields.reserve(15);
838         property<GraphicsAdapter>::add_property(L"orig", &orig::get, &orig::set);
839         property<GraphicsAdapter>::add_property(L"sz", &sz::get, &sz::set);
840         property<GraphicsAdapter>::add_property(L"flip", &flip::get, &flip::set);
841         property<GraphicsAdapter>::add_property(L"theta", &theta::get, &theta::set);
842         property<GraphicsAdapter>::add_property(L"exprs", &exprs::get, &exprs::set);
843         property<GraphicsAdapter>::add_property(L"pin", &pin::get, &pin::set);
844         property<GraphicsAdapter>::add_property(L"pout", &pout::get, &pout::set);
845         property<GraphicsAdapter>::add_property(L"pein", &pein::get, &pein::set);
846         property<GraphicsAdapter>::add_property(L"peout", &peout::get, &peout::set);
847         property<GraphicsAdapter>::add_property(L"gr_i", &gr_i::get, &gr_i::set);
848         property<GraphicsAdapter>::add_property(L"id", &id::get, &id::set);
849         property<GraphicsAdapter>::add_property(L"in_implicit", &in_implicit::get, &in_implicit::set);
850         property<GraphicsAdapter>::add_property(L"out_implicit", &out_implicit::get, &out_implicit::set);
851         property<GraphicsAdapter>::add_property(L"in_style", &in_style::get, &in_style::set);
852         property<GraphicsAdapter>::add_property(L"in_label", &in_label::get, &in_label::set);
853         property<GraphicsAdapter>::add_property(L"out_label", &out_label::get, &out_label::set);
854         property<GraphicsAdapter>::add_property(L"style", &style::get, &style::set);
855     }
856
857     gr_i_content = new types::List();
858 }
859
860 GraphicsAdapter::~GraphicsAdapter()
861 {
862     delete gr_i_content;
863 }
864
865 bool GraphicsAdapter::toString(std::wostringstream& ostr)
866 {
867     ostr << L"GraphicsAdapter.hxx: Dunno what to display there" << std::endl;
868     return true;
869 }
870
871 std::wstring GraphicsAdapter::getTypeStr()
872 {
873     return getSharedTypeStr();
874 }
875
876 std::wstring GraphicsAdapter::getShortTypeStr()
877 {
878     return getSharedTypeStr();
879 }
880
881 types::InternalType* GraphicsAdapter::getGrIContent() const
882 {
883     return gr_i_content;
884 }
885
886 void GraphicsAdapter::setGrIContent(types::InternalType* v)
887 {
888     delete gr_i_content;
889     gr_i_content = v->clone();
890 }
891
892 } /* view_scilab */
893 } /* namespace org_scilab_modules_scicos */