Skip to content

Commit

Permalink
scale size of loaded image from pixel to mm
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Oct 28, 2016
1 parent 54a8e85 commit 35cb586
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Mod/Image/Gui/Command.cpp
Expand Up @@ -135,12 +135,20 @@ void CmdCreateImagePlane::activated(int iMsg)
Base::Rotation r = Dlg.Pos.getRotation();

std::string FeatName = getUniqueObjectName("ImagePlane");
double xPixelsPerM = impQ.dotsPerMeterX();
double width = impQ.width();
width = width * 1000 / xPixelsPerM;
int nWidth = static_cast<int>(width+0.5);
double yPixelsPerM = impQ.dotsPerMeterY();
double height = impQ.height();
height = height * 1000 / yPixelsPerM;
int nHeight = static_cast<int>(height+0.5);

openCommand("Create ImagePlane");
doCommand(Doc,"App.activeDocument().addObject('Image::ImagePlane','%s\')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.ImageFile = '%s'",FeatName.c_str(),(const char*)s.toUtf8());
doCommand(Doc,"App.activeDocument().%s.XSize = %d",FeatName.c_str(),impQ.width () );
doCommand(Doc,"App.activeDocument().%s.YSize = %d",FeatName.c_str(),impQ.height() );
doCommand(Doc,"App.activeDocument().%s.XSize = %d",FeatName.c_str(),nWidth);
doCommand(Doc,"App.activeDocument().%s.YSize = %d",FeatName.c_str(),nHeight);
doCommand(Doc,"App.activeDocument().%s.Placement = App.Placement(App.Vector(%f,%f,%f),App.Rotation(%f,%f,%f,%f))"
,FeatName.c_str(),p.x,p.y,p.z,r[0],r[1],r[2],r[3]);
commitCommand();
Expand Down

0 comments on commit 35cb586

Please sign in to comment.