attempt replace GodleyIcon::iconScale() by Item::scaleFactor() toward…#194
Conversation
| // ensure that flows used as intial conditions, which inherit their values from other vars, correctly initialise corresponding stock var. for ticket 1137. | ||
| //auto vv=minsky().variableValues[VariableValue::valueIdFromScope(group.lock(),v.init)]; | ||
| //if (vv->lhs()) vv->init=str(vv->value()); |
There was a problem hiding this comment.
I've removed it, thanks.
| FlowCoef fc(v.init); | ||
| table.cell(r,c)=fc.str(); | ||
| FlowCoef fc(v.init); | ||
| table.cell(r,c)=fc.str(); |
There was a problem hiding this comment.
Fixed this up in Emacs.
| { | ||
| double dx=fabs(x-this->x()), dy=fabs(y-this->y()); | ||
| auto z=zoomFactor(); | ||
| //double w=0.5*Item::width()*z, h=0.5*Item::height()*z; |
| float flowMargin=0, stockMargin=0; | ||
| /// icon scale is adjusted when Godley icon is resized | ||
| float m_iconScale=1; | ||
| //float m_iconScale=1; |
|
|
||
| /// scale icon until it's height matches \a h | ||
| void scaleIconForHeight(float h) {update(); m_iconScale*=h/(bottomMargin()+iHeight()*iconScale()*zoomFactor());} | ||
| //void scaleIconForHeight(float h) {update(); m_iconScale*=h/(bottomMargin()+iHeight()*iconScale()*zoomFactor());} |
|
|
||
| /// icon scale is adjusted when Godley icon is resized | ||
| float iconScale() const {return m_iconScale;} | ||
| //float iconScale() const {return m_iconScale;} |
|
All looks reasonable, minor nits aside. Just waiting to see that it passes Travis. |
|
Thanks. I've committed a better version now, but there are still some issues, mentioned by Steve in tickets 1209, 1213 and now 1214. |
|
|
||
| /// icon scale is adjusted when Godley icon is resized | ||
| //float iconScale() const {return m_iconScale;} | ||
| float scaleFactor() const override; |
There was a problem hiding this comment.
This is identical to Item::scaleFactor(), so not needed.
| /// icon scale is adjusted when Godley icon is resized | ||
| //float iconScale() const {return m_iconScale;} | ||
| float scaleFactor() const override; | ||
| float scaleFactor(const float& sf) override; |
There was a problem hiding this comment.
I'm assuming this override is to prevent updating the boundingBox, is that correct?
There was a problem hiding this comment.
Yes, because the bounding box was wrong after some resize operations.
| float flowMargin=0, stockMargin=0; | ||
| /// icon scale is adjusted when Godley icon is resized | ||
| //float m_iconScale=1; | ||
| float m_sf=1; |
There was a problem hiding this comment.
Why not use Item::m_sf here?
There was a problem hiding this comment.
I guess I can dynamic_cast to Godley in Item::scaleFactor(const float& sf) to prevent the bounding box from being updated in that case.
|
On Thu, Jul 23, 2020 at 12:44:35AM -0700, Wynand wrote:
@wdednam commented on this pull request.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
In model/godleyIcon.h:
> @@ -40,7 +40,7 @@ namespace minsky
/// for placement of bank icon within complex
float flowMargin=0, stockMargin=0;
/// icon scale is adjusted when Godley icon is resized
- //float m_iconScale=1;
+ float m_sf=1;
I guess I can dynamic_cast to Godley in Item::scaleFactor(const float& sf) to
prevent the bounding box from being updated in that case.
No need. Just make m_sf protected, not private, then update in the overridden scaleFactor(const float& sf)
…
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.*
--
----------------------------------------------------------------------------
Dr Russell Standish Phone 0425 253119 (mobile)
Principal, High Performance Coders hpcoder@hpcoders.com.au
http://www.hpcoders.com.au
----------------------------------------------------------------------------
|
Mmmm, I've tried the above, but when I use Item::zoomFactor() in the GodleyIcon Class, I also have to use it in the VariableBase class where attached variables' zoomFactor are calculated and then the Godleyicon does not resize properly... |
| { | ||
| if (y.width) x1->iWidth(*y.width); | ||
| if (y.height) x1->iHeight(*y.height); | ||
| x1->bb.update(*x1); |
There was a problem hiding this comment.
As per comment on PR#195, this update call should be redundant.
| protected: | ||
| float m_sf=1; |
There was a problem hiding this comment.
I meant use Item::m_sf. I thought maybe you didn't have access, because Item::m_sf might have been private, hence the comment about making it protected, but I see it is actually public right now.
There was a problem hiding this comment.
"Overriding" a member variable like this is going to cause a lot of confusion going forward.
|
This is my best attempt so far. The test suite passes locally. i hope it also does remotely. |
| accumulateWidthHeight(m_stockVars, stockH, stockMargin); | ||
| accumulateWidthHeight(m_flowVars, flowH, flowMargin); | ||
| float iw=this->iWidth(), ih=this->iHeight(); | ||
| float iw=this->iWidth()*this->zoomFactor(), ih=this->iHeight()*this->zoomFactor(); |
There was a problem hiding this comment.
I'm comparing with the sum of all v->width() or all v->height() with g->iWidth() or g->iHeight(). I added the zoomFactor in item::width() and item::height() for ticket 1204, so I need to multiply iWdith() and iHeight() by the zoomFactor here
There was a problem hiding this comment.
This was a mistake, The fact that v->width() and height() now contain the zoomFactor causes problems, as shown in ticket 1221. I'm reverting it to RenderVariable width() and height() and removing the zoomFactors here.
| static void setPrivates | ||
| (minsky::GodleyIcon& g, const vector<vector<string> >& data, | ||
| const vector<GodleyTable::AssetClass>& assetClass,float iconScale) | ||
| const vector<GodleyTable::AssetClass>& assetClass) | ||
| { | ||
| setPrivates(g.table, data, assetClass); | ||
| g.m_iconScale=iconScale; | ||
| } |
There was a problem hiding this comment.
We can now get rid if this helper function too.
There was a problem hiding this comment.
I just tried this and it caused the variables attached to GodleyIcons to disappear. So, I've left it in.
|
I took this for a spin, and it is looking good. The resulting shape of the icon still seems a little counterintuitive when shrinking the icon down towards the flow and stock variables (the icon should really maintain its aspect ratio with the scaleFactor adjust the variables to fit, IMHO). I did make one change setting iWidth/iHeight had a mysterious factor of 1/2, which made no sense. Removing that improved things a little bit. I have integrated the changes now. I also checked the status of old schema - nothing too hilarious there! |
…s fixing tickets 1209 and 1213. I don't understand why Item::scaleFactor behaves differently to GodleyIcon::iconScale if I set it the same way in GodleyIcon::scaleIconForHeight?
This change is