Changeset 143 for js/viewer-f0


Ignore:
Timestamp:
02/26/14 11:19:05 (11 years ago)
Author:
mmichalski
Message:

Load NeuroClass? from f0def.xml and load correct xml from server

Location:
js/viewer-f0
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • js/viewer-f0/css/styles.css

    r133 r143  
    22    display: inline;
    33    position: fixed;
    4     left: 560px;
     4    left: 1050px;
    55}
    66
    77
    8 #container{
     8.cont{
    99    height: 500px;
    1010    width: 500px;
  • js/viewer-f0/index.html

    r134 r143  
    1515<script src="js/Structures/NeuroConn.js"></script>
    1616<script src="js/graphicsEngine.js"></script>
     17<script src="js/NeuronDrawer.js"></script>
     18<script src="js/SmartLayout.js"></script>
     19<script src="js/Structures/NeuroClass.js"></script>
    1720<script src="js/main.js"></script>
    1821
    1922
     23<div class="cont" id="container"></div>
     24<div class="cont" id="containerNeuron"></div>
    2025
    21 
    22 <div id="container"></div>
    2326<div id="menu">
    2427    <textarea id="geno">//0&#13;&#10;p:</textarea>
  • js/viewer-f0/js/Structures/Neuro.js

    r134 r143  
    55
    66Neuro.prototype = new Model();
    7 
    8 Neuro.prototype.getXPos = function()
    9 {
    10 
    11 }
  • js/viewer-f0/js/Structures/NeuroConn.js

    r134 r143  
    55
    66NeuroConn.prototype.getDestination = function(){
     7    return parseInt(this._properties["n1"]["VALUE"]);
     8}
     9
     10NeuroConn.prototype.getSource = function(){
    711    return parseInt(this._properties["n2"]["VALUE"]);
    812}
  • js/viewer-f0/js/graphicsEngine.js

    r134 r143  
    253253}
    254254
    255 GraphicsEngine.prototype.drawNeuron = function(){
    256     var scheme = [4,4,26,27,26,73,73,73,73,27,26,27,1,73,50,100,50,1,56,68,46,68,2,41,47,51,32,51,68];
    257     //pobieranie schematu
    258     //inne określenie położeń
    259 
    260 
    261     var obj = new THREE.Object3D();
    262 
    263     var material = new THREE.LineBasicMaterial({
    264         color: 0x0000ff
    265     });
    266     var position = 0;
    267     var noOfBlocks = 0;//number of "blocks" to draw
    268     var noOfLines = 0;//number of line to draw
    269     noOfBlocks = scheme[position++];
    270     for (var i = 0; i < noOfBlocks; i++)
    271     {
    272         noOfLines = scheme[position++];
    273 
    274         for (var j = 0; j < noOfLines; j++)
    275         {
    276             var geometry = new THREE.Geometry();
    277             geometry.vertices.push(new THREE.Vector3(scheme[position++], scheme[position++], 0));
    278             geometry.vertices.push(new THREE.Vector3(scheme[position++], scheme[position++], 0));
    279             position = position - 2; //get to last point in list
    280             var line = new THREE.Line(geometry, material);
    281             obj.add(line);
    282         }
    283         position = position + 2;//move to value which define number of lines to draw
    284     }
    285 
    286     obj.scale.set(0.1,0.1,0.1)
    287     this._scene.add(obj)
    288 }
    289 
    290 GraphicsEngine.prototype.drawConnection = function(connection, id, connestions, neurons){
    291 
    292     var destination = connection.getDestination();
    293     var numberOfConnToDest = 0;
    294     var numberOfDrawenCon = 0;
    295 
    296     //check how many conenctions have the same destination
    297     for(var i = 0; i < connestions.length; i++){
    298         if(connestions[i].getDestination() == destination)
    299             numberOfConnToDest++;
    300     }
    301 
    302     //check how many connections had been drawen
    303     for(var i = 0; i < id; i++){
    304         if(connestions[i].getDestination() == destination)
    305             numberOfDrawenCon++;
    306     }
    307 
    308     var positionY = (numberOfDrawenCon + 1) * 100 / (numberOfConnToDest + 1);
    309     var positionX = (numberOfDrawenCon + 1) * 10 / (numberOfConnToDest + 1);
    310 
    311     /*var x1 =
    312     var x2
    313     var y1
    314     var y2*/
    315 
    316 }
    317 
    318255GraphicsEngine.prototype.debugTest = function()
    319256{
    320     this.drawNeuron();
    321 
    322 
    323 }
    324 
     257
     258}
     259
  • js/viewer-f0/js/main.js

    r134 r143  
    1414    neurons: [],
    1515    neuroConns: [],
     16    neuroClasses: [],
    1617    modelOne: undefined,
    1718    _graphicsEngine: new GraphicsEngine(),
     19    _neuronDrawer: new NeuronDrawer(),
    1820    downloadXML: function () {
    1921        var local = this;
    2022        $.ajax({
    21             url: "http://localhost:63342/FramestickFavi/f0def.xml",
     23            url: "http://www.framsticks.com/files/dev/files/f0def.xml",
    2224            dataType: "xml",
    2325            async: false,
     
    3133            }
    3234        })
    33 
    3435    },
    3536    parseGeneXml: function () {
    36         var nodes = $(this.xml.find("CLASS"));
     37        this._parseClass($(this.xml.find("CLASS")));
     38        this._parseNeuroClass($(this.xml.find("NEUROCLASS")))
     39    },
     40    _parseClass: function(nodes){
    3741        var local = this;
    3842
     
    5660
    5761        });
     62    },
     63    _parseNeuroClass: function(data){
     64
     65        for(var i = 0; i < data.length; i++)
     66        {
     67            var neuroClass = new NeuroClass();
     68            neuroClass.setModel(data);
     69            this.neuroClasses.push(neuroClass);
     70        }
    5871    },
    5972    analyseLine: function (line) {
     
    108121    downloadCreature: function () {
    109122        var lines;
    110         /*$.ajax({
    111             url: "http://localhost:63342/FramestickFavi/creatures/" + this.debugCreatureName + ".txt",
     123        $.ajax({
     124            url: "http://localhost:63343/FramestickFavi/creatures/" + this.debugCreatureName + ".txt",
    112125            async: false,
    113126            dataType: "text",
     
    120133            }
    121134
    122         });*/
     135        });
    123136
    124         lines = $("#geno").val();
    125         lines = lines.split("\n");
     137        //lines = $("#geno").val();
     138        //lines = lines.split("\n");
    126139
    127140        return lines;
     
    153166        //this._graphicsEngine.debugTest();
    154167        this._graphicsEngine.renderScene();
     168
     169        this._neuronDrawer.initializeScene();
     170        new SmartLayout(this.neurons, this.neuroConns);
     171        this._neuronDrawer.drawNetwork(this.neurons, this.neuroConns, einfos);
     172        this._neuronDrawer.renderScene();
     173
    155174    }
    156175
     
    162181    geneWindow.parseCreature();
    163182    geneWindow.mainLoop();
    164     //geneWindow.context = window.open("window.html", "Window", "width=200,height=100");
    165183
    166184}
Note: See TracChangeset for help on using the changeset viewer.