public void checkIfJointNamesAreUnique(LinkNode basenode, LinkNode currentNode, List<List<string>> conflicts)
        {
            List<string> conflict = new List<string>();

            //Finds the conflicts of the currentNode with all the other nodes
            checkIfJointNamesAreUnique(basenode, currentNode.jointName, conflict);
            bool alreadyExists = false;
            foreach (List<string> existingConflict in conflicts)
            {
                if (conflict.Count > 0 && existingConflict.Contains(conflict[0]))
                {
                    alreadyExists = true;
                }
            }

            if (!alreadyExists)
            {
                conflicts.Add(conflict);
            }
            foreach (LinkNode child in currentNode.Nodes)
            {
                //Proceeds recursively through the children nodes and adds to the conflicts list of lists.
                checkIfJointNamesAreUnique(basenode, child, conflicts);
            }
        }
 //As nodes are created and destroyed, this menu gets called a lot. It basically just adds the context menu (right-click menu)
 // to the node
 public void addDocMenu(LinkNode node)
 {
     node.ContextMenuStrip = docMenu;
     foreach (LinkNode child in node.Nodes)
     {
         addDocMenu(child);
     }
 }
 public void checkIfJointNamesAreUnique(LinkNode node, string jointName, List<string> conflict)
 {
     if (node.jointName == jointName)
     {
         conflict.Add(node.linkName);
     }
     foreach (LinkNode child in node.Nodes)
     {
         checkIfLinkNamesAreUnique(child, jointName, conflict);
     }
 }
Beispiel #4
0
        public AssemblyExportForm(ISldWorks iSwApp, LinkNode node)
        {
            InitializeComponent();
            swApp = iSwApp;
            BaseNode = node;
            ActiveSWModel = swApp.ActiveDoc;
            Exporter = new URDFExporter(iSwApp);
            AutoUpdatingForm = false;


            jointBoxes = new Control[] {
                textBox_joint_name, comboBox_axis, comboBox_joint_type,
                textBox_axis_x, textBox_axis_y, textBox_axis_z,
                textBox_joint_x, textBox_joint_y, textBox_joint_z, textBox_joint_pitch, textBox_joint_roll, textBox_joint_yaw,
                textBox_limit_lower, textBox_limit_upper, textBox_limit_effort, textBox_limit_velocity,
                textBox_damping, textBox_friction,
                textBox_calibration_falling, textBox_calibration_rising,
                textBox_soft_lower, textBox_soft_upper, textBox_k_position, textBox_k_velocity
            };
            linkBoxes = new Control[] {
                textBox_inertial_origin_x, textBox_inertial_origin_y, textBox_inertial_origin_z, textBox_inertial_origin_roll, textBox_inertial_origin_pitch, textBox_inertial_origin_yaw,
                textBox_visual_origin_x, textBox_visual_origin_y, textBox_visual_origin_z, textBox_visual_origin_roll, textBox_visual_origin_pitch, textBox_visual_origin_yaw,
                textBox_collision_origin_x, textBox_collision_origin_y, textBox_collision_origin_z, textBox_collision_origin_roll, textBox_collision_origin_pitch, textBox_collision_origin_yaw,
                textBox_ixx, textBox_ixy, textBox_ixz, textBox_iyy, textBox_iyz, textBox_izz,
                textBox_mass, 
                domainUpDown_red, domainUpDown_green, domainUpDown_blue, domainUpDown_alpha,
                comboBox_materials,
                textBox_texture
            };

            saveConfigurationAttributeDef = iSwApp.DefineAttribute("URDF Export Configuration");
            int Options = 0;

            saveConfigurationAttributeDef.AddParameter("data", (int)swParamType_e.swParamTypeString, 0, Options);
            saveConfigurationAttributeDef.AddParameter("name", (int)swParamType_e.swParamTypeString, 0, Options);
            saveConfigurationAttributeDef.AddParameter("date", (int)swParamType_e.swParamTypeString, 0, Options);
            saveConfigurationAttributeDef.AddParameter("exporterVersion", (int)swParamType_e.swParamTypeDouble, 1.0, Options);
            saveConfigurationAttributeDef.Register();
        }
