Click here to Skip to main content
15,918,031 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to change title bar? Pin
valikac6-Mar-03 8:40
valikac6-Mar-03 8:40 
GeneralQuery amount of memory on graphic card Pin
CodeBrain6-Mar-03 3:54
CodeBrain6-Mar-03 3:54 
GeneralRe: Query amount of memory on graphic card Pin
Daniel Strigl6-Mar-03 4:07
Daniel Strigl6-Mar-03 4:07 
GeneralRe: Query amount of memory on graphic card Pin
CodeBrain6-Mar-03 21:45
CodeBrain6-Mar-03 21:45 
Generaldraw an ellipse given the coeffs Pin
affzan6-Mar-03 3:29
affzan6-Mar-03 3:29 
GeneralRe: draw an ellipse given the coeffs Pin
G. Steudtel6-Mar-03 4:54
G. Steudtel6-Mar-03 4:54 
GeneralRe: draw an ellipse given the coeffs Pin
affzan6-Mar-03 5:49
affzan6-Mar-03 5:49 
GeneralRe: draw an ellipse given the coeffs Pin
G. Steudtel8-Mar-03 6:40
G. Steudtel8-Mar-03 6:40 
Okay,
here is the code. I took it from a private project, I developed in 1996. It took me quite a while to find it.

void CGraphEllipse::zeichne(CDC* pDC)// Draw an ellipse
{ if( m_listAbschnitte.IsEmpty() ) return;
  if( m_a == 0.0 )             return;
  CPen   *pOldPen   = pDC->SelectObject(&m_penStift);// use my pen
  CBrush *pOldBrush = pDC->SelectObject(&m_brPinsel);// use my brush for drawing

  XFORM xfMatrix;//Transformation matrix
  xfMatrix.eM11 = 1.0;//At the beginning there is no transformation
  xfMatrix.eM12 = 0.0;
  xfMatrix.eM21 = 0.0;
  xfMatrix.eM22 = 1.0;
  xfMatrix.eDx  = 0.0;// and no translation
  xfMatrix.eDy  = 0.0;

  double dSinPhi = 0;// no rotation so far
  double dCosPhi = 1;
  double dPhi    = 0;
  // m_a = r1²  m_c = r2² m_b = 0(initially)
  // Circles can't be rotated 
  if( m_c != m_a ) dPhi = atan2(2*m_b,(m_a-m_c))/2.0;

  dSinPhi = sin(dPhi);
  dCosPhi = cos(dPhi);

  xfMatrix.eM11 = dCosPhi; // Now fill in the rotating values
  xfMatrix.eM12 = dSinPhi;
  xfMatrix.eM21 = -dSinPhi;
  xfMatrix.eM22 = dCosPhi;
  xfMatrix.eDx  = m_ptZiehZentrum.x; // Translation component
  xfMatrix.eDy  = m_ptZiehZentrum.y;
  SetGraphicsMode(pDC->m_hDC,GM_ADVANCED);// Tell the DC we want to use path functions
  pDC->BeginPath(); // start path
  SetWorldTransform(pDC->m_hDC,&xfMatrix);// set transforming to do
  pDC->Ellipse(-(int)m_dR1,-(int)m_dR2,(int)m_dR1,(int)m_dR2);// Draw ellipse
  pDC->EndPath();// Path finished
// Now draw the lines and/ or fill pattern
  if( m_bGeschlossen )
    { if( m_bOpaque ) pDC->StrokeAndFillPath();//  with fill pattern
      else            pDC->StrokePath();// without fill pattern
    }
  else				   pDC->StrokePath();
  pDC->SelectObject(pOldPen);
  pDC->SelectObject(pOldBrush);  
  ModifyWorldTransform(pDC->m_hDC,NULL,MWT_IDENTITY);// restore old transformation
  SetGraphicsMode(pDC->m_hDC,GM_COMPATIBLE);// restore old DC mode
}

This function was used to draw a arbitrary rotated ellipse.
Of course, you have to do your own calculations for the centerpoints and that stuff.

The point of interest is the calculation of the transformation matrix. But this you should have alredy done if you have the coeffx of your ellipse.

Hope this helps

See also help for XFORM and CDC Path functions in your VC-Compiler

G. Steudtel

Even dwarves started small.
GeneralRe: draw an ellipse given the coeffs Pin
G. Steudtel6-Mar-03 4:55
G. Steudtel6-Mar-03 4:55 
GeneralDesign question. Pin
Maximilien6-Mar-03 3:06
Maximilien6-Mar-03 3:06 
GeneralRe: Design question. Pin
Joel Lucsy6-Mar-03 13:51
Joel Lucsy6-Mar-03 13:51 
GeneralWrite Image of CD-ROM Pin
Andrea Ferraro6-Mar-03 2:53
Andrea Ferraro6-Mar-03 2:53 
GeneralRe: Write Image of CD-ROM Pin
Anonymous6-Mar-03 3:03
Anonymous6-Mar-03 3:03 
Generalproblem with new operator constructing GDI+ classes Pin
Baris Kurtlutepe6-Mar-03 2:40
Baris Kurtlutepe6-Mar-03 2:40 
GeneralRe: problem with new operator constructing GDI+ classes Pin
56789012346-Mar-03 2:58
56789012346-Mar-03 2:58 
GeneralRe: problem with new operator constructing GDI+ classes Pin
Joel Lucsy6-Mar-03 2:58
Joel Lucsy6-Mar-03 2:58 
GeneralRe: problem with new operator constructing GDI+ classes Pin
Baris Kurtlutepe6-Mar-03 3:47
Baris Kurtlutepe6-Mar-03 3:47 
Generalturn off "are you sure you want to delete?" NonVS question Pin
ns6-Mar-03 1:21
ns6-Mar-03 1:21 
GeneralRe: turn off "are you sure you want to delete?" NonVS question Pin
-Dy6-Mar-03 1:35
-Dy6-Mar-03 1:35 
Generalthanks! Pin
ns6-Mar-03 1:37
ns6-Mar-03 1:37 
GeneralMember functions are "unresolved external symbol" Pin
Rickard Andersson206-Mar-03 0:47
Rickard Andersson206-Mar-03 0:47 
GeneralRe: Member functions are "unresolved external symbol" Pin
Rage6-Mar-03 0:55
professionalRage6-Mar-03 0:55 
GeneralRe: Member functions are "unresolved external symbol" Pin
Rickard Andersson206-Mar-03 2:40
Rickard Andersson206-Mar-03 2:40 
GeneralRe: Member functions are "unresolved external symbol" Pin
Brian Shifrin6-Mar-03 1:39
Brian Shifrin6-Mar-03 1:39 
GeneralRe: Member functions are "unresolved external symbol" Pin
Rickard Andersson206-Mar-03 2:46
Rickard Andersson206-Mar-03 2:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.