<commit_before>// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id:

#include "ballviewDemo.h"
#include <BALL/VIEW/KERNEL/mainControl.h>
#include <BALL/VIEW/KERNEL/common.h>
#include <BALL/KERNEL/system.h>
#include <BALL/VIEW/DIALOGS/displayProperties.h>
#include <BALL/VIEW/WIDGETS/molecularStructure.h>
#include <BALL/VIEW/DIALOGS/FDPBDialog.h>
#include <BALL/FORMAT/PDBFile.h>
#include <BALL/FORMAT/HINFile.h>
#include <BALL/DATATYPE/contourSurface.h>
#include <BALL/VIEW/PRIMITIVES/mesh.h>
#include <BALL/STRUCTURE/HBondProcessor.h>
#include <BALL/VIEW/WIDGETS/scene.h>
#include <BALL/VIEW/DATATYPE/colorTable.h>
#include <BALL/VIEW/DIALOGS/colorMeshDialog.h>
#include <BALL/VIEW/DIALOGS/molecularFileDialog.h>

#include <qlabel.h>
#include <qpushbutton.h>
#include <qwidgetstack.h>

namespace BALL
{
	namespace VIEW
	{

BALLViewDemo::BALLViewDemo(QWidget* parent, const char* name)
	throw()
	:	BALLViewDemoData(parent, name),
		ModularWidget(name)
{
#ifdef BALL_VIEW_DEBUG
	Log.error() << "new BALLViewDemo " << this << std::endl;
#endif
	// register the widget with the MainControl
 	ModularWidget::registerWidget(this);
	hide();
}

BALLViewDemo::~BALLViewDemo()
	throw()
{
#ifdef BALL_VIEW_DEBUG
	Log.error() << "deleting BALLViewDemo " << this << std::endl;
#endif
}

void BALLViewDemo::show()
{
	widget_stack->raiseWidget(0);
	DisplayProperties* dp = DisplayProperties::getInstance(0);
	dp->setDrawingPrecision(DRAWING_PRECISION_HIGH);
	dp->enableCreationForNewMolecules(false);
	system_ = new System();

	try
	{
		Path path;
		String file_name(path.getDataPath());
		file_name = file_name.before("data");
		file_name += "data";
		file_name += FileSystem::PATH_SEPARATOR;
		file_name += String("structures");
		file_name += FileSystem::PATH_SEPARATOR;
		file_name += "bpti.pdb";
		MolecularFileDialog* dialog = MolecularFileDialog::getInstance(0);
		system_ = dialog->openFile(file_name);
	}
	catch(Exception::FileNotFound e)
	{
		Log.error() << "Could not open " << e.getFilename() << std::endl;
		return;
	}

	composites_.clear();
	composites_.push_back(system_);
	QDialog::show();
	raise();
}

void BALLViewDemo::onNotify(Message *message)
	throw()
{
#ifdef BALL_VIEW_DEBUG
	Log.error() << "BALLViewDemo " << this << " onNotify " << message << std::endl;
#endif

	if (!isVisible()) return;

//   	CompositeMessage* cmsg = RTTI::castTo<CompositeMessage>(*message);
	RepresentationMessage* rmsg = RTTI::castTo<RepresentationMessage>(*message);

	Index id = widget_stack->id(widget_stack->visibleWidget());

	if (id == MODEL_HBONDS + 5)
	{
		if (RTTI::isKindOf<FinishedSimulationMessage>(*message))
		{
			nextStep_();
		}
		return;
	}


	if (id == MODEL_HBONDS + 6)
	{
		RegularData3DMessage* msg = RTTI::castTo<RegularData3DMessage>(*message);
		if (msg != 0 &&
			  ((RegularData3DMessage::RegularDataMessageType)msg->getType()) == RegularDataMessage::NEW)
		{
			grid_ = msg->getData();
			nextStep_();
		}
		return;
	}

	if (//id <= MODEL_HBONDS + 6 &&
		  rmsg != 0 && 
			rmsg->getType() == RepresentationMessage::UPDATE)
	{
		nextStep_();
	}

	
}

void BALLViewDemo::nextStep_()
{
	buttonOk->setEnabled(true);
	widget_stack->raiseWidget(widget_stack->id(widget_stack->visibleWidget()) + 1);
}

void BALLViewDemo::accept()
{
	Index id = widget_stack->id(widget_stack->visibleWidget());
	MolecularStructure* ms = MolecularStructure::getInstance(0);
	bool disable_button = true;

	if (id < MODEL_HBONDS + 7)
	{
		// remove representations
		PrimitiveManager& pm = getMainControl()->getPrimitiveManager();
		Size nr = pm.getNumberOfRepresentations();
		list<Representation*> reps = pm.getRepresentations();
		for (Position p = 0; p < nr; p++)
		{
			getMainControl()->remove(**reps.begin());
			reps.pop_front();
		}
	}

	if (id < MODEL_HBONDS - 1)
	{
		if (((ModelType)id) >= MODEL_SE_SURFACE) id ++;
 		CreateRepresentationMessage* crmsg = new CreateRepresentationMessage(composites_, (ModelType) id, COLORING_ELEMENT);
//   CreateRepresentationMessage* crmsg = new CreateRepresentationMessage(composites_, MODEL_STICK, COLORING_ELEMENT);
		notify_(crmsg);
	}<commit_msg>no message<commit_after>// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id:

#include "ballviewDemo.h"
#include <BALL/VIEW/KERNEL/mainControl.h>
#include <BALL/VIEW/KERNEL/common.h>
#include <BALL/KERNEL/system.h>
#include <BALL/VIEW/DIALOGS/displayProperties.h>
#include <BALL/VIEW/WIDGETS/molecularStructure.h>
#include <BALL/VIEW/DIALOGS/FDPBDialog.h>
#include <BALL/FORMAT/PDBFile.h>
#include <BALL/FORMAT/HINFile.h>
#include <BALL/DATATYPE/contourSurface.h>
#include <BALL/VIEW/PRIMITIVES/mesh.h>
#include <BALL/STRUCTURE/HBondProcessor.h>
#include <BALL/VIEW/WIDGETS/scene.h>
#include <BALL/VIEW/DATATYPE/colorTable.h>
#include <BALL/VIEW/DIALOGS/colorMeshDialog.h>
#include <BALL/VIEW/DIALOGS/molecularFileDialog.h>

#include <qlabel.h>
#include <qpushbutton.h>
#include <qwidgetstack.h>

namespace BALL
{
	namespace VIEW
	{

BALLViewDemo::BALLViewDemo(QWidget* parent, const char* name)
	throw()
	:	BALLViewDemoData(parent, name),
		ModularWidget(name)
{
#ifdef BALL_VIEW_DEBUG
	Log.error() << "new BALLViewDemo " << this << std::endl;
#endif
	// register the widget with the MainControl
 	ModularWidget::registerWidget(this);
	hide();
}

BALLViewDemo::~BALLViewDemo()
	throw()
{
#ifdef BALL_VIEW_DEBUG
	Log.error() << "deleting BALLViewDemo " << this << std::endl;
#endif
}

void BALLViewDemo::show()
{
	widget_stack->raiseWidget(0);
	DisplayProperties* dp = DisplayProperties::getInstance(0);
	dp->setDrawingPrecision(DRAWING_PRECISION_HIGH);
	dp->enableCreationForNewMolecules(false);
	system_ = new System();

	try
	{
		Path path;
		String file_name(path.getDataPath());
		file_name = file_name.before("data");
		file_name += "data";
		file_name += FileSystem::PATH_SEPARATOR;
		file_name += String("structures");
		file_name += FileSystem::PATH_SEPARATOR;
		file_name += "bpti.pdb";
		MolecularFileDialog* dialog = MolecularFileDialog::getInstance(0);
		system_ = dialog->openFile(file_name);
	}
	catch(Exception::FileNotFound e)
	{
		Log.error() << "Could not open " << e.getFilename() << std::endl;
		return;
	}

	composites_.clear();
	composites_.push_back(system_);
	QDialog::show();
	raise();
}

void BALLViewDemo::onNotify(Message *message)
	throw()
{
#ifdef BALL_VIEW_DEBUG
	Log.error() << "BALLViewDemo " << this << " onNotify " << message << std::endl;
#endif

	if (!isVisible()) return;

//   	CompositeMessage* cmsg = RTTI::castTo<CompositeMessage>(*message);
	RepresentationMessage* rmsg = RTTI::castTo<RepresentationMessage>(*message);

	Index id = widget_stack->id(widget_stack->visibleWidget());

	if (id == MODEL_HBONDS + 5)
	{
		if (RTTI::isKindOf<FinishedSimulationMessage>(*message))
		{
			nextStep_();
		}
		return;
	}


	if (id == MODEL_HBONDS + 6)
	{
		RegularData3DMessage* msg = RTTI::castTo<RegularData3DMessage>(*message);
		if (msg != 0 &&
			  ((RegularData3DMessage::RegularDataMessageType)msg->getType()) == RegularDataMessage::NEW)
		{
			grid_ = msg->getData();
			nextStep_();
		}
		return;
	}

	if (//id <= MODEL_HBONDS + 6 &&
		  rmsg != 0 && 
			rmsg->getType() == RepresentationMessage::UPDATE)
	{
		nextStep_();
	}

	
}

void BALLViewDemo::nextStep_()
{
	buttonOk->setEnabled(true);
	widget_stack->raiseWidget(widget_stack->id(widget_stack->visibleWidget()) + 1);
}

void BALLViewDemo::accept()
{
	Index id = widget_stack->id(widget_stack->visibleWidget());
	MolecularStructure* ms = MolecularStructure::getInstance(0);
	bool disable_button = true;

	if (id < MODEL_HBONDS + 7)
	{
		// remove representations
		PrimitiveManager& pm = getMainControl()->getPrimitiveManager();
		Size nr = pm.getNumberOfRepresentations();
		list<Representation*> reps = pm.getRepresentations();
		for (Position p = 0; p < nr; p++)
		{
			getMainControl()->remove(**reps.begin());
			reps.pop_front();
		}
	}

	if (id < MODEL_HBONDS - 1)
	{
		if (((ModelType)id) >= MODEL_SE_SURFACE -1) id ++;
 		CreateRepresentationMessage* crmsg = new CreateRepresentationMessage(composites_, (ModelType) id, COLORING_ELEMENT);
//   CreateRepresentationMessage* crmsg = new CreateRepresentationMessage(composites_, MODEL_STICK, COLORING_ELEMENT);
		notify_(crmsg);
	}
{'fraction_non_alphanumeric': 0.15975103734439833, 'fraction_numerical': 0.004515499145716377, 'mean_word_length': 5.313559322033898, 'pattern_counts': {'":': 0, '<': 113, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2391182', 'n_tokens_mistral': 3218, 'n_tokens_neox': 3002, 'n_words': 506}