Beispiel #5
0
        private void button_joint_next_Click(object sender, EventArgs e)
        {
            if (!(previouslySelectedNode == null || previouslySelectedNode.Link.Joint == null))
            {
                 saveJointDataFromPropertyBoxes(previouslySelectedNode.Link.Joint);
            }
            previouslySelectedNode = null; // Need to clear this for the link properties page
            //treeView_linkProperties.Nodes.Clear();
            //Exporter.mRobot = createRobotFromTreeView(treeView_jointtree);
            //fillTreeViewFromRobot(Exporter.mRobot, treeView_linkProperties);

            while (treeView_jointtree.Nodes.Count > 0)
            {
                LinkNode node = (LinkNode)treeView_jointtree.Nodes[0];
                treeView_jointtree.Nodes.Remove(node);
                BaseNode.Nodes.Add(node);
            }
            changeAllNodeFont(BaseNode, new System.Drawing.Font(treeView_jointtree.Font, FontStyle.Regular));
            fillLinkTree();
            panel_link_properties.Visible = true;
            this.Focus();
        }
        // Calls the Exporter loadConfigTree method and then populates the tree with the loaded config
        public void loadConfigTree()
        {
            Object[] objects = ActiveSWModel.FeatureManager.GetFeatures(true);
            string data = "";
            foreach (Object obj in objects)
            {
                Feature feat = (Feature)obj;
                string t = feat.GetTypeName2();
                if (feat.GetTypeName2() == "Attribute")
                {
                    SolidWorks.Interop.sldworks.Attribute att = (SolidWorks.Interop.sldworks.Attribute)feat.GetSpecificFeature2();
                    if (att.GetName() == "URDF Export Configuration")
                    {
                        Parameter param = att.GetParameter("data");
                        data = param.GetStringValue();
                    }
                }

            }
            LinkNode basenode = null;
            if (!data.Equals(""))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(SerialNode));
                XmlTextReader textReader = new XmlTextReader(new StringReader(data));
                SerialNode node = (SerialNode)serializer.Deserialize(textReader);
                basenode = new LinkNode(node);
                Common.loadSWComponents(ActiveSWModel, basenode);
                textReader.Close();
            }

            if (basenode == null)
            {
                basenode = createEmptyNode(null);
            }
            addDocMenu(basenode);

            tree.Nodes.Clear();
            tree.Nodes.Add(basenode);
            tree.ExpandAll();
            tree.SelectedNode = tree.Nodes[0];
        }
 // Finds the next incomplete node and returns that
 public LinkNode findNextLinkToVisit(LinkNode nodeToCheck)
 {
     if (nodeToCheck.Link.isIncomplete)
     {
         return nodeToCheck;
     }
     foreach (LinkNode node in nodeToCheck.Nodes)
     {
         return findNextLinkToVisit(node);
     }
     return null;
 }
Beispiel #8
0
        // The one used by the Assembly Exporter
        public void createRobotFromTreeView(LinkNode baseNode)
        {
            mRobot = new robot();

            progressBar.Start(0, Common.getCount(baseNode.Nodes) + 1, "Building links");
            int count = 0;

            progressBar.UpdateProgress(count);
            progressBar.UpdateTitle("Building link: " + baseNode.Name);
            count++;

            link BaseLink = createLink(baseNode, 1);
            mRobot.BaseLink = BaseLink;
            baseNode.Link = BaseLink;

            progressBar.End();
        }
        //Populates the TreeView with the organized links from the robot
        public void fillTreeViewFromRobot(robot robot)
        {
            tree.Nodes.Clear();
            LinkNode baseNode = new LinkNode();
            link baseLink = robot.BaseLink;
            baseNode.Name = baseLink.name;
            baseNode.Text = baseLink.name;
            baseNode.Link = baseLink;
            baseNode.ContextMenuStrip = docMenu;

            foreach (link child in baseLink.Children)
            {
                baseNode.Nodes.Add(createLinkNodeFromLink(child));
            }
            tree.Nodes.Add(baseNode);
            tree.ExpandAll();
        }
