diff --git a/src/laybasic/laybasic/layConverters.cc b/src/laybasic/laybasic/layConverters.cc index 3a5f0497a..9aababc46 100644 --- a/src/laybasic/laybasic/layConverters.cc +++ b/src/laybasic/laybasic/layConverters.cc @@ -31,6 +31,7 @@ namespace lay // ---------------------------------------------------------------- // ColorConverter implementation +#if defined(HAVE_QT) std::string ColorConverter::to_string (const QColor &c) const { @@ -40,6 +41,7 @@ ColorConverter::to_string (const QColor &c) const return tl::to_string (c.name ()); } } +#endif std::string ColorConverter::to_string (const lay::Color &c) const @@ -51,6 +53,7 @@ ColorConverter::to_string (const lay::Color &c) const } } +#if defined(HAVE_QT) void ColorConverter::from_string (const std::string &s, QColor &c) const { @@ -61,6 +64,7 @@ ColorConverter::from_string (const std::string &s, QColor &c) const c = QColor (t.c_str ()); } } +#endif void ColorConverter::from_string (const std::string &s, lay::Color &c) const diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index ea9eb5e1c..8d830b78a 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -1006,7 +1006,8 @@ LayoutCanvas::screenshot () return img; } -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) + void LayoutCanvas::resizeEvent (QResizeEvent *) { @@ -1020,6 +1021,23 @@ LayoutCanvas::resizeEvent (QResizeEvent *) do_redraw_all (true); viewport_changed_event (); } + +#else + +void +LayoutCanvas::resize (unsigned int width, unsigned int height) +{ + // clear the image cache + m_image_cache.clear (); + + // set the viewport to the new size + m_viewport.set_size (width * m_dpr, height * m_dpr); + m_viewport_l.set_size (width * m_oversampling * m_dpr, height * m_oversampling * m_dpr); + mouse_event_trans (db::DCplxTrans (1.0 / double (m_dpr)) * m_viewport.trans ()); + do_redraw_all (true); + viewport_changed_event (); +} + #endif void diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index 8e254a1fb..8af843e87 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -396,7 +396,10 @@ private: virtual void paintEvent (QPaintEvent *); virtual void resizeEvent (QResizeEvent *); virtual bool event (QEvent *e); +#else + void resize (unsigned int width, unsigned int height); #endif + virtual void key_event (unsigned int key, unsigned int buttons); // implementation of the lay::Drawings interface diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index e427b4ef7..8901d20bd 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -354,7 +354,7 @@ LayoutViewBase::init (db::Manager *mgr) m_no_stipples = false; m_stipple_offset = true; m_fit_new_cell = true; - m_full_hier_new_cell = true; + m_full_hier_new_cell = false; m_clear_ruler_new_cell = false; m_dbu_coordinates = false; m_absolute_coordinates = false; @@ -2475,7 +2475,7 @@ LayoutViewBase::init_layer_properties (LayerProperties &p, const LayerProperties QImage LayoutViewBase::get_screenshot () { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2487,7 +2487,7 @@ LayoutViewBase::get_screenshot () lay::PixelBuffer LayoutViewBase::get_screenshot_pb () { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2519,7 +2519,7 @@ png_texts (const lay::LayoutViewBase *view, const db::DBox &box) void LayoutViewBase::save_screenshot (const std::string &fn) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot"))); QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); @@ -2532,7 +2532,7 @@ LayoutViewBase::save_screenshot (const std::string &fn) tl::DeferredMethodScheduler::execute (); if (! writer.write (mp_canvas->screenshot ().to_image ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } tl::log << "Saved screen shot to " << fn; @@ -2541,7 +2541,7 @@ LayoutViewBase::save_screenshot (const std::string &fn) void LayoutViewBase::save_screenshot (const std::string &fn) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2559,7 +2559,7 @@ LayoutViewBase::save_screenshot (const std::string &fn) QImage LayoutViewBase::get_image (unsigned int width, unsigned int height) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2571,7 +2571,7 @@ LayoutViewBase::get_image (unsigned int width, unsigned int height) lay::PixelBuffer LayoutViewBase::get_pixels (unsigned int width, unsigned int height) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2584,7 +2584,7 @@ QImage LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2601,7 +2601,7 @@ lay::PixelBuffer LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2613,7 +2613,7 @@ lay::BitmapBuffer LayoutViewBase::get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2625,7 +2625,7 @@ LayoutViewBase::get_pixels_with_options_mono (unsigned int width, unsigned int h void LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); @@ -2639,7 +2639,7 @@ LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned tl::DeferredMethodScheduler::execute (); if (! writer.write (mp_canvas->image (width, height).to_image ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } tl::log << "Saved image to " << fn; @@ -2648,7 +2648,7 @@ LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned void LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); @@ -2671,7 +2671,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); @@ -2686,11 +2686,11 @@ LayoutViewBase::save_image_with_options (const std::string &fn, if (monochrome) { if (! writer.write (mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box).to_image ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } } else { if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box).to_image ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } } @@ -2702,7 +2702,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); std::vector > texts = png_texts (this, vp.box ()); diff --git a/src/laybasic/laybasic/laySelector.cc b/src/laybasic/laybasic/laySelector.cc index 029b1cbe1..a6bd77b4d 100644 --- a/src/laybasic/laybasic/laySelector.cc +++ b/src/laybasic/laybasic/laySelector.cc @@ -28,8 +28,10 @@ #include "tlLog.h" #include "tlException.h" -#include -#include +#if defined(HAVE_QT) +# include +# include +#endif namespace lay { @@ -37,8 +39,10 @@ namespace lay // ------------------------------------------------------------- // SelectionService implementation -SelectionService::SelectionService (lay::LayoutViewBase *view) - : QObject (), +SelectionService::SelectionService (lay::LayoutViewBase *view) : +#if defined(HAVE_QT) + QObject (), +#endif lay::ViewService (view->view_object_widget ()), mp_view (view), mp_box (0), @@ -48,9 +52,11 @@ SelectionService::SelectionService (lay::LayoutViewBase *view) m_hover_wait (false), m_mouse_in_window (false) { +#if defined(HAVE_QT) m_timer.setInterval (100 /*hover time*/); m_timer.setSingleShot (true); connect (&m_timer, SIGNAL (timeout ()), this, SLOT (timeout ())); +#endif } SelectionService::~SelectionService () @@ -81,7 +87,9 @@ void SelectionService::hover_reset () { if (m_hover_wait) { +#if defined(HAVE_QT) m_timer.stop (); +#endif m_hover_wait = false; } if (m_hover) { @@ -90,6 +98,7 @@ SelectionService::hover_reset () } } +#if defined(HAVE_QT) void SelectionService::timeout () { @@ -98,6 +107,7 @@ SelectionService::timeout () mp_view->clear_transient_selection (); mp_view->transient_select (m_hover_point); } +#endif void SelectionService::reset_box () @@ -155,7 +165,9 @@ SelectionService::mouse_move_event (const db::DPoint &p, unsigned int buttons, b mp_box->set_points (m_p1, m_p2); } else if (m_mouse_in_window && mp_view->transient_selection_mode ()) { m_hover_wait = true; +#if defined(HAVE_QT) m_timer.start (); +#endif m_hover_point = p; } @@ -173,10 +185,12 @@ SelectionService::mouse_double_click_event (const db::DPoint & /*p*/, unsigned i reset_box (); } +#if defined(HAVE_QT) if (prio && (buttons & lay::LeftButton) != 0) { mp_view->show_properties (QApplication::activeWindow ()); return true; } +#endif return false; } @@ -230,13 +244,17 @@ SelectionService::mouse_click_event (const db::DPoint &p, unsigned int buttons, // add a transient selection trigger to capture the "next" selection. if (mp_view->transient_selection_mode ()) { m_hover_wait = true; +#if defined(HAVE_QT) m_timer.start (); +#endif m_hover_point = p; } } catch (tl::Exception &ex) { tl::error << ex.msg (); - QMessageBox::critical (0, QObject::tr ("Error"), tl::to_qstring (ex.msg ())); +#if defined(HAVE_QT) + QMessageBox::critical (0, tr ("Error"), tl::to_qstring (ex.msg ())); +#endif // clear selection mp_view->select (db::DBox (), lay::Editable::Reset); } @@ -273,7 +291,9 @@ SelectionService::mouse_release_event (const db::DPoint & /*p*/, unsigned int /* mp_view->select (db::DBox (m_p1, m_p2), mode); } catch (tl::Exception &ex) { tl::error << ex.msg (); - QMessageBox::critical (0, QObject::tr ("Error"), tl::to_qstring (ex.msg ())); +#if defined(HAVE_QT) + QMessageBox::critical (0, tr ("Error"), tl::to_qstring (ex.msg ())); +#endif // clear selection mp_view->select (db::DBox (), lay::Editable::Reset); } @@ -301,4 +321,3 @@ SelectionService::begin (const db::DPoint &pos) } } - diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 1702e9fac..81e2fceb3 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -90,7 +90,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY gtf.cc \ layAbstractMenu.cc \ layBackgroundAwareTreeStyle.cc \ - layBitmapsToImage.cc \ layBookmarkList.cc \ layBookmarkManagementForm.cc \ layBookmarksView.cc \ @@ -103,7 +102,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layCellSelectionForm.cc \ layCellTreeModel.cc \ layConfigurationDialog.cc \ - layConverters.cc \ layCursor.cc \ layDialogs.cc \ layEditLineStyleWidget.cc \ @@ -146,12 +144,10 @@ DEFINES += MAKE_LAYBASIC_LIBRARY laySelectCellViewForm.cc \ laySelectLineStyleForm.cc \ laySelectStippleForm.cc \ - laySelector.cc \ layStream.cc \ layTechnology.cc \ layTipDialog.cc \ layWidgets.cc \ - layZoomBox.cc \ rdbInfoWidget.cc \ rdbMarkerBrowser.cc \ rdbMarkerBrowserDialog.cc \ @@ -162,7 +158,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layAbstractMenu.h \ layBackgroundAwareTreeStyle.h \ layBitmap.h \ - layBitmapsToImage.h \ layBookmarkList.h \ layBookmarkManagementForm.h \ layBookmarksView.h \ @@ -175,7 +170,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layCellSelectionForm.h \ layCellTreeModel.h \ layConfigurationDialog.h \ - layConverters.h \ layColor.h \ layCursor.h \ layDialogs.h \ @@ -219,12 +213,10 @@ DEFINES += MAKE_LAYBASIC_LIBRARY laySelectCellViewForm.h \ laySelectLineStyleForm.h \ laySelectStippleForm.h \ - laySelector.h \ layStream.h \ layTechnology.h \ layTipDialog.h \ layWidgets.h \ - layZoomBox.h \ laybasicConfig.h \ rdbInfoWidget.h \ rdbMarkerBrowser.h \ @@ -242,9 +234,11 @@ SOURCES += \ layAnnotationShapes.cc \ layBitmap.cc \ layBitmapRenderer.cc \ + layBitmapsToImage.cc \ layCellView.cc \ layColor.cc \ layColorPalette.cc \ + layConverters.cc \ layDispatcher.cc \ layDisplayState.cc \ layDitherPattern.cc \ @@ -272,6 +266,7 @@ SOURCES += \ layRedrawThreadWorker.cc \ layRenderer.cc \ layRubberBox.cc \ + laySelector.cc \ laySnap.cc \ layStipplePalette.cc \ layCanvasPlane.cc \ @@ -280,13 +275,16 @@ SOURCES += \ layViewObject.cc \ layViewOp.cc \ layViewport.cc \ + layZoomBox.cc \ HEADERS += \ layAnnotationShapes.h \ layBitmap.h \ layBitmapRenderer.h \ + layBitmapsToImage.h \ layCellView.h \ layColorPalette.h \ + layConverters.h \ layDispatcher.h \ layDisplayState.h \ layDitherPattern.h \ @@ -315,6 +313,7 @@ HEADERS += \ layRedrawThreadWorker.h \ layRenderer.h \ layRubberBox.h \ + laySelector.h \ laySnap.h \ layStipplePalette.h \ layLayerProperties.h \ @@ -322,6 +321,7 @@ HEADERS += \ layViewObject.h \ layViewOp.h \ layViewport.h \ + layZoomBox.h \ laybasicCommon.h \ diff --git a/src/laybasic/unit_tests/layLayoutViewTests.cc b/src/laybasic/unit_tests/layLayoutViewTests.cc index 806026609..3e0936add 100644 --- a/src/laybasic/unit_tests/layLayoutViewTests.cc +++ b/src/laybasic/unit_tests/layLayoutViewTests.cc @@ -69,6 +69,8 @@ static bool compare_images_mono (const QImage &qimg, const std::string &au) } } +#endif + static bool compare_images (const lay::PixelBuffer &img, const lay::PixelBuffer &img2) { return img == img2; @@ -79,8 +81,6 @@ static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffe return img == img2; } -#endif - #if defined(HAVE_QT) TEST(1) {