Ignore:
Timestamp:
04/03/14 17:07:28 (10 years ago)
Author:
mmichalski
Message:

New NeuronDrawer? without U-shape in connections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • js/viewer-f0/js/Viewer.js

    r193 r208  
    1212    this._neuronsContext = undefined;
    1313    this._context = undefined;
    14     this._urlToXML = "http://www.framsticks.com/files/apps/config/f0def.xml";
     14    this._urlToXML = 'f0def.xml';//"http://www.framsticks.com/files/apps/config/f0def.xml";
    1515    this._xml = undefined;
    1616    this._model = new Model();
     
    2929    this.downloadXML();
    3030    this.parseGeneXml();
    31 }
    32 
    33 Viewer.prototype.showVisualization = function(value, context){
    34     this._showVisualization = value;
    35     this._visualizationContext = context;
    36 }
    37 
    38 Viewer.prototype.showNeuron = function(value, context)
    39 {
    40      this._showNeurons = true;
    41      this._neuronsContext = context;
     31    this.VisualizationSettings = {
     32        context: undefined,
     33        width: undefined,
     34        height: undefined
     35    };
     36    this.NetworkSettings = {
     37        context: undefined,
     38        width: undefined,
     39        height: undefined
     40    };
    4241}
    4342
     
    165164};
    166165
    167 
    168166Viewer.prototype._getCreatureFromLink = function (link) {
    169167    var lines = undefined;
     
    239237};
    240238
    241 Viewer.prototype.mainLoop = function () {
    242     this._graphicsEngine.initializeScene();
    243     this.renderCreature();
    244     this._graphicsEngine.debugTest();
    245     this._graphicsEngine.renderScene();
    246 
    247     this._neuronDrawer.initializeScene();
    248     new SmartLayout(this._neurons, this._neuroConns);
    249     this._neuronDrawer.drawNetwork(this._neurons, this._neuroConns, einfos, this._neuroClasses);
    250     this._neuronDrawer.renderScene();
    251 
    252 };
    253 
    254239Viewer.prototype.run = function (mode, content) {
    255240    this.parseCreature(mode, content);
    256241
    257     if (this._showVisualization) {
    258         this._graphicsEngine = new GraphicsEngine(this._visualizationContext)
     242    if (this.VisualizationSettings.context) {
     243        this._graphicsEngine = new GraphicsEngine(this.VisualizationSettings.context, this.VisualizationSettings.width, this.VisualizationSettings.height);
    259244        this._graphicsEngine.initializeScene();
    260245        this.renderCreature();
     
    262247        this._graphicsEngine.renderScene();
    263248    }
    264     if (this._showNeurons) {
    265         this._neuronDrawer = new NeuronDrawer(this._neuronsContext);
     249    if (this.NetworkSettings.context) {
     250        this._neuronDrawer = new NeuronDrawer(this.NetworkSettings.context, this.NetworkSettings.width, this.NetworkSettings.height );
     251        this._neuronDrawer.initializeNewCanvas();
     252        new SmartLayout(this._neurons, this._neuroConns);
     253        this._neuronDrawer.drawNeuralNetwork(this._neurons, this._neuroConns, einfos, this._neuroClasses);
     254        this._neuronDrawer.finalize();
     255
     256        /*this._neuronDrawer = new NeuronDrawer(this._neuronsContext);
    266257        this._neuronDrawer.initializeScene();
    267258        new SmartLayout(this._neurons, this._neuroConns);
    268         this._neuronDrawer.drawNetwork(this._neurons, this._neuroConns, einfos, this._neuroClasses);
    269         this._neuronDrawer.renderScene();
     259        this._neuronDrawer.drawNeuralNetwork(this._neurons, this._neuroConns, einfos, this._neuroClasses);
     260        this._neuronDrawer.renderScene();*/
    270261    }
    271262}
     
    274265    var viewer = new Viewer();
    275266
    276     viewer.showVisualization(true, $("#container"));
    277     viewer.showNeuron(true, $("#containerNeuron"));
     267    viewer.VisualizationSettings.context = $("#container");
     268    viewer.VisualizationSettings.width = 400;
     269    viewer.VisualizationSettings.height = 400;
     270
     271    viewer.NetworkSettings.context =  "containerNeuron";
     272    viewer.NetworkSettings.width = 400;
     273    viewer.NetworkSettings.height = 400;
    278274    viewer.run(viewer.Mode.TEXTAREA, $("#geno"));
    279275}
     
    281277function openEmbeddedCreature() {
    282278    var viewer = new Viewer();
    283     viewer.showVisualization(true, $("#container1"));
    284     viewer.showNeuron(true, $("#containerNeuron1"));
     279    viewer.VisualizationSettings.context = $("#container1");
     280    viewer.VisualizationSettings.width = 400;
     281    viewer.VisualizationSettings.height = 400;
     282
     283    viewer.NetworkSettings.context =  "containerNeuron1";
     284    viewer.NetworkSettings.width = 400;
     285    viewer.NetworkSettings.height = 400;
    285286    viewer.run(viewer.Mode.EMBEDDED, "http://ec.framsticks.com/www/index.php?PAGE=view_genotype&ID=55");
    286287}
     
    288289function openCodeCreature() {
    289290    var viewer = new Viewer();
    290 
    291     viewer.showVisualization(true, $("#container2"));
    292     viewer.showNeuron(true, $("#containerNeuron2"));
     291    viewer.VisualizationSettings.context = $("#container2");
     292    viewer.VisualizationSettings.width = 400;
     293    viewer.VisualizationSettings.height = 400;
     294    viewer.NetworkSettings.context =  "containerNeuron2";
     295    viewer.NetworkSettings.width = 400;
     296    viewer.NetworkSettings.height = 400;
    293297    viewer.run(viewer.Mode.CODE, "//0\np:\np: x=1");
    294298}
     
    296300function openFileCreature() {
    297301    var viewer = new Viewer();
    298 
    299     var debugCreatureName = "example4";
    300     viewer.showVisualization(true, $("#container3"));
    301     viewer.showNeuron(true, $("#containerNeuron3"));
     302    //var debugCreatureName = "example4";
     303    //var debugCreatureName = "caterpillar";
     304    var debugCreatureName = "Quadro";
     305    //viewer.VisualizationSettings.context = $("#container3");
     306    //viewer.VisualizationSettings.width = 400;
     307    //viewer.VisualizationSettings.height = 400;
     308    viewer.NetworkSettings.context =  "containerNeuron3";
     309    viewer.NetworkSettings.width = 400;
     310    viewer.NetworkSettings.height = 400;
    302311    viewer.run(viewer.Mode.LINK, "http://localhost:63343/FramestickFavi/creatures/" + debugCreatureName + ".txt");
    303312}
Note: See TracChangeset for help on using the changeset viewer.