Skip to content

Commit

Permalink
+ fix problems on unit tests, open transaction when creating distance…
Browse files Browse the repository at this point in the history
… object, layout warning, ...
  • Loading branch information
wwmayer committed Jan 25, 2015
1 parent 2cff92a commit 97987db
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 26 deletions.
3 changes: 3 additions & 0 deletions src/App/Document.cpp
Expand Up @@ -1541,6 +1541,9 @@ void Document::_addObject(DocumentObject* pcObject, const char* pObjectName)
}
// send the signal
signalNewObject(*pcObject);

d->activeObject = pcObject;
signalActivatedObject(*pcObject);
}

/// Remove an object out of the document
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/SelectionView.cpp
Expand Up @@ -63,7 +63,7 @@ SelectionView::SelectionView(Gui::Document* pcDocument, QWidget *parent)
searchBox->setPlaceholderText(tr("Search"));
#endif
searchBox->setToolTip(tr("Searches object labels"));
QHBoxLayout* hLayout = new QHBoxLayout(this);
QHBoxLayout* hLayout = new QHBoxLayout();
QToolButton* clearButton = new QToolButton(this);
clearButton->setFixedSize(18, 21);
clearButton->setCursor(Qt::ArrowCursor);
Expand Down
40 changes: 22 additions & 18 deletions src/Gui/Thumbnail.cpp
Expand Up @@ -101,22 +101,24 @@ void Thumbnail::SaveDocFile (Base::Writer &writer) const
}
}

QPixmap px = Gui::BitmapFactory().pixmap(App::Application::Config()["AppIcon"].c_str());
px = BitmapFactory().merge(QPixmap::fromImage(img),px,BitmapFactoryInst::BottomRight);

// according to specification add some meta-information to the image
uint mt = QDateTime::currentDateTime().toTime_t();
QString mtime = QString::fromAscii("%1").arg(mt);
img.setText(QLatin1String("Software"), qApp->applicationName());
img.setText(QLatin1String("Thumb::Mimetype"), QLatin1String("application/x-extension-fcstd"));
img.setText(QLatin1String("Thumb::MTime"), mtime);
img.setText(QLatin1String("Thumb::URI"), this->uri.toString());

QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
px.save(&buffer, "PNG");
writer.Stream().write(ba.constData(), ba.length());
if (!img.isNull()) {
QPixmap px = Gui::BitmapFactory().pixmap(App::Application::Config()["AppIcon"].c_str());
px = BitmapFactory().merge(QPixmap::fromImage(img),px,BitmapFactoryInst::BottomRight);

// according to specification add some meta-information to the image
uint mt = QDateTime::currentDateTime().toTime_t();
QString mtime = QString::fromAscii("%1").arg(mt);
img.setText(QLatin1String("Software"), qApp->applicationName());
img.setText(QLatin1String("Thumb::Mimetype"), QLatin1String("application/x-extension-fcstd"));
img.setText(QLatin1String("Thumb::MTime"), mtime);
img.setText(QLatin1String("Thumb::URI"), this->uri.toString());

QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
px.save(&buffer, "PNG");
writer.Stream().write(ba.constData(), ba.length());
}
}

void Thumbnail::RestoreDocFile(Base::Reader &reader)
Expand All @@ -127,6 +129,8 @@ void Thumbnail::createThumbnailFromFramebuffer(QImage& img) const
{
// Alternative way of off-screen rendering
QGLFramebufferObject fbo(this->size, this->size,QGLFramebufferObject::Depth);
this->viewer->renderToFramebuffer(&fbo);
img = fbo.toImage();
if (this->viewer->isActiveWindow()) {
this->viewer->renderToFramebuffer(&fbo);
img = fbo.toImage();
}
}
2 changes: 2 additions & 0 deletions src/Gui/ViewProviderMeasureDistance.cpp
Expand Up @@ -262,6 +262,7 @@ int PointMarker::countPoints() const
void PointMarker::customEvent(QEvent* e)
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
doc->openCommand("Measure distance");
App::DocumentObject* obj = doc->getDocument()->addObject
(App::MeasureDistance::getClassTypeId().getName(),"Distance");

