private void Clear()
        {
            ClearMyShapeDatas();

            foreach (PointData pointData in m_Points)
            {
                pointData.NameUpdated.Unsubscribe(NameUpdated);
                ShapeDataFactory.RemoveShapeData(pointData);
            }

            m_Points.Clear();

            foreach (LineData lineData in m_Lines)
            {
                ShapeDataFactory.RemoveShapeData(lineData);
            }

            m_Lines.Clear();

            foreach (PolygonData polygonData in m_Polygons)
            {
                ShapeDataFactory.RemoveShapeData(polygonData);
            }

            m_Polygons.Clear();
        }
Exemple #2
0
        public TetrahedronBlueprint(ShapeDataFactory dataFactory) : base(dataFactory)
        {
            for (int i = 0; i < m_Points.Length; i++)
            {
                m_Points[i] = dataFactory.CreatePointData();
                m_Points[i].NameUpdated.Subscribe(NameUpdated);
            }

            for (int i = 0; i < m_Lines.Length; i++)
            {
                m_Lines[i] = dataFactory.CreateLineData();
            }

            for (int i = 0; i < m_Polygons.Length; i++)
            {
                m_Polygons[i] = dataFactory.CreatePolygonData();
            }

            ConstructLines();
            ConstructPolygons();

            m_CompositeShapeData = dataFactory.CreateCompositeShapeData();

            m_CompositeShapeData.SetPoints(m_Points);
            m_CompositeShapeData.SetLines(m_Lines);
            m_CompositeShapeData.SetPolygons(m_Polygons);

            OnDeserialized();
        }
Exemple #3
0
        public CubeBlueprint(ShapeDataFactory dataFactory) : base(dataFactory)
        {
            for (int i = 0; i < m_Points.Length; i++)
            {
                m_Points[i] = dataFactory.CreatePointData();
                m_Points[i].NameUpdated.Subscribe(NameUpdated);
            }
            for (int i = 0; i < m_Lines.Length; i++)
            {
                m_Lines[i] = dataFactory.CreateLineData();
            }
            for (int i = 0; i < m_Polygons.Length; i++)
            {
                m_Polygons[i] = dataFactory.CreatePolygonData();
                m_Polygons[i].SetPointsCount(4); // By default polygon has 3 points, we need 4
            }

            ConstructLines();
            ConstructPolygons();

            m_CompositeShapeData = dataFactory.CreateCompositeShapeData();

            m_CompositeShapeData.SetPoints(m_Points);
            m_CompositeShapeData.SetLines(m_Lines);
            m_CompositeShapeData.SetPolygons(m_Polygons);

            OnDeserialized();
        }
Exemple #4
0
 private void ApplyDefaultState(ShapeDataFactory shapeDataFactory)
 {
     foreach (ShapeData shapeData in shapeDataFactory.AllDatas)
     {
         shapeData.View.Active    = m_DefaultActiveState;
         shapeData.View.Highlight = m_DefaultHighlightType;
     }
 }
Exemple #5
0
 public void SetShapeDataFactory(ShapeDataFactory shapeDataFactory)
 {
     m_ShapeDataFactory = shapeDataFactory;
     foreach (ShapeAction shapeAction in m_ShapeActions)
     {
         shapeAction.SetShapeDataFactory(m_ShapeDataFactory);
     }
 }
Exemple #6
0
 public void SetShapeDataFactory(ShapeDataFactory shapeDataFactory)
 {
     m_ShapeDataFactory = shapeDataFactory;
     foreach (ShapeBlueprint shapeBlueprint in m_ShapeBlueprints)
     {
         shapeBlueprint.SetShapeDataFactory(shapeDataFactory);
     }
 }
Exemple #7
0
        public PointOfIntersectionBlueprint(ShapeDataFactory dataFactory) : base(dataFactory)
        {
            PointData = ShapeDataFactory.CreatePointData();

            m_PointsOnLines[0] = new PointData[2];
            m_PointsOnLines[1] = new PointData[2];

            OnDeserialized();
        }
Exemple #8
0
        public void SetShapeDataFactory(ShapeDataFactory shapeDataFactory)
        {
            m_ShapeDataFactory = shapeDataFactory;

            ViewFactory.CollectLostViews();
            ViewFactory.Dispose();
            m_ShapeDataFactory.SetViewFactory(ViewFactory);

            m_LastOrigin = Vector3.positiveInfinity;
        }
