source: cpp/frams/canvas/nn_layout_model.cpp @ 210

Last change on this file since 210 was 197, checked in by Maciej Komosinski, 11 years ago

GDK used by developers since 1999, distributed on the web since 2002

  • Property svn:eol-style set to native
File size: 1.1 KB
Line 
1// This file is a part of the Framsticks GDK.
2// Copyright (C) 1999-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.framsticks.com/ for further information.
4
5#include "nn_layout_model.h"
6
7NNLayoutState_Model::NNLayoutState_Model(Model* m)
8{
9        model = m;
10        neuron_pos = (m->getNeuroCount() > 0) ? new NeuronPos[m->getNeuroCount()] : NULL;
11}
12
13NNLayoutState_Model::~NNLayoutState_Model()
14{
15        if (neuron_pos) delete[] neuron_pos;
16}
17
18int NNLayoutState_Model::GetElements()
19{
20        return model->getNeuroCount();
21}
22
23int *NNLayoutState_Model::GetXYWH(int el)
24{
25        return &neuron_pos[el].x;
26}
27
28void NNLayoutState_Model::SetXYWH(int el, int x, int y, int w, int h)
29{
30        NeuronPos &np = neuron_pos[el];
31        np.x = x; np.y = y; np.w = w; np.h = h;
32}
33
34int NNLayoutState_Model::GetInputs(int el)
35{
36        return model->getNeuro(el)->getInputCount();
37}
38
39int NNLayoutState_Model::GetLink(int el, int i)
40{
41        return model->getNeuro(el)->getInput(i)->refno;
42}
43
44int *NNLayoutState_Model::GetLinkXY(int el, int i)
45{
46        static int XY[2];
47        int *xywh = GetXYWH(el);
48        XY[0] = 0;
49        XY[1] = ((1 + i)*xywh[3]) / (GetInputs(el) + 1);
50        return XY;
51}
Note: See TracBrowser for help on using the repository browser.