📄 udlgopprmisrulebased.pas
字号:
unit UDlgOpPrmISRuleBased;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, UDlgBaseOperatorParameter, ComCtrls, StdCtrls, ExtCtrls, Buttons,
Menus;
type
TDlgOpPrmISRuleBased = class(TDlgBaseOperatorParameter)
Panel1: TPanel;
Panel2: TPanel;
tvCondition: TTreeView;
lstboxAttributes: TListBox;
Label1: TLabel;
Label2: TLabel;
pgCondition: TPageControl;
btnCondition: TSpeedButton;
btnRule: TSpeedButton;
tabDiscrete: TTabSheet;
tabContinuous: TTabSheet;
cmbOperator: TComboBox;
edValue: TEdit;
Label3: TLabel;
Label4: TLabel;
lstboxValues: TListBox;
Label5: TLabel;
Label6: TLabel;
rgCombination: TRadioGroup;
PopupMenu1: TPopupMenu;
Deleterule1: TMenuItem;
Deletecondition1: TMenuItem;
procedure lstboxAttributesClick(Sender: TObject);
procedure btnConditionClick(Sender: TObject);
procedure btnRuleClick(Sender: TObject);
procedure PopupMenu1Popup(Sender: TObject);
procedure Deletecondition1Click(Sender: TObject);
private
{ D閏larations priv閑s }
//r閏up閞er la condition
function getCondition(): string;
public
{ D閏larations publiques }
procedure SetParameters(); override;
procedure ApplyModifications(); override;
end;
var
DlgOpPrmISRuleBased: TDlgOpPrmISRuleBased;
implementation
uses UCompISRuleBased, UDatasetImplementation, UCalcRulesImplementation,
UDatasetDefinition, ULogFile;
{$R *.dfm}
{ TDlgOpPrmISRuleBased }
procedure TDlgOpPrmISRuleBased.ApplyModifications;
var parameter: TOpPrmISRuleBased;
node: TTreeNode;
regle: string;
k: integer;
begin
parameter:= self.OpPrm as TOpPrmISRuleBased;
parameter.RuleCombination:= TTypeISRuleCombination(self.rgCombination.ItemIndex);
parameter.LstRules.Clear();
//r閏up閞er chaque noeud du premier niveau
if (self.tvCondition.Items.Count > 0)
then
begin
node:= self.tvCondition.Items[0];
while (node <> nil) do
begin
regle:= '';
for k:= 0 to pred(node.Count) do
regle:= regle + node.Item[k].Text + '_AND_';
if (length(regle) > 0)
then
begin
regle:= copy(regle,1,length(regle) - 5);
parameter.LstRules.Add(regle);
//TraceLog.WriteToLogFile(format('[RULE-BASED IS] >> add rule : %s',[regle]));
end;
node:= node.getNextSibling();
end;
end;
end;
procedure TDlgOpPrmISRuleBased.SetParameters;
var operator: TOpISRuleBased;
parameter: TOpPrmISRuleBased;
chaine: string;
tmpLst: TStringList;
k,j: integer;
node: TTreeNode;
begin
operator:= self.OpPrm.Operator as TOpISRuleBased;
parameter:= self.OpPrm as TOpPrmISRuleBased;
//mode de combinaison
self.rgCombination.ItemIndex:= ord(parameter.RuleCombination);
//liste des variables
operator.WorkData.LstAtts[asAll].FlashLstAtt(self.lstboxAttributes.Items);
//les r鑗les existantes
for k:= 0 to pred(parameter.LstRules.Count) do
begin
chaine:= parameter.LstRules[k];
tmpLst:= TRulePremisse.decomposeRegle(chaine,nil);
if (tmpLst.Count > 0)
then
begin
node:= tvCondition.Items.AddChild(nil,'Rule');
for j:= 0 to pred(tmpLst.Count) do
self.tvCondition.Items.AddChild(node,tmpLst[j]);
end;
end;
self.tvCondition.FullExpand();
//s閘ectionner par d閒aut la premi鑢e variable
self.lstboxAttributes.ItemIndex:= 0;
self.lstboxAttributesClick(NIL);
end;
procedure TDlgOpPrmISRuleBased.lstboxAttributesClick(Sender: TObject);
var selAtt: TAttribute;
j: integer;
begin
if (self.lstboxAttributes.ItemIndex >= 0)
then
begin
selAtt:= self.lstBoxAttributes.Items.Objects[self.lstboxAttributes.ItemIndex] as TAttribute;
if selAtt.isCategory(caContinue)
then self.pgCondition.ActivePage:= self.tabContinuous
else
begin
self.lstboxValues.Clear();
for j:= 0 to pred(selAtt.nbValues) do
self.lstboxValues.Items.Add(selAtt.LstValues.getDescription(succ(j)));
self.pgCondition.ActivePage:= self.tabDiscrete;
end;
end;
end;
procedure TDlgOpPrmISRuleBased.btnConditionClick(Sender: TObject);
var node: TTreeNode;
chaine: string;
begin
//r閏up閞er le noeud en cours de s閘ection
node:= self.tvCondition.Selected;
if (node = nil)
//ajout de r鑗le
then self.btnRuleClick(sender)
else
begin
//v閞ifier qu'il s'agit bien du premier niveau
if (node.Level > 0) then node:= node.GetPrev();
//
chaine:= self.getCondition();
if (length(chaine) > 0)
then self.tvCondition.Items.AddChild(node,chaine);
end;
end;
procedure TDlgOpPrmISRuleBased.btnRuleClick(Sender: TObject);
var node: TTreeNode;
chaine: string;
begin
chaine:= self.getCondition();
if (length(chaine) > 0)
then
begin
//tr鑣 simple, on ajoute un nouveau noeud
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -