#include "ortoolcluster_tool.h"
#define ORTOOLCLUSTER__CLASS ORTOOLCLUSTER__CLASSNAME
#define ORTOOLCLUSTER__LABEL "Cluster"
#define ORTOOLCLUSTER__DESC "OR - Cluster Tool Description"
ORTOOLCLUSTER__LABEL,
ORTOOLCLUSTER__DESC,
bool ORToolCluster::FBCreate()
{
StartSize[0] = 330;
StartSize[1] = 200;
UICreate ();
UIConfigure ();
UIReset ();
OnShow.Add(
this, (
FBCallback) &ORToolCluster::EventToolShow );
OnIdle.Add(
this, (
FBCallback) &ORToolCluster::EventToolIdle );
mApplication.OnFileNewCompleted.Add(
this, (
FBCallback)&ORToolCluster::EventListen );
mApplication.OnFileOpenCompleted.Add(
this, (
FBCallback)&ORToolCluster::EventListen );
mApplication.OnFileNew.Add(
this, (
FBCallback)&ORToolCluster::EventSuspend );
mApplication.OnFileOpen.Add(
this, (
FBCallback)&ORToolCluster::EventSuspend );
mApplication.OnFileExit.Add(
this, (
FBCallback)&ORToolCluster::EventSuspend );
return true;
}
void ORToolCluster::FBDestroy()
{
mApplication.OnFileNewCompleted.Remove(
this, (
FBCallback)&ORToolCluster::EventListen );
mApplication.OnFileOpenCompleted.Remove(
this, (
FBCallback)&ORToolCluster::EventListen );
mApplication.OnFileNew.Remove(
this, (
FBCallback)&ORToolCluster::EventSuspend );
mApplication.OnFileOpen.Remove(
this, (
FBCallback)&ORToolCluster::EventSuspend );
mApplication.OnFileExit.Remove(
this, (
FBCallback)&ORToolCluster::EventSuspend );
}
void ORToolCluster::UICreate()
{
int lW = 100;
int lS = 4;
int lH = 23;
AddRegion( "LabelDirections", "LabelDirections",
AddRegion( "LabelCluster", "LabelCluster",
AddRegion( "ContainerCluster", "ContainerCluster",
AddRegion( "Inspector", "Inspector",
SetControl( "LabelDirections", mLabelDirections );
SetControl( "LabelCluster", mLabelCluster );
SetControl( "ContainerCluster", mContainerCluster );
SetControl( "Inspector", mInspector );
}
void ORToolCluster::UIConfigure()
{
mLabelDirections.Caption = "Drag a model to see a simple use of FBCluster.";
mContainerCluster.OnDragAndDrop.Add(
this, (
FBCallback) &ORToolCluster::EventContainerClusterDragAndDrop );
mLabelCluster.Caption = "Cluster (Drag)";
mInspector.Component =
NULL;
}
void ORToolCluster::UIReset()
{
}
void ORToolCluster::UIRefresh()
{
}
{
FBEventShow lEvent( pEvent );
if( lEvent.Shown )
{
UIReset();
}
else
{
}
}
{
UIRefresh();
}
void ORToolCluster::EventContainerClusterDragAndDrop(
HISender pSender,
HKEvent pEvent )
{
FBEventDragAndDrop lDragAndDrop( pEvent );
switch( lDragAndDrop.State )
{
{
lDragAndDrop.Accept();
}
break;
{
mHdlModel = (FBModel*) lDragAndDrop.Get(0);
if( mHdlModel->Is( FBModel::TypeInfo ) )
{
SetClusterModel( mHdlModel );
FBCluster* cluster = mHdlModel->Cluster;
if (cluster && cluster->LinkGetCount())
{
FBString linkName;
FBModel* linkModel;
int numLinks, numVerts, vertIndex, vertWeight;
numLinks = cluster->LinkGetCount();
for (
int n=0;
n < numLinks;
n++)
{
cluster->ClusterBegin(
n);
linkName = cluster->LinkGetName(
n);
linkModel = cluster->LinkGetModel(
n);
numVerts = cluster->VertexGetCount();
for (
int v=0;
v < numVerts;
v++)
{
vertIndex = cluster->VertexGetNumber(
v);
vertWeight = cluster->VertexGetWeight(
v);
}
cluster->ClusterEnd();
}
}
}
else
{
}
}
break;
}
}
{
mSystem.OnConnectionStateNotify.Add(
this, (
FBCallback)&ORToolCluster::ConnectionStateNotify);
}
{
mSystem.OnConnectionStateNotify.Remove(
this, (
FBCallback)&ORToolCluster::ConnectionStateNotify);
}
void ORToolCluster::SetClusterModel( FBModel* lModel )
{
mInspector.Component =
NULL;
mContainerCluster.Items.Clear();
if( lModel )
{
mContainerCluster.Items.Add( lModel->Name, (kReference)lModel );
mInspector.Component = lModel->Cluster;
}
}
{
FBEventConnectionStateNotify lEvent(pEvent);
{
FBPlug* lPlug = lEvent.Plug;
if( lPlug->Is( FBModel::TypeInfo ) && (FBModel*)lPlug == mHdlModel )
{
SetClusterModel( mHdlModel );
}
}
}