public string GetEffectModel() { //assemble the effect model StringBuilder effectModel = new StringBuilder(Response + "~"); //add in the response if (Covariates != null) { effectModel.Append(String.Join('+', Covariates) + '+'); } if (OtherDesignFactors != null) { effectModel.Append(String.Join('+', OtherDesignFactors) + '+'); } //complicated business of assembling the other part of the model from the interactions etc... string[] splitter = { " * " }; List <string> interactionEffects = new List <string>(SelectedEffect.Split(splitter, StringSplitOptions.RemoveEmptyEntries)); List <string> factors = new List <string>(Treatments); factors.Add(RepeatedFactor); //add in time to the factors foreach (string s in factors) { if (!interactionEffects.Contains(s)) //only add on effects if the "mainEffect"/selected effect does not already have it { effectModel.Append(s + "+"); } } return(effectModel + "mainEffect"); //where maineffect is the combined effect column of the selected effect in the dataset }
private string GetEffectModel() { //assemble the effect model StringBuilder effectModel = new StringBuilder(Response + "~"); //add in the response if (Covariates != null) { effectModel.Append(String.Join('+', Covariates) + '+'); } if (OtherDesignFactors != null) { effectModel.Append(String.Join('+', OtherDesignFactors) + '+'); } //complicated business of assembling the other part of the model from the interactions etc... string[] splitter = { " * " }; List <string> interactionEffects = new List <string>(SelectedEffect.Split(splitter, StringSplitOptions.RemoveEmptyEntries)); foreach (string treat in Treatments) { if (!interactionEffects.Contains(treat)) { effectModel.Append(treat.Trim() + "+"); } } return(effectModel + "mainEffect"); //where maineffect is the combined effect column of the selected effect in the dataset }
private void mnuTransparency_Click(object sender, EventArgs e) { if (tempImage != null) { tempImage.Dispose(); } // keep a copy tempImage = (Bitmap)selectedImage.Clone(); trkEffects.Maximum = 255; trkEffects.Minimum = 0; trkEffects.Value = oldTransparency; selectedEffect = SelectedEffect.Transparency; pnlEffects.Location = new Point(mouseX, mouseY); pnlEffects.Visible = true; }
private void contrastMenuItem_Click(object sender, EventArgs e) { if (tempImage != null) { tempImage.Dispose(); } // keep a copy tempImage = (Bitmap)selectedImage.Clone(); trkEffects.Maximum = 100; trkEffects.Minimum = -100; trkEffects.Value = 0; selectedEffect = SelectedEffect.Contrast; pnlEffects.Location = new Point(mouseX, mouseY); pnlEffects.Visible = true; }
//selects on command - tutorial only public void selectObject(GameObject newSelection) { // unhighlight previously selected fused part if (selectedObject != null) { //! CODE FOR REMOVING Marker FROM PREVIOUS PART. prevSelectedFuseTo Destroy(selectedObject.GetComponent <SelectedEffect>()); } prevSelectedObject = selectedObject; selectedObject = newSelection; //print("Currently Selected FuseTo: " + selectedFuseTo); FaceSelector currentFaceSelector = selectedObject.GetComponent <FaceSelector>(); currentFaceSelector.adjustPartAlignment(); //! CODE FOR ADDING MARKER TO SELECTED PART. selectedFuseTo if (selectedObject.GetComponent <SelectedEffect>() == null) { SelectedEffect sel = selectedObject.AddComponent <SelectedEffect>(); // this code obtains the correct normal for the ghost effects from the mesh rather than from a raycast from a mouse click, // as is done in the Update() method when the player themselves is doing the selecting RaycastResult hitInfo = new RaycastResult(); Mesh mesh = selectedObject.GetComponent <MeshFilter>().mesh; Vector3[] normals = mesh.normals; // this is dumb, but for some reason the normal for b1p2_bb1_a2 is being calculated as (-1,0,0) rather // than (1,0,0), so I had to hard code it if (!newSelection.name.Equals("b1p2_bb1_a2")) { hitInfo.worldNormal = normals[0]; } else { hitInfo.worldNormal = new Vector3(1, 0, 0); } sel.hitInfo = hitInfo; Debug.Log("Normals of hitInfo for " + selectedObject + ": " + hitInfo.worldNormal); } if (selectedObject != null && selectedFuseTo != null) { connectButton.interactable = true; } }
public override string[] ExportData() { DataTable dtNew = DataTable.CopyForExport(); //Get the response, treatment and covariate columns by removing all other columns from the new datatable foreach (string columnName in dtNew.GetVariableNames()) { if (Response != columnName && !Treatments.Contains(columnName) && (OtherDesignFactors == null || !OtherDesignFactors.Contains(columnName)) && (Covariates == null || !Covariates.Contains(columnName))) { dtNew.Columns.Remove(columnName); } } //if the response is blank then remove that row dtNew.RemoveBlankRow(Response); //Generate a "catfact" column from the CatFactors (used only in R)! DataColumn catFactor = new DataColumn("catfact"); dtNew.Columns.Add(catFactor); //Need to create a new column for the scatterplot data as we have to combine any interaction effects into one column dtNew.CreateCombinedEffectColumn(Treatments, "scatterPlotColumn"); //If an interaction effect is selected then we need to combine values into single column if (!String.IsNullOrEmpty(SelectedEffect)) { //create a new column and add it to the table if (SelectedEffect.Contains(" * ")) //then it is an interaction effect so we need to combine values from different columns { char[] splitChar = { '*' }; string[] effects = SelectedEffect.Split(splitChar, StringSplitOptions.RemoveEmptyEntries); //get the effect names that make up the interaction effect dtNew.CreateCombinedEffectColumn(effects, "mainEffect"); } else //just copy the column selected in the dropdown { DataColumn mainEffect = new DataColumn("mainEffect"); dtNew.Columns.Add(mainEffect); foreach (DataRow r in dtNew.Rows) { r["mainEffect"] = r[SelectedEffect].ToString(); } } } //Now do transformations... dtNew.TransformColumn(Response, ResponseTransformation); if (Covariates != null) { foreach (string covariate in Covariates) { dtNew.TransformColumn(covariate, CovariateTransformation); } } //Finally, as numeric categorical variables get misinterpreted by r, we need to go through //each column and put them in quotes... foreach (string treat in Treatments) { if (dtNew.CheckIsNumeric(treat)) { foreach (DataRow row in dtNew.Rows) { row[treat] = "'" + row[treat] + "'"; } } } if (OtherDesignFactors != null) { foreach (string odf in OtherDesignFactors) { if (dtNew.CheckIsNumeric(odf)) { foreach (DataRow row in dtNew.Rows) { row[odf] = "'" + row[odf] + "'"; } } } } string[] csvArray = dtNew.GetCSVArray(); //fix any columns with illegal chars here (at the end) ArgumentFormatter argFormatter = new ArgumentFormatter(); csvArray[0] = argFormatter.ConvertIllegalCharacters(csvArray[0]); return(csvArray); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit hitInfo = new RaycastHit(); if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hitInfo)) { GameObject objectToSelect = hitInfo.transform.gameObject; // print ("Currently selected object: " + selectedObject); // print ("Active part: " + activePart); Transform objectParent = objectToSelect.transform.parent; if (objectParent != null && objectToSelect.GetComponent <SelectBehavior>() != null && objectToSelect.transform.parent.gameObject.GetComponent <IsFused>().isFused) { //fused part // unhighlight previously selected fused part if (prevSelectedFuseTo != null) { unhighTexture = prevSelectedFuseTo.GetComponent <SelectBehavior>().unhighTex; prevSelectedFuseTo.GetComponent <Renderer>().material.mainTexture = unhighTexture; //! CODE FOR REMOVING Marker FROM PREVIOUS PART. prevSelectedFuseTo Destroy(prevSelectedFuseTo.GetComponent <SelectedEffect>()); } selectedFuseTo = objectToSelect; print("Currently Selected FuseTo: " + selectedFuseTo); highTexture = selectedFuseTo.GetComponent <SelectBehavior>().highTex; selectedFuseTo.GetComponent <Renderer>().material.mainTexture = highTexture; //! CODE FOR ADDING MARKER TO SELECTED PART. selectedFuseTo if (GetComponent <SelectedEffect>() == null) { SelectedEffect sel = selectedFuseTo.AddComponent <SelectedEffect>(); sel.hitInfo = hitInfo; sel.selected = selectedFuseTo; } prevSelectedFuseTo = selectedFuseTo; } else if (objectToSelect.transform.parent != null && objectToSelect.GetComponent <SelectBehavior>() != null) { //active part // unhighlight previously selected active part if (prevSelectedObject != null) { Texture regTex = prevSelectedObject.GetComponent <SelectBehavior>().unhighTex; prevSelectedObject.GetComponent <Renderer>().material.mainTexture = regTex; //! CODE FOR REMOVING MARKER FROM PREVIOUS PART. prevSelectedObject Destroy(prevSelectedObject.GetComponent <SelectedEffect>()); } selectedObject = hitInfo.transform.gameObject; //highlight selected object Texture highlightedTex = selectedObject.GetComponent <SelectBehavior>().highTex; if (highlightedTex) { selectedObject.GetComponent <Renderer>().material.mainTexture = highlightedTex; } else { print("Unable to load texture"); } print("Currently Selected Object: " + selectedObject); //! CODE FOR ADDING MARKER TO SELECTED PART. selectedObject if (GetComponent <SelectedEffect>() == null) { SelectedEffect sel = selectedObject.AddComponent <SelectedEffect>(); sel.hitInfo = hitInfo; sel.selected = selectedObject; } prevSelectedObject = selectedObject; //print ("prevSelected: " + prevSelectedObject.name); } if (!tutorialOn && selectedObject != null && selectedFuseTo != null) { connectButton.interactable = true; } else { connectButton.interactable = false; } } } }
private void mnuTransparency_Click(object sender, EventArgs e) { if (tempImage != null) tempImage.Dispose(); // keep a copy tempImage = (Bitmap)selectedImage.Clone(); trkEffects.Maximum = 255; trkEffects.Minimum = 0; trkEffects.Value = oldTransparency; selectedEffect = SelectedEffect.Transparency; pnlEffects.Location = new Point(mouseX, mouseY); pnlEffects.Visible = true; }
private void contrastMenuItem_Click(object sender, EventArgs e) { if (tempImage != null) tempImage.Dispose(); // keep a copy tempImage = (Bitmap)selectedImage.Clone(); trkEffects.Maximum = 100; trkEffects.Minimum = -100; trkEffects.Value = 0; selectedEffect = SelectedEffect.Contrast; pnlEffects.Location = new Point(mouseX, mouseY); pnlEffects.Visible = true; }
private void UpdateEffects(SelectedEffect se) { //set current effect Effects.CurrentEffect = se; //clear check marks //is there a better way to do this? lowerCaseToolStripMenuItem.Checked = false; lowerCaseMenuItem.Checked = false; titleCaseToolStripMenuItem.Checked = false; titleCaseMenuItem.Checked = false; removeSpacesToolStripMenuItem.Checked = false; removeSpacesMenuItem.Checked = false; upperCaseToolStripMenuItem.Checked = false; upperCaseMenuItem.Checked = false; customToolStripMenuItem.Checked = false; customMenuItem.Checked = false; oneLineToolStripMenuItem.Checked = false; oneLineMenuItem.Checked = false; //check off the good ones switch (se) { case SelectedEffect.Custom: customToolStripMenuItem.Checked = true; customMenuItem.Checked = true; break; case SelectedEffect.LowerCase: lowerCaseToolStripMenuItem.Checked = true; lowerCaseMenuItem.Checked = true; break; case SelectedEffect.OneLine: oneLineToolStripMenuItem.Checked = true; oneLineMenuItem.Checked = true; break; case SelectedEffect.RemoveSpaces: removeSpacesToolStripMenuItem.Checked = true; removeSpacesMenuItem.Checked = true; break; case SelectedEffect.TitleCase: titleCaseToolStripMenuItem.Checked = true; titleCaseMenuItem.Checked = true; break; case SelectedEffect.UpperCase: upperCaseToolStripMenuItem.Checked = true; upperCaseMenuItem.Checked = true; break; } }
// only executes if this gameobject was the first one hit by mouse's raycast // so it won't fire if UI element is clicked and object is behind it, yay public void OnPointerClick(PointerEventData data) { if (!selectPart.controlsDisabled) { //print("OnPointerClick on " + gameObject + "!"); // print ("Active part: " + activePart); bool fusedPart = isFusedComponent.isFused; globalHitInfo = data.pointerCurrentRaycast; GameObject lastSelectedFuseTo = selectPart.getSelectedFuseTo(); GameObject lastSelectedObject = selectPart.getSelectedObject(); if (fusedPart && lastSelectedFuseTo != this.gameObject) { selectPart.setFuseToNormal(globalHitInfo.worldNormal); //Debug.Log("Normal of globalFuseToHitInfo: " + globalFuseToHitInfo.worldNormal); selectPart.setSelectedFuseTo(this.gameObject); //print("Currently Selected FuseTo: " + selectPart.getSelectedFuseTo()); //print("Previously selected FuseTo: " + selectPart.getPrevSelectedFuseTo()); // unhighlight previously selected fused part if (selectPart.getPrevSelectedFuseTo() != null) { //! CODE FOR REMOVING Marker FROM PREVIOUS PART. prevSelectedFuseTo Destroy(selectPart.getPrevSelectedFuseTo().GetComponent <SelectedEffect>()); } //! CODE FOR ADDING MARKER TO SELECTED PART. selectedFuseTo if (GetComponent <SelectedEffect>() == null) { SelectedEffect sel = this.gameObject.AddComponent <SelectedEffect>(); sel.hitInfo = globalHitInfo; //Debug.Log("Normals of hitInfo for " + this.gameObject + ": " + globalHitInfo.worldNormal); } } else if (!fusedPart && lastSelectedObject != this.gameObject) { //active part //Debug.Log("Normal of globalActivePartHitinfo: " + globalActivePartHitInfo.worldNormal); selectPart.setSelectedObject(this.gameObject); //print("Currently Selected Object: " + selectPart.getSelectedObject()); // unhighlight previously selected active part if (selectPart.getPrevSelectedObject() != null) { //! CODE FOR REMOVING MARKER FROM PREVIOUS PART. prevSelectedObject Destroy(selectPart.getPrevSelectedObject().GetComponent <SelectedEffect>()); } //highlight selected object //! CODE FOR ADDING MARKER TO SELECTED PART. selectedObject if (GetComponent <SelectedEffect>() == null) { SelectedEffect sel = gameObject.AddComponent <SelectedEffect>(); sel.hitInfo = globalHitInfo; //Debug.Log("Normals of hitInfo for " + this.gameObject + ": " + globalHitInfo.worldNormal); } } GameObject currentlySelectedObject = selectPart.getSelectedObject(); GameObject currentlySelectedFuseTo = selectPart.getSelectedFuseTo(); if (currentlySelectedObject != null && currentlySelectedFuseTo != null) { // both faces selected, player is now allowed to attempt fuses between the two objects fuseButton.interactable = true; //! PART MOVEMENT. // We ALWAYS need the hitinfo of selecting a part on the static object. // To do this, globalHitInfo is set whenever we click on a fused part. // TODO: what if it could be set every time we rotate? Would that eliminate SelectedEffect and // part alignment problems? // Move it to the position of the fused object, offset by a multiple of the normal, // offset again by the scaled local positional difference of the connection face and the parent object. //! DUE TO THE CRAZINESS: All parts with non-boxy attachment points will require box colliders roughly // positioned at their center.' if (currentlySelectedObject.GetComponent <BoxCollider>() == null) { BoxCollider boxy = currentlySelectedObject.AddComponent <BoxCollider>(); boxy.size = Vector3.zero; } if (currentlySelectedFuseTo.GetComponent <BoxCollider>() == null) { BoxCollider boxy = currentlySelectedFuseTo.AddComponent <BoxCollider>(); boxy.size = Vector3.zero; } // The actual location of the selected fuse marker... Wow. Vector3 properFuseToPos = currentlySelectedFuseTo.transform.position + (Quaternion.Euler(currentlySelectedFuseTo.transform.eulerAngles) * (currentlySelectedFuseTo.transform.parent.localScale.x * (currentlySelectedFuseTo.GetComponent <BoxCollider>().center))); // The actual offset of the object face from the object parent... Also wow. Vector3 properOffset = Quaternion.Euler(this.gameObject.transform.parent.localEulerAngles) * (currentlySelectedObject.transform.parent.localScale.x * (currentlySelectedObject.transform.localPosition + Quaternion.Euler(this.gameObject.transform.localEulerAngles) * (currentlySelectedObject.GetComponent <BoxCollider>().center))); //Debug.DrawLine(selectedObject.transform.parent.position, selectedObject.transform.parent.position + properOffset, Color.red, 25f, false); //Debug.DrawLine(selectedFuseTo.transform.parent.position, properFuseToPos, Color.red, 25f, false); //Vector3 targetPosition = properFuseToPos + (OFFSET * selectPart.getFuseToNormal()); Vector3 targetPosition = properFuseToPos - properOffset + (OFFSET * selectPart.getFuseToNormal()); //Set currently active coroutine variable so FuseEvent can check it and stop it if it needs to perform a fuse currentlyActiveCoroutine = StartCoroutine(SweepPosition(currentlySelectedObject.transform.parent.gameObject, targetPosition, 10)); } } }