Expand All @@ -275,6 +276,7 @@ void PointMarker::customEvent(QEvent* e)
s.setf(std::ios::fixed | std::ios::showpoint);
s << "Distance: " << md->Distance.getValue();
md->Label.setValue(s.str());
doc->commitCommand();
}

PROPERTY_SOURCE(Gui::ViewProviderPointMarker, Gui::ViewProviderDocumentObject)
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/Workbench.cpp
Expand Up @@ -519,7 +519,6 @@ MenuItem* StdWorkbench::setupMenuBar() const
<< "Separator" << visu
<< "Std_ToggleVisibility" << "Std_ToggleNavigation"
<< "Std_SetAppearance" << "Std_RandomColor" << "Separator"
<< "Std_MeasureDistance" << "Separator"
<< "Std_Workbench" << "Std_ToolBarMenu" << "Std_DockViewMenu" << "Separator"
<< "Std_ViewStatusBar";

Expand All @@ -528,7 +527,8 @@ MenuItem* StdWorkbench::setupMenuBar() const
tool->setCommand("&Tools");
*tool << "Std_DlgParameter" << "Separator"
<< "Std_ViewScreenShot" << "Std_SceneInspector"
<< "Std_ExportGraphviz" << "Std_ProjectUtil"
<< "Std_ExportGraphviz" << "Std_ProjectUtil" << "Separator"
<< "Std_MeasureDistance" << "Separator"
<< "Std_DemoMode" << "Std_UnitsCalculator" << "Separator" << "Std_DlgCustomize";

// Macro
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Complete/Gui/Workbench.cpp
Expand Up @@ -172,7 +172,6 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "Std_TextureMapping" << "Separator" << visu
<< "Std_ToggleVisibility" << "Std_ToggleNavigation"
<< "Std_SetAppearance" << "Std_RandomColor" << "Separator"
<< "Std_MeasureDistance" << "Separator"
<< "Std_Workbench" << "Std_ToolBarMenu" << "Std_DockViewMenu" << "Separator"
<< "Std_ViewStatusBar";

Expand All @@ -183,7 +182,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "Std_DlgMacroRecord" << "Std_MacroStopRecord"
<< "Std_DlgMacroExecute" << "Std_DlgMacroExecuteDirect"
<< "Separator" << "Std_ViewScreenShot" << "Std_SceneInspector"
<< "Std_ExportGraphviz" << "Std_ProjectUtil"
<< "Std_ExportGraphviz" << "Std_ProjectUtil" << "Separator"
<< "Std_MeasureDistance" << "Separator"
<< "Std_DemoMode" << "Separator" << "Std_DlgCustomize";

// Mesh ****************************************************************************************************
Expand Down
11 changes: 8 additions & 3 deletions src/Mod/Image/Gui/Workbench.cpp
Expand Up @@ -52,7 +52,10 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
Gui::ToolBarItem* root = StdWorkbench::setupToolBars();
Gui::ToolBarItem* part = new Gui::ToolBarItem(root);
part->setCommand("Image");
*part << "Image_Open" << "Image_CreateImagePlane"<< "Image_CapturerTest";
*part << "Image_Open" << "Image_CreateImagePlane";
#if HAVE_OPENCV2
*part << "Image_CapturerTest";
#endif
return root;
}

Expand All @@ -61,7 +64,9 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
Gui::ToolBarItem* root = new Gui::ToolBarItem;
Gui::ToolBarItem* img = new Gui::ToolBarItem(root);
img->setCommand("Image");
*img << "Image_Open" << "Image_CapturerTest";
*img << "Image_Open";
#if HAVE_OPENCV2
*img << "Image_CapturerTest";
#endif
return root;
}

0 comments on commit 97987db

Please sign in to comment.