#include "ordeviceinput_device.h"
#include "ordeviceinput_layout.h"
#define ORDEVICEINPUT__LAYOUT ORDeviceInputLayout
ORDEVICEINPUT__CLASSSTR,
bool ORDeviceInputLayout::FBCreate()
{
mDevice = ((ORDeviceInput *)(FBDevice *)Device);
UICreate ();
UIConfigure ();
UIReset ();
mDevice->OnStatusChange.Add (
this,(
FBCallback)&ORDeviceInputLayout::EventDeviceStatusChange );
mSystem.OnUIIdle.Add (
this,(
FBCallback)&ORDeviceInputLayout::EventUIIdle );
return true;
}
void ORDeviceInputLayout::FBDestroy()
{
mSystem.OnUIIdle.Remove (
this,(
FBCallback)&ORDeviceInputLayout::EventUIIdle );
mDevice->OnStatusChange.Remove (
this,(
FBCallback)&ORDeviceInputLayout::EventDeviceStatusChange );
}
void ORDeviceInputLayout::UICreate()
{
int lS, lH;
lS = 4;
lH = 25;
AddRegion (
"MainLayout",
"MainLayout", lS,
kFBAttachLeft,
"TabPanel", 1.00,
SetControl ( "TabPanel", mTabPanel );
SetControl ( "MainLayout", mLayoutMarkers );
UICreateLayout0();
UICreateLayout1();
}
void ORDeviceInputLayout::UICreateLayout0()
{
mLayoutMarkers.AddRegion( "SpreadMarkers", "SpreadMarkers",
mLayoutMarkers.SetControl( "SpreadMarkers", mSpreadMarkers );
}
void ORDeviceInputLayout::UICreateLayout1()
{
int lS, lW, lH;
lS = 4;
lW = 200;
lH = 18;
mLayoutInformation.AddRegion ( "LabelInformation", "LabelInformation",
mLayoutInformation.SetControl( "LabelInformation", mLabelInformation );
}
void ORDeviceInputLayout::UIConfigure()
{
mTabPanel.Items.SetString("Markers~Information");
mTabPanel.OnChange.Add(
this, (
FBCallback)&ORDeviceInputLayout::EventTabPanelChange );
UIConfigureLayout0();
UIConfigureLayout1();
}
void ORDeviceInputLayout::UIConfigureLayout0()
{
}
void ORDeviceInputLayout::UIConfigureLayout1()
{
mLabelInformation.Caption = "Information...";
}
void ORDeviceInputLayout::UIRefresh()
{
UIRefreshSpreadSheet();
}
void ORDeviceInputLayout::UIRefreshSpreadSheet()
{
for(
int i=0;
i<mDevice->GetChannelCount();
i++)
{
mSpreadMarkers.SetCell(
i, 0, mDevice->GetDataTX(
i) );
mSpreadMarkers.SetCell(
i, 1, mDevice->GetDataTY(
i) );
mSpreadMarkers.SetCell(
i, 2, mDevice->GetDataTZ(
i) );
mSpreadMarkers.SetCell(
i, 3, mDevice->GetDataRX(
i) );
mSpreadMarkers.SetCell(
i, 4, mDevice->GetDataRY(
i) );
mSpreadMarkers.SetCell(
i, 5, mDevice->GetDataRZ(
i) );
}
}
void ORDeviceInputLayout::UIReset()
{
UIResetSpreadSheet();
}
void ORDeviceInputLayout::UIResetSpreadSheet()
{
mSpreadMarkers.Clear();
int lColumnIndex = -1;
mSpreadMarkers.GetColumn(lColumnIndex).Width = 200;
mSpreadMarkers.ColumnAdd ("PosX");
lColumnIndex++;
mSpreadMarkers.GetColumn(lColumnIndex).Width = 60;
mSpreadMarkers.ColumnAdd ("PosY");
lColumnIndex++;
mSpreadMarkers.GetColumn(lColumnIndex).Width = 60;
mSpreadMarkers.ColumnAdd ("PosZ");
lColumnIndex++;
mSpreadMarkers.GetColumn(lColumnIndex).Width = 60;
mSpreadMarkers.ColumnAdd ("RotX");
lColumnIndex++;
mSpreadMarkers.GetColumn(lColumnIndex).Width = 60;
mSpreadMarkers.ColumnAdd ("RotY");
lColumnIndex++;
mSpreadMarkers.GetColumn(lColumnIndex).Width = 60;
mSpreadMarkers.ColumnAdd ("RotZ");
lColumnIndex++;
mSpreadMarkers.GetColumn(lColumnIndex).Width = 60;
for (i=0;i<mDevice->GetChannelCount();i++)
{
mSpreadMarkers.RowAdd( mDevice->GetChannelName(i),
i );
mSpreadMarkers.GetCell(i,lColumnIndex).ReadOnly = true;
}
}
void ORDeviceInputLayout::EventTabPanelChange(
HISender pSender,
HKEvent pEvent )
{
switch( mTabPanel.ItemIndex )
{
case 0: SetControl("MainLayout", mLayoutMarkers ); break;
case 1: SetControl("MainLayout", mLayoutInformation ); break;
}
}
void ORDeviceInputLayout::EventDeviceStatusChange(
HISender pSender,
HKEvent pEvent )
{
UIReset();
}
{
if( mDevice->Online )
{
UIRefresh();
}
}