00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #define _XMENU_OPT_SOURCE_
00024
00025 #include <stdio.h>
00026 #include "xsetup.h"
00027 #include "xclips.h"
00028 #include "xmenu.h"
00029 #include "xmenu_opt.h"
00030 #include "xclipstext.h"
00031 #include "xmain.h"
00032 #include "setup.h"
00033 #include "engine.h"
00034 #include "crstrtgy.h"
00035 #include "commline.h"
00036 #include "router.h"
00037 #include "globlcom.h"
00038 #include "facthsh.h"
00039 #include "exprnpsr.h"
00040 #include "bmathfun.h"
00041 #include "incrrset.h"
00042
00043 Widget optionsShell = NULL,optionsForm = NULL;
00044 Widget option_widgets[7];
00045 Widget strategy_widgets[7];
00046 Widget sal_opt_widgets[3];
00047 int optionFlags[2] = {DEPTH_STRATEGY,WHEN_DEFINED};
00048
00049 static char strategy_bits[] = {
00050 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00051 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00052 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00053 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00054 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00055 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00056 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00057 0x30, 0x1b, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x01, 0x00,
00058 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x18, 0x00, 0x00,
00059 0x03, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
00060 0x00, 0x00, 0x00, 0x00, 0x30, 0x78, 0x7c, 0x3c, 0x0f, 0x8f, 0x6b, 0x06,
00061 0xfe, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00062 0xe0, 0x19, 0xcc, 0x60, 0x83, 0xd9, 0x6c, 0x06, 0xfc, 0xff, 0x00, 0x00,
00063 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x0c, 0x7c,
00064 0x83, 0xdf, 0x6c, 0x06, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00065 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x0c, 0x66, 0x83, 0x81, 0x67, 0x06,
00066 0xf0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00067 0x30, 0x9b, 0x0d, 0x66, 0xb3, 0xd9, 0xc0, 0x07, 0xe0, 0x1f, 0x00, 0x00,
00068 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xf1, 0x0c, 0x7c,
00069 0x1e, 0x8f, 0x07, 0x06, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00070 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x6c, 0x06,
00071 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00072 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc7, 0x03, 0x00, 0x03, 0x00, 0x00,
00073 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00074 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00075 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00076 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00077 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00078 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00079 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
00080
00081 static char salience_bits[] = {
00082 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00083 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00084 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00085 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00086 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00087 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00088 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x07, 0x03,
00089 0x00, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x70, 0x00, 0x00, 0x00, 0x06, 0x00,
00090 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x06, 0x03, 0x00, 0x00, 0x00, 0xc0,
00091 0x00, 0x00, 0x60, 0x00, 0x00, 0x03, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
00092 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x60, 0x00,
00093 0x00, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x06, 0x1e, 0x86, 0xc3,
00094 0xf3, 0xf1, 0x78, 0xc0, 0x60, 0xe6, 0x61, 0xcc, 0x3c, 0x0f, 0x87, 0xe7,
00095 0x03, 0xff, 0xff, 0x00, 0x3c, 0x30, 0x06, 0x63, 0x36, 0x9b, 0xcd, 0xc0,
00096 0x67, 0x06, 0x63, 0xcc, 0x60, 0x03, 0xc6, 0x6c, 0x06, 0xff, 0xff, 0x00,
00097 0x60, 0x3e, 0x06, 0xe3, 0x37, 0x1b, 0xfc, 0xc0, 0x60, 0xe6, 0x63, 0xcc,
00098 0x7c, 0x03, 0xc6, 0x6c, 0x06, 0xfe, 0x7f, 0x00, 0x60, 0x33, 0x06, 0x63,
00099 0x30, 0x1b, 0x0c, 0xc0, 0xc0, 0x33, 0x63, 0xcc, 0x66, 0x03, 0xc6, 0x6c,
00100 0x06, 0xfc, 0x3f, 0x00, 0x66, 0x33, 0x06, 0x63, 0x36, 0x9b, 0xcd, 0xc0,
00101 0xc0, 0x33, 0x63, 0xcc, 0x66, 0x33, 0xc6, 0x6c, 0x06, 0xf8, 0x1f, 0x00,
00102 0x3c, 0xbe, 0xdf, 0xcf, 0x33, 0xf3, 0x78, 0xc0, 0x8f, 0xe1, 0xfb, 0xf9,
00103 0x7c, 0x9e, 0x9f, 0x67, 0x06, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
00104 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00105 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00,
00107 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00108 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
00109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00111 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
00112
00113
00114
00115
00116
00117
00118
00119
00120 void OptionsWindow(
00121 Widget w,
00122 XtPointer client,
00123 XtPointer data)
00124 {
00125 Widget Cancel,Okay,menu,salienceEval,strategy;
00126 int n, i;
00127 static char *optionList1[7] = {"Static Constraint Checking",
00128 "Dynamic Constraint Checking",
00129 "Reset Global Variables",
00130 "Sequence Expansion Operator Recognition",
00131 "Incremental Reset",
00132 "Auto-Float Dividend",
00133 "Fact Duplication"};
00134
00135 static char *optionList2[7] = {"Depth","Breadth","LEX","MEA","Complexity","Simplicity","Random"};
00136 static char *optionList3[3] = {"When Defined","When Activated","Every Cycle"};
00137 Pixmap SalienceBM,StrategyBM;
00138
00139
00140
00141
00142
00143 if (optionsShell != NULL)
00144 {
00145 UpdateOptionsMenu();
00146 XtPopup(optionsShell,XtGrabNonexclusive);
00147 return;
00148 }
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 n = 0;
00162 XtSetArg( TheArgs[n], XtNwidth,250);
00163 n++;
00164 XtSetArg( TheArgs[n], XtNheight,400);
00165 n++;
00166 optionsShell = XtCreatePopupShell("Execution Options",topLevelShellWidgetClass,
00167 XtParent(w),NULL,0);
00168
00169
00170
00171
00172
00173 optionsForm = XtCreateManagedWidget("watch_form", formWidgetClass,
00174 optionsShell, TheArgs,n);
00175
00176 SalienceBM = XCreateBitmapFromData(XtDisplay(toplevel),
00177 RootWindowOfScreen(XtScreen(toplevel)),
00178 salience_bits,
00179 salience_width,
00180 salience_height);
00181
00182
00183
00184
00185
00186 n = 0;
00187 XtSetArg(TheArgs[n],XtNbitmap,SalienceBM);n++;
00188 XtSetArg(TheArgs[n],XtNwidth,180);n++;
00189 salienceEval = XtCreateManagedWidget("salienceEvaluation",
00190 menuButtonWidgetClass,
00191 optionsForm,
00192 TheArgs, n);
00193 menu = XtCreatePopupShell("menu",
00194 simpleMenuWidgetClass,
00195 salienceEval,
00196 NULL,0);
00197 n = 0;
00198 XtSetArg(TheArgs[n],XtNleftMargin,15);n++;
00199 XtSetArg(TheArgs[n],XtNleftBitmap,checker);n++;
00200 for (i = 0; i < 3 ; i++)
00201 {
00202 sal_opt_widgets[i] = XtCreateManagedWidget(optionList3[i],
00203 smeBSBObjectClass,
00204 menu,
00205 TheArgs, n);
00206 XtAddCallback(sal_opt_widgets[i],XtNcallback,SetSalienceCallback,(XtPointer)i);
00207 n = 1;
00208 }
00209
00210
00211
00212
00213
00214 StrategyBM = XCreateBitmapFromData(XtDisplay(toplevel),
00215 RootWindowOfScreen(XtScreen(toplevel)),
00216 strategy_bits,
00217 strategy_width,
00218 strategy_height);
00219 n = 0;
00220 XtSetArg(TheArgs[n],XtNhorizDistance,10);
00221 n++;
00222 XtSetArg(TheArgs[n],XtNfromHoriz,salienceEval);
00223 n++;
00224 XtSetArg(TheArgs[n],XtNbitmap,StrategyBM);
00225 n++;
00226 XtSetArg(TheArgs[n],XtNwidth,150);
00227 n++;
00228 strategy = XtCreateManagedWidget("strategy",
00229 menuButtonWidgetClass,
00230 optionsForm,
00231 TheArgs, n);
00232 menu = XtCreatePopupShell("menu",
00233 simpleMenuWidgetClass,
00234 strategy,
00235 NULL, 0);
00236 n = 0;
00237 XtSetArg(TheArgs[n],XtNleftMargin, 15);
00238 n++;
00239 XtSetArg(TheArgs[n], XtNleftBitmap, checker);
00240 n++;
00241 for (i = 0; i < 7; i++)
00242 {
00243 strategy_widgets[i] = XtCreateManagedWidget(optionList2[i],
00244 smeBSBObjectClass,
00245 menu,
00246 TheArgs, n);
00247 XtAddCallback(strategy_widgets[i],XtNcallback,SetStrategyCallback,(XtPointer)i);
00248 n = 1;
00249 }
00250
00251
00252
00253
00254
00255 n = 0;
00256 XtSetArg(TheArgs[n],XtNwidth,200);
00257 n++;
00258 XtSetArg(TheArgs[n],XtNhorizDistance,80);
00259 n++;
00260 XtSetArg(TheArgs[n],XtNvertDistance,5);
00261 n++;
00262 XtSetArg(TheArgs[n],XtNfromVert,salienceEval);
00263 n++;
00264 for (i = 0; i < 7; i++)
00265 {
00266 if ((i == INT_STA_CONSTRAINT_CHK) || ( i == INT_AUTO_FLOAT_DIV) ||
00267 (i == INT_INCREMENTAL_RESET) || ( i == INT_RESET_GLOBALS))
00268 {
00269 XtSetArg(TheArgs[n], XtNstate,True);
00270 n++;
00271 }
00272
00273 option_widgets[i] = XtCreateManagedWidget(optionList1[i],
00274 toggleWidgetClass,
00275 optionsForm,
00276 TheArgs, n);
00277 n = 3;
00278 XtSetArg(TheArgs[n],XtNfromVert,option_widgets[i]);
00279 n++;
00280 }
00281
00282
00283
00284
00285
00286 n = 0;
00287 XtSetArg(TheArgs[n],XtNshapeStyle,XmuShapeRoundedRectangle);
00288 n++;
00289 XtSetArg(TheArgs[n],XtNwidth,150);
00290 n++;
00291 XtSetArg(TheArgs[n],XtNfromVert,option_widgets[6]);
00292 n++;
00293 XtSetArg(TheArgs[n],XtNvertDistance,31);n++;
00294 XtSetArg(TheArgs[n],XtNlabel,"Cancel");n++;
00295 Cancel = XtCreateManagedWidget("watchButton",
00296 commandWidgetClass,
00297 optionsForm,
00298 TheArgs, n);
00299 XtAddCallback(Cancel,XtNcallback,PopdownSelect,(XtPointer)optionsForm);
00300
00301
00302
00303
00304 n = 4;
00305 XtSetArg(TheArgs[n],XtNfromHoriz,Cancel);n++;
00306 XtSetArg(TheArgs[n],XtNhorizDistance,30);n++;
00307 XtSetArg(TheArgs[n],XtNlabel,"OKay");n++;
00308 Okay = XtCreateManagedWidget("watchButton",
00309 commandWidgetClass,
00310 optionsForm,
00311 TheArgs, n);
00312 XtAddCallback(Okay,XtNcallback,OkayOptionsCallback,(XtPointer)NULL);
00313 XtPopup(optionsShell,XtGrabNonexclusive);
00314 }
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329 void SetStrategyCallback(
00330 Widget w,
00331 XtPointer client_data,
00332 XtPointer call_data)
00333 {
00334 int i,n = 0,theIndex = (int)client_data;
00335
00336 MoveEndOfFile(dialog_text, &TheEvent);
00337
00338 XtSetArg(TheArgs[n], XtNleftBitmap, None);n++;
00339 for(i = 0 ; i <= RANDOM_STRATEGY;i++)
00340 XtSetValues(strategy_widgets[i], TheArgs, n);
00341 XtSetArg(TheArgs[0], XtNleftBitmap, checker);n++;
00342 XtSetValues(strategy_widgets[theIndex], TheArgs, n);
00343 optionFlags[STRATEGY_FLAG] = theIndex;
00344 quit_get_event = True;
00345 }
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358 void SetSalienceCallback(
00359 Widget w,
00360 XtPointer client_data,
00361 XtPointer call_data)
00362 {
00363 int i,n = 0,theIndex = (int)client_data;
00364 MoveEndOfFile(dialog_text, &TheEvent);
00365
00366 n = 0;
00367 XtSetArg(TheArgs[n], XtNleftBitmap, None);n++;
00368 for(i = 0; i <= EVERY_CYCLE; i++)
00369 {
00370 if(i != theIndex)
00371 XtSetValues(sal_opt_widgets[i],TheArgs,n);
00372 }
00373 n = 0;
00374 XtSetArg(TheArgs[n], XtNleftBitmap, checker);n++;
00375 XtSetValues(sal_opt_widgets[theIndex], TheArgs, n);
00376 optionFlags[SALIENCE_FLAG] = theIndex;
00377 quit_get_event = True;
00378 }
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388 void OkayOptionsCallback(
00389 Widget w,
00390 XtPointer client,
00391 XtPointer call)
00392 {
00393 void *theEnv = GetCurrentEnvironment();
00394 Boolean OnOff;
00395 int n;
00396
00397 if((EnvGetStrategy(theEnv)) != optionFlags[STRATEGY_FLAG])
00398 EnvSetStrategy(theEnv,optionFlags[STRATEGY_FLAG]);
00399 if((optionFlags[SALIENCE_FLAG]) != EnvGetSalienceEvaluation(theEnv))
00400 EnvSetSalienceEvaluation(theEnv,optionFlags[SALIENCE_FLAG]);
00401 n = 0;
00402
00403
00404
00405 XtSetArg(TheArgs[n],XtNstate,&OnOff);n++;
00406 XtGetValues(option_widgets[INT_FACT_DUPLICATION],TheArgs,n);
00407 if((OnOff)&&(! EnvGetFactDuplication(theEnv)))
00408 {
00409 EnvSetFactDuplication(theEnv,CLIPS_TRUE);
00410 }
00411 else if ((!OnOff)&&(EnvGetFactDuplication(theEnv)))
00412 {
00413 EnvSetFactDuplication(theEnv,CLIPS_FALSE);
00414 }
00415
00416
00417 XtGetValues(option_widgets[INT_DYN_CONSTRAINT_CHK],TheArgs,n);
00418 if((OnOff)&&(! EnvGetDynamicConstraintChecking(theEnv)))
00419 {
00420 EnvSetDynamicConstraintChecking(theEnv,CLIPS_TRUE);
00421 }
00422 else if((!OnOff) &&(EnvGetDynamicConstraintChecking(theEnv)))
00423 {
00424 EnvSetDynamicConstraintChecking(theEnv,CLIPS_FALSE);
00425 }
00426
00427
00428
00429 XtGetValues(option_widgets[INT_STA_CONSTRAINT_CHK],TheArgs,n);
00430 if((OnOff)&&(! EnvGetStaticConstraintChecking(theEnv)))
00431 {
00432 EnvSetStaticConstraintChecking(theEnv,CLIPS_TRUE);
00433 }
00434 else if((!OnOff) &&(EnvGetStaticConstraintChecking(theEnv)))
00435 {
00436 EnvSetStaticConstraintChecking(theEnv,CLIPS_FALSE);
00437 }
00438
00439
00440 XtGetValues(option_widgets[INT_SEQUENCE_OPT_REG],TheArgs,n);
00441 if((OnOff)&&(!EnvGetSequenceOperatorRecognition(theEnv)))
00442 {
00443 EnvSetSequenceOperatorRecognition(theEnv,CLIPS_TRUE);
00444 }
00445 else if((!OnOff) &&(EnvGetSequenceOperatorRecognition(theEnv)))
00446 {
00447 EnvSetSequenceOperatorRecognition(theEnv,CLIPS_FALSE);
00448 }
00449
00450
00451
00452 XtGetValues(option_widgets[INT_AUTO_FLOAT_DIV],TheArgs,n);
00453 if((OnOff)&&(!EnvGetAutoFloatDividend(theEnv)))
00454 {
00455 EnvSetAutoFloatDividend(theEnv,CLIPS_TRUE);
00456 }
00457 else if((!OnOff) &&(EnvGetAutoFloatDividend(theEnv)))
00458 {
00459 EnvSetAutoFloatDividend(theEnv,CLIPS_FALSE);
00460 }
00461
00462
00463 XtGetValues(option_widgets[INT_INCREMENTAL_RESET],TheArgs,n);
00464 if((OnOff)&&(!EnvGetIncrementalReset(theEnv)))
00465 {
00466 EnvSetIncrementalReset(theEnv,CLIPS_TRUE);
00467 }
00468 else if((!OnOff) &&(EnvGetIncrementalReset(theEnv)))
00469 {
00470 EnvSetIncrementalReset(theEnv,CLIPS_FALSE);
00471 }
00472
00473
00474 XtGetValues(option_widgets[INT_RESET_GLOBALS],TheArgs,n);
00475 if((OnOff)&&(!EnvGetResetGlobals(theEnv)))
00476 {
00477 EnvSetResetGlobals(theEnv,CLIPS_TRUE);
00478 }
00479 else if((!OnOff) &&(EnvGetResetGlobals(theEnv)))
00480 {
00481 EnvSetResetGlobals(theEnv,CLIPS_FALSE);
00482 }
00483 XtPopdown(XtParent(XtParent(w)));
00484 quit_get_event = True;
00485 }
00486
00487
00488
00489
00490
00491
00492