WIP: first 'recent options' list, dragging a PCell variant into the canvas makes the editor take a PCell with these parameters.

This commit is contained in:
Matthias Koefferlein
2020-08-15 00:13:17 +02:00
parent 9a2c091f65
commit ee5cd9cb63
13 changed files with 493 additions and 106 deletions
+47 -7
View File
@@ -28,6 +28,7 @@
#include "dbPCellVariant.h"
#include "dbLibraryProxy.h"
#include "dbLibrary.h"
#include "dbLibraryManager.h"
#include <QTreeView>
#include <QPalette>
@@ -604,14 +605,53 @@ CellTreeModel::mimeData(const QModelIndexList &indexes) const
{
for (QModelIndexList::const_iterator i = indexes.begin (); i != indexes.end (); ++i) {
if (i->isValid()) {
if (! i->isValid()) {
continue;
}
if (is_pcell (*i)) {
lay::CellDragDropData data (mp_layout, mp_library, pcell_id (*i), true);
return data.to_mime_data ();
} else {
const db::Cell *c = cell (*i);
if (c) {
// resolve library proxies
const db::Layout *layout = mp_layout;
const db::Library *library = mp_library;
const db::LibraryProxy *lib_proxy;
while (layout != 0 && (lib_proxy = dynamic_cast <const db::LibraryProxy *> (c)) != 0) {
const db::Library *lib = db::LibraryManager::instance ().lib (lib_proxy->lib_id ());
if (! lib) {
break;
}
library = lib;
layout = &lib->layout ();
if (layout->is_valid_cell_index (lib_proxy->library_cell_index ())) {
c = &layout->cell (lib_proxy->library_cell_index ());
} else {
c = 0;
}
}
// identify pcell variants and turn them into PCell drag targets
const db::PCellVariant *pcell_var = dynamic_cast<const db::PCellVariant *> (c);
if (pcell_var) {
lay::CellDragDropData data (layout, library, pcell_var->pcell_id (), true, pcell_var->parameters ());
return data.to_mime_data ();
} else if (c) {
lay::CellDragDropData data (layout, library, c->cell_index (), false);
return data.to_mime_data ();
}
if (is_pcell (*i)) {
lay::CellDragDropData data (mp_layout, mp_library, pcell_id (*i), true);
return data.to_mime_data ();
} else if (cell (*i)) {
lay::CellDragDropData data (mp_layout, mp_library, cell_index (*i), false);
return data.to_mime_data ();
}
}
+17
View File
@@ -73,6 +73,10 @@ CellDragDropData::serialized () const
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;
}
@@ -94,6 +98,19 @@ CellDragDropData::deserialize (const QByteArray &ba)
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 {
+11 -2
View File
@@ -130,8 +130,8 @@ public:
* @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)
: mp_layout (layout), mp_library (library), m_cell_index (cell_or_pcell_index), m_is_pcell (is_pcell)
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 ..
}
@@ -152,6 +152,14 @@ public:
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
*/
@@ -185,6 +193,7 @@ private:
const db::Library *mp_library;
db::cell_index_type m_cell_index;
bool m_is_pcell;
std::vector<tl::Variant> m_pcell_params;
};
/**