#include "ordeviceoptical_layout.h"
#define ORDEVICEOPTICALTEMPLATE__LAYOUT ORDeviceOptical_Template_Layout
ORDEVICEOPTICALTEMPLATE__CLASSSTR,
bool ORDeviceOptical_Template_Layout::FBCreate()
{
bool lSuccess;
lSuccess = FBDeviceOpticalLayout::FBCreate();
if( lSuccess )
{
mDeviceOptical = ((ORDeviceOptical_Template *)(FBDevice *)Device);
UICreate ();
UIConfigure ();
UIReset ();
mSystem.OnUIIdle.Add (
this,(
FBCallback) &ORDeviceOptical_Template_Layout::EventUIIdle );
mDeviceOptical->OnStatusChange.Add (
this,(
FBCallback) &ORDeviceOptical_Template_Layout::EventDeviceStatusChange );
}
return lSuccess;
}
void ORDeviceOptical_Template_Layout::FBDestroy()
{
mSystem.OnUIIdle.Remove (
this,(
FBCallback) &ORDeviceOptical_Template_Layout::EventUIIdle );
mDeviceOptical->OnStatusChange.Remove (
this,(
FBCallback) &ORDeviceOptical_Template_Layout::EventDeviceStatusChange );
}
void ORDeviceOptical_Template_Layout::UICreate()
{
int lS, lH;
lS = 5;
lH = 25;
AddRegion (
"TabPanel",
"TabPanel", 5,
kFBAttachRight,
"StandardParams", 1.00,
AddRegion (
"MainLayout",
"MainLayout", lS,
kFBAttachLeft,
"TabPanel", 1.00,
SetControl ( "Params_Border", mLayoutCommunication );
SetControl ( "TabPanel", mTabPanel );
SetControl ( "MainLayout", mLayoutMarkers );
UICreateLayout0();
UICreateLayout1();
UICreateLayout2();
}
void ORDeviceOptical_Template_Layout::UICreateLayout0()
{
mLayoutMarkers.AddRegion( "SpreadMarkers", "SpreadMarkers",
mLayoutMarkers.SetControl( "SpreadMarkers", mSpreadMarkers );
}
void ORDeviceOptical_Template_Layout::UICreateLayout1()
{
int lS = 5;
int lSx = 15;
int lSy = 20;
int lS_y = -15;
int lW = 100;
int lH = 25;
int lHlr = 75;
int lWlr = 250;
int lWrb = 140;
int lSlbx = 30;
int lSlby = 12;
int lWlb = 80;
mLayoutCommunication.AddRegion( "LayoutRegionNetwork", "LayoutRegionNetwork",
mLayoutCommunication.AddRegion( "ButtonNetworkEnable", "ButtonNetworkEnable",
mLayoutCommunication.AddRegion( "LabelNetworkAddress", "LabelNetworkAddress",
mLayoutCommunication.AddRegion( "EditNetworkAddress", "EditNetworkAddress",
mLayoutCommunication.AddRegion( "LabelNetworkPort", "LabelNetworkPort",
mLayoutCommunication.AddRegion( "EditNetworkPort", "EditNetworkPort",
mLayoutCommunication.SetControl( "ButtonNetworkEnable", mButtonNetworkEnable );
mLayoutCommunication.SetControl( "LabelNetworkAddress", mLabelNetworkAddress );
mLayoutCommunication.SetControl( "EditNetworkAddress", mEditNetworkAddress );
mLayoutCommunication.SetControl( "LabelNetworkPort", mLabelNetworkPort );
mLayoutCommunication.SetControl( "EditNetworkPort", mEditNetworkPort );
}
void ORDeviceOptical_Template_Layout::UICreateLayout2()
{
int lS, lW, lH;
lS = 5;
lW = 200;
lH = 25;
mLayoutInformation.AddRegion ( "LabelInformation", "LabelInformation",
mLayoutInformation.AddRegion ( "ButtonCreateRigidBody", "ButtonCreateRigidBody",
mLayoutInformation.SetControl( "LabelInformation", mLabelInformation );
mLayoutInformation.SetControl( "ButtonCreateRigidBody", mButtonCreateRigidBody );
mButtonCreateRigidBody.Caption = "Create RigidBody";
mButtonCreateRigidBody.OnClick.Add(
this, (
FBCallback) &ORDeviceOptical_Template_Layout::EventButtonCreateRigidBodyClick );
}
void ORDeviceOptical_Template_Layout::UIConfigure()
{
mTabPanel.Items.SetString("Markers~Information");
mTabPanel.OnChange.Add(
this, (
FBCallback) &ORDeviceOptical_Template_Layout::EventTabPanelChange );
UIConfigureLayout0();
UIConfigureLayout1();
UIConfigureLayout2();
}
void ORDeviceOptical_Template_Layout::UIConfigureLayout0()
{
}
void ORDeviceOptical_Template_Layout::UIConfigureLayout1()
{
mLayoutCommunication.SetBorder(
"LayoutRegionNetwork",
kFBEmbossBorder,
false,
true,2,1,90.0,0);
mButtonNetworkEnable.Caption = "Use optical test server";
mButtonNetworkEnable.State = mDeviceOptical->GetNetworkUse();
mButtonNetworkEnable.OnClick.Add(
this,(
FBCallback) &ORDeviceOptical_Template_Layout::EventButtonNetworkEnableClick );
mLayoutCommunication.SetBorder(
"EditNetworkAddress",
kFBStandardBorder,
false,
true, 1, 0,90,0);
mLayoutCommunication.SetBorder(
"EditNetworkPort",
kFBStandardBorder,
false,
true, 1, 0,90,0);
mLabelNetworkAddress.Caption = "Address :";
mEditNetworkAddress.Text = mDeviceOptical->GetNetworkAddress();
mEditNetworkAddress.OnChange.Add(
this, (
FBCallback) &ORDeviceOptical_Template_Layout::EventEditNetworkAddressChange );
mLabelNetworkPort.Caption = "Port :";
char lBuffer[40];
sprintf(lBuffer, "%d", mDeviceOptical->GetNetworkPort() );
mEditNetworkPort.Text = lBuffer;
mEditNetworkPort.OnChange.Add(
this, (
FBCallback) &ORDeviceOptical_Template_Layout::EventEditNetworkPortChange );
}
void ORDeviceOptical_Template_Layout::UIConfigureLayout2()
{
mLabelInformation.Caption = "Information...";
}
void ORDeviceOptical_Template_Layout::UIRefresh()
{
UIRefreshSpreadSheet();
}
void ORDeviceOptical_Template_Layout::UIRefreshSpreadSheet()
{
for(
int i=0;
i<mDeviceOptical->GetMarkerCount();
i++)
{
mSpreadMarkers.SetCell(
i, 0, mDeviceOptical->GetDataX(
i) );
mSpreadMarkers.SetCell(
i, 1, mDeviceOptical->GetDataY(
i) );
mSpreadMarkers.SetCell(
i, 2, mDeviceOptical->GetDataZ(
i) );
mSpreadMarkers.SetCell(
i, 3, mDeviceOptical->GetDataO(
i) );
if(mDeviceOptical->GetDataO(
i) == 1.0)
{
int a;
a=0;
}
}
}
void ORDeviceOptical_Template_Layout::UIReset()
{
UIResetSpreadSheet();
}
void ORDeviceOptical_Template_Layout::UIResetSpreadSheet()
{
mSpreadMarkers.Clear();
int lColumnIndex = -1;
mSpreadMarkers.GetColumn(lColumnIndex).Width = 200;
mSpreadMarkers.ColumnAdd ("X");
lColumnIndex++;
mSpreadMarkers.GetColumn(lColumnIndex).Width = 60;
mSpreadMarkers.ColumnAdd ("Y");
lColumnIndex++;
mSpreadMarkers.GetColumn(lColumnIndex).Width = 60;
mSpreadMarkers.ColumnAdd ("Z");
lColumnIndex++;
mSpreadMarkers.GetColumn(lColumnIndex).Width = 60;
mSpreadMarkers.ColumnAdd ("Occlusion");
lColumnIndex++;
mSpreadMarkers.GetColumn(lColumnIndex).Width = 60;
mSpreadMarkers.GetColumn(lColumnIndex).ReadOnly = true;
for (i=0;i<mDeviceOptical->GetMarkerCount();i++)
{
mSpreadMarkers.RowAdd( mDeviceOptical->GetMarkerName(i),
i );
mSpreadMarkers.GetCell(i,lColumnIndex).ReadOnly = true;
}
}
void ORDeviceOptical_Template_Layout::EventTabPanelChange(
HISender pSender,
HKEvent pEvent )
{
switch( mTabPanel.ItemIndex )
{
case 0: SetControl("MainLayout", mLayoutMarkers ); break;
case 1: SetControl("MainLayout", mLayoutInformation ); break;
}
}
void ORDeviceOptical_Template_Layout::EventButtonNetworkEnableClick(
HISender pSender,
HKEvent pEvent )
{
mDeviceOptical->SetNetworkUse(((int)mButtonNetworkEnable.State)==1);
}
void ORDeviceOptical_Template_Layout::EventEditNetworkPortChange(
HISender pSender,
HKEvent pEvent )
{
int lPort;
char lBuffer[40];
sscanf(mEditNetworkPort.Text.AsString(), "%d", &lPort);
mDeviceOptical->SetNetworkPort(lPort);
lPort = mDeviceOptical->GetNetworkPort();
sprintf(lBuffer, "%d", lPort );
mEditNetworkPort.Text = lBuffer;
}
void ORDeviceOptical_Template_Layout::EventEditNetworkAddressChange(
HISender pSender,
HKEvent pEvent )
{
mDeviceOptical->SetNetworkAddress(mEditNetworkAddress.Text.AsString());
mEditNetworkAddress.Text = mDeviceOptical->GetNetworkAddress();
}
void ORDeviceOptical_Template_Layout::EventButtonCreateRigidBodyClick(
HISender pSender,
HKEvent pEvent )
{
mDeviceOptical->RigidBodySetup();
}
void ORDeviceOptical_Template_Layout::EventDeviceStatusChange(
HISender pSender,
HKEvent pEvent )
{
UIReset();
}
void ORDeviceOptical_Template_Layout::EventUIIdle(
HISender pSender,
HKEvent pEvent )
{
if(mDeviceOptical->Online)
{
UIRefresh();
}
}