Skip to content

Commit

Permalink
Merge branch 'master' of github.com:highperformancecoder/minsky
Browse files Browse the repository at this point in the history
  • Loading branch information
highperformancecoder committed Jul 23, 2024
2 parents 8885eca + 542f1ba commit 9af7dc1
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 75 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,9 @@ install-doxydoc: doxydoc
rsync -r -z --progress --delete doxydoc $(SF_WEB)


doc/Ravel/labels.pl: $(wildcard doc/*.tex)
cd doc; sh makedoc.sh

# upload manual to SF
install-manual: doc/Ravel/labels.pl
rsync -r -z --progress --delete doc/minsky.html doc/Ravel $(SF_WEB)/manual
Expand Down
Binary file modified doc/Ravel.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion engine/equations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ namespace MathDAG
// try again later
integralInputs.emplace_back(input,i->ports(1).lock()->wires()[0]);
// clear error indicator
minsky::minsky().canvas.itemIndicator=false;
minsky::minsky().canvas.itemIndicator.reset();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,10 @@ export class CommandsManager {
Math.abs(itemX - 0.5 * canvasWidth) > 0.5 * canvasWidth ||
Math.abs(itemY - 0.5 * canvasHeight) > 0.5 * canvasHeight
) {
const posX = itemX - (await minsky.canvas.item.x()) + 0.5 * canvasWidth;
const posY = itemY - (await minsky.canvas.item.y()) + 0.5 * canvasHeight;
const posX = itemX - (await minsky.canvas.itemIndicator.x()) + 0.5 * canvasWidth;
const posY = itemY - (await minsky.canvas.itemIndicator.y()) + 0.5 * canvasHeight;
minsky.canvas.moveTo(posX,posY);
}
minsky.canvas.itemIndicator(true);
minsky.canvas.requestRedraw();
WindowManager.getMainWindow()?.webContents?.send(events.RESET_SCROLL);
} else {
Expand Down
3 changes: 2 additions & 1 deletion gui-js/libs/shared/src/lib/backend/minsky.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ export class Canvas extends RenderNativeWindow {
backgroundColour: ecolab__cairo__Colour;
item: Item;
itemFocus: Item;
itemIndicator: Item;
lasso: LassoBox;
model: Group;
selection: Selection;
Expand All @@ -428,6 +429,7 @@ export class Canvas extends RenderNativeWindow {
this.backgroundColour=new ecolab__cairo__Colour(this.$prefix()+'.backgroundColour');
this.item=new Item(this.$prefix()+'.item');
this.itemFocus=new Item(this.$prefix()+'.itemFocus');
this.itemIndicator=new Item(this.$prefix()+'.itemIndicator');
this.lasso=new LassoBox(this.$prefix()+'.lasso');
this.model=new Group(this.$prefix()+'.model');
this.selection=new Selection(this.$prefix()+'.selection');
Expand Down Expand Up @@ -468,7 +470,6 @@ export class Canvas extends RenderNativeWindow {
async hasScrollBars(): Promise<boolean> {return this.$callMethod('hasScrollBars');}
async init(): Promise<void> {return this.$callMethod('init');}
async itemAt(a1: number,a2: number): Promise<object> {return this.$callMethod('itemAt',a1,a2);}
async itemIndicator(...args: boolean[]): Promise<boolean> {return this.$callMethod('itemIndicator',...args);}
async keyPress(a1: minsky__EventInterface__KeyPressArgs): Promise<boolean> {return this.$callMethod('keyPress',a1);}
async lassoMode(...args: string[]): Promise<string> {return this.$callMethod('lassoMode',...args);}
async lockRavelsInSelection(): Promise<void> {return this.$callMethod('lockRavelsInSelection');}
Expand Down
6 changes: 3 additions & 3 deletions gui-js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 13 additions & 8 deletions model/canvas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ namespace minsky
lassoMode=LassoMode::none;


itemIndicator=false;
itemIndicator.reset();
rotatingItem=false;
itemFocus.reset();
wireFocus.reset();
Expand Down Expand Up @@ -776,7 +776,7 @@ namespace minsky
iv->type()==VariableType::parameter || iv->inputWired())
return true;

auto def=model->findAny
itemIndicator=model->findAny
(&GroupItems::items, [&](const ItemPtr& i) {
if (auto v=i->variableCast())
return v->inputWired() && v->valueId()==iv->valueId();
Expand All @@ -790,9 +790,7 @@ namespace minsky
return o->intVar->valueId()==iv->valueId();
return false;
});
if (def)
item=def;
return def.get();
return itemIndicator.get();
}
return false;
}
Expand Down Expand Up @@ -852,7 +850,14 @@ namespace minsky
const CairoSave cs(cairo);
cairo_identity_matrix(cairo);
cairo_translate(cairo,it.x(), it.y());
it.draw(cairo);
try
{
it.draw(cairo);
}
catch (const std::exception& ex)
{
cerr << ex.what() << endl;
}
}
return false;
});
Expand Down Expand Up @@ -910,11 +915,11 @@ namespace minsky
cairo_stroke(cairo);
}

if (itemIndicator && item) // draw a red circle to indicate an error or other marker
if (itemIndicator) // draw a red circle to indicate an error or other marker
{
const CairoSave cs(surface()->cairo());
cairo_set_source_rgb(surface()->cairo(),1,0,0);
cairo_arc(surface()->cairo(),item->x(),item->y(),15,0,2*M_PI);
cairo_arc(surface()->cairo(),itemIndicator->x(),itemIndicator->y(),15,0,2*M_PI);
cairo_stroke(surface()->cairo());
}

Expand Down
4 changes: 2 additions & 2 deletions model/canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ namespace minsky
rotatingItem=true;
}
ClickType::Type clickType;
/// for drawing error indicators on the canvas
bool itemIndicator=false;
/// for drawing error indicator on the canvas
ItemPtr itemIndicator;

/// lasso mode support
struct LassoMode {enum type {none, lasso, itemResize};};
Expand Down
14 changes: 6 additions & 8 deletions model/minsky.cc
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ namespace minsky

auto start=chrono::high_resolution_clock::now();
auto updateResetDuration=onStackExit([&]{resetDuration=chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now()-start);});
canvas.itemIndicator=false;
canvas.itemIndicator.reset();
const BusyCursor busy(*this);
EvalOpBase::t=t=t0;
lastT=t0;
Expand Down Expand Up @@ -1249,26 +1249,24 @@ namespace minsky
// this method is logically const, but because of the way
// canvas rendering is done, canvas state needs updating
auto& canvas=const_cast<Canvas&>(this->canvas);
canvas.item=nullptr;
if (op.visible())
canvas.item=canvas.model->findItem(op);
canvas.itemIndicator=canvas.model->findItem(op);
else if (auto v=op.variableCast())
if (auto c=v->controller.lock())
displayErrorItem(*c);

if (!canvas.item)
if (!canvas.itemIndicator)
if (auto g=op.group.lock())
{
while (g && !g->visible()) g=g->group.lock();
if (g && g->visible())
canvas.item=g;
canvas.itemIndicator=g;
}

canvas.itemIndicator=canvas.item.get();
if (canvas.item)
{
auto physX=canvas.item->x();
auto physY=canvas.item->y();
auto physX=canvas.itemIndicator->x();
auto physY=canvas.itemIndicator->y();
if (physX<100 || physX>canvas.frameArgs().childWidth-100 ||
physY<100 || physY>canvas.frameArgs().childHeight-100)
{
Expand Down
108 changes: 60 additions & 48 deletions model/variable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ shared_ptr<VariableValue> VariableBase::vValue() const

vector<unsigned> VariableBase::dims() const
{
if (auto v=vValue()) return v->hypercube().dims();
try
{
if (auto v=vValue()) return v->hypercube().dims();
}
catch (...) {} // ignore any exceptions caused by evaluating RHS.
return {};
}

Expand Down Expand Up @@ -324,8 +328,12 @@ string VariableBase::init(const string& x)

double VariableBase::value() const
{
if (isValueId(valueId()))
return minsky::cminsky().variableValues[valueId()]->value();
try
{
if (isValueId(valueId()))
return minsky::cminsky().variableValues[valueId()]->value();
}
catch (...) {} // ignore any errors in RHS
return 0;
}

Expand Down Expand Up @@ -696,6 +704,7 @@ void VariableBase::draw(cairo_t *cairo) const

auto vv=vValue();
if (miniPlot && vv && vv->size()==1)
try
{
if (cachedTime!=cminsky().t)
{
Expand All @@ -707,56 +716,59 @@ void VariableBase::draw(cairo_t *cairo) const
cairo_translate(cairo,-w,-h);
miniPlot->draw(cairo,2*w,2*h);
}

catch (...) {} // ignore errors in obtaining values

// For feature 47
if (type()!=constant && !ioVar() && vv && vv->size()==1 && vv->idxInRange())
try
{
if (!cachedMantissa || cachedMantissa->cairoContext()!=cairo)
{
cachedMantissa=make_shared<Pango>(cairo);
cachedMantissa->setFontSize(6.0);
cachedExponent=make_shared<Pango>(cairo);
cachedExponent->setFontSize(6.0);
cachedValue=nan("");
}

auto val=engExp();
if (value()!=cachedValue)
{
cachedValue=value();
if (!isnan(value())) {
if (sliderBoundsSet && vv->sliderVisible)
cachedMantissa->setMarkup
(mantissa(val,
int(1+
(sliderStepRel?
-log10(maxSliderSteps()):
log10(value()/maxSliderSteps())
))));
else
cachedMantissa->setMarkup(mantissa(val));
try
{
if (type()!=constant && !ioVar() && vv && vv->size()==1 && vv->idxInRange())
{
if (!cachedMantissa || cachedMantissa->cairoContext()!=cairo)
{
cachedMantissa=make_shared<Pango>(cairo);
cachedMantissa->setFontSize(6.0);
cachedExponent=make_shared<Pango>(cairo);
cachedExponent->setFontSize(6.0);
cachedValue=nan("");
}
else if (isinf(value())) { // Display non-zero divide by zero as infinity. For ticket 1155
if (signbit(value())) cachedMantissa->setMarkup("-∞");
else cachedMantissa->setMarkup("");

auto val=engExp();
if (value()!=cachedValue)
{
cachedValue=value();
if (!isnan(value())) {
if (sliderBoundsSet && vv->sliderVisible)
cachedMantissa->setMarkup
(mantissa(val,
int(1+
(sliderStepRel?
-log10(maxSliderSteps()):
log10(value()/maxSliderSteps())
))));
else
cachedMantissa->setMarkup(mantissa(val));
}
else if (isinf(value())) { // Display non-zero divide by zero as infinity. For ticket 1155
if (signbit(value())) cachedMantissa->setMarkup("-∞");
else cachedMantissa->setMarkup("");
}
else // Display all other NaN cases as ???. For ticket 1155
cachedMantissa->setMarkup("???");
cachedExponent->setMarkup(expMultiplier(val.engExp));
}
else // Display all other NaN cases as ???. For ticket 1155
cachedMantissa->setMarkup("???");
cachedExponent->setMarkup(expMultiplier(val.engExp));
}
cachedMantissa->angle=angle+(flipped? M_PI:0);
cachedMantissa->angle=angle+(flipped? M_PI:0);

cairo_move_to(cairo,r.x(w-cachedMantissa->width()-2,-h-hoffs+2),
r.y(w-cachedMantissa->width()-2,-h-hoffs+2));
cachedMantissa->show();
cairo_move_to(cairo,r.x(w-cachedMantissa->width()-2,-h-hoffs+2),
r.y(w-cachedMantissa->width()-2,-h-hoffs+2));
cachedMantissa->show();

if (val.engExp!=0 && !isnan(value())) // Avoid large exponential number in variable value display. For ticket 1155
{
cairo_move_to(cairo,r.x(w-cachedExponent->width()-2,0),r.y(w-cachedExponent->width()-2,0));
cachedExponent->show();
}
}
if (val.engExp!=0 && !isnan(value())) // Avoid large exponential number in variable value display. For ticket 1155
{
cairo_move_to(cairo,r.x(w-cachedExponent->width()-2,0),r.y(w-cachedExponent->width()-2,0));
cachedExponent->show();
}
}
}
catch (...) {} // ignore errors in obtaining values

{
Expand Down
2 changes: 1 addition & 1 deletion obsCheck/Dockerfile-tumbleweed
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG project=minsky
ADD . /root
RUN zypper addrepo https://download.opensuse.org/repositories/home:hpcoder1/openSUSE_Tumbleweed/home:hpcoder1.repo
RUN zypper --gpg-auto-import-keys refresh
RUN zypper --non-interactive install $project
RUN zypper --non-interactive install $project python3
RUN useradd -m minsky
RUN su - minsky -c minsky --version
RUN python3 -c "import pyminsky"

0 comments on commit 9af7dc1

Please sign in to comment.