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; --compatible to X-event -- event const knotButtonPress:INT:= 4; const knotButtonRelease:INT:= 5; const knotMotionNotify:INT:= 6; const knotLeaveNotify:INT:=8; -- moune 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 readonly shared CurrentEditMode:INT:=1; -- CorrentEditMode must match with menu list knot_edit[] in MODULE knotXW Restrictions is #OUT+"\n"+ "KNOT program. \n"+ "Restrictions:\n"+ -- WrS('(/=covering fold) <= '); WrI(maxN, 1); WrLn; --WrS('(/=covering fold) * (/=crossing) <= '); WrI(maxCN, 1); WrLn; "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,0,0); end; startProc is TrackEventK(-1,0,0,0); end; EditSelectK(select:INT):INT is closeProc; -- prepare for edit action case select when 0 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select; when 1 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select; when 2 then HISTORY::put(K::Knot.clone);K::Knot.NoCompo0;CurrentEditMode:=1; when 3 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select; when 4 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select; when 5 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select; when 6 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select; when 7 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select; when 8 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select; when 9 then HISTORY::put(K::Knot.clone);CurrentEditMode:=select; when 10 then CurrentEditMode:=select; when 11 then CurrentEditMode:=select; end; startProc; repaint; return CurrentEditMode; end; EffectSelectK(select:INT):INT is reply:INT:=0; closeProc; case select when 0 then ;-- SetBraid; when 1 then ;-- SetNDiagram; when 2 then ;-- Torus link when 3 then ;-- 2-bridge when 4 then HISTORY::put(K::Knot.clone); ALTERNATE::Alternate(inout K::Knot); when 5 then HISTORY::put(K::Knot.clone); K::Knot.make_coherent; when 6 then HISTORY::put(K::Knot.clone); K::Knot.transform(2.0); when 7 then HISTORY::put(K::Knot.clone); K::Knot.transform(1.4); when 8 then HISTORY::put(K::Knot.clone); K::Knot.transform(0.7); when 9 then HISTORY::put(K::Knot.clone); K::Knot.transform(0.5); when 10 then HISTORY::put(K::Knot.clone); K::Knot.transform(-1,0,0,1); when 11 then HISTORY::put(K::Knot.clone); K::Knot.transform(1,0,0,-1); when 12 then HISTORY::put(K::Knot.clone); K::Knot.mirrorZ; when 13 then HISTORY::put(K::Knot.clone); K::Knot.transform(0,-1,1,0); when 14 then HISTORY::put(K::Knot.clone); K::Knot.transform(0,1,-1,0); when 15 then HISTORY::back(inout K::Knot); when 16 then HISTORY::forward(inout K::Knot); when 17 then HISTORY::put(K::Knot.clone); end; startProc; repaint; return reply; end; shared PDefNum:INT; InvSelectK(select:INT):INT is tcode:TCODE; reply:INT:=0; closeProc; if select=16 then if PDefNum>=3 then PDefNum:=1; else PDefNum:=PDefNum+1; end; reply:=PDefNum; startProc; repaint; return reply; end; if K::Knot.is_Closed then K::Knot.CrossSet(0,K::Knot.length); else #OUT+"Knot is not closed.\n"; startProc; repaint; return reply; end; if K::Knot.has_band then case select when 1,2,3,4,5,6,7,8,12,13 then #OUT+"Not support on 2-knot."; startProc; repaint; return reply; else K::Knot.make_coherent; end; end; if K::Knot.SetTCode(out tcode) then -- tcode.get_Relator(tcode); else startProc; repaint; return reply; end; case select when 0 then KNOT_GROUP::printGroup(tcode); -- Group; when 1 then ALEXMAT::AlexMat(tcode,false,false);-- APOLY::ApolyC(tcode); when 2 then ALEXMAT::AlexMat(tcode,false,false,true);--CPOLY::Cpoly(tcode); when 3 then 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 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 VPOLY::Vpoly(tcode); when 6 then FPOLY::Fpoly(tcode); when 7 then QPOLY::Qpoly(tcode); when 8 then #OUT+"V-para.\n" ; --(* V parallel *) when 9 then ALEXMAT::AlexMat(tcode,false,true); when 10 then ALEXMATM::AlexMat(tcode);-- Apoly2V; when 11 then #OUT+"covering.\n"; -- (* Do coverings menu *) when 12 then #OUT+"sl2p.\n"; -- (* Do coverings menu *) when 13 then GOERITZ_MAT::KnotValue(tcode); when 14 then ALEXMAT::AlexMat(tcode,true,false); when 15 then if K::Knot.is_theta and SET_TCODE_ALG::SetTCode_Theta(K::Knot,out tcode) then KNOT_GROUP::printGroupTheta(tcode); end; when 16 then -- Alexander poly. for theta curve if K::Knot.is_theta and SET_TCODE_ALG::SetTCode_Theta(K::Knot,out tcode) then ALEXMATM::AlexMat_Theta(tcode); end; when 17 then #OUT+"Change definition of P-poly.\n"; end; startProc; repaint; return reply; end; VPara(n:INT) is tcode:TCODE; closeProc; if K::Knot.is_Closed then K::Knot.CrossSet(0,K::Knot.length); else #OUT+"Knot is not closed.\n"; startProc; repaint; return; end; if K::Knot.SetTCode(out tcode) then else startProc; repaint; return; end; if tcode.has_band then #OUT+"Not support on 2-knot."; startProc; repaint; 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 K::Knot.is_Closed then K::Knot.CrossSet(0,K::Knot.length); else #OUT+"Knot is not closed.\n"; startProc; repaint; return; end; if K::Knot.SetTCode(out tcode) then #REP.RepSearch(tcode,n,form,branchind,covlk,h1b,h1u,knotgrp,twistAlex, covDistY,covDistBr,covDistLk,covDistH1B,covDistH1U); end; startProc; repaint; end; RepSL2pSearch(n,form,twistAlex:INT) is tcode:TCODE; closeProc; if K::Knot.is_Closed then K::Knot.CrossSet(0,K::Knot.length); else #OUT+"Knot is not closed.\n"; startProc; repaint; return; end; if K::Knot.SetTCode(out tcode) then #REP_SL2P.RepSearch(tcode,n,form,twistAlex) end; startProc; repaint; end; FilesSelectK(select:INT):INT is reply:INT:=0; closeProc; case select 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; --(* LaTeX tpic *) 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 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; reply:=DRAW_ALG::latticeFlg.int; -- 0:false 1:true 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) 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 -- test tcode:TCODE; if K::Knot.SetTCode(out tcode) then CPOLY::Cpoly(tcode) else #OUT+"Failed to set tcode.\n"; end; end; startProc; repaint; return reply; end; end;