Mercurial > hg > ambi-plugin
view Source/MyPlot.cpp @ 8:d967dd1eafe8
Code update for effect and editor.
author | martinm_home <martin.morrell@eecs.qmul.ac.uk> |
---|---|
date | Sun, 16 Sep 2012 23:25:54 +0100 |
parents | f7ec6d983ec0 |
children | 53f99cbc5dbd |
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; centre_pattern = 0.5; centre_gain = 0; surround_mode = 0; surround_pattern = 0.5; surround_width = 60; surround_mode = 0; decoder_mode = 2; }; void polarPlot::draw (CDrawContext* context) { //Plot background circle circle(context); //Plot Needed Polar Patterns switch (decoder_mode) { case 2: //Stereo Mic Patterns leftMicPattern(context); rightMicPattern(context); break; case 3: //2.1 Mic Patterns leftMicPattern(context); rightMicPattern(context); break; case 4: //Quad Mic Patterns leftMicPattern(context); rightMicPattern(context); lsMicPattern(context); rsMicPattern(context); break; case 5: //5.0 Mic Patterns leftMicPattern(context); rightMicPattern(context); centreMicPattern(context); lsMicPattern(context); rsMicPattern(context); break; case 6: //5.1 Mic Patterns leftMicPattern(context); rightMicPattern(context); centreMicPattern(context); lsMicPattern(context); rsMicPattern(context); break; default: break; } 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); y = size.getCenter().y - (cos(ang/180.0*M_PI)*radius); context->beginDraw(); CPoint point = CPoint((int)x, (int)y); context->drawPoint(point, blueColor); context->endDraw(); ang++; } }; void polarPlot::centreMicPattern(CDrawContext* context)//To finish updating { CColor yellowColor = CColor(255,255,0,255); double radius, x, y; int ang = 0; while (ang<360) { radius = fabs(centre_pattern+(1-centre_pattern)*(cos((ang)/180.0*M_PI))) * size.getHeight()/2*0.8; x = size.getCenter().x - (sin(ang/180.0*M_PI)*radius*pow(10,(centre_gain/20))); //size.left + y = size.getCenter().y - (cos(ang/180.0*M_PI)*radius*pow(10,(centre_gain/20))); //+ PLOT_OFFSET context->beginDraw(); CPoint point = CPoint((int)x, (int)y); context->drawPoint(point, yellowColor); context->endDraw(); ang++; } }; void polarPlot::lsMicPattern(CDrawContext* context) { CColor greenColor = CColor(0,255,0,255); double radius, x, y, ptA, ptB; int ang = 0; while (ang<360) { switch (surround_mode) { case 0: { radius = fabs(surround_pattern+(1-surround_pattern)*(cos((ang-surround_width-180)/180.0*M_PI))) * size.getHeight()/2*0.8; break; } case 1: { ptA = cos(surround_width/180.0*M_PI) * (surround_pattern + (1-surround_pattern)*(cos((ang-180)/180.0*M_PI))); ptB = sin(surround_width/180.0*M_PI) * (sin((ang-180)/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*pow(10,(surround_gain/20))); y = size.getCenter().y - (cos(ang/180.0*M_PI)*radius*pow(10,(surround_gain/20))); context->beginDraw(); CPoint point = CPoint((int)x, (int)y); context->drawPoint(point, greenColor); context->endDraw(); ang++; } }; void polarPlot::rsMicPattern(CDrawContext* context) { CColor brownColor = CColor(139,69,19,255); double radius, x, y, ptA, ptB; int ang = 0; while (ang<360) { switch (surround_mode) { case 0: { radius = fabs(surround_pattern+(1-surround_pattern)*(cos((ang-180+surround_width)/180.0*M_PI))) * size.getHeight()/2*0.8; break; } case 1: { ptA = cos(surround_width/180.0*M_PI) * (surround_pattern + (1-surround_pattern)*(cos((ang-180)/180.0*M_PI))); ptB = sin(surround_width/180.0*M_PI) * (sin((ang-180)/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*pow(10,(surround_gain/20))); y = size.getCenter().y - (cos(ang/180.0*M_PI)*radius*pow(10,(surround_gain/20))); context->beginDraw(); CPoint point = CPoint((int)x, (int)y); context->drawPoint(point, brownColor); context->endDraw(); ang++; } };