+ fix problems on unit tests, open transaction when creating distance object, layout warning, ...

This commit is contained in:
wmayer 2015-01-25 14:04:33 +01:00
parent 2cff92a73e
commit 97987db462
7 changed files with 38 additions and 24 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);
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());
// 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());
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)
@ -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();
}
}

View File

@ -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");
@ -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)

View File

@ -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";
@ -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

View File

@ -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";
@ -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 ****************************************************************************************************

View File

@ -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;
}
@ -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;
}