Beispiel #10
0
        //Method which builds an entire link and iterates through.
        public link createLink(LinkNode node, int count)
        {
            progressBar.UpdateTitle("Building link: " + node.Name);
            progressBar.UpdateProgress(count);
            link Link;
            if (node.isBaseNode)
            {

                createBaseLinkFromComponents(node);
                Link = mRobot.BaseLink;
            }
            else
            {
                LinkNode parentNode = (LinkNode)node.Parent;
                Link = createLinkFromComponents(parentNode.Link, node.Components, node);
            }
            node.Link = Link;
            foreach (LinkNode child in node.Nodes)
            {
                link childLink = createLink(child, count + 1);
                Link.Children.Add(childLink);
            }
            return Link;
        }
 public void selectFeatures(LinkNode node)
 {
     ActiveSWModel.Extension.SelectByID2(node.coordsysName, "COORDSYS", 0, 0, 0, true, -1, null, 0);
     if (node.axisName != "None")
     {
         ActiveSWModel.Extension.SelectByID2(node.axisName, "AXIS", 0, 0, 0, true, -1, null, 0);
     }
     foreach (LinkNode child in node.Nodes)
     {
         selectFeatures(child);
     }
 }
Beispiel #12
0
 public void checkRefGeometryExists(LinkNode node)
 {
     if (!checkRefCoordsysExists(node.coordsysName))
     {
         node.coordsysName = "Automatically Generate";
     }
     if (!checkRefAxisExists(node.axisName))
     {
         node.axisName = "Automatically Generate";
     }
 }
        //Creates an Empty node when children are added to a link
        public LinkNode createEmptyNode(LinkNode Parent)
        {
            LinkNode node = new LinkNode();

            if (Parent == null)             //For the base_link node
            {
                node.linkName = "base_link";
                node.axisName = "";
                node.coordsysName = "Automatically Generate";
                node.Components = new List<Component2>();
                node.isBaseNode = true;
                node.isIncomplete = true;
            }
            else
            {
                node.isBaseNode = false;
                node.linkName = "Empty_Link";
                node.axisName = "Automatically Generate";
                node.coordsysName = "Automatically Generate";
                node.jointType = "Automatically Detect";
                node.Components = new List<Component2>();
                node.isBaseNode = false;
                node.isIncomplete = true;
            }
            node.Name = node.linkName;
            node.Text = node.linkName;
            node.ContextMenuStrip = docMenu;
            return node;
        }
 //Recursive function to iterate though nodes and build a message containing those that are incomplete
 public string checkNodesComplete(LinkNode node, string incompleteNodes)
 {
     // Determine if the node is incomplete
     checkNodeComplete(node);
     if (node.isIncomplete)
     {
         incompleteNodes += "    '" + node.Text + "':\r\n" + node.whyIncomplete + "\r\n\r\n"; //Building the message
     }
     // Cycle through the rest of the nodes
     foreach (LinkNode child in node.Nodes)
     {
         incompleteNodes = checkNodesComplete(child, incompleteNodes);
     }
     return incompleteNodes;
 }
 //Sets the node's isIncomplete flag if the node has key items that need to be completed
 public void checkNodeComplete(LinkNode node)
 {
     node.whyIncomplete = "";
     node.isIncomplete = false;
     if (node.linkName.Equals(""))
     {
         node.isIncomplete = true;
         node.whyIncomplete += "        Link name is empty. Fill in a unique link name\r\n";
     }
     if (node.Nodes.Count > 0 && node.Components.Count == 0)
     {
         node.isIncomplete = true;
         node.whyIncomplete += "        Links with children cannot be empty. Select its associated components\r\n";
     }
     if (node.Components.Count == 0 && node.coordsysName == "Automatically Generate")
     {
         node.isIncomplete = true;
         node.whyIncomplete += "        The origin reference coordinate system cannot be automatically generated\r\n";
         node.whyIncomplete += "        without components. Either select an origin or at least one component.";
     }
     if (node.jointName == "" && !node.isBaseNode)
     {
         node.isIncomplete = true;
         node.whyIncomplete += "        Joint name is empty. Fill in a unique joint name\r\n";
     }
 }
        public bool checkIfNamesAreUnique(LinkNode node)
        {
            List<List<string>> linkConflicts = new List<List<string>>();
            List<List<string>> jointConflicts = new List<List<string>>();
            checkIfLinkNamesAreUnique(node, node, linkConflicts);
            checkIfJointNamesAreUnique(node, node, jointConflicts);

            string message = "\r\nPlease fix these errors before proceeding.";
            string specificErrors = "";
            bool displayInitialMessage = true;
            bool linkNamesInConflict = false;
            foreach (List<string> conflict in linkConflicts)
            {
                if (conflict.Count > 1)
                {
                    linkNamesInConflict = true;
                    if (displayInitialMessage)
                    {
                        specificErrors += "The following links have LINK names that conflict:\r\n\r\n";
                        displayInitialMessage = false;
                    }
                    bool isFirst = true;
                    foreach (string linkName in conflict)
                    {
                        specificErrors += (isFirst) ? "     " + linkName : ", " + linkName;
                        isFirst = false;
                    }
                    specificErrors += "\r\n";

                }

            }
            displayInitialMessage = true;
            foreach (List<string> conflict in jointConflicts)
            {
                if (conflict.Count > 1)
                {
                    linkNamesInConflict = true;
                    if (displayInitialMessage)
                    {
                        specificErrors += "The following links have JOINT names that conflict:\r\n\r\n";
                        displayInitialMessage = false;
                    }
                    bool isFirst = true;
                    foreach (string linkName in conflict)
                    {
                        specificErrors += (isFirst) ? "     " + linkName : ", " + linkName;
                        isFirst = false;
                    }
                    specificErrors += "\r\n";
                }
            }
            if (linkNamesInConflict)
            {
                MessageBox.Show(specificErrors + message);
                return false;
            }
            return true;
        }
