目次 ファイル選択用ダイアログボックス 例 EPICS CA 用ルーチンを使う場合

例 emittance測定値計算用パネル


これはJ-Linacで使用されているEmittance測定値計算用パネルのコードを 単純化したものです。動作は単純化されていますが、パネルの構成自体は そのままです。この例は、他の例と違ってこのままでは実行できません。


!!! You need some beam line definition to execute the following code !!!

! Making Main Window
  mf=KBMainFrame["EmitMeas", fr, Title->"Emittance Measurement"];
! Making Canvas for OpticsPlot[]
  canv=Canvas[fr,Width->800,Height->600];
! Making TextLabel[] for displaying the name of Q magnets
  tlqn=TextLabel[fr,Text->"",Width->20,FG->"tomato",Font->TextFont["times",20]];

! Initializing variables
  ael=Append[Apply[List,ExtractBeamLine[]],$$$];
  lqnamel = LINE["NAME","Q*"];
  lscnamel = LINE["NAME","SC*"];
  dhv=1;
  qvar=ToString[lqnamel[[1]]];
  scvar=ToString[lscnamel[[1]]];

! Arranging Widgets
  kcf = KBFComponentFrame[fr,
    Add->{
      KBFGroup[Text->"Fitting Option"],
      KBFRadioButton[Text->"Fitting Direction",Items->{"Horizontal","Vertical"},Variable:>dhv,Command:>chgdir[]],
      KBFSeparator[],
      KBFButton[Text->"  Fit Panel  ",Command:>KEKBFrameRaise[fp]],
      KBFListBox[Text->"Target Position :",Items->ael,WidgetVariable:>tvar,NextColumn->True],
      KBFGroup[Text->"Measurement Condition",NextColumn->True],
      KBFText[Text->"Click the lattice to select."],
      KBFString[Text->"Adjusted Q :",Variable:>qvar,WidgetVariable:>qent],
      KBFString[Text->"Screen :",Variable:>scvar,WidgetVariable:>scent],
      KBFListBox[Text->"Unused Q's (Shift-Click to toggle) :",Items->{},WidgetVariable:>lbnq,NextColumn->True]
    }
  ];
! Configuring Widgets
  qent[State] = "disabled";
  scent[State] = "disabled";
  tvar[Select$Set] = 1;

! Making OpticsPlot[]
  $DisplayFunction=CanvasDrawer;
  Canvas$Widget=canv;
  pl=OpticsPlot[{{"SIGX","SIGY"}},Names->"SC*",Tags->True,Initialize->True];
! Changing the outline color of the initially selected Q magnet
  canv[ItemConfigure]={"C$"//qvar,Outline->"tomato"};
! Binding functions to tags
  lqs = Map[StringJoin["C$",#]&,lqnamel];
  lsc = Map[StringJoin["L$",#]&,lscnamel];
  Bind[canv, "<Button-1>", qpick[], Tags->lqs];
  Bind[canv, "<Enter>", qenter[], Tags->lqs];
  Bind[canv, "<Leave>", qleave[], Tags->lqs];
  Bind[canv, "<Enter>", scenter[], Tags->lsc];

! Defining binded functions
  qpick[] := (
    canv[ItemConfigure]={"C$"//qvar,Outline->"black"};
    qvar = (Tag/.$Event)[3,-1];
  );
  qenter[] := Module[{tagname=Tag/.$Event,name},
    name=tagname[3,-1];
    canv[ItemConfigure]={tagname,Outline->"yellow"};
    tlqn[Text] = name;
  ];
  qleave[] := Module[{tagname=Tag/.$Event,name},
    name=tagname[3,-1];
    canv[ItemConfigure]={tagname,Outline->If[name==qvar,"tomato","black"]};
    tlqn[Text] = "";
  ];
  scenter[] := (
    mf[StatusLine]=(Tag/.$Event)[3,-1];mf[FreeStatusLine];
  );
! Defining the function for radiobuttons
  chgdir[] := Print[If[dhv==1,"x","y"]];

Emittance Measurement Panel Example

以下のパネルは、mainのパネルで測定条件の設定をした後で、emittanceの計算と opticsのmatchingをとるためのパネルです。

Fit Panel Example

Matching Panel Exaple

top


このページに関する御意見・質問は Samo Stanic まで.