yankailab / OpenKAI

OpenKAI: A modern framework for unmanned vehicle and robot control
GNU Affero General Public License v3.0
230 stars 93 forks source link

Multiple windows support in same module? #14

Closed GPrathap closed 7 years ago

GPrathap commented 7 years ago

I want to open up multiple windows for visualization purpose in the same module. What would be the optimal way of approaching it?

yankailab commented 7 years ago

Hi GPrathap, this would be the supposed/simplest way:

Make two window instances in kiss:

{ "name":"myView1", "class":"Window", "bInst":1, "w":672, "h":376, .... }

{ "name":"myView2", "class":"Window", "bInst":1, "w":672, "h":376, .... }

And linked both the window into your class instance in kiss:

{ "name":"myClass", "class":"_MyClass", "bInst":1, "Window1":"myView1", "Window2":"myView2", .... }

Then in your own _MyClass, get the windows name and linke them, suppose your class has

Window m_pMyWindow1; Window m_pMyWindow2;

then implement the link function like:

bool _MyClass::link(void) { Kiss pK = (Kiss) m_pKiss;

    string iName = "";
F_INFO(pK->v("Window1", &iName));
m_pMyWin1 = (Window*) (pK->root()->getChildInstByName(&iName));

iName = "";
F_INFO(pK->v("Window2", &iName));
m_pMyWin2 = (Window*) (pK->root()->getChildInstByName(&iName));

return true;

}

Now you can use both windows in the draw function, e.g.

pFrame = m_pMyWindow1->getFrame(); pFrame->update(contents for Window1);

pFrame = m_pMyWindow2->getFrame(); pFrame->update(contents for Window2);

more number of windows can be done similarly.

GPrathap commented 7 years ago

Cool, Thanks, It worked.

You can close this issue.