Mercurial > hg > ambi-plugin
view Source/MyPlot.cpp @ 7:f7ec6d983ec0
Begins of the polar plot.
author | martinm_home <martin.morrell@eecs.qmul.ac.uk> |
---|---|
date | Sat, 15 Sep 2012 15:07:00 +0100 |
parents | 503cbcdd0b2a |
children | d967dd1eafe8 |
line wrap: on
line source
// // MyPlot.cpp // SoundField // // Created by Martin Morrell on 25/06/2012. // Copyright (c) 2012 __MyCompanyName__. All rights reserved. // #include "MyPlot.h" polarPlot::polarPlot(const CRect &size): CView (size) { stereo_mode = 0; pattern = 0.5; width = 45; }; void polarPlot::draw (CDrawContext* context) { //Plot background circle circle(context); //Stereo Mic Patterns leftMicPattern(context); rightMicPattern(context); setDirty(false); //context->beginDraw(); //context->drawRect(size); // CBitmap *knob_knob = new CBitmap ("360_knob.png"); // context->drawBitmap(knob_knob, size); // // // //Plot Ellipse // context->setLineWidth (6); // CColor eclColor = CColor(120,120,120,255); // context->setFrameColor(eclColor); // CRect hi = CRect(20, 20, 130, 130); // context->drawEllipse(hi); // double x = 75; // double y=75; // context->setFrameColor(kBlueCColor); // context->setLineWidth (2); // CRect fatPoint = CRect(x-1,y-1,x+1,y+1); // context->drawEllipse(fatPoint); //CPoint *myPoint = new CPoint(50,50); //context->drawPolygon(myPoint, 3); //context->setFillColor(eclColor); //context->setFrameColor(eclColor); //context->endDraw(); //setDirty (false); }; void polarPlot::circle(CDrawContext *context) { //Plot Ellipse context->setLineWidth (3); CColor eclColor = CColor(120,120,120,125); context->setFrameColor(eclColor); ; CRect circleSize = CRect(size.getCenter().x-size.getHeight()/2*0.82, size.getCenter().y-size.getHeight()/2*0.82, size.getCenter().x+size.getHeight()/2*0.82, size.getCenter().y+size.getHeight()/2*0.82); context->drawEllipse(circleSize); }; void polarPlot::leftMicPattern(CDrawContext* context) { CColor redColor = CColor(255,0,0,255); double radius, x, y, ptA, ptB; int ang = 0; while (ang<360) { switch (stereo_mode) { case 0: { radius = fabs(pattern+(1-pattern)*(cos((ang-width)/180.0*M_PI))) * size.getHeight()/2*0.8; break; } case 1: { ptA = cos(width/180.0*M_PI) * (pattern + (1-pattern)*(cos(ang/180.0*M_PI))); ptB = sin(width/180.0*M_PI) * (sin(ang/180.0*M_PI)); radius = fabs(ptA + ptB) * size.getHeight()/2*0.8; break; } default: break; } x = size.getCenter().x - (sin(ang/180.0*M_PI)*radius); //size.left + y = size.getCenter().y - (cos(ang/180.0*M_PI)*radius); //+ PLOT_OFFSET context->beginDraw(); CPoint point = CPoint((int)x, (int)y); context->drawPoint(point, redColor); context->endDraw(); ang++; } }; void polarPlot::rightMicPattern(CDrawContext* context) { CColor blueColor = CColor(0,0,255,255); double radius, x, y, ptA, ptB; int ang = 0; while (ang<360) { switch (stereo_mode) { case 0: { radius = fabs(pattern+(1-pattern)*(cos((ang+width)/180.0*M_PI))) * size.getHeight()/2*0.8; break; } case 1: { ptA = cos(width/180.0*M_PI) * (pattern + (1-pattern)*(cos(ang/180.0*M_PI))); ptB = sin(width/180.0*M_PI) * (sin(ang/180.0*M_PI)); radius = fabs(ptA - ptB) * size.getHeight()/2*0.8; break; } default: break; } x = size.getCenter().x - (sin(ang/180.0*M_PI)*radius); //size.left + y = size.getCenter().y - (cos(ang/180.0*M_PI)*radius); //+ PLOT_OFFSET context->beginDraw(); CPoint point = CPoint((int)x, (int)y); context->drawPoint(point, blueColor); context->endDraw(); ang++; } }; //void polarPlot::setBackgroundColour (const CColor& c) //{ // backgroundColour = c; //};