Beispiel #17
0
 // Captures which node was right clicked
 private void tree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     rightClickedNode = (LinkNode)e.Node;
 }
Beispiel #18
0
        //Base method for constructing a joint from a parent link and child link.
        public void createJoint(link parent, link child, LinkNode node)
        {
            checkRefGeometryExists(node);

            string jointName = node.jointName;
            string coordSysName = node.coordsysName;
            string axisName = node.axisName;
            string jointType = node.jointType;

            List<Component2> componentsToFix = fixComponents(parent);
            AssemblyDoc assy = (AssemblyDoc)ActiveSWModel;

            child.Joint = new joint();
            child.Joint.name = jointName;
            child.Joint.Parent.name = parent.name;
            child.Joint.Child.name = child.name;

            if (child.isFixedFrame)
            {
                axisName = "";
                jointType = "fixed";
                child.Joint.type = jointType;
            }
            else if (coordSysName == "Automatically Generate" || axisName == "Automatically Generate" || jointType == "Automatically Detect")
            {
                // We have to estimate the joint if the user specifies automatic for either the reference coordinate system, the reference axis or the joint type.
                estimateGlobalJointFromComponents(assy, parent, child);
            }

            if (coordSysName == "Automatically Generate")
            {
                child.Joint.CoordinateSystemName = "Origin_" + child.Joint.name;
                ActiveSWModel.ClearSelection2(true);
                int i = 2;
                while (ActiveSWModel.Extension.SelectByID2(child.Joint.CoordinateSystemName, "COORDSYS", 0, 0, 0, false, 0, null, 0))
                {
                    ActiveSWModel.ClearSelection2(true);
                    child.Joint.CoordinateSystemName = "Origin_" + child.Joint.name + i.ToString();
                    i++;
                }
                createRefOrigin(child.Joint);
            }
            else
            {
                child.Joint.CoordinateSystemName = coordSysName;
            }
            if (axisName == "Automatically Generate")
            {
                child.Joint.AxisName = "Axis_" + child.Joint.name;
                ActiveSWModel.ClearSelection2(true);
                int i = 2;
                while (ActiveSWModel.Extension.SelectByID2(child.Joint.AxisName, "AXIS", 0, 0, 0, false, 0, null, 0))
                {
                    ActiveSWModel.ClearSelection2(true);
                    child.Joint.AxisName = "Axis_" + child.Joint.name + i.ToString();
                    i++;
                }
                if (child.Joint.type != "fixed")
                {
                    createRefAxis(child.Joint);
                }
            }
            else
            {
                child.Joint.AxisName = axisName;
            }
            if (jointType != "Automatically Detect")
            {
                child.Joint.type = jointType;
            }

            estimateGlobalJointFromRefGeometry(parent, child);

            coordSysName = (parent.Joint == null) ? parent.CoordSysName : parent.Joint.CoordinateSystemName;
            unFixComponents(componentsToFix);
            localizeJoint(child.Joint, coordSysName);
        }
