Exemple #1
0
 private void uc_UtilityModel_Load(object sender, EventArgs e)
 {
     lbl_id.Text          = id.ToString();
     lbl_molecule.Text    = MoleculeController.getById(molecule_id).generic_name;
     lbl_name.Text        = name;
     lbl_description.Text = description;
 }
Exemple #2
0
 private void uc_CreateUpdatePatent_Load(object sender, EventArgs e)
 {
     if (molecule_id != 0)
     {
         cbox_molecules.Items.Add(MoleculeController.getById(molecule_id).real_name);
         cbox_molecules.SelectedIndex = 0;
     }
     if (company_id != 0)
     {
         cbox_companies.Items.Add(CompanyController.getById(company_id).name);
         cbox_companies.SelectedIndex = 0;
     }
     if (country != null)
     {
         tbox_country.Text = country;
     }
     if (number != null)
     {
         tbox_number.Text = number.Substring(3);
     }
     if (deposit_date >= dtime_deposit_date.MinDate)
     {
         dtime_deposit_date.Value = deposit_date;
     }
     if (duration != 0)
     {
         nbox_duration.Value = duration;
     }
 }
Exemple #3
0
 public void DisplayMolInfoSheet(bool newValue)
 {
     if (selectedMol != null)
     {
         MoleculeController selectedMolScript = selectedMol.GetComponent <MoleculeController>();
         selectedMolScript.DisplayInfoSheet(FirstPersonCamera, newValue);
     }
 }
Exemple #4
0
 /// <summary>
 /// The Unity Update() method.
 /// </summary>
 ///
 public void MoleculeSpinToggle(bool newValue)
 {
     if (selectedMol != null)
     {
         MoleculeController selectedMolScript = selectedMol.GetComponent <MoleculeController>();
         selectedMolScript.rotateMolecule = newValue;
     }
 }
    // Use this for initialization
    void Start()
    {
        MoleculeController parentMol = transform.parent.GetComponent <MoleculeController>();

        headerText.text = parentMol.moleculeName;
        bodyText.text   = parentMol.moleculeInfo;
        molImage.sprite = parentMol.molImage;
        _ShowAndroidToastMessage("test" + headerText.text);
    }
Exemple #6
0
 private void uc_PatentModel_Load(object sender, EventArgs e)
 {
     lbl_number.Text       = number;
     lbl_molecule.Text     = MoleculeController.getById(molecule_id).real_name;
     lbl_company.Text      = CompanyController.getById(company_id).name;
     lbl_deposit_date.Text = deposit_date.ToString();
     lbl_duration.Text     = duration.ToString() + "an(s)";
     lbl_country.Text      = country;
 }
 public void MoleculeUserRotationToggle(bool newValue)
 {
     if (selectedMol != null)
     {
         MoleculeController selectedMolScript = selectedMol.GetComponentInChildren <MoleculeController>();
         selectedMolScript.userRotatingMolecule = newValue;
         UserRotating = newValue;
     }
 }
        private void cbox_molecules_Click(object sender, EventArgs e)
        {
            cbox_molecules.Items.Clear();
            var molecules = MoleculeController.getAll();

            foreach (var molecule in molecules)
            {
                cbox_molecules.Items.Add(molecule.real_name);
            }
        }
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
Exemple #10
0
    public void SetMolSelectInfoSheet(ChemViewARController chemviewController)
    {
        MoleculeController selectedMol = chemviewController.loadedChemModel.GetComponentInChildren <MoleculeController>();

        molName.text           = selectedMol.moleculeName;
        subText1.text          = selectedMol.molInfo1;
        subText2.text          = selectedMol.molInfo2;
        subText3.text          = selectedMol.molInfo3;
        subText4.text          = selectedMol.molInfo4;
        molpreviewImage.sprite = selectedMol.molImage;
    }
