knotX.sa
Generated by gen_html_sa_files from ICSI. Contact gomes@icsi.berkeley.edu for details
class KNOTX
class KNOTX is
init is
PDefNum:=1;
end;
shared PDefNum:CARD; --- mode for P polynomial
--compatible to X-event
-- event
const knotButtonPress:INT:= 4;
const knotButtonRelease:INT:= 5;
const knotMotionNotify:INT:= 6;
const knotLeaveNotify:INT:=8;
-- mouse button
const knotButtonL:INT:=1;
const knotButtonC:INT:=2;
const knotButtonR:INT:=3;
-- GC table for each color
const kBack:INT:=0;
const kStr:INT:=1;
const tStr:INT:=2;
const rtStr:INT:=3;
const kMark:INT:=9;-- XOR
shared CurrentEditMode:CARD:=1;
-- CorrentEditMode must match with menu list knot_edit[] in MODULE knotXW
Restrictions is
#OUT+"\n"+
"KNOT program. \n"+
"Restriction:\n"+
"history length = "+ HISTORY::historyLength.str+"\n"+
"\n";
end;
repaint is
-- repaint window for Expose event
DRAWKNOT_ALG::DrawKnot(K::Knot);
end;
TrackEventK(event,button,mouseX,mouseY:INT) is
case CurrentEditMode
when 0 then KNOTIO::Cross(inout K::Knot, event,button,mouseX,mouseY);
when 1 then ADD_COMPO::AddCompo(inout K::Knot, event,button,mouseX,mouseY);
when 2 then ; --new knot
when 3 then MOVE_VERTEX::MoveVertex(inout K::Knot, event,button,mouseX,mouseY);
when 4 then KNOTIO::CutString(inout K::Knot, event,button,mouseX,mouseY);
when 5 then KNOTIO::DelString(inout K::Knot, event,button,mouseX,mouseY);
when 6 then MAKE_SADDLE::MakeSaddle(inout K::Knot, event,button,mouseX,mouseY);
when 7 then
SPLICE::Splice(inout K::Knot, event,button,mouseX,mouseY);
when 8 then KNOTIO::InvertString(inout K::Knot, event,button,mouseX,mouseY);
when 9 then SHIFT_DIAGRAM::ShiftDiagram(inout K::Knot, event,button,mouseX,mouseY);
when 10 then
JUMP_MOVE::SW0:=true;
JUMP_MOVE::JumpMove(inout K::Knot, event,button,mouseX,mouseY);
when 11 then
JUMP_MOVE::SW0:=false;
JUMP_MOVE::JumpMove(inout K::Knot, event,button,mouseX,mouseY);
end;
end;
closeProc is
TrackEventK(-2,0.int,0.int,0.int);
end;
startProc is
TrackEventK(-1,0.int,0.int,0.int);
end;
EditSelectK(select:INT):INT is
-- prepare for edit action
closeProc;
case select.card
when 0 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select.card;
when 1 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select.card;
when 2 then HISTORY::put(K::Knot.clone);K::Knot.NoCompo0;CurrentEditMode:=1;
when 3 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select.card;
when 4 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select.card;
when 5 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select.card;
when 6 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select.card;
when 7 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select.card;
when 8 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select.card;
when 9 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select.card;
when 10 then CurrentEditMode:=select.card;
when 11 then CurrentEditMode:=select.card;
end;
startProc;
repaint;
return CurrentEditMode.int;
end;
EffectSelectK(select:INT):INT is
reply:INT:=0;
closeProc;
case select.card
when 0 then ;-- SetBraid;
when 1 then ;-- SetNDiagram;
when 2 then ;-- Torus link
when 3 then ;-- 2-bridge
when 4 then ;-- Pretzel P(a0,a1...)
when 5 then HISTORY::put(K::Knot.clone); ALTERNATE::Alternate(inout K::Knot);
when 6 then HISTORY::put(K::Knot.clone); K::Knot.make_coherent;
when 7 then HISTORY::put(K::Knot.clone); K::Knot.transform(2.0);
when 8 then HISTORY::put(K::Knot.clone); K::Knot.transform(1.4);
when 9 then HISTORY::put(K::Knot.clone); K::Knot.transform(0.7);
when 10 then HISTORY::put(K::Knot.clone); K::Knot.transform(0.5);
when 11 then HISTORY::put(K::Knot.clone); K::Knot.transform(-1,0.int,0.int,1.int);
when 12 then HISTORY::put(K::Knot.clone); K::Knot.transform(1.int,0.int,0.int,-1);
when 13 then HISTORY::put(K::Knot.clone); K::Knot.mirrorZ;
when 14 then HISTORY::put(K::Knot.clone); K::Knot.transform(0.int,-1,1.int,0.int);
when 15 then HISTORY::put(K::Knot.clone); K::Knot.transform(0.int,1.int,-1,0.int);
when 16 then HISTORY::back(inout K::Knot);
when 17 then HISTORY::forward(inout K::Knot);
when 18 then HISTORY::put(K::Knot.clone);
end;
startProc;
repaint;
return reply;
end;
no_support(out tcode:TCODE):BOOL is
-- check if (1) knot is closed, (2) succeeded in tcode.
if K::Knot.is_Closed.not then #OUT+"Knot is not closed.(not supported)\n"; startProc; repaint; return true; end;
K::Knot.CrossSet(0.int,K::Knot.length.int);
K::Knot.make_coherent;
if K::Knot.SetTCode(out tcode) then -- tcode.get_Relator(tcode);
else startProc; repaint; return true;
end;
return false;
end;
no_support_b(out tcode:TCODE):BOOL is
-- check if (0) no-band, (1) knot is closed, (2) succeeded in tcode.
if K::Knot.has_band then
#OUT+"Not support on 2-knot."; startProc; repaint; return true;
end;
return no_support(out tcode);
end;
InvSelectK(select:INT):INT is
tcode:TCODE;
reply:INT:=0.int;
closeProc;
case select.card
when 0 then
if no_support(out tcode) then return reply; end;
KNOT_GROUP::printGroup(tcode); -- Group;
when 1 then
if no_support_b(out tcode) then return reply; end;
ALEXMAT::AlexMat(tcode,false,false);-- APOLY::ApolyC(tcode);
when 2 then
if no_support_b(out tcode) then return reply; end;
ALEXMAT::AlexMat(tcode,false,false,true);--CPOLY::Cpoly(tcode);
when 3 then -- P.poly.
if no_support_b(out tcode) then return reply; end;
case PDefNum
when 1 then PPOLY::Ppoly(tcode,PPOLY::Def_vz);
when 2 then PPOLY::Ppoly(tcode,PPOLY::Def_lm);
when 3 then PPOLY::Ppoly(tcode,PPOLY::Def_xyz);
end;
when 4 then
if no_support_b(out tcode) then return reply; end;
case PDefNum
when 1 then PPOLY::PpolyLow(tcode,PPOLY::Def_vz);
when 2 then PPOLY::PpolyLow(tcode,PPOLY::Def_lm);
when 3 then PPOLY::PpolyLow(tcode,PPOLY::Def_xyz);
end;
when 5 then
if no_support_b(out tcode) then return reply; end;
VPOLY::Vpoly(tcode);
when 6 then
if no_support_b(out tcode) then return reply; end;
FPOLY::Fpoly(tcode);
when 7 then
if no_support_b(out tcode) then return reply; end;
QPOLY::Qpoly(tcode);
when 8 then
if no_support_b(out tcode) then return reply; end;
reply := 1;
-- #OUT+"V-para.\n" ; --(* V parallel *)
when 9 then
if no_support(out tcode) then return reply; end;
ALEXMATM::AlexMat(tcode,false); -- multi variable poly
when 10 then
if no_support(out tcode) then return reply; end;
ALEXMAT::AlexMat(tcode,false,true);
when 11 then
if no_support(out tcode) then return reply; end;
ALEXMATM::AlexMat(tcode,true); -- multi variable ideal
when 12 then reply := 1;
--#OUT+"covering.\n"; -- (* Do coverings menu *)
when 13 then reply := 1;
-- #OUT+"sl2p.\n"; -- (* Do coverings menu *)
when 14 then
if no_support_b(out tcode) then return reply; end;
GOERITZ_MAT::KnotValue(tcode);
when 15 then
if no_support_b(out tcode) then return reply; end;
SIGNATURE::Signature(tcode);
when 16 then
if no_support(out tcode) then return reply; end;
ALEXMAT::AlexMat(tcode,true,false);
when 17 then
if no_support(out tcode) then return reply; end;
if K::Knot.is_theta and SET_TCODE_ALG::SetTCode_Theta(K::Knot,out tcode) then
KNOT_GROUP::printGroupTheta(tcode);
end;
when 18 then -- Alexander poly. for theta curve
if no_support(out tcode) then return reply; end;
if K::Knot.is_theta and SET_TCODE_ALG::SetTCode_Theta(K::Knot,out tcode) then
ALEXMATM::AlexMat_Theta(tcode);
end;
when 19 then
if PDefNum>=3 then PDefNum:=1; else PDefNum:=PDefNum+1; end;
reply:=PDefNum.int; startProc; repaint; #OUT+"Change definition of P-poly.\n";
return reply;
end;
startProc; repaint; return reply;
end;
VPara(n:INT) is
closeProc;
tcode:TCODE;
if no_support_b(out tcode) then return; end;
VPOLY::VPara(tcode,n);
startProc; repaint;
end;
RepSearch(n,form,branchind,covlk,h1b,h1u,knotgrp,twistAlex,
covDistY,covDistBr,covDistLk,covDistH1B,covDistH1U:INT) is
tcode:TCODE;
closeProc;
if no_support(out tcode) then return; end;
#REP.RepSearch(tcode,n.card,form.card,branchind.card,covlk.card,h1b.card,h1u.card,
knotgrp.card,twistAlex.card,
covDistY.card,covDistBr.card,covDistLk.card,covDistH1B.card,covDistH1U.card);
startProc; repaint;
end;
RepSL2pSearch(n:INT, form,twistAlex:CARD) is
tcode:TCODE;
closeProc;
if no_support(out tcode) then return; end;
#REP_SL2P.RepSearch(tcode,n,form,twistAlex);
startProc; repaint;
end;
FilesSelectK(select:INT):INT is
reply:INT:=0;
closeProc;
case select.card
when 0 then ;-- read knot
when 1 then ;-- writeKnot
when 2 then ;-- write Braid
when 3 then ; --write n-data
when 4 then ;-- write knot ver.1
when 5 then
if LOGOUT::is_enabled then LOGOUT::LogEnd;
else LOGOUT::LogBegin;
end;
if LOGOUT::is_enabled then reply:=1; end;
when 6 then
if ~ LOGOUT::is_enabled then LOGOUT::LogBegin; end;
if LOGOUT::is_enabled then reply:=1; end;
-- And print out tpic code from knotXW.c.
when 7 then
if ~ LOGOUT::is_enabled then LOGOUT::LogBegin; end;
if LOGOUT::is_enabled and KNOTFIO::WriteKnotLog(K::Knot) then reply:=1;
end;
when 8 then
if ~ LOGOUT::is_enabled then LOGOUT::LogBegin; end;
if LOGOUT::is_enabled and KNOTFIO::WriteBraidLog(K::Knot) then reply:=1;
end;
when 9 then
if ~ LOGOUT::is_enabled then LOGOUT::LogBegin; end;
if LOGOUT::is_enabled and KNOTFIO::WriteNDataLog(K::Knot) then reply:=1;
end;
end;
startProc; repaint;
return reply;
end;
OtherSelectK(select:INT):INT is
reply:INT:=0;
closeProc;
case select.card
when 0 then DRAW_ALG::smoothDraw:=~DRAW_ALG::smoothDraw;
if DRAW_ALG::smoothDraw then reply:=1; else reply:=0; end;
when 1 then
DRAW_ALG::latticeFlg:=~DRAW_ALG::latticeFlg;
if DRAW_ALG::latticeFlg then reply:=1; else reply:=0; end;
when 2 then Restrictions;
when 3 then K::Knot.printD;
when 4 then
if K::Knot.checkCode then ; end;
when 5 then -- show TCODE
tcode:TCODE;
if K::Knot.SetTCode(out tcode) then tcode.printD;
else #OUT+"Failed to set tcode.\n";
end;
when 6 then
tcode:TCODE;
if K::Knot.is_theta and SET_TCODE_ALG::SetTCode_Theta(K::Knot,out tcode) then tcode.printD;
else #OUT+"Failed to set tcode.\n";
end;
when 7 then
s:STR:="";
if BRAID_CNV::Knot2BraidWord(K::Knot,out s) then #OUT+"braid: "+s+"\n";
if BRAID_CNV::BraidWord2Knot(s,inout K::Knot,true,true) then
else #OUT+"failed to convert str to knot\n";
end;
else #OUT+"failed to make braid.\n";
end;
when 8 then
s:STR:="";
if NDATA_CNV::Knot2NDataStr(K::Knot,out s) then
#OUT+"ndata: "+s+"\n";
if NDATA_CNV::NDataStr2Knot(s,inout K::Knot) then
else #OUT+"failed to convert str to knot\n";
end;
else #OUT+"failed to make ndata.\n";
end;
when 9 then #OUT+"test code\n";
--if PRETZEL_CNV::Pretzel2Knot(|2,3,-2,4|,inout K::Knot) then; end;
--if PRETZEL_CNV::Pretzel2Knot("2 3 -2 4 endcode",inout K::Knot) then; end;
end;
startProc; repaint;
return reply;
end;
end;