Beispiel #19
0
        //Method which builds a single link
        public link createLinkFromComponents(link parent, List<Component2> components, LinkNode node)
        {
            link child = new link();
            child.name = node.linkName;

            if (components.Count > 0)
            {
                child.isFixedFrame = false;
                child.Visual = new visual();
                child.Inertial = new inertial();
                child.Collision = new collision();
                child.SWMainComponent = components[0];
                child.SWcomponents.AddRange(components);
            }
            //Get link properties from SolidWorks part

            if (parent != null)
            {
                createJoint(parent, child, node);
            }

            string childCoordSysName = "";
            if (child.Joint == null)
            {
                childCoordSysName = node.coordsysName;
            }
            else
            {
                childCoordSysName = child.Joint.CoordinateSystemName;
            }

            // Get the SolidWorks MathTransform that corresponds to the child coordinate system
            MathTransform jointTransform = getCoordinateSystemTransform(childCoordSysName);

            if (!child.isFixedFrame)
            {
                //selectComponents(components, true);
                IMassProperty swMass = ActiveSWModel.Extension.CreateMassProperty();
                swMass.SetCoordinateSystem(jointTransform);

                Body2[] bodies = getBodies(components);
                bool addedBodies = swMass.AddBodies(bodies);
                child.Inertial.Mass.value = swMass.Mass;
                double[] moment = swMass.GetMomentOfInertia((int)swMassPropertyMoment_e.swMassPropertyMomentAboutCenterOfMass); // returned as double with values [Lxx, Lxy, Lxz, Lyx, Lyy, Lyz, Lzx, Lzy, Lzz]
                child.Inertial.Inertia.setMomentMatrix(moment);

                double[] centerOfMass = swMass.CenterOfMass;
                child.Inertial.Origin.xyz = centerOfMass;
                child.Inertial.Origin.rpy = new double[3] { 0, 0, 0 };

                // Will this ever not be zeros?
                child.Visual.Origin.xyz = new double[3] { 0, 0, 0 };
                child.Visual.Origin.rpy = new double[3] { 0, 0, 0 };
                child.Collision.Origin.xyz = new double[3] { 0, 0, 0 };
                child.Collision.Origin.rpy = new double[3] { 0, 0, 0 };

                // [ R, G, B, Ambient, Diffuse, Specular, Shininess, Transparency, Emission ]
                ModelDoc2 mainCompdoc = components[0].GetModelDoc2();
                double[] values = mainCompdoc.MaterialPropertyValues;
                child.Visual.Material.Color.Red = values[0];
                child.Visual.Material.Color.Green = values[1];
                child.Visual.Material.Color.Blue = values[2];
                child.Visual.Material.Color.Alpha = 1.0 - values[7];
                //child.Visual.Material.name = "material_" + child.name;

                //The part model doesn't actually know where the origin is, but the component does and this is important when exporting from assembly
                child.Visual.Origin.xyz = new double[] { 0, 0, 0 };
                child.Visual.Origin.rpy = new double[] { 0, 0, 0 };
                child.Collision.Origin.xyz = new double[] { 0, 0, 0 };
                child.Collision.Origin.rpy = new double[] { 0, 0, 0 };
            }

            //ActiveSWModel.ClearSelection2(true);
            return child;
        }
 public void moveComponentsToFolder(LinkNode node)
 {
     bool needToCreateFolder = true;
     Object[] objects = ActiveSWModel.FeatureManager.GetFeatures(true);
     foreach (Object obj in objects)
     {
         Feature feat = (Feature)obj;
         if (feat.Name == "URDF Export Items")
         {
             needToCreateFolder = false;
         }
     }
     ActiveSWModel.ClearSelection2(true);
     ActiveSWModel.Extension.SelectByID2("Origin_global", "COORDSYS", 0, 0, 0, true, 0, null, 0);
     if (needToCreateFolder)
     {
         Feature folderFeature = ActiveSWModel.FeatureManager.InsertFeatureTreeFolder2((int)swFeatureTreeFolderType_e.swFeatureTreeFolder_Containing);
         folderFeature.Name = "URDF Export Items";
     }
     ActiveSWModel.Extension.SelectByID2("URDF Reference", "SKETCH", 0, 0, 0, true, 0, null, 0);
     ActiveSWModel.FeatureManager.MoveToFolder("URDF Export Items", "", false);
     ActiveSWModel.Extension.SelectByID2("URDF Export Configuration", "ATTRIBUTE", 0, 0, 0, true, 0, null, 0);
     ActiveSWModel.FeatureManager.MoveToFolder("URDF Export Items", "", false);
     selectFeatures(node);
     ActiveSWModel.FeatureManager.MoveToFolder("URDF Export Items", "", false);
 }
 public void retrieveSWComponentPIDs(LinkNode node)
 {
     if (node.Components != null)
     {
         node.ComponentPIDs = new List<byte[]>();
         foreach (IComponent2 comp in node.Components)
         {
             byte[] PID = ActiveSWModel.Extension.GetPersistReference3(comp);
             node.ComponentPIDs.Add(PID);
         }
     }
     foreach (LinkNode child in node.Nodes)
     {
         retrieveSWComponentPIDs(child);
     }
 }
 // Determines how many nodes need to be built, and they are added to the current node
 private void createNewNodes(LinkNode CurrentlySelectedNode)
 {
     int nodesToBuild = (int)pm_NumberBox_ChildCount.Value - CurrentlySelectedNode.Nodes.Count;
     createNewNodes(CurrentlySelectedNode, nodesToBuild);
 }
        public void saveConfigTree(ModelDoc2 model, LinkNode BaseNode, bool warnUser)
        {
            Object[] objects = model.FeatureManager.GetFeatures(true);
            string oldData = "";
            Parameter param;
            foreach (Object obj in objects)
            {
                Feature feat = (Feature)obj;
                string t = feat.GetTypeName2();
                if (feat.GetTypeName2() == "Attribute")
                {
                    SolidWorks.Interop.sldworks.Attribute att = (SolidWorks.Interop.sldworks.Attribute)feat.GetSpecificFeature2();
                    if (att.GetName() == "URDF Export Configuration")
                    {
                        param = att.GetParameter("data");
                        oldData = param.GetStringValue();
                    }
                }
            }
            //moveComponentsToFolder((LinkNode)tree.Nodes[0]);
            retrieveSWComponentPIDs(BaseNode);
            SerialNode sNode = new SerialNode(BaseNode);
            StringWriter stringWriter;
            XmlSerializer serializer = new XmlSerializer(typeof(SerialNode));
            stringWriter = new StringWriter();
            serializer.Serialize(stringWriter, sNode);
            stringWriter.Flush();
            stringWriter.Close();

            string newData = stringWriter.ToString();
            if (oldData != newData)
            {
                if (!warnUser || (warnUser && MessageBox.Show("The configuration has changed, would you like to save?", "Save Export Configuration", MessageBoxButtons.YesNo) == DialogResult.Yes))
                {
                    int ConfigurationOptions = (int)swInConfigurationOpts_e.swAllConfiguration;
                    SolidWorks.Interop.sldworks.Attribute saveExporterAttribute = createSWSaveAttribute("URDF Export Configuration");
                    param = saveExporterAttribute.GetParameter("data");
                    param.SetStringValue2(stringWriter.ToString(), ConfigurationOptions, "");
                    param = saveExporterAttribute.GetParameter("name");
                    param.SetStringValue2("config1", ConfigurationOptions, "");
                    param = saveExporterAttribute.GetParameter("date");
                    param.SetStringValue2(DateTime.Now.ToString(), ConfigurationOptions, "");
                    param = saveExporterAttribute.GetParameter("exporterVersion");
                    param.SetStringValue2("1.1", ConfigurationOptions, "");
                }
            }
        }
 // Adds an asterix to the node text if it is incomplete (not currently used)
 private void updateNodeNames(LinkNode node)
 {
     if (node.isIncomplete)
     {
         node.Text = node.linkName + "*";
     }
     foreach (LinkNode child in node.Nodes)
     {
         updateNodeNames(child);
     }
 }
        // When a new node is selected or another node is found that needs to be visited, this method saves the previously
        // active node and fills in the property mananger with the new one
        public void switchActiveNodes(LinkNode node)
        {
            saveActiveNode();

            Font fontRegular = new Font(tree.Font, FontStyle.Regular);
            Font fontBold = new Font(tree.Font, FontStyle.Bold);
            if (previouslySelectedNode != null)
            {
                previouslySelectedNode.NodeFont = fontRegular;
            }
            fillPropertyManager(node);

            //If this flag is set to true, it prevents this method from getting called again when changing the selected node
            automaticallySwitched = true;

            //Change the selected node to the argument node. This highlights the newly activated node
            tree.SelectedNode = node;

            node.NodeFont = fontBold;
            node.Text = node.Text;
            previouslySelectedNode = node;
            checkNodeComplete(node);
        }
