//---------------------------------------------------------------------------------------------------------------------- void CTRNNViz::init() { NodeGroup::init(); //m_font = ci::Font(ci::app::loadResource("pf_tempesta_seven.ttf"), 8); m_font = ci::Font("PF Tempesta Seven", 8); m_mode = kRM_Layers; m_weightMode = 0; m_selected = -1; m_angle = 0; m_labelHeight = 16; m_padding = 3; m_lineHeight = m_labelHeight - m_padding; m_unitSize = m_width / m_ctrnn->getSize(); m_textColor = ci::Color(1,1,1); m_labelColor = ci::ColorA(0.0f, 0.0f, 0.0f, 0.5f); float buttonSize = m_labelHeight - 2 * m_padding; ci::Vec2f butPos(m_width - buttonSize - m_padding, m_padding); m_modeButton = ci::Rectf(butPos.x, butPos.y, butPos.x + buttonSize, butPos.y + buttonSize); m_label2y = ((int)(m_labelHeight + 2 * m_padding + m_unitSize)) ; m_label3y = m_label2y + m_labelHeight + m_padding + m_width + m_padding; m_height = m_label3y + m_labelHeight + m_padding + 3 * m_lineHeight + 2 * m_padding; m_weightModeButton = ci::Rectf(butPos.x, m_label2y + butPos.y, butPos.x + buttonSize, m_label2y + butPos.y + buttonSize); // output vector int N = m_ctrnn->getSize(); m_outputs = new VectorView<double>(m_ctrnn->getOutputs(), N, m_width, 1.0); m_outputs->translate(Vec4f(0, m_labelHeight + m_padding, 0, 1)); m_children.push_back(m_outputs); // weight matrix m_weights = new MatrixView<double>(m_ctrnn->getWeights(), N, N, m_width, -1); m_weights->translate(Vec4f(0, m_label2y + m_labelHeight + m_padding , 0, 1)); m_children.push_back(m_weights); // neuronViz m_neuronViz = new CTRNNNeuronViz(m_ctrnn, m_width, false); m_neuronViz->translate(ci::Vec4f(m_width / 2, m_label2y - m_labelHeight + (m_label3y - m_label2y) / 2, 0, 1)); m_children.push_back(m_neuronViz); // wheelViz m_wheelViz = new CTRNNWheelViz(m_ctrnn, m_width, false); m_wheelViz->translate(ci::Vec4f(m_width / 2, m_label3y / 2, 0, 1)); m_children.push_back(m_wheelViz); // layerViz if(m_topology) { m_layerViz = new CTRNNLayerViz(m_ctrnn, m_topology, m_width, false); m_layerViz->translate(ci::Vec4f(m_width / 2, m_label3y / 2, 0, 1)); m_children.push_back(m_layerViz); } }
// ///////////////////////////////////////////////////////////////// // // ///////////////////////////////////////////////////////////////// Point3 SliderControl::CalculateButtonPositionFromSlider() { Point3 butPos(VGetPosition()); F32 sliderLeftX, sliderRightX; F32 butW = GetProjectedButtonWidth(); sliderLeftX = butPos.GetX(); sliderRightX = sliderLeftX + VGetWidth() - butW; F32 buttonX = InterpolateFloat(m_sliderPos, sliderLeftX, sliderRightX); if(buttonX + butW > sliderRightX) { buttonX -= (buttonX + butW) - sliderRightX; } butPos.SetX(buttonX); return (butPos); }