aboutsummaryrefslogtreecommitdiff
path: root/generic/OverlapMan.c
diff options
context:
space:
mode:
authorlecoanet2002-02-20 13:00:57 +0000
committerlecoanet2002-02-20 13:00:57 +0000
commit86eeded9ecb3d3de9e5cbb7c6aa4f8738c1bfb72 (patch)
tree442f33640744afe018b458d012c41cea13dda9f9 /generic/OverlapMan.c
parent6b36f92065f054abd810d956169a87180677d4f7 (diff)
downloadtkzinc-86eeded9ecb3d3de9e5cbb7c6aa4f8738c1bfb72.zip
tkzinc-86eeded9ecb3d3de9e5cbb7c6aa4f8738c1bfb72.tar.gz
tkzinc-86eeded9ecb3d3de9e5cbb7c6aa4f8738c1bfb72.tar.bz2
tkzinc-86eeded9ecb3d3de9e5cbb7c6aa4f8738c1bfb72.tar.xz
Int�gration des modifs de D.Pavet concernant l'interface d'antirec et les nouveaux controles sur l'antirec.
Diffstat (limited to 'generic/OverlapMan.c')
-rw-r--r--generic/OverlapMan.c182
1 files changed, 164 insertions, 18 deletions
diff --git a/generic/OverlapMan.c b/generic/OverlapMan.c
index c7993c0..6c92b2e 100644
--- a/generic/OverlapMan.c
+++ b/generic/OverlapMan.c
@@ -95,18 +95,14 @@ typedef struct _ZINCS {
int NBalloc_infos;
} ZINCS;
-
/*
- * Global vars.
- *
+ * Definition of tunable parameters
*/
-static ZINCS *wr = NULL;
-
-static int NBzincs=0;
-static int NBalloc_zincs=0;
-static INFOS info1;
+/*
+ * real parameters adresse
+ */
static double K0 = 2100.0; /* Repulsion factor */
static double K0min = 500.0;
static double K0max = 3000.0;
@@ -128,10 +124,51 @@ static double K3min = 1.0;
static double K3max = 10.0;
/*
+ * accessor structure need for generic set/get method
+ */
+typedef struct _OMPARAM {
+ int type;
+ int size;
+ char *name;
+ void *data;
+ BOOLEAN rw; /* 1 means readwrite, 0 means read only */
+} OMPARAM, *pOMPARAM;
+
+/*
+ * Global vars.
+ *
+ */
+static OMPARAM OmParamAccess[] = {
+ { OM_PARAM_DOUBLE, sizeof(double), "repulsion", &K0, 1 },
+ { OM_PARAM_DOUBLE, sizeof(double), "repulsion_bearing", &n0, 1 },
+ { OM_PARAM_DOUBLE, sizeof(double), "friction", &K1, 1 },
+ { OM_PARAM_DOUBLE, sizeof(double), "best_position_attraction", &K2, 1 },
+ { OM_PARAM_DOUBLE, sizeof(double), "screen_edge_repulsion", &K3, 1 },
+ { OM_PARAM_DOUBLE, sizeof(double), "min_repulsion", &K0min, 0 },
+ { OM_PARAM_DOUBLE, sizeof(double), "min_repulsion_bearing", &n0min, 0 },
+ { OM_PARAM_DOUBLE, sizeof(double), "min_friction", &K1min, 0 },
+ { OM_PARAM_DOUBLE, sizeof(double), "min_best_position_attraction", &K2min, 0 },
+ { OM_PARAM_DOUBLE, sizeof(double), "min_screen_edge_repulsion", &K3min, 0 },
+ { OM_PARAM_DOUBLE, sizeof(double), "max_repulsion", &K0max, 0 },
+ { OM_PARAM_DOUBLE, sizeof(double), "max_repulsion_bearing", &n0max, 0 },
+ { OM_PARAM_DOUBLE, sizeof(double), "max_friction", &K1max, 0 },
+ { OM_PARAM_DOUBLE, sizeof(double), "max_best_position_attraction", &K2max, 0 },
+ { OM_PARAM_DOUBLE, sizeof(double), "max_screen_edge_repulsion", &K3max, 0 },
+ { OM_PARAM_END, 0, "", NULL, 0 }
+};
+
+static int NbParam = sizeof(OmParamAccess) / sizeof(OMPARAM) - 1;
+static ZINCS *wr = NULL;
+static int NBzincs=0;
+static int NBalloc_zincs=0;
+static INFOS info1;
+
+
+/*
* Square of the distance (between two label centers) below which
* the repulsion is not computed.
*/
-static double limit_distance=6.0;
+static double limit_distance = 6.0;
/*
* Square of the minimum distance (between two label centers)
@@ -269,6 +306,21 @@ ProjToAngle(int dx,
/*
****************************************************************************
*
+ * OmInit --
+ * Called only once to initialize some internal data.
+ *
+ ****************************************************************************
+ */
+void
+OmInit()
+{
+ printf("OmInit\n");
+}
+
+
+/*
+ ****************************************************************************
+ *
* OmRegister --
* Create a database entry for the specified zinc.
*
@@ -279,7 +331,7 @@ OmRegister(void *w,
void *(*_fnext_track)(),
void (*_fset_label_angle)(),
void (*_fquery_label_pos)())
-{
+{
int iw=0;
BOOLEAN found=FALSE;
@@ -466,6 +518,7 @@ static void
ReadTracks(int iw)
{
int i=0;
+ int trash1; /* dummy variable : received unused data */
for (i = 0; i < wr[iw].NBinfos; i++) {
wr[iw].infos[i].Refresh = FALSE;
@@ -476,16 +529,21 @@ ReadTracks(int iw)
&info1.x, &info1.y,
&info1.vv_dx, &info1.vv_dy,
/* Fri Oct 13 15:15:48 2000
- &info1.label_x, &info1.label_y,
- &info1.label_width, &info1.label_height,
- */
+ * &info1.label_x, &info1.label_y,
+ * &info1.label_width, &info1.label_height,
+ */
&info1.rho, &info1.theta,
- &info1.visibility))) {
+ &info1.visibility,
+ &trash1,&trash1,&trash1))) {
info1.alpha = (ProjToAngle(info1.vv_dx, info1.vv_dy ) - M_PI_2 +
DegreesToRadian(info1.theta));
info1.dx = (int) info1.rho * cos(info1.alpha);
info1.dy = (int) info1.rho * sin(info1.alpha);
info1.Refresh = TRUE;
+ /* printf("OverlapMan(Om): ReadTracks id[%-10d], x[%4.4i], y[%4.4i], \
+ vv_dx[%4.4i], vv_dy[%4.4i], rho[%-3.3d], theta[%-3.3d], visi[%d]\n",
+ (int)info1.id,info1.x, info1.y, info1.vv_dx,info1.vv_dy,
+ info1.rho,info1.theta,info1.visibility); */
PutTrackLoaded(iw);
}
@@ -505,6 +563,94 @@ ReadTracks(int iw)
}
}
+/*
+ ***************************************************************************
+ *
+ * OmSetNParam --
+ * Return 1 if ok, anything else if nok (non existing parameters,
+ * wrong type).
+ *
+ ***************************************************************************
+ */
+int
+OmSetNParam(char *name, /* parameter's name */
+ void *value)
+{
+ int accessid = 0;
+ int status = 0;
+
+ while (OmParamAccess[accessid].type != OM_PARAM_END) {
+ if (!strcmp(name, OmParamAccess[accessid].name)) {
+ /* a parameter named name has been found */
+ if (OmParamAccess[accessid].rw) {
+ memcpy(OmParamAccess[accessid].data, value,
+ OmParamAccess[accessid].size);
+ status = 1;
+ break;
+ }
+ else {
+ status = -1 ; /* data is readonly */
+ };
+ };
+ ++accessid;
+ };
+ return(status);
+}
+
+/*
+ ***************************************************************************
+ *
+ * OmGetNParam --
+ * Return 1 if ok, anything else if nok (non existing parameters,
+ * wrong type).
+ *
+ ***************************************************************************
+ */
+int
+OmGetNParam(char *name, /* parameter's name */
+ void *ptvalue)
+{
+ int accessid = 0;
+ int status = 0;
+
+ while (OmParamAccess[accessid].type != OM_PARAM_END) {
+ if (!strcmp(name, OmParamAccess[accessid].name)) {
+ /* a parameter named "name" has been found */
+ memcpy(ptvalue, OmParamAccess[accessid].data,
+ OmParamAccess[accessid].size);
+ status = 1;
+ break;
+ };
+ ++accessid;
+ };
+ return(status);
+}
+
+/*
+ ***************************************************************************
+ *
+ * OmGetNParamList --
+ * Return 1 and next index if remains to read, the current param
+ * being written in current_param. Return 0 if end of list.
+ *
+ ***************************************************************************
+ */
+int
+OmGetNParamList(OmParam *current_param, int *idx_next)
+{
+ int status = 0 ;
+ pOMPARAM cparam ;
+ if (*idx_next < NbParam) {
+ cparam = &OmParamAccess[*idx_next];
+ current_param->type = cparam->type ;
+ strcpy(current_param->name, cparam->name);
+ /* printf("value of parameter is %f \n", *((double *)(cparam->data)));
+ printf("adresse de K0 %x \n", (int)&K0); */
+ ++(*idx_next) ;
+ status = 1;
+ };
+ return(status);
+}
void
OmSetParam(double OmKrepulsion,
@@ -901,7 +1047,7 @@ OmProcessOverlap(void *zinc,
{
double acceleration = 0.0;
int ip, iw;
-
+
if (NBzincs != 0 && FindPosW(zinc, &iw) == TRUE) {
ReadTracks(iw);
@@ -959,10 +1105,10 @@ OmProcessOverlap(void *zinc,
}
}
*/
-
+
(*wr[iw]._set_label_angle) (wr[iw].rw, wr[iw].infos[ip].id,
- wr[iw].infos[ip].theta);
-
+ 120, wr[iw].infos[ip].theta);
+ /* wr[iw].infos[ip].rho*/
}
}
}