Beispiel #26
0
 public void createBaseLinkFromComponents(LinkNode node)
 {
     // Build the link from the partdoc
     link Link = createLinkFromComponents(null, node.Components, node);
     if (node.coordsysName == "Automatically Generate")
     {
         createBaseRefOrigin(true);
         node.coordsysName = "Origin_global";
         Link.CoordSysName = node.coordsysName;
     }
     else
     {
         Link.CoordSysName = node.coordsysName;
     }
     mRobot.BaseLink = Link;
 }
        // Adds the number of empty nodes to the currently active node
        private void createNewNodes(LinkNode currentNode, int number)
        {
            for (int i = 0; i < number; i++)
            {
                LinkNode node = createEmptyNode(currentNode);
                currentNode.Nodes.Add(node);
            }
            for (int i = 0; i < -number; i++)
            {
                currentNode.Nodes.RemoveAt(currentNode.Nodes.Count - 1);
            }
            int itemsCount = Common.getCount(tree.Nodes);
            int itemHeight = 1 + itemsCount * tree.ItemHeight;
            int min = 163;
            int max = 600;

            int height = ops.envelope(itemHeight, min, max);
            tree.Height = height;
            pm_tree.Height = height;
            currentNode.ExpandAll();
        }
        // Similar to the AssemblyExportForm method. It creates a LinkNode from a Link object
        public LinkNode createLinkNodeFromLink(link Link)
        {
            LinkNode node = new LinkNode();
            node.Name = Link.name;
            node.Text = Link.name;
            node.Link = Link;
            node.ContextMenuStrip = docMenu;

            foreach (link child in Link.Children)
            {
                node.Nodes.Add(createLinkNodeFromLink(child));
            }
            node.Link.Children.Clear(); // Need to erase the children from the embedded link because they may be rearranged later.
            return node;
        }