Exemple #9
0
        public LessonData()
        {
            m_ShapeDataFactory      = new ShapeDataFactory();
            m_ShapeBlueprintFactory = new ShapeBlueprintFactory(m_ShapeDataFactory);

            m_ShapeActionFactory = new ShapeActionFactory(m_ShapeDataFactory);
            m_LessonStageFactory = new LessonStageFactory(m_ShapeActionFactory);

            OnDeserialized();
        }
        private void ConstructPrism()
        {
            UpdateVerticesPositionsList();

            for (int i = 0; i < 2 * m_VerticesAtTheBaseCount; i++)
            {
                m_Points.Add(ShapeDataFactory.CreatePointData());
                m_Points[i].NameUpdated.Subscribe(NameUpdated);
            }

            for (int i = 0; i < 3 * m_VerticesAtTheBaseCount; i++)
            {
                m_Lines.Add(ShapeDataFactory.CreateLineData());
            }

            for (int i = 0; i < m_VerticesAtTheBaseCount + 2; i++)
            {
                m_Polygons.Add(ShapeDataFactory.CreatePolygonData());
                // Side faces
                if (i < m_VerticesAtTheBaseCount)
                {
                    m_Polygons[i].SetPointsCount(4);
                }
                // Top and Bottom faces
                else
                {
                    m_Polygons[i].SetPointsCount(m_VerticesAtTheBaseCount);
                }
            }

            ConstructLines();
            ConstructPolygons();

            m_CompositeShapeData.SetPoints(m_Points.ToArray());
            m_CompositeShapeData.SetLines(m_Lines.ToArray());
            m_CompositeShapeData.SetPolygons(m_Polygons.ToArray());

            foreach (ShapeData shapeData in
                     new[] { m_CompositeShapeData }.Cast <ShapeData>()
                     .Concat(m_Points)
                     .Concat(m_Lines)
                     .Concat(m_Polygons))
            {
                AddToMyShapeDatas(shapeData);
            }
        }
        public ChoseShapeDataField(ShapeDataFactory shapeDataFactory, CanDependOnShapeBlueprint dependent,
                                   string fieldName, Func <TShapeData> getShapeDataFunc, Action <TShapeData> setShapeDataFunc)
        {
            m_DataFactory      = shapeDataFactory;
            m_Dependent        = dependent;
            m_FieldName        = fieldName;
            m_GetShapeDataFunc = getShapeDataFunc;
            m_SetShapeDataFunc = setShapeDataFunc;

            VisualElement firstRow = new VisualElement {
                style = { flexDirection = FlexDirection.Row }
            };

            firstRow.Add(m_Label = new Label());

            m_ToolbarMenu = new ToolbarMenu {
                text = "Change", style = { flexDirection = FlexDirection.Row }
            };
            m_ToolbarMenu.RemoveFromClassList("unity-toolbar-menu");
            m_ToolbarMenu.AddToClassList("unity-button");

            firstRow.Add(m_ToolbarMenu);

            Add(firstRow);

            IValidator pointNotEmptyValidator =
                new DataNotEmptyValidator <TShapeData>(getShapeDataFunc, action => m_UpdateValidatorAction = action);
            VisualElement validatorField = new ValidatorField(pointNotEmptyValidator);

            Add(validatorField);

            m_DataFactory.BecameDirty.Subscribe(BecameDirty);
            m_AutoSaveScheduler = schedule.Execute(Update);
            m_AutoSaveScheduler.Every(200);

            UpdateList();
            UpdateName();
            m_UpdateValidatorAction?.Invoke();
        }
Exemple #12
0
 protected ShapeAction(ShapeDataFactory shapeDataFactory)
 {
     m_ShapeDataFactory = shapeDataFactory;
 }
 public PrismBlueprint(ShapeDataFactory dataFactory) : base(dataFactory)
 {
     m_CompositeShapeData = dataFactory.CreateCompositeShapeData();
     ConstructPrism();
     OnDeserialized();
 }
        public PointPerpendicularProjectionBlueprint(ShapeDataFactory dataFactory) : base(dataFactory)
        {
            PointData = ShapeDataFactory.CreatePointData();

            OnDeserialized();
        }
Exemple #15
0
 public LineBlueprint(ShapeDataFactory dataFactory) : base(dataFactory)
 {
     LineData = dataFactory.CreateLineData();
     OnDeserialized();
 }
Exemple #16
0
 public ShapeActionFactory(ShapeDataFactory shapeDataFactory)
 {
     m_ShapeDataFactory = shapeDataFactory;
     m_ShapeActions     = new List <ShapeAction>();
 }
 public RegularPyramidBlueprint(ShapeDataFactory dataFactory) : base(dataFactory)
 {
     m_CompositeShapeData = dataFactory.CreateCompositeShapeData();
     ConstructPyramid();
     OnDeserialized();
 }
        public PointOnSurfaceBlueprint(ShapeDataFactory dataFactory) : base(dataFactory)
        {
            PointData = ShapeDataFactory.CreatePointData();

            OnDeserialized();
        }
Exemple #19
0
 public void SetShapeDataFactory(ShapeDataFactory shapeDataFactory)
 {
     m_ShapeDataFactory = shapeDataFactory;
 }
Exemple #20
0
 protected ShapeBlueprint(ShapeDataFactory dataFactory)
 {
     m_ShapeDataFactory = dataFactory;
     GeometryUpdated.Subscribe(UpdateGeometry);
 }
Exemple #21
0
 public ShapeBlueprintFactory(ShapeDataFactory shapeDataFactory)
 {
     m_ShapeDataFactory = shapeDataFactory;
     m_ShapeBlueprints  = new List <ShapeBlueprint>();
 }
        public PointProjectionFromPointBlueprint(ShapeDataFactory dataFactory) : base(dataFactory)
        {
            PointData = ShapeDataFactory.CreatePointData();

            OnDeserialized();
        }
 public SetActiveShapeAction(ShapeDataFactory shapeDataFactory) : base(shapeDataFactory)
 {
 }
 public PolygonBlueprint(ShapeDataFactory dataFactory) : base(dataFactory)
 {
     PolygonData = dataFactory.CreatePolygonData();
     OnDeserialized();
 }
 public SetHighlightShapeAction(ShapeDataFactory shapeDataFactory) : base(shapeDataFactory)
 {
 }