Enabled edt, ant and img for Qt-less builds, added missing files

This commit is contained in:
Matthias Koefferlein
2022-05-08 22:27:39 +02:00
parent 37a42b70db
commit f65c3d5fd7
19 changed files with 518 additions and 88 deletions
+8
View File
@@ -37,6 +37,14 @@ namespace lay
*/
typedef uint32_t color_t;
/**
* @brief Gets the color components from a color_t
*/
inline unsigned int alpha (color_t c) { return (c >> 24) & 0xff; }
inline unsigned int red (color_t c) { return (c >> 16) & 0xff; }
inline unsigned int green (color_t c) { return (c >> 8) & 0xff; }
inline unsigned int blue (color_t c) { return c & 0xff; }
/**
* @brief A wrapper for a color value
*
+108
View File
@@ -0,0 +1,108 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2022 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "layDragDropData.h"
#include <QDataStream>
#include <QIODevice>
namespace lay
{
// ---------------------------------------------------------------
// Implementation of DragDropDataBase
const char *drag_drop_mime_type ()
{
return "application/klayout-ddd";
}
QMimeData *
DragDropDataBase::to_mime_data () const
{
QMimeData *mimeData = new QMimeData();
mimeData->setData (QString::fromUtf8 (drag_drop_mime_type ()), serialized ());
return mimeData;
}
// ---------------------------------------------------------------
// Implementation of CellDragDropData
QByteArray
CellDragDropData::serialized () const
{
QByteArray data;
QDataStream stream (&data, QIODevice::WriteOnly);
stream << QString::fromUtf8 ("CellDragDropData");
stream << (quintptr) mp_layout;
stream << (quintptr) mp_library;
stream << m_cell_index;
stream << m_is_pcell;
stream << int (m_pcell_params.size ());
for (std::vector<tl::Variant>::const_iterator i = m_pcell_params.begin (); i != m_pcell_params.end (); ++i) {
stream << tl::to_qstring (i->to_parsable_string ());
}
return data;
}
bool
CellDragDropData::deserialize (const QByteArray &ba)
{
QDataStream stream (const_cast<QByteArray *> (&ba), QIODevice::ReadOnly);
QString tag;
stream >> tag;
if (tag == QString::fromUtf8 ("CellDragDropData")) {
quintptr p = 0;
stream >> p;
mp_layout = reinterpret_cast <const db::Layout *> (p);
stream >> p;
mp_library = reinterpret_cast <const db::Library *> (p);
stream >> m_cell_index;
stream >> m_is_pcell;
m_pcell_params.clear ();
int n = 0;
stream >> n;
while (n-- > 0) {
QString s;
stream >> s;
std::string stl_s = tl::to_string (s);
tl::Extractor ex (stl_s.c_str ());
m_pcell_params.push_back (tl::Variant ());
ex.read (m_pcell_params.back ());
}
return true;
} else {
return false;
}
}
}
+171
View File
@@ -0,0 +1,171 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2022 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef HDR_layDragDropData
#define HDR_layDragDropData
#include "laybasicCommon.h"
#include "dbLayout.h"
#include "dbLibrary.h"
#include <QByteArray>
#include <QMimeData>
#include <vector>
namespace lay
{
LAYBASIC_PUBLIC const char *drag_drop_mime_type ();
/**
* @brief A helper class required to store the drag/drop data
*
* Drag/drop data is basically a collection of key/value pairs.
* A category string is provided to identify the kind of data.
*/
class LAYBASIC_PUBLIC DragDropDataBase
{
public:
/**
* @brief Default constructor
*/
DragDropDataBase () { }
/**
* @brief Dtor
*/
virtual ~DragDropDataBase () { }
/**
* @brief Serializes itself to an QByteArray
*/
virtual QByteArray serialized () const = 0;
/**
* @brief Try deserialization from an QByteArray
*
* Returns false, if deserialization failed.
*/
virtual bool deserialize (const QByteArray &ba) = 0;
/**
* @brief Create a QMimeData object from the object
*/
QMimeData *to_mime_data () const;
};
/**
* @brief Drag/drop data for a cell
*/
class LAYBASIC_PUBLIC CellDragDropData
: public DragDropDataBase
{
public:
/**
* @brief Default ctor
*/
CellDragDropData ()
: mp_layout (0), mp_library (0), m_cell_index (0), m_is_pcell (false)
{
// .. nothing yet ..
}
/**
* @brief Specifies drag & drop of a cell
*
* @param layout the layout where the cell lives in
* @param cell_index The index of the cell
*/
CellDragDropData (const db::Layout *layout, const db::Library *library, db::cell_index_type cell_or_pcell_index, bool is_pcell, const std::vector<tl::Variant> &pcell_params = std::vector<tl::Variant> ())
: mp_layout (layout), mp_library (library), m_cell_index (cell_or_pcell_index), m_is_pcell (is_pcell), m_pcell_params (pcell_params)
{
// .. nothing yet ..
}
/**
* @brief Gets the layout object where the cell lives in
*/
const db::Layout *layout () const
{
return mp_layout;
}
/**
* @brief Gets the layout object where the cell lives in
*/
const db::Library *library () const
{
return mp_library;
}
/**
* @brief PCell parameters
*/
const std::vector<tl::Variant> &pcell_params () const
{
return m_pcell_params;
}
/**
* @brief Gets the index of the cell
*/
db::cell_index_type cell_index () const
{
return m_cell_index;
}
/**
* @brief Gets a value indicating whether the cell is a pcell
*/
bool is_pcell () const
{
return m_is_pcell;
}
/**
* @brief Serializes itself to an QByteArray
*/
virtual QByteArray serialized () const;
/**
* @brief Try deserialization from an QByteArray
*
* Returns false, if deserialization failed.
*/
bool deserialize (const QByteArray &ba);
private:
const db::Layout *mp_layout;
const db::Library *mp_library;
db::cell_index_type m_cell_index;
bool m_is_pcell;
std::vector<tl::Variant> m_pcell_params;
};
}
#endif