// Fields for handling and storing parts of the image messages // sent from the executive. protected override void handleImageMessage(int id, string line) { Scanner scanner = new Scanner(); String r = @"\d+:\s+IMAGE:\s+##\d+ (\d+)x(\d+) (.*)={Double} aspect={Double} " + @"from=\({Double},{Double},{Double}\) to=\({Double},{Double},{Double}\) " + @"up=\({Double},{Double},{Double}\) " + @"box=\({Double},{Double},{Double}\)\({Double},{Double},{Double}\)\({Double},{Double},{Double}\)\({Double},{Double},{Double}\) " + @"aamat=\({Double},{Double},{Double}\)\({Double},{Double},{Double}\)\({Double},{Double},{Double}\)\({Double},{Double},{Double}\)\s+" + @"ddcamera=(\d+) button=(\d+)"; r = scanner.CreateRegexPattern(r); Regex regex = new Regex(r); Match m = regex.Match(line); if (m.Success) { int x = int.Parse(m.Groups[1].Value); int y = int.Parse(m.Groups[2].Value); String s = m.Groups[3].Value; double w = double.Parse(m.Groups[4].Value); double a = double.Parse(m.Groups[5].Value); double[] from = { double.Parse(m.Groups[6].Value), double.Parse(m.Groups[7].Value), double.Parse(m.Groups[8].Value) }; double[] to = { double.Parse(m.Groups[9].Value), double.Parse(m.Groups[10].Value), double.Parse(m.Groups[11].Value) }; double[] up = { double.Parse(m.Groups[12].Value), double.Parse(m.Groups[13].Value), double.Parse(m.Groups[14].Value) }; double[,] box = { { double.Parse(m.Groups[15].Value), double.Parse(m.Groups[16].Value), double.Parse(m.Groups[17].Value) }, { double.Parse(m.Groups[18].Value), double.Parse(m.Groups[19].Value), double.Parse(m.Groups[20].Value) }, { double.Parse(m.Groups[21].Value), double.Parse(m.Groups[22].Value), double.Parse(m.Groups[23].Value) }, { double.Parse(m.Groups[24].Value), double.Parse(m.Groups[25].Value), double.Parse(m.Groups[26].Value) } }; double[,] aamat = { { double.Parse(m.Groups[27].Value), double.Parse(m.Groups[28].Value), double.Parse(m.Groups[29].Value) }, { double.Parse(m.Groups[30].Value), double.Parse(m.Groups[31].Value), double.Parse(m.Groups[32].Value) }, { double.Parse(m.Groups[33].Value), double.Parse(m.Groups[34].Value), double.Parse(m.Groups[35].Value) }, { double.Parse(m.Groups[36].Value), double.Parse(m.Groups[37].Value), double.Parse(m.Groups[38].Value) } }; int ddcamera = int.Parse(m.Groups[39].Value); int button = int.Parse(m.Groups[40].Value); bool persp; double viewAngle; if (s == "width") persp = false; else persp = true; double xdiff = from[0] - to[0]; double ydiff = from[1] - to[1]; double zdiff = from[2] - to[2]; double dist = Math.Sqrt(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); if (persp) { viewAngle = Math.Atan(w / 2) * 360 / Math.PI; w = dist * w; } else { viewAngle = Math.Atan((w / 2) / dist) * 360 / Math.PI; } DirectInteractionMode imode = image.getInteractionMode(); if (ddcamera == 1 || button == 1) { // If in navigate mode, then to, from and up are // set elsewhere. if (imode != DirectInteractionMode.NAVIGATE || ddcamera == 1) { this.setTo(to, false); this.setFrom(from, false); this.setUp(up, false); } setResolution(x, y, false); setWidth(w, false); setAspect(a, false); setBox(box, false); setProjection(persp, false); setViewAngle(viewAngle, false); enableVector(true, false); sendValuesQuietly(); image.newCamera(box, aamat, from, to, up, x, y, w, persp, viewAngle); } else if (!image.IsCameraInitialized || imode == DirectInteractionMode.NAVIGATE) image.newCamera(box, aamat, from, to, up, x, y, w, persp, viewAngle); image.allowDirectInteraction(true); if (this.saveInteractionMode != DirectInteractionMode.NONE) { image.setInteractionMode(saveInteractionMode); saveInteractionMode = DirectInteractionMode.NONE; } } else { regex = new Regex(@"\d+: IMAGE: ##\d+ (\d+)x(\d+)"); m = regex.Match(line); if (m.Success) { int x = int.Parse(m.Groups[1].Value); int y = int.Parse(m.Groups[2].Value); setResolution(x, y, false); image.allowDirectInteraction(false); image.clearFrameBufferOverlay(); } } }
public void setInteractionModeParameter(DirectInteractionMode mode) { throw new Exception("Not Yet Implemented"); }
public bool setInteractionMode(String mode) { int i, n; Regex regex = new Regex(@"(\S+)(?:\s+(\S+))?"); Match m = regex.Match(mode); String imode = m.Groups[1].Value; DirectInteractionMode interactionMode; if (imode.ToLower().StartsWith("camera")) interactionMode = DirectInteractionMode.CAMERA; else if (imode.ToLower().StartsWith("cursors")) interactionMode = DirectInteractionMode.CURSORS; else if (imode.ToLower().StartsWith("pick")) interactionMode = DirectInteractionMode.PICK; else if (imode.ToLower().StartsWith("navigate")) interactionMode = DirectInteractionMode.NAVIGATE; else if (imode.ToLower().StartsWith("panzoom")) interactionMode = DirectInteractionMode.PANZOOM; else if (imode.ToLower().StartsWith("roam")) interactionMode = DirectInteractionMode.ROAM; else if (imode.ToLower().StartsWith("rotate")) interactionMode = DirectInteractionMode.ROTATE; else if (imode.ToLower().StartsWith("zoom")) interactionMode = DirectInteractionMode.ZOOM; else interactionMode = DirectInteractionMode.NONE; ImageWindow img = this.image; if (img != null) { if (m.Groups[2].Captures.Count > 0) { Type clss; if (interactionMode == DirectInteractionMode.CURSORS) clss = typeof(ProbeNode); else if (interactionMode == DirectInteractionMode.PICK) clss = typeof(PickNode); else goto no_arg; List<Node> pl = DXApplication.theDXApplication.network.makeClassifiedNodeList(clss); if (pl != null && pl.Count > 0) { String arg = m.Groups[2].Value; if (arg.StartsWith("label=")) arg = arg.Substring(6); int inum = -1; foreach (Node nd in pl) { if (arg == nd.LabelString) { inum = nd.InstanceNumber; break; } } if (inum > 0) { if (interactionMode == DirectInteractionMode.CURSORS) img.setCurrentProbe(inum); else img.setCurrentPick(inum); } } } img.allowDirectInteraction(true); img.setInteractionMode(interactionMode); } else saveInteractionMode = interactionMode; no_arg: return true; }
public override void setDefaultCfgState() { saveInteractionMode = DirectInteractionMode.NONE; // Before resetting internal caching, check the net version number. // If it's 3.1.1 or later, then proceed. We're preventing this reset // for older nets because older versions of dx did not write internal cache // value into both .net and .cfg files. They wrote it only into the .net file. // So if we reset here, then we'll be throwing out the saved value. For current // versions of dxui, it's OK to reset because we'll find a cache value in the // .cfg file. Network net = getNetwork(); int net_major = net.getNetMajorVersion(); int net_minor = net.getNetMinorVersion(); int net_micro = net.getNetMicroVersion(); int net_version = Utils.VersionNumber(net_major, net_minor, net_micro); int fixed_version = Utils.VersionNumber(3, 1, 1); if (net_version >= fixed_version) { ImageDefinition imnd = (ImageDefinition) Definition; internalCache = imnd.DefaultInternalCacheability; } }
public ImageNode(NodeDefinition nd, Network net, int instnc) : base(nd, net, instnc) { initializeParams(); ImageDefinition imnd = (ImageDefinition)nd; macroDirty = true; translating = false; // Anything below here also belongs in this->setDefaultCfgState(). saveInteractionMode = DirectInteractionMode.NONE; internalCache = imnd.DefaultInternalCacheability; }
public bool setInteractionMode(DirectInteractionMode mode) { return true; }