Beispiel #29
0
        public SerialNode(LinkNode node)
        {
            Nodes = new List<SerialNode>();
            if (node.Link == null)
            {
                linkName = node.linkName;
                jointName = node.jointName;
                axisName = node.axisName;
                coordsysName = node.coordsysName;
                componentPIDs = node.ComponentPIDs;
                jointType = node.jointType;
                isBaseNode = node.isBaseNode;
                isIncomplete = node.isIncomplete;
            }
            else
            {
                linkName = (string)node.Link.name;
                
                componentPIDs = node.ComponentPIDs;
                if (node.Link.Joint != null)
                {
                    jointName = (string)node.Link.Joint.name;

                    if (node.Link.Joint.Axis.X == 0 && node.Link.Joint.Axis.Y == 0 && node.Link.Joint.Axis.Z == 0)
                    {
                        axisName = "None";
                    }
                    else
                    {
                        axisName = node.Link.Joint.AxisName;
                    }
                    coordsysName = node.Link.Joint.CoordinateSystemName;
                    jointType = (string)node.Link.Joint.type;
                }
                else
                {
                    coordsysName = node.coordsysName;
                }

                isBaseNode = node.isBaseNode;
                isIncomplete = node.isIncomplete;
            }
            //Proceed recursively through the nodes
            foreach (LinkNode child in node.Nodes)
            {
                Nodes.Add(new SerialNode(child));
            }
        }
        //Sets all the controls in the Property Manager from the Selected Node
        public void fillPropertyManager(LinkNode node)
        {
            pm_TextBox_LinkName.Text = node.linkName;
            pm_NumberBox_ChildCount.Value = node.Nodes.Count;

            //Selecting the associated link components
            Common.selectComponents(ActiveSWModel, node.Components, true, pm_Selection.Mark);

            //Setting joint properties
            if (!node.isBaseNode && node.Parent != null)
            {
                //Combobox needs to be blanked before de-activating
                selectComboBox(pm_ComboBox_GlobalCoordsys, "");

                //Labels need to be activated before changing them
                enableControls(!node.isBaseNode);
                pm_TextBox_JointName.Text = node.jointName;
                pm_Label_ParentLink.Caption = node.Parent.Name;

                updateComboBoxFromFeatures(pm_ComboBox_CoordSys, "CoordSys");
                //checkTransforms(ActiveSWModel);

                updateComboBoxFromFeatures(pm_ComboBox_Axes, "RefAxis");
                pm_ComboBox_Axes.AddItems("None");
                selectComboBox(pm_ComboBox_CoordSys, node.coordsysName);
                selectComboBox(pm_ComboBox_Axes, node.axisName);
                selectComboBox(pm_ComboBox_JointType, node.jointType);
            }
            else
            {
                //Labels and text box have be blanked before de-activating them
                pm_Label_ParentLink.Caption = " ";
                selectComboBox(pm_ComboBox_CoordSys, "");
                selectComboBox(pm_ComboBox_Axes, "");
                selectComboBox(pm_ComboBox_JointType, "");

                //Activate controls before changing them
                enableControls(!node.isBaseNode);
                updateComboBoxFromFeatures(pm_ComboBox_GlobalCoordsys, "CoordSys");
                selectComboBox(pm_ComboBox_GlobalCoordsys, node.coordsysName);
            }
        }