Пример #1
0
void IHaveDragPoints::FlipPointX(Vertex2D *pvCenter)
{
   GetIEditable()->BeginUndo();
   GetIEditable()->MarkForUndo();

   Vertex2D newcenter;
   GetPointCenter(&newcenter);

   const float xcenter = pvCenter->x;

   for (int i = 0; i < m_vdpoint.Size(); i++)
   {
      const float deltax = m_vdpoint.ElementAt(i)->m_v.x - xcenter;

      m_vdpoint.ElementAt(i)->m_v.x -= deltax*2.0f;
   }

   const float deltax = newcenter.x - xcenter;
   newcenter.x -= deltax*2.0f;
   PutPointCenter(&newcenter);

   ReverseOrder();

   GetIEditable()->EndUndo();

   GetPTable()->SetDirtyDraw();
}
Пример #2
0
void IHaveDragPoints::ScalePoints(float scalex, float scaley, Vertex2D *pvCenter, const bool useElementsCenter)
{
   Vertex2D newcenter;
   GetPointCenter(&newcenter);

   GetIEditable()->BeginUndo();
   GetIEditable()->MarkForUndo();

   if (useElementsCenter)
   {
      /* Don't use the pvCenter anymore! pvCenter is the mouse position when scaling is activated.
      Because the mouse position (scaling center) isn't shown in the editor use the element's center returned by GetPointCenter() */
      const float centerx = newcenter.x;
      const float centery = newcenter.y;

      for (int i = 0; i < m_vdpoint.Size(); i++)
      {
         DragPoint * const pdp1 = m_vdpoint.ElementAt(i);
         const float dx = (pdp1->m_v.x - centerx) * scalex;
         const float dy = (pdp1->m_v.y - centery) * scaley;
         pdp1->m_v.x = centerx + dx;
         pdp1->m_v.y = centery + dy;
      }
   }
   else
   {
      const float centerx = pvCenter->x;
      const float centery = pvCenter->y;

      for (int i = 0; i < m_vdpoint.Size(); i++)
      {
         DragPoint * const pdp1 = m_vdpoint.ElementAt(i);
         const float dx = (pdp1->m_v.x - centerx) * scalex;
         const float dy = (pdp1->m_v.y - centery) * scaley;
         pdp1->m_v.x = centerx + dx;
         pdp1->m_v.y = centery + dy;
      }

      // Move object center as well (if scaling from object center,
      // this will have no effect)
      {
         const float dx = (newcenter.x - centerx) * scalex;
         const float dy = (newcenter.y - centery) * scaley;
         newcenter.x = centerx + dx;
         newcenter.y = centery + dy;
         PutPointCenter(&newcenter);
      }
   }

   GetIEditable()->EndUndo();

   GetPTable()->SetDirtyDraw();
}
Пример #3
0
void ISelect::FlipX(Vertex2D * const pvCenter)
{
   GetIEditable()->MarkForUndo();

   Vertex2D vCenter;
   GetCenter(&vCenter);
   const float delta = vCenter.x - pvCenter->x;
   vCenter.x -= delta * 2;
   PutCenter(&vCenter);
}
Пример #4
0
void ISelect::Translate(Vertex2D *pvOffset)
{
   GetIEditable()->MarkForUndo();

   Vertex2D vCenter;
   GetCenter(&vCenter);

   vCenter.x += pvOffset->x;
   vCenter.y += pvOffset->y;
   PutCenter(&vCenter);
}
Пример #5
0
void ISelect::OnLButtonUp(int x, int y)
{
   m_fDragging = false;

   ReleaseCapture();

   if (m_fMarkedForUndo)
   {
      m_fMarkedForUndo = false;
      GetIEditable()->EndUndo();
   }
}
Пример #6
0
void ISelect::Scale(float scalex, float scaley, Vertex2D *pvCenter)
{
   GetIEditable()->MarkForUndo();

   Vertex2D vCenter;
   GetCenter(&vCenter);

   const float dx = vCenter.x - pvCenter->x;
   const float dy = vCenter.y - pvCenter->y;

   vCenter.x = pvCenter->x + dx*scalex;
   vCenter.y = pvCenter->y + dy*scaley;
   PutCenter(&vCenter);
}
Пример #7
0
void IHaveDragPoints::TranslatePoints(Vertex2D *pvOffset)
{
   GetIEditable()->BeginUndo();
   GetIEditable()->MarkForUndo();

   for (int i = 0; i < m_vdpoint.Size(); i++)
   {
      DragPoint * const pdp1 = m_vdpoint.ElementAt(i);
      pdp1->m_v.x += pvOffset->x;
      pdp1->m_v.y += pvOffset->y;
   }

   Vertex2D newcenter;
   GetPointCenter(&newcenter);

   newcenter.x += pvOffset->x;
   newcenter.y += pvOffset->y;

   PutPointCenter(&newcenter);

   GetIEditable()->EndUndo();

   GetPTable()->SetDirtyDraw();
}
Пример #8
0
void ISelect::OnMouseMove(int x, int y)
{
   PinTable * const ptable = GetPTable();
   const float inv_zoom = 1.0f / ptable->m_zoom;

   if ((x == m_ptLast.x) && (y == m_ptLast.y))
   {
      return;
   }

   if (m_fDragging && !GetIEditable()->GetISelect()->m_fLocked) // For drag points, follow the lock of the parent
   {
      if (!m_fMarkedForUndo)
      {
         m_fMarkedForUndo = true;
         GetIEditable()->BeginUndo();
         GetIEditable()->MarkForUndo();
      }
      MoveOffset((x - m_ptLast.x)*inv_zoom, (y - m_ptLast.y)*inv_zoom);
      m_ptLast.x = x;
      m_ptLast.y = y;
      SetObjectPos();
   }
}
Пример #9
0
void ISelect::Rotate(float ang, Vertex2D *pvCenter)
{
   GetIEditable()->MarkForUndo();

   Vertex2D vCenter;
   GetCenter(&vCenter);

   const float sn = sinf(ANGTORAD(ang));
   const float cs = cosf(ANGTORAD(ang));

   const float dx = vCenter.x - pvCenter->x;
   const float dy = vCenter.y - pvCenter->y;

   vCenter.x = pvCenter->x + cs*dx - sn*dy;
   vCenter.y = pvCenter->y + cs*dy + sn*dx;
   PutCenter(&vCenter);
}
Пример #10
0
void IHaveDragPoints::RotatePoints(float ang, Vertex2D *pvCenter, const bool useElementCenter)
{
   Vertex2D newcenter;
   GetPointCenter(&newcenter);

   GetIEditable()->BeginUndo();
   GetIEditable()->MarkForUndo();

   if (useElementCenter)
   {
      /* Don't use the pvCenter anymore! pvCenter is the mouse position when rotating is activated.
      Because the mouse position (rotation center) isn't shown in the editor use the element's center returned by GetPointCenter() */
      const float centerx = newcenter.x;
      const float centery = newcenter.y;

      const float sn = sinf(ANGTORAD(ang));
      const float cs = cosf(ANGTORAD(ang));

      for (int i = 0; i < m_vdpoint.Size(); i++)
      {
         DragPoint * const pdp1 = m_vdpoint.ElementAt(i);
         const float dx = pdp1->m_v.x - centerx;
         const float dy = pdp1->m_v.y - centery;
         const float dx2 = cs*dx - sn*dy;
         const float dy2 = cs*dy + sn*dx;
         pdp1->m_v.x = centerx + dx2;
         pdp1->m_v.y = centery + dy2;
      }
   }
   else
   {
      const float centerx = pvCenter->x;
      const float centery = pvCenter->y;

      const float sn = sinf(ANGTORAD(ang));
      const float cs = cosf(ANGTORAD(ang));

      for (int i = 0; i < m_vdpoint.Size(); i++)
      {
         DragPoint * const pdp1 = m_vdpoint.ElementAt(i);
         const float dx = pdp1->m_v.x - centerx;
         const float dy = pdp1->m_v.y - centery;
         const float dx2 = cs*dx - sn*dy;
         const float dy2 = cs*dy + sn*dx;
         pdp1->m_v.x = centerx + dx2;
         pdp1->m_v.y = centery + dy2;
      }

      // Move object center as well (if rotating around object center,
      // this will have no effect)
      {
         const float dx = newcenter.x - centerx;
         const float dy = newcenter.y - centery;
         const float dx2 = cs*dx - sn*dy;
         const float dy2 = cs*dy + sn*dx;
         newcenter.x = centerx + dx2;
         newcenter.y = centery + dy2;
         PutPointCenter(&newcenter);
      }
   }
   GetIEditable()->EndUndo();

   GetPTable()->SetDirtyDraw();
}
Пример #11
0
void ISelect::DoCommand(int icmd, int x, int y)
{
   IEditable *piedit = GetIEditable();

   if ((icmd & 0x0000FFFF) == ID_SELECT_ELEMENT)
   {
      const int ksshift = GetKeyState(VK_SHIFT);
      const int ksctrl = GetKeyState(VK_CONTROL);

      PinTable *currentTable = GetPTable();
      int i = (icmd & 0x00FF0000) >> 16;
      ISelect * const pisel = currentTable->m_allHitElements.ElementAt(i);

      const bool fAdd = ((ksshift & 0x80000000) != 0);

      if (pisel == (ISelect *)currentTable && fAdd)
      {
         // Can not include the table in multi-select
         // and table will not be unselected, because the
         // user might be drawing a box around other objects
         // to add them to the selection group
         currentTable->OnLButtonDown(x, y); // Start the band select
         return;
      }

      currentTable->AddMultiSel(pisel, fAdd, fTrue, fTrue);
      return;
   }
   if (((icmd & 0x000FFFFF) >= 0x40000) && ((icmd & 0x000FFFFF) < 0x40020))
   {
      const int ksshift = GetKeyState(VK_SHIFT);
      const int ksctrl = GetKeyState(VK_CONTROL);

      PinTable *currentTable = GetPTable();
      int i = icmd & 0x000000FF;
      currentTable->AddToCollection(i);
   }
   switch (icmd)
   {
   case ID_EDIT_DRAWINGORDER_HIT:
      g_pvp->ShowDrawingOrderDialog(false);
      break;
   case ID_EDIT_DRAWINGORDER_SELECT:
      g_pvp->ShowDrawingOrderDialog(true);
      break;
   case ID_DRAWINFRONT:
   {
      PinTable *ptable = GetPTable();
      ptable->m_vedit.RemoveElement(piedit);
      ptable->m_vedit.AddElement(piedit);
      ptable->m_layer[layerIndex].RemoveElement(piedit);
      ptable->m_layer[layerIndex].AddElement(piedit);
      ptable->SetDirtyDraw();
      break;
   }
   case ID_DRAWINBACK:
      GetPTable()->m_vedit.RemoveElement(piedit);
      GetPTable()->m_vedit.InsertElementAt(piedit, 0);
      GetPTable()->m_layer[layerIndex].RemoveElement(piedit);
      GetPTable()->m_layer[layerIndex].InsertElementAt(piedit, 0);
      GetPTable()->SetDirtyDraw();
      break;
   case ID_SETASDEFAULT:
      piedit->WriteRegDefaults();
      break;
   case ID_LOCK:
      GetIEditable()->BeginUndo();
      GetIEditable()->MarkForUndo();
      m_fLocked = !m_fLocked;
      GetIEditable()->EndUndo();
      GetPTable()->SetDirtyDraw();
      break;
   case ID_ASSIGNTO_LAYER1:
   {
      GetPTable()->AssignToLayer(piedit, 0);
      break;
   }
   case ID_ASSIGNTO_LAYER2:
   {
      GetPTable()->AssignToLayer(piedit, 1);
      break;
   }
   case ID_ASSIGNTO_LAYER3:
   {
      GetPTable()->AssignToLayer(piedit, 2);
      break;
   }
   case ID_ASSIGNTO_LAYER4:
   {
      GetPTable()->AssignToLayer(piedit, 3);
      break;
   }
   case ID_ASSIGNTO_LAYER5:
   {
      GetPTable()->AssignToLayer(piedit, 4);
      break;
   }
   case ID_ASSIGNTO_LAYER6:
   {
      GetPTable()->AssignToLayer(piedit, 5);
      break;
   }
   case ID_ASSIGNTO_LAYER7:
   {
      GetPTable()->AssignToLayer(piedit, 6);
      break;
   }
   case ID_ASSIGNTO_LAYER8:
   {
      GetPTable()->AssignToLayer(piedit, 7);
      break;
   }
   /*default:
      psel->DoCommand(command, x, y);
      break;*/
   }
}