void 
MarLpcWindow::ctrlChanged(MarControlPtr cname)
{
	string name = cname->getName();
	if (cname.isEqual(posPtr_))
	{
		mrs_real fval = cname->to<mrs_natural>()  / (512.0 * 40.0);
		if (posSlider_->isSliderDown() == false)
		{
			posSlider_->blockSignals(true);
			posSlider_->setValue((int)fval);
			posSlider_->blockSignals(false);
		}
		posControl_->updControl(cname); 
	}

	/*if (cname.isEqual(frequencyPolePtr_)) 
	{
	frequencyPoleSlider_->blockSignals(true);
	mrs_real fval = cname->to<mrs_real>();
	int val = (int)(fval * 50.0);
	frequencyPoleSlider_->setValue(val);
	frequencyPoleSlider_->blockSignals(false);
	frequencyPoleControl_->updControl(cname);
	}

	if (cname.isEqual(amplitudePolePtr_)) 
	{
	amplitudePoleSlider_->blockSignals(true);
	mrs_real fval = cname->to<mrs_real>();
	int val = (int)(fval * 50.0);
	amplitudePoleSlider_->setValue(val);
	amplitudePoleSlider_->blockSignals(false);
	amplitudePoleControl_->updControl(cname);
	}*/
}
void MarControlDiagramDisplay::loadMarControl(MarControlPtr ctrl) {
  isLoaded_ = true;
  nodes.clear();
  linkedControls_.clear();
  linkedControls_ = ctrl->getLinks();



  cout<<endl;
  string auxName1, auxName2;
  cout<<endl<<"--------------------------";
  cout<<endl<<"linked controls list:";
  for(int i=0; i<linkedControls_.size(); i++) {
    auxName1 = linkedControls_[i].first->getMarSystem()->getName() + "/" + linkedControls_[i].first->getName();
    auxName2 = linkedControls_[i].second->getMarSystem()->getName() + "/" + linkedControls_[i].second->getName();
    cout<<endl<<auxName1<<" -> "<<auxName2;
  }


  MarControlWidget* aux1;
  MarControlWidget* aux2;
  MarControlDiagramNode* aux3;
  MarControlDiagramNode* aux4;

  aux3 = NULL;

  bool highlight1;
  bool highlight2;

  for(int i=0; i<linkedControls_.size(); i++) {

    highlight1 = false;
    highlight2 = false;

    aux1 = msysw_->getTopMostParent()->ctrlMap_[linkedControls_[i].first];
    aux2 = msysw_->getTopMostParent()->ctrlMap_[linkedControls_[i].second];


    if(ctrl.isEqual(linkedControls_[i].first)) {
      highlight1 = true;
    }

    if(ctrl.isEqual(linkedControls_[i].second)) {
      highlight2 = true;
    }

    for(int j=0; j<nodes.size(); j++) {

      aux3 = nodeExists(nodes[j], aux2);

    }
    if(aux3 == NULL) {

      nodes.push_back(new MarControlDiagramNode(aux2, env_, NULL, highlight2));
      if(aux1 != aux2) {

        nodes[nodes.size() - 1]->addLinker(new MarControlDiagramNode(aux1, env_, nodes[nodes.size() - 1], highlight1));
      }
    }
    else {
      aux3->addLinker(new MarControlDiagramNode(aux1, env_, aux3, highlight1));
    }
  }
  organizeDiagram();
  debugger();
}