Mercurial > hg > ambi-plugin
view Source/MyPlot.cpp @ 12:87dc3d84c120
Addressed the load program defaults over user settings 'feature'.
Removed isChild on objects that are added before the frame creation since a)they're always there and b) doesn't write to all displays present.
author | martinm_home <martin.morrell@eecs.qmul.ac.uk> |
---|---|
date | Thu, 27 Sep 2012 23:29:16 +0100 |
parents | 53f99cbc5dbd |
children |
line wrap: on
line source
// // MyPlot.cpp // ClassicAmbiDec // // 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 = 0; decoder_prev = 0; }; 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: switch (decoder_mode5x) { case 0: //5.0 Mic Patterns leftMicPattern(context); rightMicPattern(context); centreMicPattern(context); lsMicPattern(context); rsMicPattern(context); break; case 1: //Heller 1 Plot heller1Pattern(context); break; case 2: //Heller 2 Plot heller2Pattern(context); break; default: break; } break; case 6: switch (decoder_mode5x) { case 0: //5.1 Mic Patterns leftMicPattern(context); rightMicPattern(context); centreMicPattern(context); lsMicPattern(context); rsMicPattern(context); break; case 1: //Heller 1 Plot heller1Pattern(context); break; case 2: //Heller 2 Plot heller2Pattern(context); break; default: break; } break; default: break; } setDirty(false); }; void polarPlot::circle(CDrawContext *context) { //Plot Ellipse - Background Circle 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); y = size.getCenter().y - (cos(ang/180.0*M_PI)*radius); 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) { CColor yellowColor = CColor(255,215,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/gFactor/20)))); y = size.getCenter().y - (cos(ang/180.0*M_PI)*(radius*(pow(10,centre_gain/gFactor/20)))); 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/gFactor/20)))); y = size.getCenter().y - (cos(ang/180.0*M_PI)*(radius*(pow(10,surround_gain/gFactor/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/gFactor/20)))); y = size.getCenter().y - (cos(ang/180.0*M_PI)*(radius*(pow(10,surround_gain/gFactor/20)))); context->beginDraw(); CPoint point = CPoint((int)x, (int)y); context->drawPoint(point, brownColor); context->endDraw(); ang++; } }; void polarPlot::heller1Pattern(VSTGUI::CDrawContext *context) { double radius, x, y; int ang = 0; //Left Polar CColor redColor = CColor(255,0,0,255); while (ang<360) { radius = 1.4017195157709*fabs(0.28205165*(1/sqrt(2.0)) +0.24760232*(cos(ang/180.0*M_PI)) +0.18790454*(sin(ang/180.0*M_PI))) * size.getHeight()/2*0.8; 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, redColor); context->endDraw(); ang++; } //Right Polar CColor blueColor = CColor(0,0,255,255); ang = 0; while (ang<360) { radius = 1.4017195157709*fabs(0.28204229*(1/sqrt(2.0)) +0.24758662*(cos(ang/180.0*M_PI)) -0.18792311*(sin(ang/180.0*M_PI))) * size.getHeight()/2*0.8; 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++; } //SL Polar Pattern CColor greenColor = CColor(0,255,0,255); ang = 0; while (ang<360) { radius = 1.40171951577099*fabs(0.44947336*(1/sqrt(2.0)) -0.23381746*(cos(ang/180.0*M_PI)) +0.31911519*(sin(ang/180.0*M_PI))) * size.getHeight()/2*0.8; 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, greenColor); context->endDraw(); ang++; } //SR Polar Pattern CColor brownColor = CColor(139,69,19,255); ang = 0; while (ang<360) { radius = 1.4017195157709*fabs(0.44945895*(1/sqrt(2.0)) -0.23380219*(cos(ang/180.0*M_PI)) -0.31911386*(sin(ang/180.0*M_PI))) * size.getHeight()/2*0.8; 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, brownColor); context->endDraw(); ang++; } //C Polar Pattern CColor yellowColor = CColor(255,215,0,255); ang = 0; while (ang<360) { radius = 1.4017195157709*fabs(-0.04881270*(1/sqrt(2.0)) -0.02756928*(cos(ang/180.0*M_PI)) +0.00001724*(sin(ang/180.0*M_PI))) * size.getHeight()/2*0.8; 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, yellowColor); context->endDraw(); ang++; } }; void polarPlot::heller2Pattern(VSTGUI::CDrawContext *context) { double radius, x, y; int ang = 0; //Left Polar CColor redColor = CColor(255,0,0,255); while (ang<360) { radius = 1.38921598327229*fabs(0.21426224*(1/sqrt(2.0)) +0.19218459*(cos(ang/180.0*M_PI)) +0.20409261*(sin(ang/180.0*M_PI))) * size.getHeight()/2*0.8; 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, redColor); context->endDraw(); ang++; } //Right Polar CColor blueColor = CColor(0,0,255,255); ang = 0; while (ang<360) { radius = 1.38921598327229*fabs(0.21426400*(1/sqrt(2.0)) +0.19218379*(cos(ang/180.0*M_PI)) -0.20409362*(sin(ang/180.0*M_PI))) * size.getHeight()/2*0.8; 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++; } //SL Polar Pattern CColor greenColor = CColor(0,255,0,255); ang = 0; while (ang<360) { radius = 1.38921598327229*fabs(0.44287748*(1/sqrt(2.0)) -0.27006948*(cos(ang/180.0*M_PI)) +0.30405695*(sin(ang/180.0*M_PI))) * size.getHeight()/2*0.8; 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, greenColor); context->endDraw(); ang++; } //SR Polar Pattern CColor brownColor = CColor(139,69,19,255); ang = 0; while (ang<360) { radius = 1.38921598327229*fabs(0.44287676*(1/sqrt(2.0)) -0.27006941*(cos(ang/180.0*M_PI)) -0.30405595*(sin(ang/180.0*M_PI))) * size.getHeight()/2*0.8; 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, brownColor); context->endDraw(); ang++; } //C Polar Pattern CColor yellowColor = CColor(255,215,0,255); ang = 0; while (ang<360) { radius = 1.38921598327229*fabs(0.09993309*(1/sqrt(2.0)) +0.15577050*(cos(ang/180.0*M_PI)) +0.00000000*(sin(ang/180.0*M_PI))) * size.getHeight()/2*0.8; 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, yellowColor); context->endDraw(); ang++; } };