From a6a09eb9f3859eeaf83aac002a6f3ab4848439d5 Mon Sep 17 00:00:00 2001 From: Carsten Niehaus Date: Sun, 26 Nov 2006 12:35:19 +0000 Subject: [PATCH] * Ok, I still see no real way to test my KPart-code but this might work. I will move it to libkdeedu as Kalzium is not using this code anyway. There, I will code a small mini-demo application to test the KPart-stuff. So eventually Konq will be able to display molecules in 3D by using Kalziums 3D code (which is 99.999% done by Benoit Jacob) svn path=/trunk/KDE/kdeedu/kalzium/src/kalziumglpart.cpp; revision=607947 --- kalzium/kalziumgl_part.desktop | 3 +-- kalzium/kalziumglpart.cpp | 28 +++++++++++++++++++++++----- kalzium/kalziumglpart.h | 20 +++++++++++++++++--- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/kalzium/kalziumgl_part.desktop b/kalzium/kalziumgl_part.desktop index 95222f4..c2dda42 100644 --- a/kalzium/kalziumgl_part.desktop +++ b/kalzium/kalziumgl_part.desktop @@ -2,9 +2,8 @@ Encoding=UTF-8 Icon=kalzium MimeType=application/x-ogg;audio/basic; -Name=KalziumGL +Name=KalziumGLPart Comment=An OpenGL-based 3D-renderer for molecules ServiceTypes=KParts/ReadOnlyPart Type=Service X-KDE-Library=libkalziumglpart -InitialPreference=9 diff --git a/kalzium/kalziumglpart.cpp b/kalzium/kalziumglpart.cpp index 271ffdb..009eed1 100644 --- a/kalzium/kalziumglpart.cpp +++ b/kalzium/kalziumglpart.cpp @@ -1,8 +1,23 @@ +/*************************************************************************** + copyright : (C) 2006 by Carsten Niehaus + email : cniehaus@kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ #include #include #include "kalziumglpart.h" +#include "openbabel2wrapper.h" +#include "kalziumglwidget.h" typedef KParts::GenericFactory KalziumGLPartFactory; @@ -11,6 +26,9 @@ K_EXPORT_COMPONENT_FACTORY (libkalziumglpart, KalziumGLPartFactory) KalziumGLPart::KalziumGLPart(QWidget* parentWidget, QObject* parent, const QStringList& args) { kDebug() << "KalziumGLPart::KalziumGLPart()" << endl; + + m_widget = new KalziumGLWidget(); + m_widget->setObjectName("KalziumGLWidget-KPart"); } KalziumGLPart::~KalziumGLPart() @@ -30,13 +48,13 @@ KAboutData *KalziumGLPart::createAboutData() return aboutData; } -bool KalziumGLPart::openUrl(const KUrl& url) -{ - kDebug() << "KalziumGLPart::openURL()" << endl; -} - bool KalziumGLPart::openFile() { + OpenBabel::OBMol* mol = OpenBabel2Wrapper::readMolecule( m_url.path() ); + mol->Center(); + + m_widget->slotSetMolecule( mol ); + m_widget->update(); } #include "kalziumglpart.moc" diff --git a/kalzium/kalziumglpart.h b/kalzium/kalziumglpart.h index 5b734cb..246da6f 100644 --- a/kalzium/kalziumglpart.h +++ b/kalzium/kalziumglpart.h @@ -1,9 +1,24 @@ +/*************************************************************************** + copyright : (C) 2006 by Carsten Niehaus + email : cniehaus@kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ #ifndef KALZIUMGLPART_H #define KALZIUMGLPART_H #include #include +#include "kalziumglwidget.h" + class KalziumGLPart : public KParts::ReadOnlyPart { Q_OBJECT @@ -13,11 +28,10 @@ class KalziumGLPart : public KParts::ReadOnlyPart static KAboutData* createAboutData(); - public slots: - bool openUrl(const KUrl& url); - protected: bool openFile(); + + KalziumGLWidget * m_widget; }; #endif // KALZIUMGLPART_H -- 2.47.3