예제 #1
0
 public override List<SpatialManip> GetManips(Shape shape)
 {
   List<SpatialManip> manips = new List<SpatialManip>();
   ShapeCircle root = shape.RootCircle;
   ShapeCircle radiusVectorCircle = GetRadiusVectorCircle(root);
   Dictionary<ShapeCircle, ShapeCircleSettings> shapeSettings = GetCirclesSettingsMap(shape.RootCircle);
   RequestAddManip(manips, shapeSettings, shape, radiusVectorCircle);
   return manips;
 }
예제 #2
0
 public override void Render(Shape shape, Renderer renderer, bool selected)
 {
   if(this.Material != null)
   {
     Quad2f imageQuad = GetShapeQuad(shape);
     renderer.DrawImage(this.Material, imageQuad);
     if(selected)
     {
       renderer.PushPen();
       renderer.Pen = SceneConstants.HighlightPen;
       renderer.DrawLine(imageQuad.Vertices, true);
       renderer.PopPen();
     }
   }
 }
예제 #3
0
 public override bool TryTouch(Shape shape, Vector2f position, bool selected)
 {
   Circle circle = GetShapeCircle(shape);
   if(circle.CheckPointInside(position))
   {
     return true;
   }
   
   if(selected)
   {
     return TryTouchManip(shape, position, selected);
   }
   
   return false;
 }
예제 #4
0
 public override bool TryTouch(Shape shape, Vector2f position, bool selected)
 {
   Quad2f shapeQuad = GetShapeQuad(shape);
   if(Helpers.CheckPointInside(position, shapeQuad.Vertices))
   {
     return true;
   }
   
   if(selected)
   {
     return TryTouchManip(shape, position, selected);
   }
   
   return false;
 }
예제 #5
0
    private static void SaveShape(DataElement node, Shape shape)
    {
      node.CreateAttribute("template_name", shape.Template.Name);
      node.CreateAttribute("z_order", shape.ZOrder.ToString());
      if(shape.EditableColor)
      {
        node.CreateAttribute("color", shape.Color.ToArgb().ToString());
      }

      DataElement circlesEl = node.CreateChild("circles");
      foreach(ShapeCircle circle in shape.Circles)
      {
        SaveShapeCircle(circlesEl.CreateChild("circle"), circle);
      }
      
      DataElement propertiesEl = node.CreateChild("user_properties");
      SaveUserProperties(propertiesEl, shape);
    }
예제 #6
0
파일: Shape.cs 프로젝트: Paltr/SceneEditor
 public ShapeColorProperty(Shape owner)
 {
   m_Owner = owner;
   this.Value = m_Owner.Color;
 }
예제 #7
0
파일: Shape.cs 프로젝트: Paltr/SceneEditor
 private void HandleAngleChanged(Shape sender)
 {
   this.Value = this.Degrees;
 }
예제 #8
0
파일: Shape.cs 프로젝트: Paltr/SceneEditor
 private void HandlePositionChanged(Shape sender)
 {
   this.Value = m_Owner.Position;
 }
예제 #9
0
파일: Shape.cs 프로젝트: Paltr/SceneEditor
 public NameProperty(Shape owner)
 {
   m_Owner = owner;
   m_Owner.NameChanged += this.OnOwnerRenamed;
   this.Value = owner.Name;
 }
예제 #10
0
파일: Scene.cs 프로젝트: Paltr/SceneEditor
 private void AddShape(Shape shape)
 {
   m_Shapes.Add(shape);
   if(this.ShapeAdded != null)
   {
     this.ShapeAdded(this, shape);
   }
   
   m_SceneView.Invalidate();
 }
예제 #11
0
 public virtual SpatialManip GetSelectionManip(Shape shape)
 {
   if(shape.EditTemplateMode)
   {
     return new RefManip(shape.RootCircle, shape.SceneView);
   }
   else
   {
     PivotManip manip = new PivotManip(shape.RootCircle, shape.SceneView);
     ShapeCircleSettings shapeCircleSettings = GetCircleSettings(shape.RootCircle);
     manip.EnableRotate = shapeCircleSettings.EnableRotate;
     return manip;
   }
 }
예제 #12
0
 public abstract void Render(Shape shape, Renderer renderer, bool selected);
예제 #13
0
 public abstract List<SpatialManip> GetManips(Shape shape);
예제 #14
0
 public abstract bool TryTouch(Shape shape, Vector2f position, bool selected);
