source: cpp/frams/model/modelparts.cpp @ 1263

Last change on this file since 1263 was 1039, checked in by Maciej Komosinski, 4 years ago

Removed Part's "visual thickness" property

  • Property svn:eol-style set to native
File size: 16.8 KB
RevLine 
[286]1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
[932]2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
[286]3// See LICENSE.txt for details.
[109]4
5#include <stdlib.h>
6#include <math.h>
7#include <stdio.h>
8#include <string.h>
9#include <ctype.h>
10#include <time.h>
11#include <errno.h>
12
13///////////////////////////////     MODELPARTS.CPP     ///////////////
14
15#include "modelparts.h"
16#include "model.h"
17
18#include <common/nonstd.h>
19#include <frams/param/param.h>
20#include <frams/neuro/neurolibrary.h>
21#include <frams/util/multirange.h>
22#include <frams/util/extvalue.h>
23#include <frams/param/paramobj.h>
[952]24#include <frams/neuro/neuroimpl.h>
[109]25
26#include F0_DEFASSIGN_FILE
27
[288]28#ifndef SDK_WITHOUT_FRAMS
[109]29#include <frams/neuro/neuroclsobject.h>
30#endif
31
32/////////////////////////
33
34PartBase::~PartBase()
[714]35{
36        if (mapped) delete mapped;
37}
[109]38
39void PartBase::notifyMappingChange()
40{
[714]41        if (owner) owner->partmappingchanged = 1;
[109]42}
43
44void PartBase::setMapping(const IRange &r)
45{
[714]46        if (mapped) (*mapped) = r;
47        else mapped = new MultiRange(r);
48        notifyMappingChange();
[109]49}
50
51void PartBase::clearMapping()
52{
[714]53        if (mapped) { delete mapped; mapped = 0; }
[109]54}
55
56void PartBase::addMapping(const IRange &r)
57{
[714]58        if (mapped) mapped->add(r);
59        else mapped = new MultiRange(r);
60        notifyMappingChange();
[109]61}
62
63void PartBase::setMapping(const MultiRange &mr)
64{
[714]65        if (mapped) (*mapped) = mr;
66        else mapped = new MultiRange(mr);
67        notifyMappingChange();
[109]68}
69
70void PartBase::addMapping(const MultiRange &mr)
71{
[714]72        if (mapped) mapped->add(mr);
73        else mapped = new MultiRange(mr);
74        notifyMappingChange();
[109]75}
76
[899]77void PartBase::setInfo(const SString &name, const SString &value)
[109]78{
[714]79        strSetField(info, name, value);
[109]80}
81
[899]82void PartBase::setInfo(const SString &name, int value)
[109]83{
[714]84        setInfo(name, SString::valueOf(value));
[109]85}
86
[899]87void PartBase::setInfo(const SString &name, double value)
[109]88{
[714]89        setInfo(name, SString::valueOf(value));
[109]90}
91
[899]92SString PartBase::getInfo(const SString &name)
[109]93{
[714]94        return strGetField(info, name);
[109]95}
96
97/////////////////////////
98
[714]99NeuroClass::NeuroClass(ParamEntry *_props, SString _description,
100        int _prefinputs, int _prefoutput, int _preflocation,
[975]101        int *_vectordata, bool own_vd, int vhints, int sup_shapes, int sup_joints)
[109]102        :ownedvectordata(own_vd),
[714]103        name(_props->name), longname(_props->id), description(_description),
104        props(_props), ownedprops(false),
105        prefinputs(_prefinputs),
106        prefoutput(_prefoutput),
107        preflocation(_preflocation),
[932]108        supported_shape_types(sup_shapes),
[977]109        supported_joint_shapes(sup_joints),
[714]110        vectordata(_vectordata),
111        visualhints(vhints), impl_count(0),/*impl(0),*/active(1), genactive(0)
[109]112{}
113
114NeuroClass::~NeuroClass()
115{
[714]116        setSymbolGlyph(0, 0);
117        if (props && ownedprops)
118                ParamObject::freeParamTab(props);
[109]119}
120
121NeuroClass::NeuroClass()
122        :ownedvectordata(0),
[714]123        name("Invalid"),
124        props(empty_paramtab), ownedprops(false),
125        prefinputs(0), prefoutput(0),
126        preflocation(0), vectordata(0),
127        visualhints(0), impl_count(0), /*impl(0),*/ active(1), genactive(0)
[109]128{}
129
[714]130void NeuroClass::resetActive()
131{
132        for (int i = 0; i < Neuro::getClassCount(); i++)
133        {
134                Neuro::getClass(i)->genactive = 0;
135                Neuro::getClass(i)->active = 1;
136        }
137}
138
[899]139void NeuroClass::setGenActive(const char *genactive_classes[])
[714]140{
[899]141        for (const char **n = genactive_classes; *n; n++)
[714]142        {
[899]143                NeuroClass *cls = Neuro::getClass(*n);
[714]144                if (cls) cls->genactive = 1;
145        }
146}
147
[109]148SString NeuroClass::getSummary()
149{
[714]150        SString t;
151        t = getDescription();
[973]152        if (t.length()) t += "\n\n";
[714]153        t += "Characteristics:\n";
154        if (getPreferredInputs())
[109]155        {
[714]156                if (getPreferredInputs() < 0) t += "   supports any number of inputs\n";
157                else if (getPreferredInputs() == 1) t += "   uses single input\n";
158                else t += SString::sprintf("   uses %d inputs\n", getPreferredInputs());
[109]159        }
[714]160        else t += "   does not use inputs\n";
161        if (getPreferredOutput())
162                t += "   provides output value\n";
163        else
164                t += "   does not provide output value\n";
165        switch (getPreferredLocation())
[109]166        {
[714]167        case 0: t += "   does not require location in body\n"; break;
168        case 1: t += "   should be located on a Part\n"; break;
169        case 2: t += "   should be located on a Joint\n"; break;
[109]170        }
[714]171        Param p = getProperties();
172        if (p.getPropCount())
[109]173        {
[973]174                if (t.length()) t += "\n\n";
[714]175                t += "Properties:\n";
176                const char *h;
177                int i;
178                for (i = 0; i < p.getPropCount(); i++)
[109]179                {
[714]180                        if (i) t += "\n";
181                        t += "   "; t += p.name(i); t += " ("; t += p.id(i); t += ") ";
[743]182                        t += p.friendlyTypeDescr(i);
[714]183                        if (h = p.help(i)) if (*h) { t += " - "; t += h; }
[109]184                }
185        }
[714]186        return t;
[109]187}
188
189/////////////////////////
190
191/////////////////////////////////////
192
[714]193Neuro::Neuro(double _state, double _inertia, double _force, double _sigmo)
194        :PartBase(getDefaultStyle()), state(_state)
[109]195{
[714]196        flags = 0;
197        myclass = 0;
198        knownclass = 1;
199        part_refno = -1; joint_refno = -1;
[109]200}
201
[714]202Neuro::Neuro(void) :PartBase(getDefaultStyle())
[109]203{
[714]204        defassign();
205        state = 0.0;
206        myclass = NULL;
207        myclassname = "N";//default d="N" but f0.def is unable to set this (d is GETSET, not a regular FIELD)
208        knownclass = 0;
209        refno = 0;
210        pos = Pt3D_0; rot = Pt3D_0;
211        parent = 0; part = 0; joint = 0;
212        parentcount = 0;
213        flags = 0;
214        part_refno = -1; joint_refno = -1;
[109]215}
216
217
218Neuro::~Neuro()
219{
[714]220        int i;
221        for (i = 0; i < inputs.size(); i++)
[109]222        {
[714]223                NInput &ni = inputs(i);
224                if (ni.info) delete ni.info;
[109]225        }
226}
227
[899]228SString **Neuro::inputInfo(int i)
[109]229{
[714]230        if (i >= getInputCount()) return 0;
231        return &inputs(i).info;
[109]232}
233
[899]234void Neuro::setInputInfo(int i, const SString &name, const SString &value)
[109]235{
[714]236        SString **s = inputInfo(i);
237        if (!s) return;
238        if (!*s) *s = new SString();
239        strSetField(**s, name, value);
[109]240}
241
[899]242void Neuro::setInputInfo(int i, const SString &name, int value)
[109]243{
[714]244        setInputInfo(i, name, SString::valueOf(value));
[109]245}
246
[899]247void Neuro::setInputInfo(int i, const SString &name, double value)
[109]248{
[714]249        setInputInfo(i, name, SString::valueOf(value));
[109]250}
251
252SString Neuro::getInputInfo(int i)
253{
[714]254        SString **s = inputInfo(i);
255        if (!s) return SString();
256        if (!*s) return SString();
257        return **s;
[109]258}
259
[899]260SString Neuro::getInputInfo(int i, const SString &name)
[109]261{
[714]262        SString **s = inputInfo(i);
263        if (!s) return SString();
264        if (!*s) return SString();
265        return strGetField(**s, name);
[109]266}
267
[899]268void Neuro::operator=(const Neuro &src)
[109]269{
[714]270        refno = src.refno;
271        state = src.state;
272        part_refno = -1;
273        joint_refno = -1;
274        pos = src.pos; rot = src.rot;
275        parent = 0; part = 0; joint = 0;
276        parentcount = 0;
277        flags = 0;
278        myclass = src.myclass;
279        knownclass = src.knownclass;
280        myclassname = src.myclassname;
281        myclassparams = src.myclassparams;
[109]282}
283
284void Neuro::attachToPart(int i)
[714]285{
286        attachToPart((i >= 0) ? owner->getPart(i) : 0);
287}
[109]288
289void Neuro::attachToJoint(int i)
[714]290{
291        attachToJoint((i >= 0) ? owner->getJoint(i) : 0);
292}
[109]293
294int Neuro::getClassCount()
[714]295{
296        return NeuroLibrary::staticlibrary.getClassCount();
297}
[109]298
[899]299NeuroClass *Neuro::getClass(int classindex)
[714]300{
301        return NeuroLibrary::staticlibrary.getClass(classindex);
302}
[109]303
[899]304NeuroClass *Neuro::getClass(const SString &classname)
[714]305{
306        return NeuroLibrary::staticlibrary.findClass(classname);
307}
[109]308
[899]309int Neuro::getClassIndex(const NeuroClass *nc)
[714]310{
[899]311        return NeuroLibrary::staticlibrary.classes.find((void *)nc);
[714]312}
[109]313
[899]314NeuroClass *Neuro::getClass()
[109]315{
[714]316        checkClass();
317        return myclass;
[109]318}
319
[899]320void Neuro::setClass(NeuroClass *cl)
[109]321{
[714]322        myclass = cl;
323        myclassname = cl->getName();
324        knownclass = 1;
[109]325}
326
327SString Neuro::getClassName(int classindex)
328{
[714]329        NeuroClass *cl = NeuroLibrary::staticlibrary.getClass(classindex);
330        return cl ? cl->getName() : SString();
[109]331}
332
[899]333void Neuro::setDetails(const SString &details)
[109]334{
[714]335        int colon = details.indexOf(':');
336        if (colon >= 0) { myclassname = details.substr(0, colon); myclassparams = details.substr(colon + 1); }
337        else { myclassname = details; myclassparams = 0; }
338        knownclass = 0;
[109]339}
340
341SString Neuro::getDetails()
342{
[714]343        SString ret = getClassName();
[973]344        if (myclassparams.length()) { if (!ret.length()) ret = "N"; ret += ":"; ret += myclassparams; }
[714]345        return ret;
[109]346}
347
348void Neuro::checkClass()
349{
[714]350        if (knownclass) return;
351        myclass = getClass(myclassname);
352        knownclass = 1;
[109]353}
354
355SyntParam Neuro::classProperties(bool handle_defaults_when_saving)
356{
[714]357        NeuroClass *cl = getClass();
358        ParamEntry *pe = cl ? cl->getParamTab() : emptyParamTab;
359        return SyntParam(pe, &myclassparams, handle_defaults_when_saving);
[109]360}
361
362SString Neuro::getClassName()
363{
[714]364        return myclassname;
[109]365}
366
[899]367void Neuro::setClassName(const SString &clazz)
[109]368{
[714]369        myclassname = clazz;
370        knownclass = 0;
[109]371}
372
[899]373int Neuro::addInput(Neuro *child, double weight, const SString *info)
[109]374{
[973]375        inputs += NInput(child, weight, (info && (info->length())) ? new SString(*info) : 0);
[714]376        child->parentcount++;
377        if (child->parentcount == 1) { child->parent = this; }
378        return inputs.size() - 1;
[109]379}
380
[899]381int Neuro::findInput(Neuro *child) const
[109]382{
[714]383        for (int i = 0; i < inputs.size(); i++)
384                if (inputs(i).n == child) return i;
385        return -1;
[109]386}
387
[899]388Neuro *Neuro::getInput(int i, double &weight) const
[109]389{
[714]390        if (i >= getInputCount()) return 0;
391        NInput &inp = inputs(i);
392        weight = inp.weight;
393        return inp.n;
[109]394}
395
396double Neuro::getInputWeight(int i) const
397{
[714]398        return inputs(i).weight;
[109]399}
400
[714]401void Neuro::setInputWeight(int i, double w)
[109]402{
[714]403        inputs(i).weight = w;
[109]404}
405
[899]406void Neuro::setInput(int i, Neuro *n)
[109]407{
[714]408        NInput &inp = inputs(i);
409        inp.n = n;
[109]410}
411
[899]412void Neuro::setInput(int i, Neuro *n, double w)
[109]413{
[714]414        NInput &inp = inputs(i);
415        inp.n = n;
416        inp.weight = w;
[109]417}
418
419void Neuro::removeInput(int refno)
420{
[714]421        Neuro *child = getInput(refno);
422        child->parentcount--;
423        if (child->parent == this) child->parent = 0;
424        SString *s = inputs(refno).info;
425        if (s) delete s;
426        inputs.remove(refno);
[109]427}
428
[899]429int Neuro::removeInput(Neuro *child)
[109]430{
[714]431        int i = findInput(child);
432        if (i >= 0) removeInput(i);
433        return i;
[109]434}
435
436int Neuro::getOutputsCount() const
437{
[714]438        int c = 0;
439        for (int i = 0; i < owner->getNeuroCount(); i++)
440                for (int j = 0; j < owner->getNeuro(i)->getInputCount(); j++) c += owner->getNeuro(i)->getInput(j) == this;
441        return c;
[109]442}
443
444int Neuro::isOldEffector()
445{
[714]446        static SString bend("|"), rot("@");
447        return ((getClassName() == bend) || (getClassName() == rot));
[109]448}
449
450int Neuro::isOldReceptor()
451{
[714]452        static SString g("G"), t("T"), s("S");
453        return ((getClassName() == g) || (getClassName() == t) || (getClassName() == s));
[109]454}
455
456int Neuro::isOldNeuron()
457{
[714]458        static SString n("N");
459        return (getClassName() == n);
[109]460}
461
462int Neuro::isNNConnection()
463{
[714]464        static SString conn("-");
465        return (getClassName() == conn);
[109]466}
467
[899]468int Neuro::findInputs(SList &result, const char *classname, const Part *part, const Joint *joint) const
[109]469{
[714]470        Neuro *nu;
471        SString cn(classname);
472        int n0 = result.size();
473        for (int i = 0; nu = getInput(i); i++)
[109]474        {
[714]475                if (part)
476                        if (nu->part != part) continue;
477                if (joint)
478                        if (nu->joint != joint) continue;
479                if (classname)
480                        if (nu->getClassName() != cn) continue;
[899]481                result += (void *)nu;
[109]482        }
[714]483        return result.size() - n0;
[109]484}
485
[899]486int Neuro::findOutputs(SList &result, const char *classname, const Part *part, const Joint *joint) const
[109]487{ // not very efficient...
[714]488        Neuro *nu, *inp;
489        SString cn(classname);
490        SList found;
491        int n0 = result.size();
492        for (int i = 0; nu = getModel().getNeuro(i); i++)
[109]493        {
[714]494                if (part)
495                        if (nu->part != part) continue;
496                if (joint)
497                        if (nu->joint != joint) continue;
498                if (classname)
499                        if (inp->getClassName() != cn) continue;
500                for (int j = 0; inp = nu->getInput(j); j++)
501                        if (inp == this)
[109]502                        {
[899]503                                result += (void *)nu;
504                                break;
[109]505                        }
506        }
[714]507        return result.size() - n0;
[109]508}
509
510void Neuro::get_inputCount(PARAMGETARGS)
[714]511{
512        ret->setInt(inputs.size());
513}
[109]514
[714]515void Neuro::p_getInputNeuroDef(ExtValue *args, ExtValue *ret)
[109]516{
[714]517        int i = args->getInt();
518        if ((i < 0) || (i >= inputs.size()))
519                ret->setEmpty();
520        else
521                ret->setObject(ExtObject(&Neuro::getStaticParam(), inputs(i).n));
[109]522}
523
[714]524void Neuro::p_getInputWeight(ExtValue *args, ExtValue *ret)
[109]525{
[714]526        int i = args->getInt();
527        if ((i < 0) || (i >= inputs.size()))
528                ret->setEmpty();
529        else
530                ret->setDouble(inputs(i).weight);
[109]531}
532
[714]533void Neuro::p_getInputNeuroIndex(ExtValue *args, ExtValue *ret)
[109]534{
[714]535        int i = args->getInt();
536        if ((i < 0) || (i >= inputs.size()))
537                ret->setInt(-1);
538        else
539                ret->setInt(inputs(i).n->refno);
[109]540}
541
542void Neuro::get_classObject(PARAMGETARGS)
543{
[288]544#ifndef SDK_WITHOUT_FRAMS
[714]545        NeuroClassExt::makeStaticObject(ret, getClass());
[109]546#endif
547}
548
549///////////////////////////////////////
550
551SString Part::getDefaultStyle()
[714]552{
553        return SString("part");
554}
[109]555SString Joint::getDefaultStyle()
[714]556{
557        return SString("joint");
558}
[109]559/*
560const SString& Neuro::getDefaultStyle()
561{static SString s("neuro"); return s;}
562const SString& NeuroItem::getDefaultStyle()
563{static SString s("neuroitem"); return s;}
564*/
565SString Neuro::getDefaultStyle()
[714]566{
567        return SString("neuro");
568}
[109]569
[714]570Part::Part(enum Shape s) :PartBase(getDefaultStyle())
[109]571{
[714]572        o = Orient_1;
573        p = Pt3D_0;
574        rot = Pt3D_0;
575        flags = 0;
576        defassign();
577        shape = s;
578        mass = 1;
[109]579}
580
[899]581void Part::operator=(const Part &src)
[109]582{
[714]583        p = src.p; o = src.o;
584        flags = src.flags;
585        mass = src.mass; density = src.density;
586        friction = src.friction;
587        ingest = src.ingest;
588        assim = src.assim;
589        size = src.size;
590        rot = src.rot;
591        refno = src.refno;
592        vcolor = src.vcolor;
593        vis_style = src.vis_style;
594        shape = src.shape;
595        scale = src.scale;
596        hollow = src.hollow;
[109]597}
598
599void Part::setOrient(const Orient &_o)
600{
[714]601        o = _o;
602        rot.getAngles(o.x, o.z);
[109]603}
604
605void Part::setRot(const Pt3D &r)
606{
[714]607        rot = r;
608        o = Orient_1;
609        o.rotate(rot);
[109]610}
611
[714]612void Part::setPositionAndRotationFromAxis(const Pt3D &p1, const Pt3D &p2)
[109]613{
[714]614        Pt3D x = p2 - p1;
615        Pt3D dir(x.y, x.z, x.x);
[899]616        p = p1 + x * 0.5;
[714]617        rot.getAngles(x, dir);
[109]618}
619
[899]620Param &Part::getStaticParam()
[109]621{
[714]622        static Param p(f0_part_paramtab, 0, "Part");
623        return p;
[109]624}
625
[977]626const char* Part::getShapeName(Shape sh)
627{
628        switch (sh)
629        {
[999]630        case SHAPE_BALL: return "ball[-and-stick]";
[977]631        case SHAPE_ELLIPSOID: return "ellipsoid";
632        case SHAPE_CUBOID: return "cuboid";
633        case SHAPE_CYLINDER: return "cylinder";
[109]634
[977]635        default:
636                return "unknown shape";
637        }
638}
639
[109]640///////////////////////////
641
[714]642Joint::Joint() :PartBase(getDefaultStyle())
[109]643{
[714]644        rot = Pt3D_0;
645        defassign();
646        d.x = JOINT_DELTA_MARKER;
647        d.y = JOINT_DELTA_MARKER;
648        d.z = JOINT_DELTA_MARKER;
649        part1 = 0; part2 = 0;
650        flags = 0;
651        usedelta = 0;
[109]652}
653
[899]654void Joint::operator=(const Joint &src)
[109]655{
[714]656        rot = src.rot;
657        d = src.d;
658        shape = src.shape;
[915]659        hinge_pos = src.hinge_pos;
660        hinge_rot = src.hinge_rot;
[926]661        hinge_limit_x[0] = src.hinge_limit_x[0];
662        hinge_limit_x[1] = src.hinge_limit_x[1];
663        hinge_limit_y[0] = src.hinge_limit_y[0];
664        hinge_limit_y[1] = src.hinge_limit_y[1];
[714]665        stamina = src.stamina;
666        stif = src.stif; rotstif = src.rotstif;
667        vis_style = src.vis_style;
668        vcolor = src.vcolor;
669        part1 = 0; part2 = 0;
670        flags = src.flags;
671        usedelta = src.usedelta;
672        refno = src.refno;
[109]673}
674
[899]675void Joint::attachToParts(Part *p1, Part *p2)
[109]676{
[714]677        part1 = p1;
678        part2 = p2;
679        if (p1 && p2)
[109]680        {
[714]681                o = rot;
682                if (usedelta)
[109]683                {
[714]684                        p1->o.transform(p2->o, o);
685                        //              p2->o.x=p1->o/o.x; p2->o.y=p1->o/o.y; p2->o.z=p1->o/o.z;
686                        p2->p = p2->o.transform(d) + p1->p;
[109]687                }
688        }
689}
690
[714]691void Joint::attachToParts(int p1, int p2)
[109]692{
[714]693        attachToParts((p1 >= 0) ? owner->getPart(p1) : 0, (p2 >= 0) ? owner->getPart(p2) : 0);
[109]694}
695
696void Joint::resetDelta()
697{
[714]698        d = Pt3D(JOINT_DELTA_MARKER, JOINT_DELTA_MARKER, JOINT_DELTA_MARKER);
[109]699}
700
[114]701void Joint::resetDeltaMarkers()
[109]702{
[714]703        if (d.x == JOINT_DELTA_MARKER) d.x = 0;
704        if (d.y == JOINT_DELTA_MARKER) d.y = 0;
705        if (d.z == JOINT_DELTA_MARKER) d.z = 0;
[109]706}
707
[114]708void Joint::useDelta(bool use)
[109]709{
[714]710        usedelta = use;
[114]711}
712
713bool Joint::isDelta()
714{
[714]715        return usedelta;
[109]716}
717
[899]718Param &Joint::getStaticParam()
[109]719{
[714]720        static Param p(f0_joint_paramtab, 0, "Joint");
721        return p;
[109]722}
723
[977]724const char* Joint::getShapeName(Shape sh)
725{
726        switch (sh)
727        {
[999]728        case SHAPE_STICK: return "[ball-and-]stick";
[977]729        case SHAPE_FIXED: return "fixed";
730        case SHAPE_HINGE_X: return "hinge x";
731        case SHAPE_HINGE_XY: return "hinge xy";
732
733        default:
734                return "unknown shape";
735        }
736}
737
738
[109]739/////////////////////////////////////////////////////////////////
740
741#include F0_CLASSES_FILE
742
743////////////////////////////////////////
744
[714]745ParamEntry Neuro::emptyParamTab[] =
[109]746{
[714]747        { "Undefined Neuro", 1, 0, "?", },
748        { 0, 0, 0, },
[109]749};
750
751Param Part::extraProperties()
752{
[714]753        return Param(f0_part_xtra_paramtab, this);
[109]754}
755
756Param Joint::extraProperties()
757{
[714]758        return Param(f0_joint_xtra_paramtab, this);
[109]759}
760
761Param Neuro::extraProperties()
762{
[714]763        return Param(f0_neuro_xtra_paramtab, this);
[109]764}
765
766Param Part::properties()
767{
[714]768        return Param(f0_part_paramtab, this);
[109]769}
770
771Param Joint::properties()
772{
[714]773        return Param(usedelta ? f0_joint_paramtab : f0_nodeltajoint_paramtab, this);
[109]774}
775
776Param Neuro::properties()
777{
[714]778        return Param(f0_neuro_paramtab, this);
[109]779}
780
[714]781class NeuroExtParamTab : public ParamTab
[109]782{
[714]783public:
784        NeuroExtParamTab() :ParamTab(f0_neuro_paramtab)
[109]785        {
786#define FIELDSTRUCT NeuroExt
[952]787                ParamEntry entries[] = {
788                 { "class", 2, 0, "neuro class", "s", GETSET(neuroclass) },
[973]789                 { "liveNeuro", 2, 1, "live Neuro object", "oNeuro", GETONLY(liveNeuro) } };
[109]790#undef FIELDSTRUCT
[973]791                for (auto& e : entries) add(&e);
[109]792
793#define FIELDSTRUCT Neuro
[714]794                ParamEntry entry2 = { "state", 2, 0, "state", "f", FIELD(state) };
[109]795#undef FIELDSTRUCT
[714]796                add(&entry2);
[109]797        }
798};
799
[899]800Param &Neuro::getStaticParam()
[109]801{
[714]802        static Param p(f0_neuro_paramtab, 0, "NeuroDef");
803        return p;
[109]804}
805
806////////////////////////
807
808NeuroConn::NeuroConn()
809{
[714]810        defassign();
[109]811}
812
813//////////////////////////////////////
814
815ParamEntry *NeuroExt::getParamTab()
816{
[714]817        static NeuroExtParamTab tab;
818        return tab.getParamTab();
[109]819}
820
821void NeuroExt::get_neuroclass(PARAMGETARGS)
[714]822{
823        ret->setString(getClassName());
824}
[109]825
826int NeuroExt::set_neuroclass(PARAMSETARGS)
[714]827{
828        setClassName(arg->getString()); return PSET_CHANGED;
829}
[952]830
831void NeuroExt::get_liveNeuro(PARAMGETARGS)
832{
833#ifndef SDK_WITHOUT_FRAMS
[973]834        NeuroNetImpl::getLiveNeuroObject(this, ret);
[952]835#endif
836}
Note: See TracBrowser for help on using the repository browser.