package AtomSiteObject;
use Exporter;
use Common;
@ISA = qw(Exporter Common);
#公開したいサブルーチン
@EXPORT = qw();
use strict;
use Utils;
sub new
{
my ($module) = @_;
my $this = {};
bless $this;
$this->{'IsSelected'} = 1;
# $this->{'Id'} = 0;
return $this;
}
sub DESTROY
{
my $this = shift;
}
sub SetIsSelected
{
my ($this,$IsSelected) = @_;
return $this->{'IsSelected'} = $IsSelected;
}
sub IsSelected
{
my ($this) = @_;
return $this->{'IsSelected'};
}
sub SetLabel
{
my ($this,$Label) = @_;
return $this->{'Label'} = $Label;
}
sub SetAtomName
{
my ($this,$AtomName) = @_;
return $this->{'AtomName'} = $AtomName;
}
sub SetPosition
{
my ($this,$x,$y,$z) = @_;
#print "$x,$y,$z => ";
$this->{x} = Sci::Round($x, 8);
$this->{y} = Sci::Round($y, 8);
$this->{z} = Sci::Round($z, 8);
#print "$this->{x},$this->{y},$this->{z}\n";
return ($x,$y,$z);
}
sub Position
{
my ($this,$IsReduce01) = @_;
if($IsReduce01) {
my $x = &Round01($this->{'x'});
my $y = &Round01($this->{'y'});
my $z = &Round01($this->{'z'});
return (Utils::Reduce01($x),
Utils::Reduce01($y),
Utils::Reduce01($z) );
}
return ($this->{x}, $this->{y}, $this->{z});
}
sub SetForce
{
my ($this,$fx,$fy,$fz) = @_;
$this->{fx} = Sci::Round($fx, 8);
$this->{fy} = Sci::Round($fy, 8);
$this->{fz} = Sci::Round($fz, 8);
#print "SetForce=", $this->{fx}, ", ", $this->{fy}, ", ", $this->{fz}, "\n";
return ($fx, $fy, $fz);
}
sub Force
{
my ($this) = @_;
#print "Force=", $this->{fx}, "\n";
return ($this->{fx}, $this->{fy}, $this->{fz});
}
sub SetVelocity
{
my ($this,$vx,$vy,$vz) = @_;
#print "SetVelocity: ($vx,$vy,$vz)
\n";
$this->{vx} = $vx;
$this->{vy} = $vy;
$this->{vz} = $vz;
return ($vx, $vy, $vz);
}
sub Velocity
{
my ($this) = @_;
my $vx = $this->{vx};
my $vy = $this->{vy};
my $vz = $this->{vz};
#print "Velocity: ($vx, $vy, $vz)
\n";
return ($vx, $vy, $vz);
}
sub SetOccupancy
{
my ($this,$occ) = @_;
$occ = 1.0 if(!defined $occ);
return $this->{'Occupancy'} = $occ;
}
sub Label
{
my ($this) = @_;
return $this->{'Label'};
}
sub AtomNameOnly
{
my ($this, $DelPar) = @_;
my $name = $this->{'AtomName'};
$name =~ s/\[.*?\]//g;
$name =~ s/^([^\d+-]*)([\d+-\.]*)/$1/;
$name =~ s/\{[^\{\}]*\}//g if($DelPar);
return $name;
}
sub AtomName
{
my ($this) = @_;
return $this->{'AtomName'};
}
sub SetCharge
{
my ($this, $Charge) = @_;
return $this->{Charge} = $Charge;
}
sub Charge
{
my ($this) = @_;
return $this->{Charge} if defined $this->{Charge};
my $charge = $this->{'AtomName'};
#print("charge=$charge\n");
# Delete additional info in []
$charge =~ s/\[.*?\]//g;
#print(" $charge\n");
if($charge =~ /^[A-Za-z]+$/) {
#print(" $charge\n");
$charge += 0.0;
}
elsif($charge =~ /(\-)(\d*)?/) {
if($2 eq '') {
$charge = -1.0;
}
else {
$charge = -1.0 * $2;
}
#print(" $charge\n");
}
else {
$charge =~ s/^(\D*)(\d*)?([\+-]*)?/$3$2/;
#print(" $charge\n");
$charge += 0.0;
}
#print(" $charge\n");
return $charge;
}
sub Round01
{
my ($x) = @_;
return 1.0 if(abs($x - 1.0) < 0.0002);
return 0.0 if(abs($x) < 0.0002);
# return 0.0 if(abs($x) < 0.001);
return $x;
}
sub Occupancy
{
my ($this) = @_;
return ($this->{'Occupancy'});
}
sub SetiAtomType
{
my ($this, $i) = @_;
return $this->{'iAtomType'} = $i;
}
sub iAtomType
{
my ($this) = @_;
return $this->{'iAtomType'};
}
sub SetIdAsymmetricAtomSite
{
my ($this, $i) = @_;
$this->{idSite} = $i - 1;
return $this->{IdAsymmetricAtomSite} = $i;
}
sub SetIdSite
{
my ($this, $i) = @_;
return $this->{idSite} = $i - 1;
}
sub IdSite
{
my ($this) = @_;
return $this->{'idSite'};
}
sub IdAsymmetricAtomSite
{
my ($this) = @_;
return $this->{'IdAsymmetricAtomSite'};
}
sub SetId
{
my ($this,$id) = @_;
#print "SetId: $id
\n";
# return $this->{'Id'} = $id;
return $this->SetIdAsymmetricAtomSite($id);
}
sub Id
{
my ($this) = @_;
#print "ReturnId: ", $this->{'Id'}, "
\n";
return $this->IdAsymmetricAtomSite();
# return $this->{'Id'};
}
sub SetMultiplicity
{
my ($this,$mult) = @_;
return $this->{'Multiplicity'} = $mult;
}
sub Multiplicity
{
my ($this) = @_;
return $this->{'Multiplicity'};
}
1;