예제 #15
0
 public void Render(Renderer renderer, Vector2f position)
 {
   Shape shape = new Shape(null);
   shape.Template = this;
   shape.Position = position;
   Render(shape, renderer, false);
 }
예제 #16
0
파일: Scene.cs 프로젝트: Paltr/SceneEditor
 public bool CheckContains(Shape shape)
 {
   return m_Shapes.Contains(shape);
 }
예제 #17
0
파일: Scene.cs 프로젝트: Paltr/SceneEditor
 public void RemoveShape(Shape shape)
 {
   History.Change();
   if(!m_Shapes.Remove(shape))
   {
     throw new ArgumentException();
   }
   
   if(this.ShapeRemoved != null)
   {
     this.ShapeRemoved(this, shape);
   }
   
   m_SceneView.Invalidate();
 }
예제 #18
0
    protected bool TryTouchManip(Shape shape, Vector2f position, bool selected)
    {
      List<SpatialManip> manips = GetManips(shape);
      manips.Add(GetSelectionManip(shape));
      foreach(SpatialManip manip in manips)
      {
        if(manip.TryTouch(position, selected))
        {
          return true;
        }
      }

      return false;
    }
예제 #19
0
파일: Scene.cs 프로젝트: Paltr/SceneEditor
    public Shape CreateShape(string name)
    {
      History.Change();
      Shape result = new Shape(m_SceneView);
      if(FindShape(name) != null)
      {
        name = NameGenerator.GenerateName(name, true, CreateObjectNameChecker());
      }

      result.Name = name;
      AddShape(result);
      return result;
    }
예제 #20
0
 protected void RequestAddManip(List<SpatialManip> manips,
   Dictionary<ShapeCircle, ShapeCircleSettings> shapeSettings, Shape shape, ShapeCircle circle)
 {
   ShapeCircleSettings circleSettings = shapeSettings[circle];
   if(shape.EditTemplateMode || circleSettings.EnableOffset || circleSettings.EnableRotate)
   {
     PivotManip manip = new PivotManip(circle, shape.SceneView);
     manips.Add(manip);
     if(!shape.EditTemplateMode)
     {
       manip.EnableOffset = circleSettings.EnableOffset;
       manip.EnableRotate = circleSettings.EnableRotate;
     }
   }
 }
예제 #21
0
파일: Shape.cs 프로젝트: Paltr/SceneEditor
 public PositionProperty(Shape owner)
 {
   m_Owner = owner;
   this.Value = m_Owner.Position;
   m_Owner.PositionChanged += this.HandlePositionChanged;
 }
예제 #22
0
 private void OnShapeAdded(Scene.Scene sender, Shape shape)
 {
   TreeNodeEx sceneNode = this.ProjectNode.Nodes.FindFirstByTag(sender);
   sceneNode.Nodes.Add(shape.Name, shape);
   sceneNode.Expand();
 }
예제 #23
0
파일: Shape.cs 프로젝트: Paltr/SceneEditor
 public AngleProperty(Shape owner)
 {
   m_Owner = owner;
   this.Value = this.Degrees;
   m_Owner.AngleChanged += this.HandleAngleChanged;
 }
예제 #24
0
 private void OnShapeRemoved(Scene.Scene sender, Shape shape)
 {
   TreeNodeEx sceneNode = this.ProjectNode.Nodes.FindFirstByTag(sender);
   TreeNodeEx shapeNode = sceneNode.Nodes.FindFirstByTag(shape);
   shapeNode.Remove();
 }
예제 #25
0
파일: Shape.cs 프로젝트: Paltr/SceneEditor
 public ZOrderProperty(Shape owner)
 {
   m_Owner = owner;
   this.Value = m_Owner.ZOrder;
 }
예제 #26
0
 private void OnSelectedShapeChanged(IEditor sender, Shape previous)
 {
   if(previous != null)
   {
     TreeNodeEx node = this.ProjectNode.Nodes.FindFirstRecursivelyByTag(previous);
     if(node != null)
     {
       node.BackColor = node.BackDefaultColor;
     }
   }
   
   if(sender.SelectedShape != null)
   {
     TreeNodeEx node = this.ProjectNode.Nodes.FindFirstRecursivelyByTag(sender.SelectedShape);
     node.Select();
     node.BackColor = Color.Yellow;
   }
 }
예제 #27
0
 private void OnShapeSelected(IEditor sender, Shape shape)
 {
   m_Property.Value = shape;
 }