Exemple #11
0
 private void btn_delete_Click(object sender, EventArgs e)
 {
     if (MoleculeController.MoleculeUsed(id))
     {
         MoleculeController.Delete(id);
         uc_MainMolecule.Instance.ReloadPanel();
     }
     else
     {
         MessageBox.Show("La molécule est utilisée par un brevet ou par une utilitée", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #12
0
 private void btn_send_to_database_Click(object sender, EventArgs e)
 {
     if (id != 0)
     {
         PatentController.UpdatePatent(id, MoleculeController.getByName(cbox_molecules.Text), CompanyController.getByName(cbox_companies.Text), tbox_country.Text, tbox_number.Text, dtime_deposit_date.Value, (int)nbox_duration.Value);
         MessageBox.Show("Le brevet a été correctement mise à jour dans la base de données", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         PatentController.AddPatent(MoleculeController.getByName(cbox_molecules.Text), CompanyController.getByName(cbox_companies.Text), tbox_country.Text, tbox_number.Text, dtime_deposit_date.Value, (int)nbox_duration.Value);
         MessageBox.Show("Le brevet a été correctement ajoutée à la base de données", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     uc_MainPatent.Instance.ReloadPanel();
     this.SendToBack();
 }
 private void btn_send_to_database_Click(object sender, EventArgs e)
 {
     if (id != 0)
     {
         UtilityController.UpdateUtility(id, MoleculeController.getByName(cbox_molecules.Text), tbox_name.Text, tbox_description.Text);
         MessageBox.Show("L'utilité a été correctement mise à jour dans la base de données", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         UtilityController.AddUtility(MoleculeController.getByName(cbox_molecules.Text), tbox_name.Text, tbox_description.Text);
         MessageBox.Show("L'utilité a été correctement ajoutée à la base de données", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     uc_MainUtility.Instance.ReloadPanel();
     this.SendToBack();
 }
Exemple #14
0
        public void ReloadPanel()
        {
            pnl_molecules.Controls.Clear();
            var molecules = MoleculeController.getAll();

            foreach (var m in molecules)
            {
                pnl_molecules.Controls.Add(new uc_MoleculeModel
                {
                    id           = m.id,
                    generic_name = m.generic_name,
                    real_name    = m.real_name,
                    formula      = m.formula
                });
            }
        }
 private void uc_CreateUpdateUtility_Load(object sender, EventArgs e)
 {
     if (molecule_id != 0)
     {
         cbox_molecules.Items.Add(MoleculeController.getById(molecule_id).real_name);
         cbox_molecules.SelectedIndex = 0;
     }
     if (name != null)
     {
         tbox_name.Text = name;
     }
     if (description != null)
     {
         tbox_description.Text = description;
     }
 }
        private void btn_send_to_database_Click(object sender, EventArgs e)
        {
            if (id != 0)
            {
                MoleculeController.UpdateMolecule(id, tbox_generic_name.Text, tbox_real_name.Text, tbox_formula.Text);
                MessageBox.Show("La molécule a été correctement mise à jour dans la base de données", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MoleculeController.AddMolecule(tbox_generic_name.Text, tbox_real_name.Text, tbox_formula.Text);
                MessageBox.Show("La molécule a été correctement ajoutée à la base de données", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            uc_MainMolecule.Instance.ReloadPanel();
            this.SendToBack();
        }
    public void DisplayMolInfoSheet(bool newValue)
    {
        if (selectedMol != null)
        {
            if (enableVelocity && newValue)
            {
                _ShowAndroidToastMessage("Disable physics to show information sheet!");
                uIController.TurnOffToggle(2);
            }


            else if (enableVelocity == false)
            {
                MoleculeController selectedMolScript = selectedMol.GetComponentInChildren <MoleculeController>();
                selectedMolScript.DisplayInfoSheet(FirstPersonCamera, newValue);
            }
        }
    }
Exemple #18
0
    private void SpawnMolecule()
    {
        Touch             touch = Input.GetTouch(0);
        TrackableHit      hit;
        TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon |
                                          TrackableHitFlags.FeaturePointWithSurfaceNormal;

        if (Frame.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit))
        {
            // Use hit pose and camera pose to check if hittest is from the
            // back of the plane, if it is, no need to create the anchor.
            if ((hit.Trackable is DetectedPlane) &&
                Vector3.Dot(FirstPersonCamera.transform.position - hit.Pose.position,
                            hit.Pose.rotation * Vector3.up) < 0)
            {
                Debug.Log("Hit at back of the current DetectedPlane");
            }
            else
            {
                // Instantiate chemical model at the hit pose.
                var molObj = Instantiate(loadedChemModel, hit.Pose.position, hit.Pose.rotation);
                molObj.transform.Translate(0, 0.5f, 0, Space.World);

                // Compensate for the hitPose rotation facing away from the raycast (i.e. camera).
                molObj.transform.Rotate(0, k_ModelRotation, 0, Space.Self);

                //rotate the loaded molecule

                // Create an anchor to allow ARCore to track the hitpoint as understanding of the physical
                // world evolves.
                var anchor = hit.Trackable.CreateAnchor(hit.Pose);

                // Make molecule model a child of the anchor.
                molObj.transform.parent = anchor.transform;

                MoleculeController selectedMolScript = molObj.GetComponent <MoleculeController>();
                selectedMolScript.planePosition = anchor.transform.position;
                selectedMolScript.Highlight();
                selectedMol = selectedMolScript;
            }
        }
    }
Exemple #19
0
 private void btn_search_Click(object sender, EventArgs e)
 {
     if (tbox_search.Text != "Rechercher...")
     {
         pnl_molecules.Controls.Clear();
         var molecules = MoleculeController.getAll();
         molecules = molecules.Where(m => m.real_name.Contains(tbox_search.Text) || m.generic_name.Contains(tbox_search.Text) || m.formula.Contains(tbox_search.Text));
         foreach (var m in molecules)
         {
             pnl_molecules.Controls.Add(new uc_MoleculeModel
             {
                 id           = m.id,
                 generic_name = m.generic_name,
                 real_name    = m.real_name,
                 formula      = m.formula
             });
         }
     }
     else
     {
         ReloadPanel();
     }
 }
Exemple #20
0
        private void LoadAnalytic()
        {
            cartesianChart_MoneyByTime.Series.Clear();
            cartesianChart_MoneyByTime.AxisX.Clear();
            cartesianChart_MoneyByTime.AxisY.Clear();
            pieChart_ContractsByCompany.Series.Clear();
            pieChart_UtilitiesByMolecule.Series.Clear();

            #region CartesianChart
            cartesianChart_MoneyByTime.AxisX.Add(new Axis
            {
                Title  = "Mois",
                Labels = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }
            });
            cartesianChart_MoneyByTime.AxisY.Add(new Axis
            {
                Title          = "Revenue",
                LabelFormatter = value => value.ToString("C2")
            });
            SeriesCollection series = new SeriesCollection();
            var request             = ContractController.getYears();
            for (int year = request.Item1; year <= request.Item2; year++)
            {
                List <double> values = new List <double>();
                for (int month = 0; month <= 12; month++)
                {
                    values.Add(ContractController.getPriceFromMonth(year, month));
                }
                series.Add(new LineSeries()
                {
                    Title = year.ToString(), Values = new ChartValues <double>(values)
                });
            }
            cartesianChart_MoneyByTime.Series         = series;
            cartesianChart_MoneyByTime.LegendLocation = LegendLocation.Right;
            #endregion

            #region pieChart
            var companies = CompanyController.getAll();
            Func <ChartPoint, string> labelPoint = chartPoint => string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);
            foreach (var company in companies)
            {
                var contracts = ContractController.getByCompany(company.id);
                pieChart_ContractsByCompany.Series.Add(new PieSeries
                {
                    Title  = company.name,
                    Values = new ChartValues <double> {
                        contracts.Count()
                    },
                    DataLabels = true,
                    LabelPoint = labelPoint
                });
            }
            pieChart_ContractsByCompany.LegendLocation = LegendLocation.Bottom;
            var molecules = MoleculeController.getAll();
            foreach (var molecule in molecules)
            {
                var utilities = UtilityController.getByMolecule(molecule.id);
                pieChart_UtilitiesByMolecule.Series.Add(new PieSeries
                {
                    Title  = molecule.real_name,
                    Values = new ChartValues <double> {
                        utilities.Count()
                    },
                    DataLabels = true,
                    LabelPoint = labelPoint
                });
            }
            pieChart_UtilitiesByMolecule.LegendLocation = LegendLocation.Bottom;
            #endregion

            // Load all chart
            cartesianChart_MoneyByTime.Hide();
            cartesianChart_MoneyByTime.Show();
            pieChart_ContractsByCompany.Hide();
            pieChart_ContractsByCompany.Show();
            pieChart_UtilitiesByMolecule.Hide();
            pieChart_UtilitiesByMolecule.Show();
        }
Exemple #21
0
    public void Update()
    {
        _UpdateApplicationLifecycle();

        // Hide snackbar when currently tracking at least one plane.
        Session.GetTrackables <DetectedPlane>(m_AllPlanes);
        bool showSearchingUI = true;

        for (int i = 0; i < m_AllPlanes.Count; i++)
        {
            if (m_AllPlanes[i].TrackingState == TrackingState.Tracking)
            {
                showSearchingUI = false;
                break;
            }
        }

        SearchingForPlaneUI.SetActive(showSearchingUI);

        Touch touch;

        // If the player has not touched the screen, we are done with this update.
        if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began)
        {
            return;
        }


        if (touch.tapCount == 1)
        {
            if (!EventSystem.current.IsPointerOverGameObject(touch.fingerId))
            {
                Ray        raycast = FirstPersonCamera.ScreenPointToRay(touch.position);
                RaycastHit raycastHit;

                if (Physics.Raycast(raycast, out raycastHit))
                {
                    if (raycastHit.collider.tag == "Molecule" && UserRotating == false)
                    {
                        if (selectedMol == null)
                        {
                            selectedMol = raycastHit.collider.GetComponent <MoleculeController>();
                            MoleculeController selectedMolScript = selectedMol.GetComponent <MoleculeController>();
                            selectedMolScript.isSelected = true;
                            selectedMol.Highlight();
                        }

                        else
                        {
                            selectedMol.Dehighlight();
                            selectedMol = raycastHit.collider.GetComponent <MoleculeController>();
                            MoleculeController selectedMolScript = selectedMol.GetComponent <MoleculeController>();
                            selectedMolScript.isSelected = true;
                            selectedMol.Highlight();
                        }
                    }
                }
                else
                {
                    if (selectedMol != null && UserRotating == false)
                    {
                        selectedMol.Dehighlight();
                        MoleculeController selectedMolScript = selectedMol.GetComponent <MoleculeController>();
                        selectedMolScript.isSelected = false;
                        selectedMol = null;
                    }
                }
                return;
            }
        }

        if (touch.tapCount == 2)
        {
            if (!EventSystem.current.IsPointerOverGameObject(touch.fingerId) && UserRotating == false)
            {
                _ShowAndroidToastMessage("mol Spawned");
                SpawnMolecule();
                return;
            }
        }
    }
    public void Update()
    {
        _UpdateApplicationLifecycle();

        // Hide snackbar when currently tracking at least one plane.
        Session.GetTrackables <DetectedPlane>(m_AllPlanes);
        bool showSearchingUI = true;

        for (int i = 0; i < m_AllPlanes.Count; i++)
        {
            if (m_AllPlanes[i].TrackingState == TrackingState.Tracking)
            {
                showSearchingUI = false;
                break;
            }
        }


        if (showSearchingUI != uIController.SearchingForPlanes)
        {
            if (firstSurface == true)
            {
                ChemviewHelper.ShowAndroidToastMessage("Double tap on a surface to spawn a molecule");
                firstSurface = false;
            }

            uIController.SearchingForPlanes = showSearchingUI;
            SearchingForPlaneUI.GetComponent <SearchingForPlaneController>().MovePosition(showSearchingUI);

            if (showSearchingUI)
            {
                SearchingForPlaneUI.GetComponent <SearchingForPlaneController>().StartMessageCoroutine();
                uIController.FadeOut();
            }

            else
            {
                uIController.FadeIn();
            }
        }

        Touch touch;

        // If the player has not touched the screen, we are done with this update.
        if (Input.touchCount < 1 || (touch = Input.GetTouch(0)).phase != TouchPhase.Began)
        {
            return;
        }


        if (touch.tapCount == 1 && UserRotating == false)
        {
            if (!EventSystem.current.IsPointerOverGameObject(touch.fingerId))
            {
                Ray        raycast = FirstPersonCamera.ScreenPointToRay(touch.position);
                RaycastHit raycastHit;
                if (Physics.Raycast(raycast, out raycastHit))
                {
                    if (raycastHit.collider.tag == "Molecule" && UserRotating == false)
                    {
                        if (selectedMol == null)
                        {
                            selectedMol            = raycastHit.collider.GetComponentInChildren <MoleculeController>();
                            _lastSelectedMol       = selectedMol;
                            selectedMol.isSelected = true;
                            selectedMol.Highlight();
                            uIController.SetToggles(selectedMol);
                        }

                        else
                        {
                            if (selectedMol != raycastHit.collider.GetComponentInChildren <MoleculeController>())
                            {
                                selectedMol.Dehighlight();
                                UserRotating = false;
                                uIController.TurnOffToggles();

                                selectedMol            = raycastHit.collider.GetComponentInChildren <MoleculeController>();
                                _lastSelectedMol       = selectedMol;
                                selectedMol.isSelected = true;
                                selectedMol.Highlight();
                                uIController.SetToggles(selectedMol);
                            }
                        }
                    }
                }
                else
                {
                    if (selectedMol != null && UserRotating == false)
                    {
                        selectedMol.Dehighlight();
                        MoleculeController selectedMolScript = selectedMol.GetComponentInChildren <MoleculeController>();
                        selectedMolScript.isSelected = false;
                        selectedMol = null;
                        uIController.TurnOffToggles();
                        UserRotating = false;
                    }
                }
                return;
            }
        }

        if (touch.tapCount == 2)
        {
            if (!EventSystem.current.IsPointerOverGameObject(touch.fingerId) && UserRotating == false)
            {
                SpawnMolecule();
                return;
            }
        }
    }
    private void SpawnMolecule()
    {
        try
        {
            Touch             touch = Input.GetTouch(0);
            TrackableHit      hit;
            TrackableHitFlags raycastFilter = TrackableHitFlags.PlaneWithinPolygon |
                                              TrackableHitFlags.FeaturePointWithSurfaceNormal;

            if (Frame.Raycast(touch.position.x, touch.position.y, raycastFilter, out hit))
            {
                // Use hit pose and camera pose to check if hittest is from the
                // back of the plane, if it is, no need to create the anchor.
                if ((hit.Trackable is DetectedPlane) &&
                    Vector3.Dot(FirstPersonCamera.transform.position - hit.Pose.position,
                                hit.Pose.rotation * Vector3.up) < 0)
                {
                    Debug.Log("Hit at back of the current DetectedPlane");
                }
                else
                {
                    // Instantiate chemical model at the hit pose.
                    var molObj = Instantiate(loadedChemModel, hit.Pose.position, hit.Pose.rotation);
                    molObj.SetActive(true);
                    molObj.GetComponentInChildren <MoleculeController>().enabled = true;
                    molObj.transform.GetChild(0).position = hit.Pose.position;

                    Collider[] myColliders    = molObj.GetComponentsInChildren <Collider>();
                    Bounds     moleculeBounds = new Bounds(transform.position, Vector3.zero);
                    foreach (Collider nextCollider in myColliders)
                    {
                        moleculeBounds.Encapsulate(nextCollider.bounds);
                    }

                    molObj.GetComponentInChildren <MoleculeController>().moleculeBounds = moleculeBounds;

                    molObj.transform.Translate(0, molObj.GetComponentInChildren <MoleculeController>().moleculeBounds.extents.y, 0, Space.World);

                    // Compensate for the hitPose rotation facing away from the raycast (i.e. camera).
                    molObj.transform.Rotate(0, k_ModelRotation, 0, Space.Self);

                    //rotate the loaded molecule

                    // Create an anchor to allow ARCore to track the hitpoint as understanding of the physical
                    // world evolves.
                    var anchor = hit.Trackable.CreateAnchor(hit.Pose);

                    // Make molecule model a child of the anchor.
                    molObj.transform.parent = anchor.transform;

                    if (selectedMol != null)
                    {
                        selectedMol.Dehighlight();
                    }

                    MoleculeController selectedMolScript = molObj.GetComponentInChildren <MoleculeController>();
                    selectedMolScript.planePosition = anchor.transform.position;
                    selectedMolScript.Highlight();
                    selectedMol      = selectedMolScript;
                    _lastSelectedMol = selectedMol;
                    uIController.SetToggles(selectedMol);
                }
            }
        }

        catch (Exception e)
        {
            _ShowAndroidToastMessage(e.ToString());
        }
    }