예제 #28
0
 private void OnNodeClick(TreeViewEx sender, MouseClickArgs args)
 {
   switch((NodeLevel)args.Node.Level)
   {
     case NodeLevel.PROJECT:
     {
       if(args.Button == MouseButtons.Right)
       {
         LightContextMenu contextMenu = new LightContextMenu();
         ItemClickHandler addSceneHandler = delegate()
         {
           CheckValueCorrectnessDelegate checker = Solution.Instance.CreateSceneNameChecker();
           string sceneName = NameGenerator.GenerateName("Scene", checker);
           Scene.Scene scene = m_Scenes.CreateScene(sceneName);
           this.SelectedScene = scene;
         };
         contextMenu.AddItem("Add scene", addSceneHandler);
         contextMenu.Show(this, args.Location);
       }
       
       break;
     }
     
     case NodeLevel.SCENE:
     {
       Scene.Scene scene = (Scene.Scene)args.Node.Tag;
       this.SelectedScene = scene;
       if(args.Button == MouseButtons.Right)
       {
         LightContextMenu contextMenu = new LightContextMenu();
         if(Settings.SceneTranslator != null)
         {
           ItemClickHandler codeToClipboardHandler = delegate()
           {
             try
             {
               string code = Settings.SceneTranslator.Translate(m_Scenes, scene);
               System.Windows.Forms.Clipboard.SetText(code);
             }
             catch(Exception e)
             {
               MessageBox.Show("Translation error: " + e.Message, "Translation error",
                 MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
           };
           contextMenu.AddItem("Copy code to clipboard", codeToClipboardHandler);
         }
         
         ItemClickHandler cloneSceneHandler = delegate()
         {
           CheckValueCorrectnessDelegate checker = Solution.Instance.CreateSceneNameChecker();
           string cloneName = NameGenerator.GenerateName(scene.Name, checker);
           Scene.Scene clone = m_Scenes.CloneScene(scene, cloneName);
           this.SelectedScene = clone;
         };
         ItemClickHandler removeSceneHandler = delegate()
         {
           m_Scenes.RemoveScene(scene);
           this.SelectedScene = null;
         };
         contextMenu.AddItem("Clone scene", cloneSceneHandler);
         contextMenu.AddItem("Remove scene", removeSceneHandler);
         contextMenu.Show(this, args.Location);
       }
       
       break;
     }
     
     case NodeLevel.SHAPE:
     {
       Shape shape = (Shape)args.Node.Tag;
       if(shape != null && m_ShapeSelectedHandler != null)
       {
         m_ShapeSelectedHandler(this, shape);
         m_ShapeSelectedHandler = null;
       }
       else
       {
         this.SelectedShape = shape;
         if(args.Button == MouseButtons.Right)
         {
           LightContextMenu contextMenu = new LightContextMenu();
           ItemClickHandler removeObjectHandler = delegate()
           {
             this.SelectedScene.RemoveShape(shape);
             this.SelectedShape = null;
           };
           contextMenu.AddItem("Remove object", removeObjectHandler);
           contextMenu.Show(this, args.Location);
         }
       }
       
       break;
     }
   }
 }
예제 #29
0
    private static void LoadShape(DataElement node, Shape shape, ShapeTemplatesSet templates)
    {
      string templateName = node.GetAttribValue("template_name");
      ShapeTemplate template = templates.FindTemplate(templateName);
      shape.Template = template;
      shape.ZOrder = float.Parse(node.GetAttribValue("z_order"));

      string colorStr = node.GetAttribValue("color");
      if(colorStr != null)
      {
        shape.Color = Color.FromArgb(int.Parse(colorStr));
      }

      if(shape.EditableColor)
      {
        node.CreateAttribute("color", shape.Color.ToArgb().ToString());
      }

      DataElement circlesEl = node.GetChild("circles");
      IList<DataElement> circleElList = circlesEl.CollectChildren("circle");
      IList<ShapeCircle> circles = shape.Circles;
      for(int index = 0; index < circleElList.Count; ++index)
      {
        DataElement circleEl = circleElList[index];
        ShapeCircle circle = circles[index];
        LoadShapeCircle(circleEl, circle);
      }
      
      DataElement userPropertiesEl = node.GetChild("user_properties");
      LoadUserProperties(userPropertiesEl, shape);
    }
예제 #30
0
파일: Scene.cs 프로젝트: Paltr/SceneEditor
    public Shape CreateShapeClone(Shape shape)
    {
      History.Change();
      Shape result = shape.Clone(this);
      if(FindShape(result.Name) != null)
      {
        result.Name = NameGenerator.GenerateName(result.Name, true, CreateObjectNameChecker());
      }

      return result;
    }